Vrs 0.4.1.0
Vrs 0.4.1.0 Compilata da CSiCoAlm il 2025/12/27 Gestito l'importazione dei racconti da file di testo - Inserito nel DB le tabelle per l'archivio dei racconti - Inserito gestione in memoria del DB (manca ottimizzazione lasciando l'archivio su file come fatto per ATDB) - Inserito classe cRac per rappresentare un racconto - Testata procedura per estrarre un racconto da un file. - Testata procedura per salvare un racconto sul DB - Inserito pulsante per far partire l'importazione su un singolo thread secondario ToDo: - Aggiungere gestione parallela della FIFO secondo vecchi modello per aumentare il feedback alla UI - Inserire anche l'estrazione dei racconti - Per ora metto tutto il DB in memoria, poi dovrò ottimizzare come su ATDB Merge pull request 'Importazione dei racconti dai file' (#5) from mrk/Issue: MrkPi/A69WD#4 into master Reviewed-on: http://mrkalm.ddns.net:34333/MrkPi/A69WD/pulls/5 Issue: MrkPi/A69WD#4 Push command: git push origin HEAD:refs/for/master -o topic="Issue: MrkPi/A69WD#4" -o title="Importazione dei racconti dai file" -o description="Gestione dell'importazione dei racconti da file."
This commit is contained in:
commit
d748536041
10 files changed
+3017
-152
No files matched your search
@@ -1 +1 @@
|
|||||||
{"RootPath":"C:\\Commesse\\_zPrivate\\A69WD\\Src\\A69WD","ProjectFileName":"A69WD.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"App.cs"},{"SourceFile":"Data\\DBTools.cs"},{"SourceFile":"Net\\ATLink.cs"},{"SourceFile":"Net\\ATLinkState.cs"},{"SourceFile":"Net\\cA69Engine.cs"},{"SourceFile":"Net\\DownloadClient.cs"},{"SourceFile":"Net\\frmDownloader.cs"},{"SourceFile":"Net\\frmDownloader.Designer.cs"},{"SourceFile":"Data\\eLinkState.cs"},{"SourceFile":"General\\Cfg.cs"},{"SourceFile":"General\\cTools.cs"},{"SourceFile":"Logger.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Properties\\Resources.Designer.cs"},{"SourceFile":"Properties\\Settings.Designer.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\Commesse\\_zPrivate\\A69WD\\Src\\_Lib\\HtmlAgilityPack.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Commesse\\_zPrivate\\A69WD\\Src\\_Lib\\System.Data.SQLite.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Deployment.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Drawing.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Windows.Forms.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Commesse\\_zPrivate\\A69WD\\Src\\A69WD\\bin\\Debug\\A69WD.exe","OutputItemRelativePath":"A69WD.exe"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]}
|
{"RootPath":"C:\\Commesse\\_zPrivate\\A69WD\\Src\\A69WD","ProjectFileName":"A69WD.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"App.cs"},{"SourceFile":"Data\\cNota.cs"},{"SourceFile":"Data\\cRac.cs"},{"SourceFile":"Data\\DBTools.cs"},{"SourceFile":"Net\\eLinkState.cs"},{"SourceFile":"Net\\cLink_A69.cs"},{"SourceFile":"Service\\Service_Crawler.cs"},{"SourceFile":"Site\\cSite_A69.cs"},{"SourceFile":"UI\\frmDownloader.cs"},{"SourceFile":"UI\\frmDownloader.Designer.cs"},{"SourceFile":"General\\Cfg.cs"},{"SourceFile":"General\\cTools.cs"},{"SourceFile":"General\\Logger.cs"},{"SourceFile":"Net\\iLink.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Site\\iSiteType.cs"},{"SourceFile":"Properties\\Resources.Designer.cs"},{"SourceFile":"Properties\\Settings.Designer.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\Commesse\\_zPrivate\\A69WD\\Src\\_Lib\\HtmlAgilityPack.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Commesse\\_zPrivate\\A69WD\\Src\\_Lib\\System.Data.SQLite.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Deployment.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Drawing.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Windows.Forms.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Commesse\\_zPrivate\\A69WD\\Src\\A69WD\\bin\\Debug\\A69WD.exe","OutputItemRelativePath":"A69WD.exe"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]}
|
||||||
@@ -59,10 +59,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="App.cs" />
|
<Compile Include="App.cs" />
|
||||||
|
<Compile Include="Data\cNota.cs" />
|
||||||
|
<Compile Include="Data\cRac.cs" />
|
||||||
<Compile Include="Data\DBTools.cs" />
|
<Compile Include="Data\DBTools.cs" />
|
||||||
<Compile Include="Net\eLinkState.cs" />
|
<Compile Include="Net\eLinkState.cs" />
|
||||||
<Compile Include="Net\cLink_A69.cs" />
|
<Compile Include="Net\cLink_A69.cs" />
|
||||||
<Compile Include="Service\Service_Crawler.cs" />
|
<Compile Include="Service\Service_Crawler.cs" />
|
||||||
|
<Compile Include="Service\Service_Importer.cs" />
|
||||||
<Compile Include="Site\cSite_A69.cs" />
|
<Compile Include="Site\cSite_A69.cs" />
|
||||||
<Compile Include="UI\frmDownloader.cs">
|
<Compile Include="UI\frmDownloader.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
|
|||||||
+1426
-122
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace A69WD.Data {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Serve per gestire una nota che sarà la coppia di stringhe: {Key} - {Descrizione}
|
||||||
|
/// </summary>
|
||||||
|
public class cNota {
|
||||||
|
|
||||||
|
public string Key { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stringa di separazione fra i vari campi quando esprimo un elenco tramite una singola stringa
|
||||||
|
/// </summary>
|
||||||
|
private const string SEPARATORETXT = " -|- ";
|
||||||
|
|
||||||
|
public cNota() {
|
||||||
|
Key = "";
|
||||||
|
Description = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public cNota(string key, string description) {
|
||||||
|
Key = key;
|
||||||
|
Description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return Key + SEPARATORETXT + Description;
|
||||||
|
}
|
||||||
|
|
||||||
|
}//class cNota
|
||||||
|
|
||||||
|
}//namespace A69WD.Data
|
||||||
@@ -0,0 +1,830 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace A69WD.Data {
|
||||||
|
|
||||||
|
public class cRac {
|
||||||
|
|
||||||
|
#region Costruttori
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Costruttore
|
||||||
|
/// </summary>
|
||||||
|
public cRac() { isValid = false; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Costruttore per un racconto nullo, utilizzato per mostrare eventuali errori o messaggi
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title">Stringa che si vuole visualizzare come titolo del racconto</param>
|
||||||
|
/// <param name="trama">Stringa che si vuole visualizzare come testo del racconto</param>
|
||||||
|
public cRac(string title, string trama) {
|
||||||
|
this.IDrac = 0;
|
||||||
|
this.Title = title;
|
||||||
|
this.Trama = "\n\n" + trama + "\n\n";
|
||||||
|
this.Creato = DateTime.Now;
|
||||||
|
this.Updated = DateTime.Now;
|
||||||
|
this.isValid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Propietà e Fields:
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Identificativo del racconto
|
||||||
|
/// </summary>
|
||||||
|
public long IDrac = -1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Titolo del racconto
|
||||||
|
/// </summary>
|
||||||
|
public string Title = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sottotitolo del racconto
|
||||||
|
/// </summary>
|
||||||
|
public string SubTitle = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Elenco dei tag (ex Props) associati al racconto
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Tags = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Note aggiuntive associate al racconto, sono del tipo: {Key} - {Descrizione}
|
||||||
|
/// Un tipo di nota sempre presente è la "Src" che individua la sorgente (link del file downloadato) da dove ho preso il racconto
|
||||||
|
/// Devo poter aver più source e quindi abbandono la struttura dizionario per avere una lista di coppie di stringhe
|
||||||
|
/// </summary>
|
||||||
|
//public System.Collections.Generic.Dictionary<string, string> Notes = null;
|
||||||
|
public List<cNota> Notes = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Elenco degli autori del racconto
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Autori = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Elenco delle origini del racconto
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Origini = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Voto assegnato al racconto
|
||||||
|
/// </summary>
|
||||||
|
public string Voto = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Trama del racconto
|
||||||
|
/// </summary>
|
||||||
|
public string Trama = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data di creazione/pubblicazione del racconto o in mancanza di essa, data di inserimento del racconto in ATDB
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Creato = DateTime.MinValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data dell'ultimo update del racconto.
|
||||||
|
/// Inizialmente sarà la data di inserimento in ATDB, poi sarà la data dell'ultima lettura o dell'ultima iterazione con il racconto stesso.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Updated = DateTime.MinValue;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Metodi: strIDrac, strTags, fullTitle
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ID del racconto espresso in formato testuale
|
||||||
|
/// </summary>
|
||||||
|
public string strIDrac { get { return IDrac.ToString("000000"); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data di creazione del racconto espressa in forma testuale
|
||||||
|
/// </summary>
|
||||||
|
public string strCreato { get { return DateFormat(Creato); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data di creazione del racconto espressa in forma testuale
|
||||||
|
/// </summary>
|
||||||
|
public string strUpdated { get { return DateFormat(Updated); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Elenco dei tags associati al racconto, espresso come singola stringa in cui i tag sono separati da |
|
||||||
|
/// </summary>
|
||||||
|
public string strTags {
|
||||||
|
get {
|
||||||
|
try {
|
||||||
|
string msg = "";
|
||||||
|
Tags.Sort();
|
||||||
|
foreach (string tags in Tags) {
|
||||||
|
msg += tags + SEPARATORETXT;
|
||||||
|
}
|
||||||
|
return msg.Remove(msg.Length - SEPARATORETXT.Length);
|
||||||
|
} catch {
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Elenco delle note associate al racconto, espresso come singola stringa in cui ciascuna riga è una nota e utilizzo il separatore per dividere la Key dalla Descrizione
|
||||||
|
/// </summary>
|
||||||
|
public string strNotes {
|
||||||
|
get {
|
||||||
|
try {
|
||||||
|
string msg = "";
|
||||||
|
string endLine = "\r\n";
|
||||||
|
Notes.Sort();
|
||||||
|
foreach (cNota nota in Notes) {
|
||||||
|
msg += nota.ToString() + endLine;
|
||||||
|
}
|
||||||
|
return msg.Remove(msg.Length - endLine.Length);
|
||||||
|
} catch {
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Titolo completo del racconto, cioè il suo titolo con il sottotitolo
|
||||||
|
/// </summary>
|
||||||
|
public string fullTitle {
|
||||||
|
get {
|
||||||
|
if (string.IsNullOrEmpty(SubTitle)) {
|
||||||
|
return Title;
|
||||||
|
} else {
|
||||||
|
return Title + " - " + SubTitle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indica se il racconto è valido o no (nullo)
|
||||||
|
/// </summary>
|
||||||
|
public bool IsValid { get { return isValid; } }
|
||||||
|
private bool isValid = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Esegue la verifica dei dati del racconto e ritorna lo stato di raconto valido.
|
||||||
|
/// Per ora lo imposta di ufficio a valido, ma in futuro questo è da rivedere.
|
||||||
|
/// </summary>
|
||||||
|
public bool Validate() {
|
||||||
|
try {
|
||||||
|
isValid = true;
|
||||||
|
if (String.IsNullOrEmpty(Title) || String.IsNullOrWhiteSpace(Title)) {
|
||||||
|
Logger.Warning("NOT VALIDATE - Missing Title - " + strIDrac + " - " + fullTitle);
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
if (String.IsNullOrEmpty(Trama) || String.IsNullOrWhiteSpace(Trama)) {
|
||||||
|
Logger.Warning("NOT VALIDATE - Missing Trama - " + strIDrac + " - " + fullTitle);
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
if (Autori == null) {
|
||||||
|
Logger.Warning("NOT VALIDATE - Missing Autors -" + strIDrac + " - " + fullTitle);
|
||||||
|
isValid = false;
|
||||||
|
} else {
|
||||||
|
foreach (string autor in Autori) {
|
||||||
|
if (String.IsNullOrEmpty(autor) || String.IsNullOrWhiteSpace(autor)) {
|
||||||
|
Logger.Warning("NOT VALIDATE - Missing Autor -" + strIDrac + " - " + fullTitle);
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Tags == null) {
|
||||||
|
Logger.Warning("NOT VALIDATE - Missing Tags -" + strIDrac + " - " + fullTitle);
|
||||||
|
isValid = false;
|
||||||
|
} else {
|
||||||
|
foreach (string tag in Tags) {
|
||||||
|
if (String.IsNullOrEmpty(tag) || String.IsNullOrWhiteSpace(tag)) {
|
||||||
|
Logger.Warning("NOT VALIDATE - Missing Tag -" + strIDrac + " - " + fullTitle);
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Creato > Updated) {
|
||||||
|
Logger.Warning("NOT VALIDATE - Creato > Updated -" + strIDrac + " - " + fullTitle);
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
} catch (Exception ex) { Logger.Log(new object[] { "Error Code:val001", "Errore in ATWD.Rac.Validate", ex }); }
|
||||||
|
|
||||||
|
try {
|
||||||
|
//if (!isValid) {
|
||||||
|
// Logger.Warning("NOT VALIDATE: " + strIDrac + " - " + fullTitle);
|
||||||
|
//}
|
||||||
|
} catch (Exception ex) { Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER375278", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); }
|
||||||
|
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Crea il file html che rappresenta il racconto.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True se tutto ok, False altrimenti.</returns>
|
||||||
|
public bool CreaFileRac() {
|
||||||
|
bool res = true;
|
||||||
|
try {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.AppendFormat("<html>\n\t<head>\n\t\t<Title>{0}</Title>\n\t\t<link href=\"stylesheet.css\" rel=\"stylesheet\" type=\"text/css\"/>\n\t</head>\n\t<body>\n", fullTitle);
|
||||||
|
sb.AppendFormat("\t\t<h2 class=Title>{0}</h2>\n", Title);
|
||||||
|
if (!string.IsNullOrEmpty(SubTitle)) sb.AppendFormat("\t\t<p class=SubTitle>{0}</p>\n", SubTitle);
|
||||||
|
sb.Append("\t\t<div class=Menu><a href=\"#EndRac\">Salta</a></div>\n");
|
||||||
|
if (Autori.Count == 1) {
|
||||||
|
sb.AppendFormat("\t\t<p class=Autore>Autore: {0}</p>\n", Autori[0]);
|
||||||
|
} else {
|
||||||
|
sb.Append("\t\t<p class=Autore>Autore: ");
|
||||||
|
foreach (string autor in Autori) {
|
||||||
|
sb.AppendFormat("{0} - ", autor);
|
||||||
|
}
|
||||||
|
sb.Append("</p>\n");
|
||||||
|
}
|
||||||
|
sb.Append("\t\t<p class=Property>Propietà del racconto: <br />\n");
|
||||||
|
foreach (string prop in Tags) {
|
||||||
|
sb.AppendFormat("{0}<br />\n", prop);
|
||||||
|
}
|
||||||
|
sb.Append("\t\t</p>");
|
||||||
|
sb.AppendFormat("\t\t<p class=Data>Inserito il: {0}</p>\n", Creato.ToString("dd/MM/yyyy"));
|
||||||
|
if (Origini.Count == 1) {
|
||||||
|
sb.AppendFormat("\t\t<p class=Origine>Origine: {0}</p>\n", Origini[0]);
|
||||||
|
} else {
|
||||||
|
sb.Append("\t\t<p class=Origine>Origine: ");
|
||||||
|
foreach (string orig in Origini) {
|
||||||
|
sb.AppendFormat("{0} - ", orig);
|
||||||
|
}
|
||||||
|
sb.Append("</p>\n");
|
||||||
|
}
|
||||||
|
sb.Append("\t\t<p class=Property>Note del racconto:<br />\n");
|
||||||
|
foreach (cNota nota in Notes) { sb.AppendFormat("{0}<br />\n", nota.ToString()); }
|
||||||
|
sb.AppendFormat("ID: {0}<br />\n</p>", strIDrac);
|
||||||
|
//sb.AppendFormat("\t\t<p class=Trama>{0}</p>\n", rac.Trama.Replace("\n", "</p>\n<p class=Trama>"));
|
||||||
|
sb.AppendFormat("\t\t<p class=Trama>{0}</p>\n", Trama.Replace("\n", "<br />"));
|
||||||
|
sb.Append("\t\t<div class=Menu><a name=\"EndRac\" href=\"#\">Fine</a></div>\n");
|
||||||
|
sb.AppendLine("\t</body>\n<html>");
|
||||||
|
// Salvo il file
|
||||||
|
cTools.WriteTextFile(System.IO.Path.Combine(Cfg.Settings.PathDownloadWorking, FileRacName(IDrac)), sb);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.Log(new object[] { "Error Code: eBook003", "Errore in ATWD.frmMain.CreaFileToc(Racs)", ex });
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Crea il file Markdown che rappresenta un racconto.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True se tutto ok, False altrimenti.</returns>
|
||||||
|
public bool CreaFileMD() {
|
||||||
|
bool res = true;
|
||||||
|
try {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.AppendFormat("# {0}\n", Title);
|
||||||
|
if (!string.IsNullOrEmpty(SubTitle)) sb.AppendFormat("## {0}\n", SubTitle);
|
||||||
|
if (Autori.Count == 1) {
|
||||||
|
sb.AppendFormat("### By {0}\n", Autori[0]);
|
||||||
|
} else {
|
||||||
|
sb.Append("### By ");
|
||||||
|
foreach (string autor in Autori) {
|
||||||
|
sb.AppendFormat("{0}, ", autor);
|
||||||
|
}
|
||||||
|
sb.Append("\n");
|
||||||
|
}
|
||||||
|
sb.AppendFormat("- Voto: #{0} \n", Voto.Replace(" ", ""));
|
||||||
|
sb.Append("- Tags: ");
|
||||||
|
foreach (string prop in Tags) {
|
||||||
|
sb.AppendFormat("#{0} ", prop.Replace(" ", ""));
|
||||||
|
}
|
||||||
|
sb.Append("\n");
|
||||||
|
sb.AppendFormat("- Creato: {0}\n", Creato.ToString("dd/MM/yyyy"));
|
||||||
|
sb.AppendFormat("- Update: {0}\n", Updated.ToString("dd/MM/yyyy"));
|
||||||
|
if (Origini.Count == 1) {
|
||||||
|
sb.AppendFormat("- Origin: {0}\n", Origini[0]);
|
||||||
|
} else {
|
||||||
|
sb.Append("- Origin: ");
|
||||||
|
foreach (string orig in Origini) {
|
||||||
|
sb.AppendFormat(" - {0}\n", orig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.Append("- Notes: \n");
|
||||||
|
foreach (cNota nota in Notes) { sb.AppendFormat(" - {0}<br />\n", nota.ToString()); }
|
||||||
|
sb.Append("\n");
|
||||||
|
sb.AppendFormat("{0}\n", Trama);
|
||||||
|
sb.Append("\n");
|
||||||
|
sb.Append("\n");
|
||||||
|
// Salvo il file
|
||||||
|
cTools.WriteTextFile(System.IO.Path.Combine(Cfg.Settings.PathDownloadWorking, "Rac" + IDrac.ToString("00000") + ".md"), sb);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.Log(new object[] { "Error Code: eBook003", "Errore in ATWD.frmMain.CreaFileMD(Racs)", ex });
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Crea un nome univoco per il file htm che rappresenta un racconto.
|
||||||
|
/// Rac00000.htm
|
||||||
|
/// </summary>
|
||||||
|
public static string FileRacName(long RacID) { return "Rac" + RacID.ToString("00000") + ".htm"; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stringa di separazione fra i vari campi quando esprimo un elenco tramite una singola stringa
|
||||||
|
/// </summary>
|
||||||
|
private const string SEPARATORETXT = " -|- ";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Esprime la data indicata con una stringa opportunamente formattata
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt">DateTime da esprimere in testo</param>
|
||||||
|
/// <returns>Il testo opportunamente formattato</returns>
|
||||||
|
private string DateFormat(DateTime dt) { return dt.ToString("yyyy/MM/dd"); }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Override per esprimere in modo formale un racconto con una singola stringa.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Stringa che rappresenta l'intero racconto</returns>
|
||||||
|
public override string ToString() {
|
||||||
|
try {
|
||||||
|
if (!Validate()) return string.Format("Racconto (ID={0}) non valido.", strIDrac);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.AppendFormat("- ID Rac:\t{0}\n", strIDrac);
|
||||||
|
sb.AppendFormat("- Title: \t{0}\n", Title);
|
||||||
|
sb.AppendFormat("- SubTit:\t{0}\n", SubTitle);
|
||||||
|
string tmp = "";
|
||||||
|
if (Autori != null) {
|
||||||
|
Autori.Sort();
|
||||||
|
foreach (string aut in Autori) {
|
||||||
|
tmp += string.Format("{0}{1}", aut, SEPARATORETXT);
|
||||||
|
}
|
||||||
|
if (tmp.Length > 0) tmp = tmp.Remove(tmp.Length - SEPARATORETXT.Length);
|
||||||
|
}
|
||||||
|
sb.AppendFormat("- Autors:\t{0}\n", tmp);
|
||||||
|
sb.AppendFormat("- Voto: \t{0}\n", Voto);
|
||||||
|
tmp = "";
|
||||||
|
if (Tags != null) {
|
||||||
|
Tags.Sort();
|
||||||
|
foreach (string tag in Tags) { tmp += string.Format("{0}{1}", tag, SEPARATORETXT); }
|
||||||
|
if (tmp.Length > 0) tmp = tmp.Remove(tmp.Length - SEPARATORETXT.Length);
|
||||||
|
}
|
||||||
|
sb.AppendFormat("- Tags: \t{0}\n", tmp);
|
||||||
|
tmp = "";
|
||||||
|
if (Notes != null) {
|
||||||
|
foreach (cNota nota in Notes) { sb.AppendFormat("- Notes: \t{0}{2}{1}\n", nota.Key, nota.Description, SEPARATORETXT); }
|
||||||
|
} else { sb.Append("- Notes: \n"); }
|
||||||
|
sb.AppendFormat("- Creato:\t{0}\n", strCreato);
|
||||||
|
sb.AppendFormat("- Update:\t{0}\n", strUpdated);
|
||||||
|
tmp = "";
|
||||||
|
if (Origini != null) {
|
||||||
|
Origini.Sort();
|
||||||
|
foreach (string origine in Origini) {
|
||||||
|
tmp += string.Format("{0}{1}", origine, SEPARATORETXT);
|
||||||
|
}
|
||||||
|
if (tmp.Length > 0) tmp = tmp.Remove(tmp.Length - SEPARATORETXT.Length);
|
||||||
|
}
|
||||||
|
sb.AppendFormat("- Origin:\t{0}\n", tmp);
|
||||||
|
sb.AppendFormat("- Trama: \t{0}\n", Trama);
|
||||||
|
sb.AppendLine("");
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00030", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
return string.Format(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00030", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Esprime il racconto in formato HTML formale.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Stringa html che rappresenta l'intero racconto</returns>
|
||||||
|
public string ToHTML() {
|
||||||
|
try {
|
||||||
|
if (!Validate()) return string.Format("<html><body>Racconto (ID={0}) non valido.</body></html>", strIDrac);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.AppendFormat("<html>\n\t<head>\n\t\t<title>{0}</title>\n\t</head>\n\t<body>\n", fullTitle);
|
||||||
|
sb.AppendLine("\t\t</ BR>");
|
||||||
|
sb.AppendFormat("\t\t<P><CENTER><A NAME=\"Start{0}\" HREF=\"#End{0}\">Salta alla fine</A></CENTER></P>\n", strIDrac);
|
||||||
|
sb.AppendLine("\t\t</ BR>");
|
||||||
|
sb.AppendFormat("\t\t<P>- ID Rac: {0}</P>\n", strIDrac);
|
||||||
|
sb.AppendFormat("\t\t<P>- Title: {0}</P>\n", Title);
|
||||||
|
sb.AppendFormat("\t\t<P>- SubTit: {0}</P>\n", SubTitle);
|
||||||
|
string tmp = "";
|
||||||
|
if (Autori != null) {
|
||||||
|
Autori.Sort();
|
||||||
|
foreach (string aut in Autori) {
|
||||||
|
tmp += string.Format("{0}{1}", aut, SEPARATORETXT);
|
||||||
|
}
|
||||||
|
if (tmp.Length > 2) tmp = tmp.Remove(tmp.Length - SEPARATORETXT.Length);
|
||||||
|
}
|
||||||
|
sb.AppendFormat("\t\t<P>- Autors: {0}</P>\n", tmp);
|
||||||
|
sb.AppendFormat("\t\t<P>- Voto: {0}</P>\n", Voto);
|
||||||
|
tmp = "";
|
||||||
|
if (Tags != null) {
|
||||||
|
Tags.Sort();
|
||||||
|
foreach (string tag in Tags) { tmp += string.Format("{0}{1}", tag, SEPARATORETXT); }
|
||||||
|
if (tmp.Length > 2) tmp = tmp.Remove(tmp.Length - SEPARATORETXT.Length);
|
||||||
|
}
|
||||||
|
sb.AppendFormat("\t\t<P>- Tags: {0}</P>\n", tmp);
|
||||||
|
|
||||||
|
tmp = "";
|
||||||
|
if (Notes != null) {
|
||||||
|
foreach (cNota nota in Notes) { sb.AppendFormat("\t\t<P>- Notes: {0}{2}{1}</P>\n", nota.Key, nota.Description, SEPARATORETXT); }
|
||||||
|
} else { sb.Append("\t\t<P>- Notes: </P>\n"); }
|
||||||
|
sb.AppendFormat("\t\t<P>- Creato: {0}</P>\n", strCreato);
|
||||||
|
sb.AppendFormat("\t\t<P>- Update: {0}</P>\n", strUpdated);
|
||||||
|
sb.AppendFormat("\t\t<P>- Trama: {0}</P>\n", Trama.Replace("\n", "</ BR>\n"));
|
||||||
|
sb.AppendLine("\t\t</ BR>");
|
||||||
|
sb.AppendFormat("\t\t<P><CENTER><A NAME=\"End{0}\" HREF=\"#Start{0}\">Ritorna all'inizio</A></CENTER></P>\n", strIDrac);
|
||||||
|
sb.AppendLine("\t\t</ BR>");
|
||||||
|
sb.AppendLine("\t</body>\n</html>");
|
||||||
|
return sb.ToString();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
return string.Format(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Esprime il racconto in una pagina html con lo style interno.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="NextRacHtmlName">Nome del racconto successivo a cui lincare</param>
|
||||||
|
/// <returns>Stringa html che rappresenta l'intero racconto</returns>
|
||||||
|
public string ToHTML(string NextRacHtmlName) {
|
||||||
|
//try {
|
||||||
|
// if (!IsValid) return string.Format("<html><body>Racconto (ID={0}) non valido.</body></html>", strIDrac);
|
||||||
|
|
||||||
|
// StringBuilder sb = new StringBuilder();
|
||||||
|
// sb.AppendFormat("<html>\n\t<head>\n\t\t<title>{0}</title>\n\t</head>\n\t<body>\n", fullTitle);
|
||||||
|
// sb.AppendLine("\t\t</ BR>");
|
||||||
|
// //sb.AppendFormat("\t\t<P><CENTER><A NAME=\"Start\" HREF=\"#End\">Salta alla fine</A></CENTER></P>\n", strIDrac);
|
||||||
|
// sb.AppendFormat("\t\t<P><CENTER><A NAME=\"Start\" HREF=\".\\" + NextRacHtmlName + "\">Salta al prossimo</A></CENTER></P>\n", strIDrac);
|
||||||
|
// sb.AppendLine("\t\t</ BR>");
|
||||||
|
// sb.AppendFormat("\t\t<P>- ID Rac: {0}</P>\n", strIDrac);
|
||||||
|
// sb.AppendFormat("\t\t<P>- Title: {0}</P>\n", Title);
|
||||||
|
// sb.AppendFormat("\t\t<P>- SubTit: {0}</P>\n", SubTitle);
|
||||||
|
// string tmp = "";
|
||||||
|
// if (Autori != null) {
|
||||||
|
// for (int i = 0; i < Autori.Length; i++) {
|
||||||
|
// tmp += string.Format("{0} | ", Autori[i]);
|
||||||
|
// }
|
||||||
|
// if (tmp.Length > 2) tmp = tmp.Remove(tmp.Length - 3);
|
||||||
|
// }
|
||||||
|
// sb.AppendFormat("\t\t<P>- Autors: {0}</P>\n", tmp);
|
||||||
|
// sb.AppendFormat("\t\t<P>- Voto: {0}</P>\n", Voto);
|
||||||
|
// tmp = "";
|
||||||
|
// if (Tags != null) {
|
||||||
|
// for (int i = 0; i < Tags.Length; i++) {
|
||||||
|
// tmp += string.Format("{0} | ", Tags[i]);
|
||||||
|
// }
|
||||||
|
// if (tmp.Length > 2) tmp = tmp.Remove(tmp.Length - 3);
|
||||||
|
// }
|
||||||
|
// sb.AppendFormat("\t\t<P>- Tags: {0}</P>\n", tmp);
|
||||||
|
|
||||||
|
// tmp = "";
|
||||||
|
// if (Notes != null) {
|
||||||
|
// for (int i = 0; i < Notes.Length; i++) { sb.AppendFormat("\t\t<P>- {0}</P>\n", Notes[i]); }
|
||||||
|
// } else { sb.Append("\t\t<P>- Notes: </P>\n"); }
|
||||||
|
// sb.AppendFormat("\t\t<P>- Creato: {0}</P>\n", Creato.ToString("dd/MM/yyyy"));
|
||||||
|
// sb.AppendFormat("\t\t<P>- Update: {0}</P>\n", Updated.ToString("dd/MM/yyyy"));
|
||||||
|
// sb.AppendFormat("\t\t<P>- Trama: {0}</P>\n", Trama.Replace("\n", "</ BR>\n"));
|
||||||
|
// sb.AppendLine("\t\t</ BR>");
|
||||||
|
// sb.AppendFormat("\t\t<P><CENTER><A NAME=\"End\" HREF=\"#Start\">Ritorna all'inizio</A></CENTER></P>\n", strIDrac);
|
||||||
|
// sb.AppendLine("\t\t</ BR>");
|
||||||
|
// sb.AppendLine("\t</body>\n</html>");
|
||||||
|
// return sb.ToString();
|
||||||
|
//} catch (Exception ex) {
|
||||||
|
// Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
// return string.Format(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
//}
|
||||||
|
try {
|
||||||
|
if (!Validate()) return string.Format("<html><body>Racconto (ID={0}) non valido.</body></html>", strIDrac);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.Append("<HTML>\n\t<HEAD>\n\t\t<SCRIPT language=\"javascript\" type=\"text/javascript\">\n\t\t\tvar win=window.external;\n\t\t</SCRIPT>\n\t\t<STYLE type=\"text/css\">\n");
|
||||||
|
sb.Append("\t\t<!--\n\t\tBODY{\n\t\t\tmargin-left : .5cm;\n\t\t\tmargin-right : .5cm;\n\t\t\tcolor : #000099;\n\t\t\tfont-family : Verdana,Arial,Helvetica;\n\t\t\tbackground-color : #F4F4F4;\n\t\t}");
|
||||||
|
sb.Append("\t\t.Title {\n\t\t\ttext-align : center;\n\t\t\tfont-family : \"Helvetica\";\n\t\t\tfont-size : x-large;\n\t\t}");
|
||||||
|
sb.Append("\t\t.SubTitle {\n\t\t\ttext-align : center; \n\t\t\ttext-indent : 16px;\n\t\t\tfont-family : \"Helvetica\";\n\t\t\tfont-size : large;\n\t\t\tfont-style : italic;\n\t\t}");
|
||||||
|
sb.Append("\t\t.Property {\n\t\t\ttext-align : justify; \n\t\t\ttext-indent : 25px;\n\t\t\tfont-style : italic;\n\t\t}");
|
||||||
|
sb.Append("\t\t.Origine {\n\t\t\ttext-align : justify; \n\t\t\ttext-indent : 25px;\n\t\t\tfont-style : italic;\n\t\t}");
|
||||||
|
sb.Append("\t\t.Autore {\n\t\t\ttext-align : justify; \n\t\t\ttext-indent : 25px;\n\t\t\tfont-style : italic;\n\t\t}");
|
||||||
|
sb.Append("\t\t.Data {\n\t\t\ttext-align : justify; \n\t\t\ttext-indent : 25px;\n\t\t\tfont-style : italic;\n\t\t}");
|
||||||
|
sb.Append("\t\t.Trama {\n\t\t\ttext-align : justify; \n\t\t\ttext-indent : 12px;\n\t\t\tcolor : #000000;\n\t\t}");
|
||||||
|
sb.Append("\t\t.Menu {\n\t\t\ttext-align : center; \n\t\t\ttext-indent : 12px;\n\t\t\tcolor : #000000;\n\t\t}");
|
||||||
|
sb.Append("\t\t.MsgTitle {\n\t\t\ttext-align : justify; \n\t\t\ttext-indent : 25px;\n\t\t\tfont-style : italic;\n\t\t}");
|
||||||
|
sb.Append("\t\t.MsgText {\n\t\t\ttext-align : justify; \n\t\t\ttext-indent : 12px;\n\t\t\tcolor : #000000;\n\t\t}");
|
||||||
|
sb.Append("\t\t.ReportTitle {\n\t\t\ttext-align : center; \n\t\t\tfont-family : \"Helvetica\";\n\t\t\tfont-size : x-large;\n\t\t}");
|
||||||
|
sb.Append("\t\t.ReportText {\n\t\t\ttext-align : justify; \n\t\t\ttext-indent : 25px;\n\t\t\tfont-style : italic;\n\t\t}");
|
||||||
|
sb.Append("\t\t.Menu_Row {\n\t\t\tfont-size:70%;\n\t\t\twhite-space:nowrap;\n\t\t}");
|
||||||
|
sb.Append("\t\t.Menu_sx { text-align:left; width:50%; float: left; }");
|
||||||
|
sb.Append("\t\t.Menu_dx { text-align:right; width:50%; float: right; }");
|
||||||
|
sb.AppendFormat("\t\t-->\n\t\t</STYLE>\n\t\t<TITLE>{0}</TITLE>\n\t</HEAD>\n\t<BODY BGCOLOR=#F4F4F4 LINK=#BDA73A VLINK=#626262>", fullTitle);
|
||||||
|
sb.AppendLine("\t\t</ BR>");
|
||||||
|
sb.AppendFormat("\t\t<P CLASS=Menu><CENTER><A NAME=\"Start\" HREF=\".\\" + NextRacHtmlName + "\">Salta al prossimo</A></CENTER></P>\n", strIDrac);
|
||||||
|
sb.AppendLine("\t\t</ BR>");
|
||||||
|
sb.AppendFormat("\t\t<P CLASS=SubTitle>{0}</P>\n", strIDrac);
|
||||||
|
sb.AppendFormat("\t\t<P CLASS=Title>{0}</P>\n", Title);
|
||||||
|
sb.AppendFormat("\t\t<P CLASS=SubTitle>{0}</P>\n", SubTitle);
|
||||||
|
string tmp = "";
|
||||||
|
if (Autori != null) {
|
||||||
|
Autori.Sort();
|
||||||
|
foreach (string aut in Autori) {
|
||||||
|
tmp += string.Format("{0}{1}", aut, SEPARATORETXT);
|
||||||
|
}
|
||||||
|
if (tmp.Length > 2) tmp = tmp.Remove(tmp.Length - 3);
|
||||||
|
}
|
||||||
|
sb.AppendFormat("\t\t<P CLASS=Autore>- Autors: {0}</P>\n", tmp);
|
||||||
|
sb.AppendFormat("\t\t<P CLASS=Property>- Voto: {0}</P>\n", Voto);
|
||||||
|
tmp = "";
|
||||||
|
if (Tags != null) {
|
||||||
|
Tags.Sort();
|
||||||
|
foreach (string tag in Tags) {
|
||||||
|
tmp += string.Format("{0}{1}", tag, SEPARATORETXT);
|
||||||
|
}
|
||||||
|
if (tmp.Length > 2) tmp = tmp.Remove(tmp.Length - 3);
|
||||||
|
}
|
||||||
|
sb.AppendFormat("\t\t<P CLASS=Property>- Tags: {0}</P>\n", tmp);
|
||||||
|
|
||||||
|
tmp = "";
|
||||||
|
if (Notes != null) {
|
||||||
|
foreach (cNota nota in Notes) { sb.AppendFormat("\t\t<P CLASS=Property>- Notes: {0} - {1}</P>\n", nota.Key, nota.Description); }
|
||||||
|
} else { sb.Append("\t\t<P CLASS=Property>- Notes: </P>\n"); }
|
||||||
|
sb.AppendFormat("\t\t<P CLASS=Data>- Creato: {0}</P>\n", strCreato);
|
||||||
|
sb.AppendFormat("\t\t<P CLASS=Data>- Update: {0}</P>\n", strUpdated);
|
||||||
|
sb.AppendFormat("\t\t<P CLASS=Trama>{0}</P>\n", Trama.Replace("\n", "</ BR>\n"));
|
||||||
|
sb.AppendLine("\t\t</ BR>");
|
||||||
|
sb.AppendFormat("\t\t<P CLASS=Menu><CENTER><A NAME=\"End\" HREF=\"#Start\">Ritorna all'inizio</A></CENTER></P>\n", strIDrac);
|
||||||
|
sb.AppendLine("\t\t</ BR>");
|
||||||
|
sb.AppendLine("\t</body>\n</html>");
|
||||||
|
return sb.ToString();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
return string.Format(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static int Read(string Txt, out cRac[] Racs) {
|
||||||
|
|
||||||
|
// I racconti inseriti devono avere la struttura formale:
|
||||||
|
//
|
||||||
|
// - ID Rac:\t{0}\n
|
||||||
|
// - Title: \t{0}\n
|
||||||
|
// - SubTit:\t{0}\n
|
||||||
|
// - Autors:\t{0}\n Elenco degli autori separati tramite il separatore
|
||||||
|
// - Voto: \t{0}\n
|
||||||
|
// - Tags: \t{0}\n Elenco dei tag separati tramite il separatore
|
||||||
|
// - Notes: \t{0}{2}{1}\n Per ciascuna riga, la coppia Key e Descr separati tramite il separatore
|
||||||
|
// - Creato:\t{0}\n
|
||||||
|
// - Update:\t{0}\n
|
||||||
|
// - Origin:\t{0}\n
|
||||||
|
// - Trama: \t{0}\n
|
||||||
|
//
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Suddivido i vari racconti:
|
||||||
|
string[] splitSeparator = new string[] { "- ID Rac:" };
|
||||||
|
string[] txtRacs = Txt.Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
List<cRac> elenco = new List<cRac>();
|
||||||
|
// Analizzo ciascuno di essi:
|
||||||
|
foreach (string txtRac in txtRacs) {
|
||||||
|
// Leggo il testo riga per riga, fino a che inizia il primo racconto (trovo il tag ID o il titolo):
|
||||||
|
splitSeparator = new string[] { "\n" };
|
||||||
|
string[] rows = ("- ID Rac:" + txtRac).Replace("\r\n", "\n").Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
cRac rac = new cRac();
|
||||||
|
int i;
|
||||||
|
// Ricerco inizio del racconto:
|
||||||
|
for (i = 0; i < rows.Length; i++) {
|
||||||
|
if (rows[i].Trim().StartsWith("- ID Rac:")) {
|
||||||
|
rac.IDrac = long.Parse(rows[i].Replace("- ID Rac:", "").Trim());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Title:")) {
|
||||||
|
rac.Title = rows[i].Replace("- Title:", "").Trim();
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- SubTit:")) {
|
||||||
|
rac.SubTitle = rows[i].Replace("- SubTit:", "").Trim();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Autors:")) {
|
||||||
|
splitSeparator[0] = SEPARATORETXT.Trim();
|
||||||
|
string[] autors = rows[i].Replace("- Autors:", "").Trim().Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
rac.Autori = new List<string>();
|
||||||
|
foreach (string aut in autors) { rac.Autori.Add(aut.Trim()); }
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Voto:")) {
|
||||||
|
rac.Voto = rows[i].Replace("- Voto:", "").Trim();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Tags:")) {
|
||||||
|
splitSeparator[0] = SEPARATORETXT.Trim();
|
||||||
|
string[] tags = rows[i].Replace("- Tags:", "").Trim().Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
rac.Tags = new List<string>();
|
||||||
|
foreach (string tag in tags) { rac.Tags.Add(tag.Trim()); }
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
rac.Notes = new List<cNota>();
|
||||||
|
while (rows[i].Trim().StartsWith("- Notes:")) {
|
||||||
|
string[] note = rows[i].Replace("- Notes:", "").Trim().Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (note.Length == 2) { rac.Notes.Add(new cNota(note[0].Trim(), note[1].Trim())); }
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Creato:")) {
|
||||||
|
rac.Creato = DateTime.Parse(rows[i].Replace("- Creato:", "").Trim());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Update:")) {
|
||||||
|
rac.Updated = DateTime.Parse(rows[i].Replace("- Update:", "").Trim());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Origin:")) {
|
||||||
|
splitSeparator[0] = SEPARATORETXT.Trim();
|
||||||
|
string[] origini = rows[i].Replace("- Origin:", "").Trim().Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
rac.Origini = new List<string>();
|
||||||
|
foreach (string origine in origini) { rac.Origini.Add(origine.Trim()); }
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Trama:")) {
|
||||||
|
rac.Trama = rows[i].Replace("- Trama:", "").Trim() + "\n";
|
||||||
|
i++;
|
||||||
|
for (int j = i; j < rows.Length; j++) {
|
||||||
|
rac.Trama += rows[j].Trim() + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rac.Validate()) {
|
||||||
|
elenco.Add(rac);
|
||||||
|
} else {
|
||||||
|
Logger.Error("Decodifica del racconto dal testo inserito, non riuscita");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Racs = elenco.ToArray();
|
||||||
|
return Racs.Length;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00030", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
Racs = null;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int Read_Old(string Txt, out cRac[] Racs) {
|
||||||
|
|
||||||
|
// ToDo: Gestire più racconti in modo da fare una vera e propia importazione
|
||||||
|
|
||||||
|
// I racconti inseriti devono avere la struttura formale:
|
||||||
|
//
|
||||||
|
// - ID Rac:\t{0}\n
|
||||||
|
// - Title: \t{0}\n
|
||||||
|
// - SubTit:\t{0}\n
|
||||||
|
// - Autors:\t{0}\n Elenco degli autori separati tramite il separatore
|
||||||
|
// - Voto: \t{0}\n
|
||||||
|
// - Tags: \t{0}\n Elenco dei tag separati tramite il separatore
|
||||||
|
// - Notes: \t{0}{2}{1}\n Per ciascuna riga, la coppia Key e Descr separati tramite il separatore
|
||||||
|
// - Creato:\t{0}\n
|
||||||
|
// - Update:\t{0}\n
|
||||||
|
// - Origin:\t{0}\n
|
||||||
|
// - Trama: \t{0}\n
|
||||||
|
//
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Leggo il testo riga per riga, fino a che inizia il primo racconto (trovo il tag ID o il titolo):
|
||||||
|
string[] splitSeparator = new string[] { "\n" };
|
||||||
|
string[] rows = Txt.Replace("\r\n", "\n").Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
cRac rac = new cRac();
|
||||||
|
int i;
|
||||||
|
// Ricerco inizio del racconto:
|
||||||
|
for (i = 0; i < rows.Length; i++) {
|
||||||
|
if (rows[i].Trim().StartsWith("- ID Rac:")) {
|
||||||
|
rac.IDrac = long.Parse(rows[i].Replace("- ID Rac:", "").Trim());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Title:")) {
|
||||||
|
rac.Title = rows[i].Replace("- Title:", "").Trim();
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- SubTit:")) {
|
||||||
|
rac.SubTitle = rows[i].Replace("- SubTit:", "").Trim();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Autors:")) {
|
||||||
|
splitSeparator[0] = SEPARATORETXT.Trim();
|
||||||
|
string[] autors = rows[i].Replace("- Autors:", "").Trim().Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
rac.Autori = new List<string>();
|
||||||
|
foreach (string aut in autors) { rac.Autori.Add(aut.Trim()); }
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Voto:")) {
|
||||||
|
rac.Voto = rows[i].Replace("- Voto:", "").Trim();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Tags:")) {
|
||||||
|
splitSeparator[0] = SEPARATORETXT.Trim();
|
||||||
|
string[] tags = rows[i].Replace("- Tags:", "").Trim().Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
rac.Tags = new List<string>();
|
||||||
|
foreach (string tag in tags) { rac.Tags.Add(tag.Trim()); }
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
rac.Notes = new List<cNota>();
|
||||||
|
while (rows[i].Trim().StartsWith("- Notes:")) {
|
||||||
|
string[] note = rows[i].Replace("- Notes:", "").Trim().Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (note.Length == 2) { rac.Notes.Add(new cNota(note[0].Trim(), note[1].Trim())); }
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Creato:")) {
|
||||||
|
rac.Creato = DateTime.Parse(rows[i].Replace("- Creato:", "").Trim());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Update:")) {
|
||||||
|
rac.Updated = DateTime.Parse(rows[i].Replace("- Update:", "").Trim());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Origin:")) {
|
||||||
|
splitSeparator[0] = SEPARATORETXT.Trim();
|
||||||
|
string[] origini = rows[i].Replace("- Origin:", "").Trim().Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
rac.Origini = new List<string>();
|
||||||
|
foreach (string origine in origini) { rac.Origini.Add(origine.Trim()); }
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (rows[i].Trim().StartsWith("- Trama:")) {
|
||||||
|
rac.Trama = rows[i].Replace("- Trama:", "").Trim() + "\n";
|
||||||
|
i++;
|
||||||
|
for (int j = i; j < rows.Length; j++) {
|
||||||
|
rac.Trama += rows[j].Trim() + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Racs = new cRac[1];
|
||||||
|
rac.isValid = true;
|
||||||
|
Racs[0] = rac;
|
||||||
|
return 1;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00030", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
Racs = null;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UnificaConDuplicato(cRac copia) {
|
||||||
|
try {
|
||||||
|
// ID Rac: Tengo l'ID del racconto attuale
|
||||||
|
// Title: Il titolo è lo stesso e non devo fare nulla
|
||||||
|
// SubTit: Se è lo stesso tengo l'attuale, altrimenti se uno solo è non nullo lo tengo, altrimenti li unisco.
|
||||||
|
if (this.SubTitle != copia.SubTitle) {
|
||||||
|
if (string.IsNullOrEmpty(this.SubTitle)) {
|
||||||
|
this.SubTitle = copia.SubTitle;
|
||||||
|
} else {
|
||||||
|
this.SubTitle = this.SubTitle + SEPARATORETXT + copia.SubTitle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Autors: Unisco tutti gli autori distinti:
|
||||||
|
foreach (string aut in copia.Autori) {
|
||||||
|
if (!this.Autori.Contains(aut)) {
|
||||||
|
this.Autori.Add(aut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Voto: Metto il voto più alto fra i due
|
||||||
|
if (copia.Voto != this.Voto) if (this.Voto == "Non Letto") this.Voto = copia.Voto;
|
||||||
|
// Tags: Unisco tutti i tag distinti:
|
||||||
|
foreach (string tag in copia.Tags) {
|
||||||
|
if (!this.Tags.Contains(tag)) this.Tags.Add(tag);
|
||||||
|
}
|
||||||
|
// Notes: Unisco tutte le note distinte:
|
||||||
|
foreach (cNota nota in copia.Notes) {
|
||||||
|
if (!this.Notes.Contains(nota)) this.Notes.Add(nota);
|
||||||
|
}
|
||||||
|
// Creato: Uso la data di creazione più vecchia:
|
||||||
|
if (copia.Creato < this.Creato) this.Creato = copia.Creato;
|
||||||
|
// Update: Uso la data più nuova
|
||||||
|
if (copia.Updated > this.Updated) this.Updated = copia.Updated;
|
||||||
|
// Origin: Unisco tutte le origini distinte:
|
||||||
|
foreach (string orig in copia.Origini) {
|
||||||
|
if (!this.Origini.Contains(orig)) this.Origini.Add(orig);
|
||||||
|
}
|
||||||
|
// Trama: La trama è la stessa e non devo fare nulla
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // class cRac
|
||||||
|
|
||||||
|
}//namespace A69WD.Data
|
||||||
+85
-14
@@ -473,17 +473,17 @@ namespace A69WD {
|
|||||||
public static string FormattaTesto(string txt, bool eliminaTagHtml) {
|
public static string FormattaTesto(string txt, bool eliminaTagHtml) {
|
||||||
try {
|
try {
|
||||||
// Analisi dei tag prima di levarli:
|
// Analisi dei tag prima di levarli:
|
||||||
string testo = Regex.Replace(txt, @"<P>", "\n", RegexOptions.IgnoreCase);
|
string testo = Regex.Replace(txt, @"<P>", "\r\n", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"</P>", "\n", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"</P>", "\r\n", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"<P />", "\n", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"<P />", "\r\n", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"<B>", "\n", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"<B>", "\r\n", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"</B>", "\n", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"</B>", "\r\n", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"<B />", "\n", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"<B />", "\r\n", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"<BR>", "\n", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"<BR>", "\r\n", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"</BR>", "\n", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"</BR>", "\r\n", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"<br />", "\n", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"<br />", "\r\n", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"</div>", "\n", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"</div>", "\r\n", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"<div />", "\n", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"<div />", "\r\n", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"<<", "«", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"<<", "«", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @">>", "»", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @">>", "»", RegexOptions.IgnoreCase);
|
||||||
// Se richiesto, elimino i tag html:
|
// Se richiesto, elimino i tag html:
|
||||||
@@ -496,10 +496,79 @@ namespace A69WD {
|
|||||||
testo = re.Replace(testo, "");
|
testo = re.Replace(testo, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special Entities dal sito https://www.htmlhelp.com/reference/html40/entities/special.html
|
||||||
|
testo = Regex.Replace(testo, @""", "\"", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"&", "&", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"<", "<", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @">", ">", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"œ", "œ", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"š", "š", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"Ÿ", "Ÿ", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"ˆ", "ˆ", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"˜", "", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"–", "–", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"—", "—", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‘", "‘", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"’", "’", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‚", "‚", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"“", "“", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"”", "”", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"„", "„", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"†", "†", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‰", "‰", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‹", "‹", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"›", "›", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"€", "€", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @""", "\"", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"&", "&", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"<", "<", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @">", ">", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"œ", "œ", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"š", "š", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"Ÿ", "Ÿ", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"ˆ", "ˆ", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"˜", "", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"–", "–", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"—", "—", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‘", "‘", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"’", "’", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‚", "‚", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"“", "“", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"”", "”", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"„", "„", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"†", "†", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‰", "‰", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‹", "‹", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"›", "›", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"€", "€", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @""", "\"", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"&", "&", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"<", "<", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @">", ">", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"œ", "œ", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"š", "š", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"Ÿ", "Ÿ", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"ˆ", "ˆ", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"˜", "", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"–", "–", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"—", "—", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‘", "‘", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"’", "’", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‚", "‚", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"“", "“", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"”", "”", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"„", "„", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"†", "†", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‰", "‰", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"‹", "‹", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"›", "›", RegexOptions.IgnoreCase);
|
||||||
|
testo = Regex.Replace(testo, @"€", "€", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Correggo risultato togliendo doppie linee e caratteri html:
|
// Correggo risultato togliendo doppie linee e caratteri html:
|
||||||
testo = Regex.Replace(testo, @" ", " ", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @" ", " ", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"•", " * ", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"•", " * ", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"‹", " < ", RegexOptions.IgnoreCase);
|
|
||||||
testo = Regex.Replace(testo, @"<", "<", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"<", "<", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"›", " > ", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"›", " > ", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @">", ">", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @">", ">", RegexOptions.IgnoreCase);
|
||||||
@@ -513,6 +582,7 @@ namespace A69WD {
|
|||||||
testo = Regex.Replace(testo, @"ò", "ò", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"ò", "ò", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"ù", "ù", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"ù", "ù", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
|
||||||
testo = Regex.Replace(testo, @"–", "–", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"–", "–", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"—", "—", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"—", "—", RegexOptions.IgnoreCase);
|
||||||
testo = Regex.Replace(testo, @"‘", "‘", RegexOptions.IgnoreCase);
|
testo = Regex.Replace(testo, @"‘", "‘", RegexOptions.IgnoreCase);
|
||||||
@@ -541,9 +611,10 @@ namespace A69WD {
|
|||||||
//while (testo.Contains("ù")) { testo = testo.Replace("ù", "ù"); }
|
//while (testo.Contains("ù")) { testo = testo.Replace("ù", "ù"); }
|
||||||
//while (testo.Contains("’")) { testo = testo.Replace("’", "'"); }
|
//while (testo.Contains("’")) { testo = testo.Replace("’", "'"); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Correggo scritto:
|
// Correggo scritto:
|
||||||
|
testo = testo.Replace("&egrave", "è");
|
||||||
|
testo = testo.Replace("&", "&");
|
||||||
|
testo = testo.Replace("…", "…");
|
||||||
testo = testo.Replace("\r", "");
|
testo = testo.Replace("\r", "");
|
||||||
while (testo.Contains("\t")) { testo = testo.Replace("\t", " "); }
|
while (testo.Contains("\t")) { testo = testo.Replace("\t", " "); }
|
||||||
while (testo.Contains("...")) { testo = testo.Replace("...", "…"); }
|
while (testo.Contains("...")) { testo = testo.Replace("...", "…"); }
|
||||||
|
|||||||
+457
-1
@@ -1,12 +1,16 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Remoting.Messaging;
|
using System.Runtime.Remoting.Messaging;
|
||||||
using System.Security.Policy;
|
using System.Security.Policy;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using A69WD.Data;
|
||||||
using A69WD.Service;
|
using A69WD.Service;
|
||||||
|
using HtmlAgilityPack;
|
||||||
|
|
||||||
namespace A69WD.Net {
|
namespace A69WD.Net {
|
||||||
public class cLink_A69 : iLink {
|
public class cLink_A69 : iLink {
|
||||||
@@ -86,7 +90,7 @@ namespace A69WD.Net {
|
|||||||
public static bool InsertStartLink(Service_Crawler service) {
|
public static bool InsertStartLink(Service_Crawler service) {
|
||||||
//string url = LinkIdxBase.Replace("{Categoria}", "altro").Replace("{ID}", "1"); //LinkIdxBase.Replace("{Categoria}", "trio").Replace("{ID}", "1");
|
//string url = LinkIdxBase.Replace("{Categoria}", "altro").Replace("{ID}", "1"); //LinkIdxBase.Replace("{Categoria}", "trio").Replace("{ID}", "1");
|
||||||
//string name = "_A69_altro_0001.html"; //"_A69_trio_0001.html";
|
//string name = "_A69_altro_0001.html"; //"_A69_trio_0001.html";
|
||||||
//service.EnqueueUrl(new cLink_A69(url, name));
|
//serviceCrawler.EnqueueUrl(new cLink_A69(url, name));
|
||||||
//return true;
|
//return true;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
try {
|
try {
|
||||||
@@ -102,6 +106,458 @@ namespace A69WD.Net {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<cRac> EstraiRac(string FileFullPath) {
|
||||||
|
/*
|
||||||
|
* Analisi html dei racconti aggiornata al 2025/12/27:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Per ciascun file html, si ha un unico racconto che ha un formato interno pari a:
|
||||||
|
* <html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
* <body>
|
||||||
|
* ...
|
||||||
|
* <div class="targhetta_racconti" style=" width:100%; background-color:#5d5d5d;">incesto</div>
|
||||||
|
* ...
|
||||||
|
* <h1 class="titolone_nero" ...>Mia Madre , La mia Amante</h1>
|
||||||
|
* <strong> di<a href="/user/Bambino">Bambino</a>
|
||||||
|
* ...
|
||||||
|
* <div style="float:left; margin-right:5px; color: #9999CC; ">
|
||||||
|
* <span class="text_grigio" style="line-height:1.6em; color: #9999CC; font-size:13px;"> <strong>Scritto il</strong> 22.08.2015 |
|
||||||
|
* <strong>Letture:</strong> 8.947 |
|
||||||
|
* <strong>Votazione 8.0:</strong></span>
|
||||||
|
* </div>
|
||||||
|
* ...
|
||||||
|
* <div class="testoracc" style="color:#666666; text-align:justify; padding:20px 20px 0px 0px;">
|
||||||
|
* Eliminare i DIV interni che hanno cose grafiche
|
||||||
|
* Il testo è quello che rimane.
|
||||||
|
* </div>
|
||||||
|
* </body>
|
||||||
|
* </html>
|
||||||
|
*
|
||||||
|
* quindi i dati del racconto che si possono estrapolare sono:
|
||||||
|
* Titolo: --> Testo del nodo <h1 class="titolone_nero">
|
||||||
|
* SubTitle: --> Sempre Vuoto
|
||||||
|
* Autore: --> Testo del nodo <strong><a>
|
||||||
|
* Creato: --> Estrarre la parte dal <div style="float:left; margin-right:5px; color: #9999CC; ">
|
||||||
|
* Tags: --> Testo del nodo div class="targhetta_racconti">
|
||||||
|
* Trama: --> Testo del nodo <div class="testoracc"> a cui si levano i DIV interni.
|
||||||
|
* Notes: --> SrcFile - Nome del file che si analizza
|
||||||
|
* Origini: --> Sempre l'ID della sorgente web
|
||||||
|
* Voto: --> Sempre "Non Letto"
|
||||||
|
* Updated: --> Data attuale
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
cRac rac = new cRac();
|
||||||
|
HtmlNodeCollection nodes;
|
||||||
|
try {
|
||||||
|
Console.WriteLine($"A69 - Importo: {FileFullPath}");
|
||||||
|
|
||||||
|
string filePathName = System.IO.Path.GetFileName(FileFullPath);
|
||||||
|
|
||||||
|
// Ricavo il nodo radice del racconto:
|
||||||
|
HtmlDocument tdoc = new HtmlDocument();
|
||||||
|
tdoc.Load(FileFullPath);
|
||||||
|
HtmlNode root = tdoc.DocumentNode;
|
||||||
|
if (root == null) {
|
||||||
|
// racconto non presente
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Origini: --> Sempre l'ID della sorgente web
|
||||||
|
rac.Origini = new List<string> { ID };
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Titolo: --> Testo del nodo <h1 class="titolone_nero">
|
||||||
|
try {
|
||||||
|
nodes = root.SelectNodes("//h1[@class='titolone_nero']");
|
||||||
|
rac.Title = cTools.FormattaTesto(nodes[0].InnerText.Trim(), false);
|
||||||
|
if (string.IsNullOrEmpty(rac.Title)) {
|
||||||
|
Logger.Error($"A69 - Import - No Title - {filePathName}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (Exception ex) { Logger.Error(string.Format("Fallita estrazione titolo dal file {0}\r\n{1}", FileName, ex.Message)); return null; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SubTitle: --> Sempre Vuoto
|
||||||
|
rac.SubTitle = "";
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Autore: --> Testo del nodo <strong><a>
|
||||||
|
try {
|
||||||
|
// Autore --> Testo del nodo <span class="text_grigio><a>"
|
||||||
|
nodes = root.SelectNodes("//span[@class='text_grigio']//a");
|
||||||
|
List<string> items = new List<string>();
|
||||||
|
foreach (HtmlNode nd in nodes) {
|
||||||
|
string aut = nd.ParentNode.InnerText.Replace(" ", "").Trim();
|
||||||
|
if (aut.StartsWith("di")) {
|
||||||
|
items.Add(aut.Replace("di", "").Trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items.Sort();
|
||||||
|
string tmp = "";
|
||||||
|
rac.Autori = new List<string>();
|
||||||
|
// Rimuovo eventuali duplicati
|
||||||
|
foreach (string aut in items) {
|
||||||
|
if (tmp != aut) {
|
||||||
|
rac.Autori.Add(aut);
|
||||||
|
tmp = aut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rac.Autori == null || string.IsNullOrEmpty(rac.Autori[0])) {
|
||||||
|
Logger.Error($"A69 - Import - No Autors - {filePathName}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (Exception ex) { Logger.Error(string.Format("Fallita estrazione autore dal file {0}\r\n{1}", FileName, ex.Message)); return null; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Creato: --> Estrarre la parte dal <div style="float:left; margin-right:5px; color: #9999CC; ">
|
||||||
|
rac.Creato = DateTime.Now;
|
||||||
|
try {
|
||||||
|
// Creato --> Estrarre la prima parte dal <span class="text_grigio"> che ha il testo "Data|Visite|Commenti":
|
||||||
|
nodes = root.SelectNodes("//span[@class='text_grigio']");
|
||||||
|
foreach (HtmlNode nd in nodes) {
|
||||||
|
string txt = nd.InnerText.Trim().Replace(" ", "");
|
||||||
|
string[] parts = txt.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
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)) {
|
||||||
|
Logger.Error($"A69 - Import - No data - {filePathName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ex) { Logger.Warning(string.Format("Data non riconosciuta nel file {0}\r\n{1}", FileName, ex.Message)); return null; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Updated: --> Data attuale
|
||||||
|
rac.Updated = DateTime.Now;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Tags: --> Testo del nodo div class="targhetta_racconti">
|
||||||
|
try {
|
||||||
|
nodes = root.SelectNodes("//div[@class='targhetta_racconti']");
|
||||||
|
List<string> items = new List<string>();
|
||||||
|
foreach (HtmlNode nd in nodes) {
|
||||||
|
items.Add(cTools.FormattaTesto(nd.InnerText.Replace("genere", "").Trim(), false));
|
||||||
|
}
|
||||||
|
//items.Sort();
|
||||||
|
items = items
|
||||||
|
.OrderBy(s => s) // ordina alfabeticamente
|
||||||
|
.Distinct() // elimina duplicati
|
||||||
|
.ToList();
|
||||||
|
Format_Insert_Tags(rac, items); // rac.Tags = items;
|
||||||
|
} catch (Exception ex) { Logger.Warning(string.Format("Fallita estrazione Tags dal file {0}\r\n{1}", FileName, ex.Message)); return null; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Trama: --> Testo del nodo <div class="testoracc"> a cui si levano i DIV interni.
|
||||||
|
try {
|
||||||
|
nodes = root.SelectNodes("//div[@class='testoracc']");
|
||||||
|
foreach (HtmlNode nd in nodes) {
|
||||||
|
foreach (HtmlNode n in nd.ChildNodes) {
|
||||||
|
if (n.Name.ToUpper() == "#TEXT") { rac.Trama += cTools.FormattaTesto(n.InnerText.Trim(), false); }
|
||||||
|
if (n.Name.ToUpper() == "BR") { rac.Trama += "\r"; }
|
||||||
|
if (n.Name.ToUpper() == "DIV") {; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ex) { Logger.Error(string.Format("Fallita estrazione Trama dal file {0}\r\n{1}", FileName, ex.Message)); return null; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Voto: --> Sempre "Non Letto"
|
||||||
|
rac.Voto = "Non Letto";
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Notes: --> SrcFile - Nome del file che si analizza
|
||||||
|
rac.Notes = new List<Data.cNota>();
|
||||||
|
rac.Notes.Add(new Data.cNota("SrcFile", System.IO.Path.GetFileName(filePathName)));
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// Formalizzo esito estrazione:
|
||||||
|
if (!rac.Validate()) {
|
||||||
|
rac = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.Error($"A69 - Import Error - {FileFullPath}: {ex.Message}");
|
||||||
|
Console.WriteLine($"A69 - Import Error - {FileFullPath}: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return rac;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected virtual void Format_Insert_Tags(Data.cRac rac, List<string> items) {
|
||||||
|
// Per ora riporto tutti i tag rilevati, mentre in futuro dovrò:
|
||||||
|
// - parsare la lista e formattare correttamente i tag
|
||||||
|
// - ordinare la lista dei tag formattati ed eliminare i duplicati
|
||||||
|
// - se non sono rimasti tag, inserisco il tag generale per indicare che non vi sono tag
|
||||||
|
// - altrimenti inserisco tutti i tag rimasti.
|
||||||
|
rac.Tags = new List<string>();
|
||||||
|
try {
|
||||||
|
items.Sort();
|
||||||
|
string tmp = "";
|
||||||
|
foreach (string item in items) {
|
||||||
|
string it = item.Trim().ToLower();
|
||||||
|
if (tmp != it) {
|
||||||
|
#region switch per formattare il testo
|
||||||
|
switch (it) {
|
||||||
|
//case "racconti 69":
|
||||||
|
// rac.Tags.Add("69");
|
||||||
|
// break;
|
||||||
|
//case "abusi":
|
||||||
|
// rac.Tags.Add("Abusi");
|
||||||
|
// break;
|
||||||
|
//case "camgirl":
|
||||||
|
//case "chat e siti di incontri…":
|
||||||
|
//case "fiche":
|
||||||
|
// rac.Tags.Add("Altro");
|
||||||
|
// break;
|
||||||
|
//case "amatoriali":
|
||||||
|
// rac.Tags.Add("Amatoriali");
|
||||||
|
// break;
|
||||||
|
//case "anale":
|
||||||
|
// rac.Tags.Add("Anale");
|
||||||
|
// break;
|
||||||
|
//case "audio libri erotici":
|
||||||
|
//case "audio racconti erotici":
|
||||||
|
// rac.Tags.Add("Audio");
|
||||||
|
// break;
|
||||||
|
//case "bdsm":
|
||||||
|
// rac.Tags.Add("BDMS");
|
||||||
|
// break;
|
||||||
|
//case "bisex":
|
||||||
|
//case "bisex ♀":
|
||||||
|
//case "bisex ♂":
|
||||||
|
// rac.Tags.Add("Bisex");
|
||||||
|
// break;
|
||||||
|
//case "bondage":
|
||||||
|
// rac.Tags.Add("Bondage");
|
||||||
|
// break;
|
||||||
|
//case "bondage e sadomaso":
|
||||||
|
// rac.Tags.Add("Bondage");
|
||||||
|
// rac.Tags.Add("Sadomaso");
|
||||||
|
// break;
|
||||||
|
//case "bukkake":
|
||||||
|
// rac.Tags.Add("Bukkake");
|
||||||
|
// break;
|
||||||
|
//case "comici":
|
||||||
|
//case "comunità":
|
||||||
|
// rac.Tags.Add("Comico");
|
||||||
|
// break;
|
||||||
|
//case "concorso estate 2019":
|
||||||
|
//case "concorso natale 2018":
|
||||||
|
//case "decameron 2020":
|
||||||
|
// rac.Tags.Add("Concorso");
|
||||||
|
// break;
|
||||||
|
//case "confessioni":
|
||||||
|
// rac.Tags.Add("Confessioni");
|
||||||
|
// break;
|
||||||
|
//case "coppie":
|
||||||
|
//case "scambio di coppia":
|
||||||
|
//case "scambio di coppie":
|
||||||
|
// rac.Tags.Add("Coppie");
|
||||||
|
// break;
|
||||||
|
//case "cuckold":
|
||||||
|
//case "racconti cuckold":
|
||||||
|
// rac.Tags.Add("Cuckold");
|
||||||
|
// break;
|
||||||
|
//case "curiosità":
|
||||||
|
//case "curiosità sul sesso":
|
||||||
|
// rac.Tags.Add("Curiosità");
|
||||||
|
// break;
|
||||||
|
//case "dominazione":
|
||||||
|
//case "racconti di dominazione":
|
||||||
|
//case "schiavi&padroni":
|
||||||
|
// rac.Tags.Add("Dominazione");
|
||||||
|
// break;
|
||||||
|
//case "doppia penetrazione":
|
||||||
|
// rac.Tags.Add("Doppia Penetrazione");
|
||||||
|
// break;
|
||||||
|
//case "esibizionismo":
|
||||||
|
// rac.Tags.Add("Esibizionismo");
|
||||||
|
// break;
|
||||||
|
//case "etero":
|
||||||
|
//case "lui & lei":
|
||||||
|
//case "racconti erotici etero":
|
||||||
|
// rac.Tags.Add("Etero");
|
||||||
|
// break;
|
||||||
|
//case "feticismo":
|
||||||
|
// rac.Tags.Add("Feticismo");
|
||||||
|
// break;
|
||||||
|
//case "fisting":
|
||||||
|
// rac.Tags.Add("Fisting");
|
||||||
|
// break;
|
||||||
|
//case "gang bang":
|
||||||
|
// rac.Tags.Add("Gang Bang");
|
||||||
|
// break;
|
||||||
|
//case "gay":
|
||||||
|
//case "racconti gay":
|
||||||
|
// rac.Tags.Add("Gay");
|
||||||
|
// break;
|
||||||
|
//case "gay & bisex":
|
||||||
|
//case "gay e bisex":
|
||||||
|
// rac.Tags.Add("Gay");
|
||||||
|
// rac.Tags.Add("Bisex");
|
||||||
|
// break;
|
||||||
|
//case "gay - travestiti":
|
||||||
|
// rac.Tags.Add("Gay");
|
||||||
|
// rac.Tags.Add("Trans");
|
||||||
|
// break;
|
||||||
|
//case "incesti":
|
||||||
|
//case "incesto":
|
||||||
|
//case "racconti erotici sull'incesto":
|
||||||
|
// rac.Tags.Add("Incesto");
|
||||||
|
// break;
|
||||||
|
//case "interviste":
|
||||||
|
//case "interviste erotiche":
|
||||||
|
// rac.Tags.Add("Intervista");
|
||||||
|
// break;
|
||||||
|
//case "lesbo":
|
||||||
|
//case "racconti erotici lesbo":
|
||||||
|
//case "saffico":
|
||||||
|
// rac.Tags.Add("Lesbo");
|
||||||
|
// break;
|
||||||
|
//case "autoerotismo":
|
||||||
|
//case "masturbazione":
|
||||||
|
//case "masturbazioni":
|
||||||
|
//case "racconti sull'autoerotismo":
|
||||||
|
// rac.Tags.Add("Masturbazione");
|
||||||
|
// break;
|
||||||
|
//case "milf":
|
||||||
|
// rac.Tags.Add("MILF");
|
||||||
|
// break;
|
||||||
|
//case "nudismo":
|
||||||
|
// rac.Tags.Add("Nudismo");
|
||||||
|
// break;
|
||||||
|
//case "orge":
|
||||||
|
//case "orgia":
|
||||||
|
//case "sesso di gruppo":
|
||||||
|
// rac.Tags.Add("Orge");
|
||||||
|
// break;
|
||||||
|
//case "pissing":
|
||||||
|
// rac.Tags.Add("Pissing");
|
||||||
|
// break;
|
||||||
|
//case "lirica erotica":
|
||||||
|
//case "poesia erotica":
|
||||||
|
//case "poesie":
|
||||||
|
//case "poesie erotiche":
|
||||||
|
// rac.Tags.Add("Poesia");
|
||||||
|
// break;
|
||||||
|
//case "pompini":
|
||||||
|
// rac.Tags.Add("Pompini");
|
||||||
|
// break;
|
||||||
|
//case "giochi erotici":
|
||||||
|
//case "prime esperienze":
|
||||||
|
//case "prime volte":
|
||||||
|
// rac.Tags.Add("Prime Esperienze");
|
||||||
|
// break;
|
||||||
|
//case "pulp":
|
||||||
|
// rac.Tags.Add("Pulp");
|
||||||
|
// break;
|
||||||
|
//case "sadomaso":
|
||||||
|
// rac.Tags.Add("Sadomaso");
|
||||||
|
// break;
|
||||||
|
//case "sensazioni":
|
||||||
|
//case "sentimentali":
|
||||||
|
// rac.Tags.Add("Sentimentali");
|
||||||
|
// break;
|
||||||
|
//case "cornuti":
|
||||||
|
//case "tradimenti":
|
||||||
|
//case "tradimento":
|
||||||
|
// rac.Tags.Add("Tradimento");
|
||||||
|
// break;
|
||||||
|
//case "racconti con trans":
|
||||||
|
//case "racconti trans":
|
||||||
|
//case "trans":
|
||||||
|
//case "trans e travestiti":
|
||||||
|
// rac.Tags.Add("Trans");
|
||||||
|
// break;
|
||||||
|
//case "trasgressivo":
|
||||||
|
// rac.Tags.Add("Trasgressivo");
|
||||||
|
// break;
|
||||||
|
//case "trio":
|
||||||
|
// rac.Tags.Add("Trio");
|
||||||
|
// break;
|
||||||
|
//case "uncategorized":
|
||||||
|
// rac.Tags.Add("Uncategorized");
|
||||||
|
// break;
|
||||||
|
//case "voyeur":
|
||||||
|
//case "voyeurismo":
|
||||||
|
// rac.Tags.Add("Voyeur");
|
||||||
|
// break;
|
||||||
|
//case "animali":
|
||||||
|
//case "zoofilia":
|
||||||
|
// rac.Tags.Add("Zoofilia");
|
||||||
|
// break;
|
||||||
|
|
||||||
|
//case "Gay":
|
||||||
|
// rac.Tags.Add("Gay");
|
||||||
|
// break;
|
||||||
|
//case "Racconti bisex":
|
||||||
|
// rac.Tags.Add("Bisex");
|
||||||
|
// break;
|
||||||
|
//case "Racconti etero":
|
||||||
|
// rac.Tags.Add("Etero");
|
||||||
|
// break;
|
||||||
|
//case "Racconti fetish":
|
||||||
|
// rac.Tags.Add("Feticismo");
|
||||||
|
// break;
|
||||||
|
//case "Racconti incesto":
|
||||||
|
// rac.Tags.Add("Incesto");
|
||||||
|
// break;
|
||||||
|
//case "Racconti lesbo":
|
||||||
|
// rac.Tags.Add("Lesbo");
|
||||||
|
// break;
|
||||||
|
//case "Racconti masturbazione":
|
||||||
|
// rac.Tags.Add("Masturbazione");
|
||||||
|
// break;
|
||||||
|
//case "Racconti mature":
|
||||||
|
// rac.Tags.Add("Mature");
|
||||||
|
// break;
|
||||||
|
//case "Racconti orge":
|
||||||
|
// rac.Tags.Add("Orge");
|
||||||
|
// break;
|
||||||
|
//case "Racconti prima volta":
|
||||||
|
// rac.Tags.Add("Prime Esperienze");
|
||||||
|
// break;
|
||||||
|
//case "Racconti ricatto":
|
||||||
|
// rac.Tags.Add("Ricatto");
|
||||||
|
// break;
|
||||||
|
//case "Racconti scambio di coppia":
|
||||||
|
// rac.Tags.Add("Coppie");
|
||||||
|
// break;
|
||||||
|
//case "Racconti sottomissione":
|
||||||
|
// rac.Tags.Add("Dominazione");
|
||||||
|
// break;
|
||||||
|
//case "Racconti tradimenti":
|
||||||
|
// rac.Tags.Add("Tradimento");
|
||||||
|
// break;
|
||||||
|
//case "Racconti trav":
|
||||||
|
//case "Trans":
|
||||||
|
// rac.Tags.Add("Trans");
|
||||||
|
// break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
rac.Tags.Add(item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
tmp = it;
|
||||||
|
|
||||||
|
}//if
|
||||||
|
|
||||||
|
}//foreach
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
|
||||||
|
} finally {
|
||||||
|
if (rac.Tags.Count == 0) rac.Tags.Add("_None_");
|
||||||
|
}
|
||||||
|
}//function
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}//class cLink_A69
|
}//class cLink_A69
|
||||||
|
|
||||||
}//namespace A69WD.Net
|
}//namespace A69WD.Net
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using A69WD.Data;
|
||||||
|
using A69WD.Net;
|
||||||
|
using A69WD.Site;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace A69WD.Service {
|
||||||
|
|
||||||
|
|
||||||
|
public class Service_Importer {
|
||||||
|
|
||||||
|
// Thread worker che consuma la coda
|
||||||
|
private Thread _workerThread;
|
||||||
|
private readonly Label _lblInCorso;
|
||||||
|
private readonly ProgressBar _progressBar;
|
||||||
|
private string _path;
|
||||||
|
// Contatori
|
||||||
|
private int _totali = 0;
|
||||||
|
private int _completati = 0;
|
||||||
|
private int _errori = 0;
|
||||||
|
|
||||||
|
public Service_Importer(Label lblInCorso, ProgressBar pbStatus) {
|
||||||
|
_lblInCorso = lblInCorso;
|
||||||
|
_progressBar = pbStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartWorker(string path) {
|
||||||
|
_path = path;
|
||||||
|
_workerThread = new Thread(ProcessWorking) { IsBackground = true };
|
||||||
|
_workerThread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopWorker() {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private async void ProcessWorking() {
|
||||||
|
string[] files = System.IO.Directory.GetFiles(_path, "A69_*.html");
|
||||||
|
_totali = files.Length;
|
||||||
|
_completati = 0;
|
||||||
|
_errori = 0;
|
||||||
|
UpdateCounters();
|
||||||
|
|
||||||
|
// foreach (string file in files) {
|
||||||
|
// Task.Run(async () => {
|
||||||
|
// Logger.Warning($"Start estrazione racconto: {file}");
|
||||||
|
// cLink_A69 lk = new cLink_A69("url", file);
|
||||||
|
// cRac rac = await lk.EstraiRac(file);
|
||||||
|
// if (rac != null) {
|
||||||
|
// // Racconto estratto correttamente, lo salvo sul DB
|
||||||
|
// Logger.Warning($"Start estrazione racconto: {file}");
|
||||||
|
// int res = App.DB.ImportRac(rac);
|
||||||
|
// if (res != 1) {
|
||||||
|
// // Errore nel salvataggio
|
||||||
|
// Interlocked.Increment(ref _errori);
|
||||||
|
// } else {
|
||||||
|
// // salvataggio corretto
|
||||||
|
// Interlocked.Increment(ref _completati);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// Interlocked.Increment(ref _errori);
|
||||||
|
// }
|
||||||
|
// UpdateCounters();
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
foreach (string file in files) {
|
||||||
|
string name = System.IO.Path.GetFileName(file);
|
||||||
|
Logger.Warning($"Import - Start estrazione racconto: {name}");
|
||||||
|
|
||||||
|
cLink_A69 lk = new cLink_A69(file, name);
|
||||||
|
cRac rac = await lk.EstraiRac(file);
|
||||||
|
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) {
|
||||||
|
// errore nel salvataggio
|
||||||
|
Logger.Warning($"Import - errore nel salvataggio: {name}");
|
||||||
|
Interlocked.Increment(ref _errori);
|
||||||
|
} else {
|
||||||
|
// salvataggio ok
|
||||||
|
Logger.Warning($"Import - racconto salvato: {name}");
|
||||||
|
Interlocked.Increment(ref _completati);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Logger.Warning($"Import - estrazione errata: {name}");
|
||||||
|
Interlocked.Increment(ref _errori);
|
||||||
|
}
|
||||||
|
UpdateCounters();
|
||||||
|
}
|
||||||
|
UpdateCounters();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void UpdateCounters() {
|
||||||
|
if (_lblInCorso.InvokeRequired) {
|
||||||
|
_lblInCorso.Invoke(new Action(UpdateCounters));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int daFare = _totali - _completati - _errori;
|
||||||
|
|
||||||
|
_lblInCorso.Text = $"Totali: {_totali} - Completati: {_completati} - Errori: {_errori} - Da fare: {daFare}";
|
||||||
|
|
||||||
|
_progressBar.Maximum = _totali > 0 ? _totali : 1;
|
||||||
|
_progressBar.Value = _completati + _errori;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}//class Service_Importer
|
||||||
|
|
||||||
|
}//namespace A69WD.Service
|
||||||
Generated
+18
-5
@@ -30,11 +30,12 @@
|
|||||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||||
this.btnShowLog = new System.Windows.Forms.Button();
|
this.btnShowLog = new System.Windows.Forms.Button();
|
||||||
this.pbST = new System.Windows.Forms.ProgressBar();
|
this.pbST = new System.Windows.Forms.ProgressBar();
|
||||||
|
this.btnImport = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// btnClose
|
// btnClose
|
||||||
//
|
//
|
||||||
this.btnClose.Location = new System.Drawing.Point(263, 12);
|
this.btnClose.Location = new System.Drawing.Point(348, 12);
|
||||||
this.btnClose.Name = "btnClose";
|
this.btnClose.Name = "btnClose";
|
||||||
this.btnClose.Size = new System.Drawing.Size(79, 33);
|
this.btnClose.Size = new System.Drawing.Size(79, 33);
|
||||||
this.btnClose.TabIndex = 14;
|
this.btnClose.TabIndex = 14;
|
||||||
@@ -58,7 +59,7 @@
|
|||||||
this.lblST.Dock = System.Windows.Forms.DockStyle.Bottom;
|
this.lblST.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
this.lblST.Location = new System.Drawing.Point(0, 73);
|
this.lblST.Location = new System.Drawing.Point(0, 73);
|
||||||
this.lblST.Name = "lblST";
|
this.lblST.Name = "lblST";
|
||||||
this.lblST.Size = new System.Drawing.Size(352, 22);
|
this.lblST.Size = new System.Drawing.Size(433, 22);
|
||||||
this.lblST.TabIndex = 9;
|
this.lblST.TabIndex = 9;
|
||||||
this.lblST.Text = "Status";
|
this.lblST.Text = "Status";
|
||||||
this.lblST.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
this.lblST.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
@@ -81,7 +82,7 @@
|
|||||||
//
|
//
|
||||||
// btnShowLog
|
// btnShowLog
|
||||||
//
|
//
|
||||||
this.btnShowLog.Location = new System.Drawing.Point(178, 12);
|
this.btnShowLog.Location = new System.Drawing.Point(263, 12);
|
||||||
this.btnShowLog.Name = "btnShowLog";
|
this.btnShowLog.Name = "btnShowLog";
|
||||||
this.btnShowLog.Size = new System.Drawing.Size(79, 33);
|
this.btnShowLog.Size = new System.Drawing.Size(79, 33);
|
||||||
this.btnShowLog.TabIndex = 17;
|
this.btnShowLog.TabIndex = 17;
|
||||||
@@ -94,14 +95,25 @@
|
|||||||
this.pbST.Dock = System.Windows.Forms.DockStyle.Bottom;
|
this.pbST.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
this.pbST.Location = new System.Drawing.Point(0, 55);
|
this.pbST.Location = new System.Drawing.Point(0, 55);
|
||||||
this.pbST.Name = "pbST";
|
this.pbST.Name = "pbST";
|
||||||
this.pbST.Size = new System.Drawing.Size(352, 18);
|
this.pbST.Size = new System.Drawing.Size(433, 18);
|
||||||
this.pbST.TabIndex = 18;
|
this.pbST.TabIndex = 18;
|
||||||
//
|
//
|
||||||
|
// btnImport
|
||||||
|
//
|
||||||
|
this.btnImport.Location = new System.Drawing.Point(182, 12);
|
||||||
|
this.btnImport.Name = "btnImport";
|
||||||
|
this.btnImport.Size = new System.Drawing.Size(79, 33);
|
||||||
|
this.btnImport.TabIndex = 19;
|
||||||
|
this.btnImport.Text = "Import Rac";
|
||||||
|
this.btnImport.UseVisualStyleBackColor = true;
|
||||||
|
this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
|
||||||
|
//
|
||||||
// frmDownloader
|
// frmDownloader
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(352, 95);
|
this.ClientSize = new System.Drawing.Size(433, 95);
|
||||||
|
this.Controls.Add(this.btnImport);
|
||||||
this.Controls.Add(this.pbST);
|
this.Controls.Add(this.pbST);
|
||||||
this.Controls.Add(this.btnShowLog);
|
this.Controls.Add(this.btnShowLog);
|
||||||
this.Controls.Add(this.btnImportLinks);
|
this.Controls.Add(this.btnImportLinks);
|
||||||
@@ -123,5 +135,6 @@
|
|||||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||||
private System.Windows.Forms.Button btnShowLog;
|
private System.Windows.Forms.Button btnShowLog;
|
||||||
private System.Windows.Forms.ProgressBar pbST;
|
private System.Windows.Forms.ProgressBar pbST;
|
||||||
|
private System.Windows.Forms.Button btnImport;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,7 @@ using A69WD.Net;
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using A69WD.Service;
|
using A69WD.Service;
|
||||||
|
using A69WD.Data;
|
||||||
|
|
||||||
namespace A69WD {
|
namespace A69WD {
|
||||||
|
|
||||||
@@ -53,9 +54,7 @@ namespace A69WD {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void btnDownloadAll_Click(object sender, EventArgs e) {
|
private async void btnDownloadAll_Click(object sender, EventArgs e) {
|
||||||
////engine.Start(true);
|
btnDownloadAll.Enabled = false;
|
||||||
////engine.Start(!cbSoloFileIndice.Checked);
|
|
||||||
//engine.StartParallel(!cbSoloFileIndice.Checked, int.Parse(tbNumThred.Text));
|
|
||||||
|
|
||||||
// - Creo istanza del client per il sito con autenticazione:
|
// - Creo istanza del client per il sito con autenticazione:
|
||||||
lblST.Text = DateTime.Now.ToString() + " - Login";
|
lblST.Text = DateTime.Now.ToString() + " - Login";
|
||||||
@@ -99,18 +98,18 @@ namespace A69WD {
|
|||||||
|
|
||||||
|
|
||||||
// Preparo il servizio
|
// Preparo il servizio
|
||||||
service = new Service_Crawler(lblST, pbST);
|
serviceCrawler = new Service_Crawler(lblST, pbST);
|
||||||
// Inserisco i link iniziali nella coda
|
// Inserisco i link iniziali nella coda
|
||||||
if (!cLink_A69.InsertStartLink(service)) {
|
if (!cLink_A69.InsertStartLink(serviceCrawler)) {
|
||||||
lblST.Text = "Inserimento A69 start link fault.";
|
lblST.Text = "Inserimento A69 start link fault.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// avvio il servizio
|
// avvio il servizio
|
||||||
service.StartWorker(siteA69);
|
serviceCrawler.StartWorker(siteA69);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private Service_Crawler service = null;
|
private Service_Crawler serviceCrawler = null;
|
||||||
|
|
||||||
|
|
||||||
private void btnShowLog_Click(object sender, EventArgs e) {
|
private void btnShowLog_Click(object sender, EventArgs e) {
|
||||||
@@ -126,12 +125,15 @@ namespace A69WD {
|
|||||||
private void btnClose_Click(object sender, EventArgs e) {
|
private void btnClose_Click(object sender, EventArgs e) {
|
||||||
//if (engine.Stop()) this.Close();
|
//if (engine.Stop()) this.Close();
|
||||||
|
|
||||||
// fermo il servizio
|
// fermo i servizi
|
||||||
if (service != null) service.StopWorker();
|
if (serviceCrawler != null) serviceCrawler.StopWorker();
|
||||||
|
if (serviceImporter != null) serviceImporter.StopWorker();
|
||||||
|
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Gestione eventi dal engine
|
#region Gestione eventi dal engine
|
||||||
//
|
//
|
||||||
// private void Engine_Updating(object sender, EngineEventArgs e) { EngineUpdatingStatus(e.Message, e.NTot, e.NtoDown, e.NDown); }
|
// private void Engine_Updating(object sender, EngineEventArgs e) { EngineUpdatingStatus(e.Message, e.NTot, e.NtoDown, e.NDown); }
|
||||||
@@ -156,6 +158,31 @@ namespace A69WD {
|
|||||||
//
|
//
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private void btnImport_Click(object sender, EventArgs e) {
|
||||||
|
// string fp = "C:\\Commesse\\_zPrivate\\A69WD\\Test\\Down\\__A69_altro_Collarini-e-fantasie_166756.html";
|
||||||
|
// cLink_A69 lk = new cLink_A69("Tmp", "tmp");
|
||||||
|
// cRac rac = await lk.EstraiRac(fp);
|
||||||
|
// if (rac != null) {
|
||||||
|
// //foreach (string tag in rac.Tags) {
|
||||||
|
// for (int i = 0; i<rac.Tags.Count; i++) {
|
||||||
|
// Console.WriteLine(rac.Tags[i]);
|
||||||
|
// }
|
||||||
|
// // Racconto estratto correttamente, lo salvo sul DB
|
||||||
|
// App.DB.ImportRac(rac);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Preparo il servizio
|
||||||
|
serviceImporter = new Service_Importer(lblST, pbST);
|
||||||
|
|
||||||
|
// Per ora uso la directory di default, poi metteremo selezione
|
||||||
|
string path = Cfg.Settings.PathDownloadWorking;
|
||||||
|
|
||||||
|
// avvio il servizio
|
||||||
|
serviceImporter.StartWorker(path);
|
||||||
|
|
||||||
|
}
|
||||||
|
private Service_Importer serviceImporter = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}//class frmDownloader
|
}//class frmDownloader
|
||||||
|
|||||||
Reference in new issue
Block a user