diff --git a/Src/A69WD/.vs/A69WD.csproj.dtbcache.json b/Src/A69WD/.vs/A69WD.csproj.dtbcache.json index 0b1ca31..e9b8bfe 100644 --- a/Src/A69WD/.vs/A69WD.csproj.dtbcache.json +++ b/Src/A69WD/.vs/A69WD.csproj.dtbcache.json @@ -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\\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":[]} \ No newline at end of file +{"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":[]} \ No newline at end of file diff --git a/Src/A69WD/A69WD.csproj b/Src/A69WD/A69WD.csproj index 9497c87..c18b60b 100644 --- a/Src/A69WD/A69WD.csproj +++ b/Src/A69WD/A69WD.csproj @@ -65,6 +65,7 @@ + Form diff --git a/Src/A69WD/A69WD.csproj.user b/Src/A69WD/A69WD.csproj.user index e0be25f..56fd5d8 100644 --- a/Src/A69WD/A69WD.csproj.user +++ b/Src/A69WD/A69WD.csproj.user @@ -1,6 +1,6 @@ - ShowAllFiles + ProjectFiles \ No newline at end of file diff --git a/Src/A69WD/Data/DBTools.cs b/Src/A69WD/Data/DBTools.cs index 043224f..e0b4cff 100644 --- a/Src/A69WD/Data/DBTools.cs +++ b/Src/A69WD/Data/DBTools.cs @@ -4,6 +4,7 @@ using System.Text; using System.Data.SQLite; using A69WD.Net; using System.Drawing; +using A69WD.Data; namespace A69WD { @@ -860,6 +861,874 @@ namespace A69WD { } + + /// + /// Seleziona dal DB il racconto richiesto + /// + /// Identificativo del racconto desiderato + /// Ritorna il racconto estratto dal DB + public cRac GetRacById(long IDrac) { + lock (objLock) { + cRac rac = null; + List tmp = null; + try { + + // Creo nuovo racconto vuoto: + rac = new cRac(); + + #region Estraggo i dati dalla tabella 'Racconti': + + // Query per interrogare la tabella 'Racconti': + SQLiteCommand SelRac = new System.Data.SQLite.SQLiteCommand(); + SelRac.Connection = cn; + SelRac.CommandText = "SELECT * FROM Racconti WHERE IDrac=@IDrac"; + SelRac.CommandType = System.Data.CommandType.Text; + System.Data.SQLite.SQLiteParameter param = new System.Data.SQLite.SQLiteParameter(); + param.ParameterName = "@IDrac"; + param.DbType = global::System.Data.DbType.Int64; + param.SourceColumn = "IDrac"; + param.Value = IDrac; //SelRac.Parameters["@IDrac"].Value = IDrac; + SelRac.Parameters.Add(param); + SQLiteDataReader rdr = SelRac.ExecuteReader(); + bool res = rdr.Read(); + if (res == false) { + rdr.Close(); + rdr = null; + Logger.Information(String.Format("Attenzione, il racconto richiesto ({0}), non è stasto trovato.", IDrac.ToString())); + return new cRac("Errore", "Attenzione, il racconto richiesto non è stato trovato."); + } + rac.IDrac = (long)(rdr["IDrac"]); + if (rac.IDrac != IDrac) throw new Exception("Attenzione trovato ID diverso da quello richiesto"); + rac.Title = rdr["Title"] as string; + rac.SubTitle = rdr["SubTitle"] as string; + //rac.Creato = DateTime.Parse(rdr["Creato"].ToString()); + rac.Creato = DateTime.Parse(rdr["Creato"] as string); + //rac.Updated = DateTime.Parse(rdr["Aggiornato"].ToString()); + rac.Updated = DateTime.Parse(rdr["Aggiornato"].ToString()); + rdr.Close(); + rdr = null; + + #endregion + + #region Estraggo i dati dalla tabella 'Trame': + + // Query per interrogare la tabella 'Trame': + SQLiteCommand SelTra = new System.Data.SQLite.SQLiteCommand(); + SelTra.Connection = cn; + SelTra.CommandText = "SELECT Trama FROM Trame WHERE IDrac=@IDrac"; + SelTra.CommandType = System.Data.CommandType.Text; + param = new System.Data.SQLite.SQLiteParameter(); + param.ParameterName = "@IDrac"; + param.DbType = global::System.Data.DbType.Int64; + param.SourceColumn = "IDrac"; + param.Value = IDrac; //SelTra.Parameters["@IDrac"].Value = IDrac; + SelTra.Parameters.Add(param); + rdr = SelTra.ExecuteReader(); + res = rdr.Read(); + rac.Trama = rdr["Trama"] as string; + rdr.Close(); + rdr = null; + + #endregion + + #region Estraggo i dati dalla tabella 'Autori': + + // Query per interrogare la tabella 'Autori': + SQLiteCommand SelAut = new System.Data.SQLite.SQLiteCommand(); + SelAut.Connection = cn; + SelAut.CommandText = "SELECT Autori.Autore AS Autore FROM Autori, Links_Rac_Aut WHERE Autori.IDaut=Links_Rac_Aut.IDaut AND Links_Rac_Aut.IDrac=@IDrac GROUP BY Autori.Autore"; + SelAut.CommandType = System.Data.CommandType.Text; + param = new System.Data.SQLite.SQLiteParameter(); + param.ParameterName = "@IDrac"; + param.DbType = global::System.Data.DbType.Int64; + param.SourceColumn = "IDrac"; + param.Value = IDrac; //SelAut.Parameters["@IDrac"].Value = IDrac; + SelAut.Parameters.Add(param); + rdr = SelAut.ExecuteReader(); + if (rdr.HasRows) { + tmp = new List(); + while (rdr.Read()) { + tmp.Add(rdr["Autore"] as string); + } + tmp.Sort(); + rac.Autori = tmp; + tmp = null; + } + rdr.Close(); + rdr = null; + #endregion + + #region Estraggo i dati dalla tabella 'Tags': + + // Query per interrogare la tabella 'Tags': + SQLiteCommand SelTag = new System.Data.SQLite.SQLiteCommand(); + SelTag.Connection = cn; + SelTag.CommandText = "SELECT Tags.Tag as Tag FROM Tags, Links_Rac_Tag WHERE Tags.IDtag=Links_Rac_Tag.IDtag AND Links_Rac_Tag.IDrac=@IDrac"; + SelTag.CommandType = System.Data.CommandType.Text; + param = new System.Data.SQLite.SQLiteParameter(); + param.ParameterName = "@IDrac"; + param.DbType = global::System.Data.DbType.Int64; + param.SourceColumn = "IDrac"; + param.Value = IDrac; //SelTag.Parameters["@IDrac"].Value = IDrac; + SelTag.Parameters.Add(param); + rdr = SelTag.ExecuteReader(); + if (rdr.HasRows) { + tmp = new List(); + while (rdr.Read()) { + tmp.Add(rdr["Tag"] as string); + } + tmp.Sort(); + rac.Tags = tmp; + tmp = null; + } + rdr.Close(); + rdr = null; + + #endregion + + #region Estraggo i dati dalla tabella 'Origini': + + // Query per interrogare la tabella 'Origini': + SQLiteCommand SelOri = new System.Data.SQLite.SQLiteCommand(); + SelOri.Connection = cn; + SelOri.CommandText = "SELECT Origini.Origine as Origine FROM Origini, Links_Rac_Ori WHERE Origini.IDori=Links_Rac_Ori.IDori AND Links_Rac_Ori.IDrac=@IDrac"; + SelOri.CommandType = System.Data.CommandType.Text; + param = new System.Data.SQLite.SQLiteParameter(); + param.ParameterName = "@IDrac"; + param.DbType = global::System.Data.DbType.Int64; + param.SourceColumn = "IDrac"; + param.Value = IDrac; //SelOri.Parameters["@IDrac"].Value = IDrac; + SelOri.Parameters.Add(param); + rdr = SelOri.ExecuteReader(); + if (rdr.HasRows) { + tmp = new List(); + while (rdr.Read()) { + tmp.Add(rdr["Origine"] as string); + } + tmp.Sort(); + rac.Origini = tmp; + tmp = null; + } + rdr.Close(); + rdr = null; + #endregion + + #region Estraggo i dati dalla tabella 'Notes': + + // Query per interrogare la tabella 'Notes': + SQLiteCommand SelNot = new System.Data.SQLite.SQLiteCommand(); + SelNot.Connection = cn; + SelNot.CommandText = "SELECT Notes.NKey AS NKey, Notes.NVal AS NVal FROM Notes, Links_Rac_Not WHERE Notes.IDnot=Links_Rac_Not.IDnot AND Links_Rac_Not.IDrac=@IDrac"; + SelNot.CommandType = System.Data.CommandType.Text; + param = new System.Data.SQLite.SQLiteParameter(); + param.ParameterName = "@IDrac"; + param.DbType = global::System.Data.DbType.Int64; + param.SourceColumn = "IDrac"; + param.Value = IDrac; //SelNot.Parameters["@IDrac"].Value = IDrac; + SelNot.Parameters.Add(param); + rdr = SelNot.ExecuteReader(); + rac.Notes = new List(); + if (rdr.HasRows) { + while (rdr.Read()) { + rac.Notes.Add(new cNota((rdr["NKey"] as string), (rdr["NVal"] as string))); + } + } + rdr.Close(); + rdr = null; + + #endregion + + + #region Estraggo i dati dalla tabella 'Voti': + + // Query per interrogare la tabella 'Voti': + SQLiteCommand SelVot = new System.Data.SQLite.SQLiteCommand(); + SelVot.Connection = cn; + SelVot.CommandText = "SELECT Voti.Voto as Voto FROM Voti, Links_Rac_Vot WHERE Voti.IDvot=Links_Rac_Vot.IDvot AND Links_Rac_Vot.IDrac=@IDrac"; + SelVot.CommandType = System.Data.CommandType.Text; + param = new System.Data.SQLite.SQLiteParameter(); + param.ParameterName = "@IDrac"; + param.DbType = global::System.Data.DbType.Int64; + param.SourceColumn = "IDrac"; + param.Value = IDrac; //SelTag.Parameters["@IDrac"].Value = IDrac; + SelVot.Parameters.Add(param); + rdr = SelVot.ExecuteReader(); + res = rdr.Read(); + rac.Voto = rdr["Voto"] as string; + rdr.Close(); + rdr = null; + + #endregion + + rac.Validate(); + return rac; + + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00080", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + rac = null; + } + return rac; + } + } + + + + + /// + /// Importa il racconto passato sul DB + /// + /// Racconto d aimportare + /// 1 se tutto ok, -1 se importazione abortita per errore, -10 se importazione abortita per duplicato, .... + public int ImportRac(cRac rac) { + lock (objLock) { + // Inizializzo le variabili che occorrono + int res = 0; + long IDvot = 0; + long IDrac = 0; + long IDtag = 0; + long IDaut = 0; + long IDori = 0; + long IDnot = 0; + try { + SQLiteCommand cmd = null; + + #region Verifico se il racconto da inserire è un duplicato + { + // Per ora definisco un racconto duplicato quando ha lo stesso titolo e la stessa trama. + cmd = new System.Data.SQLite.SQLiteCommand(); + cmd.Connection = cn; + cmd.CommandText = "SELECT IDrac FROM Trame WHERE Trama=@Trama LIMIT 1"; + cmd.CommandType = System.Data.CommandType.Text; + System.Data.SQLite.SQLiteParameter param = new System.Data.SQLite.SQLiteParameter(); + param.ParameterName = "@Trama"; + param.DbType = global::System.Data.DbType.String; + param.SourceColumn = "Trama"; + param.Value = rac.Trama; + cmd.Parameters.Add(param); + object RacID = cmd.ExecuteScalar(); + if (RacID != null) { + IDrac = (long)RacID; + if (IDrac > 0) { + + #region Unione del duplicato: + { + + // Ricavo il racconto originale su cui voglio unificare il duplicato: + cRac racOrig = GetRacById(IDrac); + + // Title & SubTitle + // Se titoli diversi, metto tutti e due i titoli suddividendoli e numerandoli: + if (racOrig.Title != rac.Title) { + racOrig.Title = string.Format("1 -> {0} -|- 2 -> {1}", racOrig.Title, rac.Title); + } + if (racOrig.SubTitle != rac.SubTitle) { + racOrig.SubTitle = string.Format("1 -> {0} -|- 2 -> {1}", racOrig.SubTitle, rac.SubTitle); + } + + // Creato + // Mantengo come data di creazione quella più antica delle due: + if (rac.Creato < racOrig.Creato) racOrig.Creato = rac.Creato; + + // Updated + // Mantengo come data di aggiornamento, quella più recente delle due: + if (rac.Updated > racOrig.Updated) racOrig.Updated = rac.Updated; + + // Autors + // Unisco tutti gli autori + if (racOrig.Autori == null) { + racOrig.Autori = rac.Autori; + } else { + foreach (string autore in rac.Autori) { + if (!racOrig.Autori.Contains(autore)) { + racOrig.Autori.Add(autore); + } + } + } + + // Voto + // Se uno dei due è "Non Letto" mantengo l'altro voto, altrimenti se non sono uguali lo segnalo. + if (rac.Voto != racOrig.Voto) { + if (racOrig.Voto == "Non Letto") { + racOrig.Voto = rac.Voto; + } else { + Logger.FailureAudit("ATTENZIONE UNIONE DI UN RACCONTO DUPLICATO; TROVATO VOTAZIONI DISCORDANTI"); + return -222; + } + } + + // Origine + // Unisco le varie origini raccogliendole tutte + if (racOrig.Origini == null) { + racOrig.Origini = rac.Origini; + } else { + foreach (string origine in rac.Origini) { + if (!racOrig.Origini.Contains(origine)) { + racOrig.Origini.Add(origine); + } + } + } + + // Tags + // Unisco le varie tag raccogliendole tutte + if (racOrig.Tags == null) { + racOrig.Tags = rac.Tags; + } else { + foreach (string tag in rac.Tags) { + if (!racOrig.Tags.Contains(tag)) { + racOrig.Tags.Add(tag); + } + } + } + + // Notes + // Per ora inserisco tutte le note ma devo fare attenzione ai duplicati o il DB mi dà errore: + if (racOrig.Notes == null) { + racOrig.Notes = rac.Notes; + } else { + foreach (cNota nota in rac.Notes) { + bool duplicata = false; + // Verifico se la key è già presente: + foreach (cNota notaOrig in racOrig.Notes) { + if (nota.Key == notaOrig.Key) { + if (nota.Description == notaOrig.Description) { + duplicata = true; + break; + } + } + } + if (!duplicata) racOrig.Notes.Add(nota); + } + } + + // Avviso di quanto fatto: + Logger.Warning("ATTENZIONE UNIONE DI UN RACCONTO DUPLICATO SUL RACCONTO: " + racOrig.strIDrac + " -> " + racOrig.fullTitle); + + // Eseguo l'update delle informazioni sul DB: + return UpdateRac(racOrig); + } + #endregion + + } + } + } + #endregion + + // Start a local transaction + SQLiteTransaction myTrans = cn.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); + + + #region 10) Inserisco sulla tabella Racconti + try { + // Creo il nuovo record + cmd = new System.Data.SQLite.SQLiteCommand(); + cmd.Connection = cn; + cmd.CommandText = "INSERT INTO [Racconti]([Title], [SubTitle], [Creato], [Aggiornato]) VALUES (@Title, @SubTitle, @Creato, @Aggiornato)"; + cmd.CommandType = System.Data.CommandType.Text; + cmd.Parameters.Add("@Title", System.Data.DbType.String).Value = rac.Title; + cmd.Parameters.Add("@SubTitle", System.Data.DbType.String).Value = rac.SubTitle; + cmd.Parameters.Add("@Creato", System.Data.DbType.String).Value = rac.strCreato; + cmd.Parameters.Add("@Aggiornato", System.Data.DbType.String).Value = rac.strUpdated; + + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -10; } + // Ricavo l'ID del record appena inserito + cmd.CommandText = "SELECT last_insert_rowid()"; + IDrac = (long)cmd.ExecuteScalar(); + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00009", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + myTrans.Rollback(); + return -10; + } + #endregion + + #region 20) Inserisco sulla tabella Trama + try { + // Creo il nuovo record + cmd = new System.Data.SQLite.SQLiteCommand(); + cmd.Connection = cn; + cmd.CommandText = "INSERT INTO [Trame]([IDrac], [Trama]) VALUES (@IDrac, @Trama)"; + cmd.CommandType = System.Data.CommandType.Text; + cmd.Parameters.Add("@IDrac", System.Data.DbType.Int64).Value = IDrac; + cmd.Parameters.Add("@Trama", System.Data.DbType.String).Value = rac.Trama; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -20; } + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00010", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + myTrans.Rollback(); + return -20; + } + #endregion + + #region 30) Inserisco sulla tabella Links_Rac_Vot + try { + // Decodifico il voto + // ToDo: Ricavare il IDvot dal Voto e non assegnarlo d'ufficio. + IDvot = 0; // Si sa già che il voto "Non Letto" ha indice 1 perchè fa parte dei valori predefiniti. + // Creo il nuovo record + cmd = new System.Data.SQLite.SQLiteCommand(); + cmd.Connection = cn; + cmd.CommandText = "INSERT INTO [Links_Rac_Vot]([IDrac], [IDvot]) VALUES (@IDrac, @IDvot)"; + cmd.CommandType = System.Data.CommandType.Text; + cmd.Parameters.Add("@IDrac", System.Data.DbType.Int64).Value = IDrac; + cmd.Parameters.Add("@IDvot", System.Data.DbType.Int64).Value = IDvot; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -30; } + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00011", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + myTrans.Rollback(); + return -30; + } + #endregion + + #region 40) Inserisco i Tags (edito tabelle: Tags, Links_Rac_Tag) + try { + //foreach (string tag in rac.Tags) { + for (int i = 0; i < rac.Tags.Count; i++) { + // Ricavo l'ID del tag o lo inserisco sul DB: + cmd = new System.Data.SQLite.SQLiteCommand(); + cmd.Connection = cn; + cmd.CommandText = "SELECT IDtag FROM [Tags] WHERE [Tag]=@Tag"; + cmd.CommandType = System.Data.CommandType.Text; + cmd.Parameters.Add("@Tag", System.Data.DbType.String).Value = rac.Tags[i]; + try { IDtag = (long)cmd.ExecuteScalar(); } catch { + // Tag non presente in archivio, lo inserisco: + cmd.Parameters.Clear(); + cmd.CommandText = "INSERT INTO [Tags]([Tag]) VALUES (@Tag)"; + cmd.Parameters.Add("@Tag", System.Data.DbType.String).Value = rac.Tags[i]; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -40; } + // Ricavo l'ID del record appena inserito + cmd.Parameters.Clear(); + cmd.CommandText = "SELECT last_insert_rowid()"; + IDtag = (long)cmd.ExecuteScalar(); + } + // Assegno al racconto il tag: + cmd.Parameters.Clear(); + cmd.CommandText = "INSERT INTO [Links_Rac_Tag]([IDrac], [IDtag]) VALUES (@IDrac, @IDtag)"; + cmd.CommandType = System.Data.CommandType.Text; + cmd.Parameters.Add("@IDrac", System.Data.DbType.Int64).Value = IDrac; + cmd.Parameters.Add("@IDtag", System.Data.DbType.Int64).Value = IDtag; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -40; } + } + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00012", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + myTrans.Rollback(); + return -40; + } + #endregion + + #region 50) Inserisco gli Autori (edito tabelle: Autori, Links_Rac_Aut) + try { + //foreach (string autore in rac.Autori) { + for (int i=0; i + /// Aggiorna i dati del racconto passato. + /// Se ID è valido aggiorna i dati del racconto già presente in memoria, altrimenti ne inserisce uno nuovo. + /// + /// Racconto da inserire sul DB + /// Codice di errore se negativo + public int UpdateRac(cRac rac) { + if (rac.IDrac == 0) { + return ImportRac(rac); + } else { + return _updateRac(rac); + } + } + + + /// + /// Aggiorna, nel DB, i dati del racconto passato. + /// + /// Racconto da inserire sul DB + /// Codice di errore se negativo + private int _updateRac(cRac rac) { + lock (objLock) { + + // Inizializzo le variabili che occorrono + int res = 0; + long IDvot = 0; + long IDtag = 0; + long IDaut = 0; + long IDori = 0; + long IDnot = 0; + + // Elimino il racconto per poi reinserirlo: + + try { + + #region 05) Elimino il racconto per poi reinserirlo + try { + SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand { + Connection = cn, + CommandText = "DELETE FROM [Racconti] WHERE [IDrac]=@IDrac", + CommandType = System.Data.CommandType.Text + }; + cmd.Parameters.Add("@IDrac", System.Data.DbType.Int64).Value = rac.IDrac; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -5; } + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00001", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + return -10; + } + #endregion + + #region 10) Inserisco sulla tabella Racconti + try { + // Creo il nuovo record + SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand { + Connection = cn, + CommandText = "INSERT INTO [Racconti]([IDrac], [Title], [SubTitle], [Creato], [Aggiornato]) VALUES (@IDrac, @Title, @SubTitle, @Creato, @Aggiornato)", + CommandType = System.Data.CommandType.Text + }; + cmd.Parameters.Add("@IDrac", System.Data.DbType.Int64).Value = rac.IDrac; + cmd.Parameters.Add("@Title", System.Data.DbType.String).Value = rac.Title; + cmd.Parameters.Add("@SubTitle", System.Data.DbType.String).Value = rac.SubTitle; + cmd.Parameters.Add("@Creato", System.Data.DbType.String).Value = rac.strCreato; + cmd.Parameters.Add("@Aggiornato", System.Data.DbType.String).Value = rac.strUpdated; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -10; } + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00002", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + return -10; + } + #endregion + + #region 20) Inserisco sulla tabella Trama + try { + // Creo il nuovo record + SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand { + Connection = cn, + CommandText = "INSERT INTO [Trame]([IDrac], [Trama]) VALUES (@IDrac, @Trama)", + CommandType = System.Data.CommandType.Text + }; + cmd.Parameters.Add("@IDrac", System.Data.DbType.Int64).Value = rac.IDrac; + cmd.Parameters.Add("@Trama", System.Data.DbType.String).Value = rac.Trama; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -20; } + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00003", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + return -20; + } + #endregion + + #region 30) Inserisco sulla tabella Links_Rac_Vot + try { + // Decodifico il voto + SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand { + Connection = cn, + CommandText = "SELECT IDvot FROM Voti WHERE Voto=@Voto", + CommandType = System.Data.CommandType.Text + }; + cmd.Parameters.Add("@Voto", System.Data.DbType.String).Value = rac.Voto; + //IDvot = (long)cmd.ExecuteScalar(System.Data.CommandBehavior.Default); + IDvot = (long)cmd.ExecuteScalar(); + // Creo il nuovo record + cmd = new System.Data.SQLite.SQLiteCommand { + Connection = cn, + CommandText = "INSERT INTO [Links_Rac_Vot]([IDrac], [IDvot]) VALUES (@IDrac, @IDvot)", + CommandType = System.Data.CommandType.Text + }; + cmd.Parameters.Add("@IDrac", System.Data.DbType.Int64).Value = rac.IDrac; + cmd.Parameters.Add("@IDvot", System.Data.DbType.Int64).Value = IDvot; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -30; } + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00004", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + return -30; + } + #endregion + + #region 40) Inserisco i Tags (edito tabelle: Tags, Links_Rac_Tag) + try { + foreach (string tag in rac.Tags) { + // Ricavo l'ID del tag o lo inserisco sul DB: + SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand { + Connection = cn, + CommandText = "SELECT IDtag FROM [Tags] WHERE [Tag]=@Tag", + CommandType = System.Data.CommandType.Text + }; + cmd.Parameters.Add("@Tag", System.Data.DbType.String).Value = tag; + try { IDtag = (long)cmd.ExecuteScalar(); } catch { + // Tag non presente in archivio, lo inserisco: + cmd.Parameters.Clear(); + cmd.CommandText = "INSERT INTO [Tags]([Tag]) VALUES (@Tag)"; + cmd.Parameters.Add("@Tag", System.Data.DbType.String).Value = tag; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -40; } + // Ricavo l'ID del record appena inserito + cmd.Parameters.Clear(); + cmd.CommandText = "SELECT last_insert_rowid()"; + IDtag = (long)cmd.ExecuteScalar(); + } + // Assegno al racconto il tag: + cmd.Parameters.Clear(); + cmd.CommandText = "INSERT INTO [Links_Rac_Tag]([IDrac], [IDtag]) VALUES (@IDrac, @IDtag)"; + cmd.CommandType = System.Data.CommandType.Text; + cmd.Parameters.Add("@IDrac", System.Data.DbType.Int64).Value = rac.IDrac; + cmd.Parameters.Add("@IDtag", System.Data.DbType.Int64).Value = IDtag; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -40; } + } + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00005", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + return -40; + } + #endregion + + #region 50) Inserisco gli Autori (edito tabelle: Autori, Links_Rac_Aut) + try { + foreach (string autore in rac.Autori) { + // Ricavo l'ID del tag o lo inserisco sul DB: + SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand { + Connection = cn, + CommandText = "SELECT IDaut FROM [Autori] WHERE [Autore]=@Autore", + CommandType = System.Data.CommandType.Text + }; + cmd.Parameters.Add("@Autore", System.Data.DbType.String).Value = autore; + try { IDaut = (long)cmd.ExecuteScalar(); } catch { + // Tag non presente in archivio, lo inserisco: + cmd.Parameters.Clear(); + cmd.CommandText = "INSERT INTO [Autori]([Autore]) VALUES (@Autore)"; + cmd.Parameters.Add("@Autore", System.Data.DbType.String).Value = autore; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -50; } + // Ricavo l'ID del record appena inserito + cmd.Parameters.Clear(); + cmd.CommandText = "SELECT last_insert_rowid()"; + IDaut = (long)cmd.ExecuteScalar(); + } + // Assegno al racconto il tag: + cmd.Parameters.Clear(); + cmd.CommandText = "INSERT INTO [Links_Rac_Aut]([IDrac], [IDaut]) VALUES (@IDrac, @IDaut)"; + cmd.CommandType = System.Data.CommandType.Text; + cmd.Parameters.Add("@IDrac", System.Data.DbType.Int64).Value = rac.IDrac; + cmd.Parameters.Add("@IDaut", System.Data.DbType.Int64).Value = IDaut; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -50; } + } + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00006", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + return -50; + } + #endregion + + #region 60) Inserisco le Origini (edito tabelle: Origini, Links_Rac_Ori) + try { + foreach (string origine in rac.Origini) { + // Ricavo l'ID dell'origine: + SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand { + Connection = cn, + CommandText = "SELECT IDori FROM [Origini] WHERE [Origine]=@Origine", + CommandType = System.Data.CommandType.Text + }; + cmd.Parameters.Add("@Origine", System.Data.DbType.String).Value = origine; + try { IDori = (long)cmd.ExecuteScalar(); } catch { + // Tag non presente in archivio, lo inserisco: + cmd.Parameters.Clear(); + cmd.CommandText = "INSERT INTO [Origini]([Origine]) VALUES (@Origine)"; + cmd.Parameters.Add("@Origine", System.Data.DbType.String).Value = origine; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -60; } + // Ricavo l'ID del record appena inserito + cmd.Parameters.Clear(); + cmd.CommandText = "SELECT last_insert_rowid()"; + IDori = (long)cmd.ExecuteScalar(); + } + // Assegno al racconto il tag: + cmd.Parameters.Clear(); + cmd.CommandText = "INSERT INTO [Links_Rac_Ori]([IDrac], [IDori]) VALUES (@IDrac, @IDori)"; + cmd.CommandType = System.Data.CommandType.Text; + cmd.Parameters.Add("@IDrac", System.Data.DbType.Int64).Value = rac.IDrac; + cmd.Parameters.Add("@IDori", System.Data.DbType.Int64).Value = IDori; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -60; } + } + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00007", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + return -60; + } + #endregion + + #region 70) Inserisco le Note (edito tabelle: Notes, Links_Rac_Not) + try { + foreach (cNota nota in rac.Notes) { + // Verifico se la nota esiste ancora: + SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand { + Connection = cn, + CommandText = "SELECT IDnot FROM Notes WHERE NKey=@NKey AND NVal=@NVal", + CommandType = System.Data.CommandType.Text + }; + cmd.Parameters.Add("@NKey", System.Data.DbType.String).Value = nota.Key; + cmd.Parameters.Add("@NVal", System.Data.DbType.String).Value = nota.Description; + //try { IDnot = (long)cmd.ExecuteScalar(System.Data.CommandBehavior.Default); } catch (Exception ex) { + try { IDnot = (long)cmd.ExecuteScalar(); } catch (Exception ex) { + // Nota non presente in archivio, la inserisco: + SQLiteCommand cmdi = new System.Data.SQLite.SQLiteCommand { + Connection = cn, + CommandText = "INSERT INTO [Notes]([NKey], [NVal]) VALUES (@NKey, @NVal)", + CommandType = System.Data.CommandType.Text + }; + cmdi.Parameters.Add("@NKey", System.Data.DbType.String).Value = nota.Key; + cmdi.Parameters.Add("@NVal", System.Data.DbType.String).Value = nota.Description; + res = cmdi.ExecuteNonQuery(); + if (res != 1) { return -70; } + // Ricavo l'ID del record appena inserito + cmd.CommandText = "SELECT last_insert_rowid()"; + IDnot = (long)cmd.ExecuteScalar(); + } + // Lo associo al racconto + cmd.Parameters.Clear(); + cmd.CommandText = "INSERT INTO [Links_Rac_Not]([IDrac], [IDnot]) VALUES (@IDrac, @IDnot)"; + cmd.CommandType = System.Data.CommandType.Text; + cmd.Parameters.Add("@IDrac", System.Data.DbType.Int64).Value = rac.IDrac; + cmd.Parameters.Add("@IDnot", System.Data.DbType.Int64).Value = IDnot; + res = cmd.ExecuteNonQuery(); + if (res != 1) { return -70; } + } + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00008", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + return -70; + } + #endregion + + return 1; + + } catch (Exception ex) { + Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00093", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); + return -1; + } + } + } + + + + } // class DBTools diff --git a/Src/A69WD/General/cTools.cs b/Src/A69WD/General/cTools.cs index 55aae75..67d9d91 100644 --- a/Src/A69WD/General/cTools.cs +++ b/Src/A69WD/General/cTools.cs @@ -473,17 +473,17 @@ namespace A69WD { public static string FormattaTesto(string txt, bool eliminaTagHtml) { try { // Analisi dei tag prima di levarli: - string testo = Regex.Replace(txt, @"

