");
+
+ // Intestazione
+ sb.AppendLine($"
{racconto.Title}
");
+ if (!string.IsNullOrEmpty(racconto.SubTitle))
+ sb.AppendLine($"
{racconto.SubTitle}
");
+
+ // Metadata (Autori, Voto, Origini)
+ sb.AppendLine("
");
+
+ // Corpo del racconto (Trama)
+ sb.AppendLine("
");
+ sb.AppendLine(racconto.Trama); // Preserva i ritorni a capo grazie a white-space: pre-wrap
+ sb.AppendLine("
");
+
+ // Note (se presenti)
+ if (racconto.Notes.Any()) {
+ sb.AppendLine("
");
+ sb.AppendLine("
Note
");
+ foreach (var nota in racconto.Notes)
+ sb.AppendLine($"
{nota.Key}: {nota.Description}
");
+ sb.AppendLine("
");
+ }
+
+ // Tags
+ if (racconto.Tags.Any()) {
+ sb.AppendLine("
");
+ racconto.Tags.Sort();
+ //foreach (var tag in racconto.Tags)
+ // sb.AppendLine($" #{tag}");
+ racconto.Tags.ForEach(t => sb.AppendLine($" #{t}"));
+ sb.AppendLine("
");
+ }
+
+ // Footer
+ sb.AppendLine(" ");
+
+ sb.AppendLine("
"); // Fine container
+ sb.AppendLine("");
+ sb.AppendLine("");
+
+ // Scrittura su file
+ File.WriteAllText(pathCompleto, sb.ToString());
+ } catch (Exception ex) { Logger.Error("A69 Export - " + ex.Message); }
+ return pathCompleto;
+ }
+
+
+
} // class cRac
}//namespace A69WD.Data
diff --git a/Src/A69WD/Net/cLink_A69.cs b/Src/A69WD/Net/cLink_A69.cs
index 3d3a7a2..84ea899 100644
--- a/Src/A69WD/Net/cLink_A69.cs
+++ b/Src/A69WD/Net/cLink_A69.cs
@@ -222,10 +222,11 @@ namespace A69WD.Net {
if (parts.Length == 3) {
CultureInfo culture = CultureInfo.CreateSpecificCulture("it-IT");
DateTimeStyles styles = DateTimeStyles.None;
- rac.Creato = DateTime.Now;
- if (!DateTime.TryParse(parts[0].Trim(), culture, styles, out rac.Creato)) {
+ DateTime tmpDT = DateTime.Now;
+ if (!DateTime.TryParse(parts[0].Trim(), culture, styles, out tmpDT)) {
Logger.Error($"A69 - Import - No data - {filePathName}");
}
+ rac.Creato = tmpDT;
}
}
} catch (Exception ex) { Logger.Warning(string.Format("Data non riconosciuta nel file {0}\r\n{1}", FileName, ex.Message)); return null; }
diff --git a/Src/A69WD/Service/Service_Importer.cs b/Src/A69WD/Service/Service_Importer.cs
index 3ba7d0b..c14c1f1 100644
--- a/Src/A69WD/Service/Service_Importer.cs
+++ b/Src/A69WD/Service/Service_Importer.cs
@@ -83,8 +83,8 @@ namespace A69WD.Service {
if (rac != null) {
// Racconto estratto correttamente, lo salvo sul DB
Logger.Warning($"Import - estrazione corretta: {name}");
- int res = App.DB.ImportRac(rac);
- if (res != 1) {
+ int res = App.DB.ImportRac(rac); // res=id del racconto nel DB
+ if (res < 1) {
// errore nel salvataggio
Logger.Warning($"Import - errore nel salvataggio: {name}");
Interlocked.Increment(ref _errori);
diff --git a/Src/A69WD/UI/frmDownloader.Designer.cs b/Src/A69WD/UI/frmDownloader.Designer.cs
index 915fa03..2c1e625 100644
--- a/Src/A69WD/UI/frmDownloader.Designer.cs
+++ b/Src/A69WD/UI/frmDownloader.Designer.cs
@@ -31,6 +31,7 @@
this.btnShowLog = new System.Windows.Forms.Button();
this.pbST = new System.Windows.Forms.ProgressBar();
this.btnImport = new System.Windows.Forms.Button();
+ this.btnTest = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnClose
@@ -108,11 +109,22 @@
this.btnImport.UseVisualStyleBackColor = true;
this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
//
+ // btnTest
+ //
+ this.btnTest.Location = new System.Drawing.Point(121, -1);
+ this.btnTest.Name = "btnTest";
+ this.btnTest.Size = new System.Drawing.Size(55, 33);
+ this.btnTest.TabIndex = 20;
+ this.btnTest.Text = "Test";
+ this.btnTest.UseVisualStyleBackColor = true;
+ this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
+ //
// frmDownloader
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(433, 95);
+ this.Controls.Add(this.btnTest);
this.Controls.Add(this.btnImport);
this.Controls.Add(this.pbST);
this.Controls.Add(this.btnShowLog);
@@ -136,5 +148,6 @@
private System.Windows.Forms.Button btnShowLog;
private System.Windows.Forms.ProgressBar pbST;
private System.Windows.Forms.Button btnImport;
+ private System.Windows.Forms.Button btnTest;
}
}
\ No newline at end of file
diff --git a/Src/A69WD/UI/frmDownloader.cs b/Src/A69WD/UI/frmDownloader.cs
index 2e8a854..cc3562d 100644
--- a/Src/A69WD/UI/frmDownloader.cs
+++ b/Src/A69WD/UI/frmDownloader.cs
@@ -183,6 +183,76 @@ namespace A69WD {
}
private Service_Importer serviceImporter = null;
+ private async void btnTest_Click(object sender, EventArgs e) {
+ // // Test dell'esportazione in html
+ // int MaxRac = 60;
+ // pbST.Maximum = MaxRac;
+ // pbST.Minimum = 0;
+ // pbST.Value = 0;
+ // lblST.Text = "Inizio esportazione racconti";
+ // for (int i = 0; i < 61; i++) {
+ // cRac rac = App.DB.GetRacById(i);
+ // cRac.EsportaInHtml(rac, Cfg.Settings.PathDownloadWorking);
+ // pbST.Value = i;
+ // lblST.Text = $"Esportato racconto ID={rac.strIDrac}";
+ // }
+ // lblST.Text = $"Fine esportazione {MaxRac.ToString("000")} racconti";
+
+
+
+ // // Test funzione di lettura dal DB
+ // Logger.Information("-- Start test 100*50 letture originali --");
+ // DateTime start = DateTime.Now;
+ // for (int j = 0; j < 100; j++) {
+ // for (int i = 1; i <= 50; i++) {
+ // cRac rac = App.DB.GetRacById_Orig(i);
+ // if (rac.IDrac != i) Logger.Information($"Letto ID={i.ToString()}");
+ // }
+ // }
+ // TimeSpan tp = start-DateTime.Now;
+ // Logger.Information($" End test in {tp.ToString()}");
+ // Logger.Information("-- Start test 100*50 letture nuove --");
+ // start = DateTime.Now;
+ // for (int j = 0; j < 100; j++) {
+ // for (int i = 1; i <= 50; i++) {
+ // cRac rac = App.DB.GetRacById(i);
+ // if (rac.IDrac != i) Logger.Information($"Letto ID={i.ToString()}");
+ // }
+ // }
+ // tp = start - DateTime.Now;
+ // Logger.Information($" End test in {tp.ToString()}");
+
+ // Test di salvataggio sul DB
+ // leggo 3 nuovi racconti
+ string file = @"C:\Commesse\_zPrivate\A69WD\Test\Down\A69_altro_Decisione-estrema_133364.html";
+ cLink_A69 lk = new cLink_A69(file, "A69_altro_Decisione-estrema_133364.html");
+ cRac rac1 = await lk.EstraiRac(file);
+ file = @"C:\Commesse\_zPrivate\A69WD\Test\Down\A69_altro_Decisione_133364 - Copy.html";
+ lk = new cLink_A69(file, "A69_altro_Decisione_133364 - Copy.html");
+ cRac rac2 = await lk.EstraiRac(file);
+ file = @"C:\Commesse\_zPrivate\A69WD\Test\Down\A69_altro_Dammi-un-bacio_153877.html";
+ lk = new cLink_A69(file, "A69_altro_Dammi-un-bacio_153877.html");
+ cRac rac3 = await lk.EstraiRac(file);
+ file = @"C:\Commesse\_zPrivate\A69WD\Test\Down\A69_altro_dammi-la-mano_157904.html";
+ lk = new cLink_A69(file, "A69_altro_dammi-la-mano_157904.html");
+ cRac rac4 = await lk.EstraiRac(file);
+ // // Controprova:
+ // var res1 = App.DB.ImportRac(rac1);
+ // var res2 = App.DB.ImportRac(rac2);
+ // var res3 = App.DB.ImportRac(rac3);
+ // var res4 = App.DB.ImportRac(rac4);
+ // Provo a salvarli
+ var res1 = App.DB.SalvaRacconto(rac1);
+ var res2 = App.DB.SalvaRacconto(rac2);
+ var res3 = App.DB.SalvaRacconto(rac3);
+ var res4 = App.DB.SalvaRacconto(rac4);
+
+ //
+ }
+
+
+
+
}//class frmDownloader