- Autocommit - 2021/10/27 17:01:14
This commit is contained in:
1 parent
da733d7ac5
commit
5acd3b3935
6 files changed
+106
-19
No files matched your search
+13
-1
@@ -35,7 +35,19 @@ velocemente ai link fatti, e a quelli da fare
|
||||
- Update :: indica la data in cui eseguo l'ultimo update al record
|
||||
|
||||
|
||||
* TODO Vrs 0.1.5.0 :DONE:
|
||||
* TODO Vrs 0.1.5.2 :WORKING:
|
||||
Modifica per:
|
||||
- Inserire l'importazione di link (solo Idx o Rac di A69) da file di testo
|
||||
- Correggere l'importazione ed esportazione degli elenchi dal DB
|
||||
|
||||
|
||||
* Vrs 0.1.5.1 :DONE:
|
||||
Breve modifica per:
|
||||
- Corretto formato del numero di versione
|
||||
- Razionalizzato il messaggio di update dell'engine.
|
||||
- Inserito gli aggiornamenti dell'engine sul log degli eventi
|
||||
|
||||
* Vrs 0.1.5.0 :DONE:
|
||||
Applicazione che serializza i dati su SQLite, ma continua ad usare liste internamente per
|
||||
recuperare il codice già fatto.
|
||||
|
||||
|
||||
@@ -56,13 +56,19 @@ namespace A69WD {
|
||||
/// <param name="FullFileName">Nome completo del file da creare/sovrascrivere</param>
|
||||
/// <param name="Text">StringBuilder con il testo da riportare nel file</param>
|
||||
public static void WriteTextFile(string FullFileName, StringBuilder Text) {
|
||||
System.IO.StreamWriter sw = new System.IO.StreamWriter(FullFileName, false, Encoding.UTF8);
|
||||
//System.IO.StreamWriter sw = new System.IO.StreamWriter(FullFileName, false, Encoding.UTF8);
|
||||
//sw.Write(Text.ToString());
|
||||
//sw.Flush();
|
||||
//sw.Close();
|
||||
WriteTextFile(FullFileName, Text, Encoding.UTF8);
|
||||
}
|
||||
public static void WriteTextFile(string FullFileName, StringBuilder Text, Encoding code) {
|
||||
System.IO.StreamWriter sw = new System.IO.StreamWriter(FullFileName, false, code);
|
||||
sw.Write(Text.ToString());
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Metodo che legge un testo da file (UTF8)
|
||||
/// </summary>
|
||||
|
||||
@@ -98,6 +98,50 @@ namespace A69WD {
|
||||
state = EngineStatusEnum.Stopping;
|
||||
}
|
||||
|
||||
public int ImportLinkFromFile(string SrcFilePath) {
|
||||
int res = 0;
|
||||
try {
|
||||
if (File.Exists(SrcFilePath)) {
|
||||
StreamReader sr = new StreamReader(SrcFilePath, Encoding.UTF8);
|
||||
string row = sr.ReadLine().Trim();
|
||||
while (row != null) {
|
||||
// verifico che non sia un commento:
|
||||
if (!(row.StartsWith("#") || row.StartsWith("//"))) {
|
||||
// Se link nuovo:
|
||||
if (!allLinks.Contains(row)) {
|
||||
// Link nuovo, mi comporto di conseguenza alla tipologia:
|
||||
if (IsRacLink(row)) {
|
||||
// Link ad un racconto
|
||||
allLinks.Add(row);
|
||||
if (downRac) { toDownload.Add(row); }
|
||||
racLinks.Add(row);
|
||||
res++;
|
||||
} else {
|
||||
if (IsIdxLink(row)) {
|
||||
// Link ad un indice
|
||||
allLinks.Add(row);
|
||||
toDownload.Add(row);
|
||||
res++;
|
||||
} else {
|
||||
// Link non riconosciuto, lo scarto
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Read the next line
|
||||
row = sr.ReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
Logger.Log(new object[] { "Error Code: DB07403", "Errore in ImportLinkFromFile()", ex });
|
||||
if (res > 0) res = -1 * res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -135,6 +179,7 @@ namespace A69WD {
|
||||
|
||||
|
||||
|
||||
|
||||
private void Wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
|
||||
object obj = new Object();
|
||||
lock (obj) {
|
||||
@@ -153,6 +198,8 @@ namespace A69WD {
|
||||
sb = new StringBuilder();
|
||||
sb.Append(wb.DocumentText);
|
||||
string fn = Path.Combine(Cfg.Settings.PathAnalizadedRaccFile, GetFileName(link));
|
||||
cTools.WriteTextFile(fn, sb, Encoding.GetEncoding(wb.Document.Encoding));
|
||||
fn = Path.Combine(Cfg.Settings.PathAnalizadedRaccFile, "UTF8_" +GetFileName(link));
|
||||
cTools.WriteTextFile(fn, sb);
|
||||
}
|
||||
|
||||
|
||||
Generated
+19
-12
@@ -28,7 +28,8 @@
|
||||
this.btnDownloadAll = new System.Windows.Forms.Button();
|
||||
this.lblST = new System.Windows.Forms.Label();
|
||||
this.wb1 = new System.Windows.Forms.WebBrowser();
|
||||
this.btnDownloadLink = new System.Windows.Forms.Button();
|
||||
this.btnImportLinks = new System.Windows.Forms.Button();
|
||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnClose
|
||||
@@ -53,7 +54,7 @@
|
||||
//
|
||||
// btnDownloadAll
|
||||
//
|
||||
this.btnDownloadAll.Location = new System.Drawing.Point(135, 12);
|
||||
this.btnDownloadAll.Location = new System.Drawing.Point(12, 12);
|
||||
this.btnDownloadAll.Name = "btnDownloadAll";
|
||||
this.btnDownloadAll.Size = new System.Drawing.Size(117, 33);
|
||||
this.btnDownloadAll.TabIndex = 11;
|
||||
@@ -84,25 +85,30 @@
|
||||
this.wb1.TabStop = false;
|
||||
this.wb1.Visible = false;
|
||||
//
|
||||
// btnDownloadLink
|
||||
// btnImportLinks
|
||||
//
|
||||
this.btnDownloadLink.Location = new System.Drawing.Point(12, 12);
|
||||
this.btnDownloadLink.Name = "btnDownloadLink";
|
||||
this.btnDownloadLink.Size = new System.Drawing.Size(117, 33);
|
||||
this.btnDownloadLink.TabIndex = 10;
|
||||
this.btnDownloadLink.Text = "Download only Link";
|
||||
this.btnDownloadLink.UseVisualStyleBackColor = true;
|
||||
this.btnDownloadLink.Click += new System.EventHandler(this.btnDownloadLink_Click);
|
||||
this.btnImportLinks.Location = new System.Drawing.Point(135, 12);
|
||||
this.btnImportLinks.Name = "btnImportLinks";
|
||||
this.btnImportLinks.Size = new System.Drawing.Size(117, 33);
|
||||
this.btnImportLinks.TabIndex = 15;
|
||||
this.btnImportLinks.Text = "Import Links";
|
||||
this.btnImportLinks.UseVisualStyleBackColor = true;
|
||||
this.btnImportLinks.Click += new System.EventHandler(this.btnImportLinks_Click);
|
||||
//
|
||||
// openFileDialog1
|
||||
//
|
||||
this.openFileDialog1.FileName = "openFileDialog1";
|
||||
this.openFileDialog1.Filter = "File Testo|*.tes|Tutti i file|*.*";
|
||||
//
|
||||
// frmDownloader
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(504, 74);
|
||||
this.Controls.Add(this.btnImportLinks);
|
||||
this.Controls.Add(this.btnClose);
|
||||
this.Controls.Add(this.btnHide);
|
||||
this.Controls.Add(this.btnDownloadAll);
|
||||
this.Controls.Add(this.btnDownloadLink);
|
||||
this.Controls.Add(this.lblST);
|
||||
this.Controls.Add(this.wb1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
@@ -118,6 +124,7 @@
|
||||
private System.Windows.Forms.Button btnDownloadAll;
|
||||
private System.Windows.Forms.Label lblST;
|
||||
private System.Windows.Forms.WebBrowser wb1;
|
||||
private System.Windows.Forms.Button btnDownloadLink;
|
||||
private System.Windows.Forms.Button btnImportLinks;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@@ -21,8 +22,16 @@ namespace A69WD {
|
||||
cA69Engine engine = null;
|
||||
|
||||
|
||||
private void btnDownloadLink_Click(object sender, EventArgs e) {
|
||||
engine.Start(false);
|
||||
/// <summary>
|
||||
/// Metodo per scansionare i link da un file di testo ed inserirli come da downloadare se non ci sono già
|
||||
/// </summary>
|
||||
private void btnImportLinks_Click(object sender, EventArgs e) {
|
||||
// Chiedo il file di testo da caricare
|
||||
lblST.Text = " ";
|
||||
this.openFileDialog1.InitialDirectory = Cfg.Settings.PathApplicationRoot;
|
||||
if (this.openFileDialog1.ShowDialog() == DialogResult.OK) {
|
||||
lblST.Text = string.Format("Importati {0} link", engine.ImportLinkFromFile(openFileDialog1.FileNames[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private void btnDownloadAll_Click(object sender, EventArgs e) {
|
||||
@@ -30,7 +39,9 @@ namespace A69WD {
|
||||
}
|
||||
|
||||
private void btnHide_Click(object sender, EventArgs e) {
|
||||
this.Hide();
|
||||
if (MessageBox.Show("Metodo ancora da terminare, la finestra non sarà più visibile, killare il processo", "ATTENZIONE", MessageBoxButtons.OKCancel) == DialogResult.OK){
|
||||
this.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e) {
|
||||
@@ -63,9 +74,10 @@ namespace A69WD {
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}//class frmDownloader
|
||||
}//namespace A69WD
|
||||
@@ -117,4 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in new issue
Block a user