", "\n", RegexOptions.IgnoreCase); - testo = Regex.Replace(testo, @"

", "\n", RegexOptions.IgnoreCase); - testo = Regex.Replace(testo, @"

", "\n", RegexOptions.IgnoreCase); - testo = Regex.Replace(testo, @"", "\n", RegexOptions.IgnoreCase); - testo = Regex.Replace(testo, @"", "\n", RegexOptions.IgnoreCase); - testo = Regex.Replace(testo, @"", "\n", RegexOptions.IgnoreCase); - testo = Regex.Replace(testo, @"
", "\n", RegexOptions.IgnoreCase); - testo = Regex.Replace(testo, @"
", "\n", RegexOptions.IgnoreCase); - testo = Regex.Replace(testo, @"
", "\n", RegexOptions.IgnoreCase); - testo = Regex.Replace(testo, @"", "\n", RegexOptions.IgnoreCase); - testo = Regex.Replace(testo, @"

", "\n", RegexOptions.IgnoreCase); + string testo = Regex.Replace(txt, @"

", "\r\n", RegexOptions.IgnoreCase); + testo = Regex.Replace(testo, @"

", "\r\n", RegexOptions.IgnoreCase); + testo = Regex.Replace(testo, @"

", "\r\n", RegexOptions.IgnoreCase); + testo = Regex.Replace(testo, @"", "\r\n", RegexOptions.IgnoreCase); + testo = Regex.Replace(testo, @"", "\r\n", RegexOptions.IgnoreCase); + testo = Regex.Replace(testo, @"", "\r\n", RegexOptions.IgnoreCase); + testo = Regex.Replace(testo, @"
", "\r\n", RegexOptions.IgnoreCase); + testo = Regex.Replace(testo, @"
", "\r\n", RegexOptions.IgnoreCase); + testo = Regex.Replace(testo, @"
", "\r\n", RegexOptions.IgnoreCase); + testo = Regex.Replace(testo, @"

", "\r\n", RegexOptions.IgnoreCase); + testo = Regex.Replace(testo, @"
", "\r\n", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @"<<", "«", RegexOptions.IgnoreCase); testo = Regex.Replace(testo, @">>", "»", RegexOptions.IgnoreCase); // Se richiesto, elimino i tag html: @@ -496,10 +496,79 @@ namespace A69WD { 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: 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); @@ -541,9 +611,10 @@ namespace A69WD { //while (testo.Contains("ù")) { testo = testo.Replace("ù", "ù"); } //while (testo.Contains("’")) { testo = testo.Replace("’", "'"); } - - // Correggo scritto: + testo = testo.Replace("&egrave", "è"); + testo = testo.Replace("&", "&"); + testo = testo.Replace("…", "…"); testo = testo.Replace("\r", ""); while (testo.Contains("\t")) { testo = testo.Replace("\t", " "); } while (testo.Contains("...")) { testo = testo.Replace("...", "…"); } diff --git a/Src/A69WD/Net/cLink_A69.cs b/Src/A69WD/Net/cLink_A69.cs index 49c8bb7..5549c2e 100644 --- a/Src/A69WD/Net/cLink_A69.cs +++ b/Src/A69WD/Net/cLink_A69.cs @@ -1,12 +1,16 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Runtime.Remoting.Messaging; using System.Security.Policy; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; +using A69WD.Data; using A69WD.Service; +using HtmlAgilityPack; namespace A69WD.Net { public class cLink_A69 : iLink { @@ -102,6 +106,458 @@ namespace A69WD.Net { } } + + + public async Task 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: + * + * + * ... + *
incesto
+ * ... + *

Mia Madre , La mia Amante

+ *            diBambino + * ... + *
+ *  Scritto il 22.08.2015    |    + * Letture: 8.947  |    + * Votazione 8.0: + *
+ * ... + *
+ * Eliminare i DIV interni che hanno cose grafiche + * Il testo è quello che rimane. + *
+ * + * + * + * quindi i dati del racconto che si possono estrapolare sono: + * Titolo: --> Testo del nodo

+ * SubTitle: --> Sempre Vuoto + * Autore: --> Testo del nodo + * Creato: --> Estrarre la parte dal
+ * Tags: --> Testo del nodo div class="targhetta_racconti"> + * Trama: --> Testo del nodo
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 { ID }; + #endregion + + #region Titolo: --> Testo del nodo

+ 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 + try { + // Autore --> Testo del nodo items = new List(); + 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(); + // 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
+ rac.Creato = DateTime.Now; + try { + // Creato --> Estrarre la prima parte dal 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 items = new List(); + 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
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(); + 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 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(); + 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 }//namespace A69WD.Net diff --git a/Src/A69WD/Service/Service_Importer.cs b/Src/A69WD/Service/Service_Importer.cs new file mode 100644 index 0000000..d219fed --- /dev/null +++ b/Src/A69WD/Service/Service_Importer.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace A69WD.Service { + + + public class Service_Importer { + + // Thread worker che consuma la coda + private Thread _workerThread; + + + }//class Service_Importer + +}//namespace A69WD.Service diff --git a/Src/A69WD/UI/frmDownloader.Designer.cs b/Src/A69WD/UI/frmDownloader.Designer.cs index b6a13a8..915fa03 100644 --- a/Src/A69WD/UI/frmDownloader.Designer.cs +++ b/Src/A69WD/UI/frmDownloader.Designer.cs @@ -30,11 +30,12 @@ this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.btnShowLog = new System.Windows.Forms.Button(); this.pbST = new System.Windows.Forms.ProgressBar(); + this.btnImport = new System.Windows.Forms.Button(); this.SuspendLayout(); // // 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.Size = new System.Drawing.Size(79, 33); this.btnClose.TabIndex = 14; @@ -58,7 +59,7 @@ this.lblST.Dock = System.Windows.Forms.DockStyle.Bottom; this.lblST.Location = new System.Drawing.Point(0, 73); 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.Text = "Status"; this.lblST.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -81,7 +82,7 @@ // // 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.Size = new System.Drawing.Size(79, 33); this.btnShowLog.TabIndex = 17; @@ -94,14 +95,25 @@ this.pbST.Dock = System.Windows.Forms.DockStyle.Bottom; this.pbST.Location = new System.Drawing.Point(0, 55); 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; // + // 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 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 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.btnShowLog); this.Controls.Add(this.btnImportLinks); @@ -123,5 +135,6 @@ private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.Button btnShowLog; private System.Windows.Forms.ProgressBar pbST; + private System.Windows.Forms.Button btnImport; } } \ No newline at end of file diff --git a/Src/A69WD/UI/frmDownloader.cs b/Src/A69WD/UI/frmDownloader.cs index 1fc7f7b..7260fe3 100644 --- a/Src/A69WD/UI/frmDownloader.cs +++ b/Src/A69WD/UI/frmDownloader.cs @@ -17,6 +17,7 @@ using A69WD.Net; using System.Collections.Concurrent; using System.Xml.Linq; using A69WD.Service; +using A69WD.Data; namespace A69WD { @@ -53,9 +54,7 @@ namespace A69WD { } private async void btnDownloadAll_Click(object sender, EventArgs e) { - ////engine.Start(true); - ////engine.Start(!cbSoloFileIndice.Checked); - //engine.StartParallel(!cbSoloFileIndice.Checked, int.Parse(tbNumThred.Text)); + btnDownloadAll.Enabled = false; // - Creo istanza del client per il sito con autenticazione: lblST.Text = DateTime.Now.ToString() + " - Login"; @@ -132,6 +131,8 @@ namespace A69WD { this.Close(); } + + #region Gestione eventi dal engine // // private void Engine_Updating(object sender, EngineEventArgs e) { EngineUpdatingStatus(e.Message, e.NTot, e.NtoDown, e.NDown); } @@ -156,6 +157,21 @@ namespace A69WD { // #endregion + private async 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