From ebe1608e98626686ef8c98f768228328cbae3b67 Mon Sep 17 00:00:00 2001 From: CSiCoAlm Date: Thu, 28 Oct 2021 09:01:10 +0200 Subject: [PATCH] - Autocommit - 2021/10/28 09:01:10 --- Src/A69WD/A69WD.csproj | 17 ++- Src/A69WD/A69WD.csproj.user | 6 + Src/A69WD/App.cs | 80 +++++------ Src/A69WD/Form1.Designer.cs | 165 ----------------------- Src/A69WD/Form1.cs | 262 ------------------------------------ Src/A69WD/Form1.resx | 120 ----------------- Src/A69WD/Program.cs | 18 --- 7 files changed, 59 insertions(+), 609 deletions(-) create mode 100644 Src/A69WD/A69WD.csproj.user delete mode 100644 Src/A69WD/Form1.Designer.cs delete mode 100644 Src/A69WD/Form1.cs delete mode 100644 Src/A69WD/Form1.resx delete mode 100644 Src/A69WD/Program.cs diff --git a/Src/A69WD/A69WD.csproj b/Src/A69WD/A69WD.csproj index dbf1889..daac807 100644 --- a/Src/A69WD/A69WD.csproj +++ b/Src/A69WD/A69WD.csproj @@ -60,16 +60,22 @@ - + Form - + Form1.cs - + + Form + + + frmTestSite.cs + + - + Form1.cs @@ -84,6 +90,9 @@ True Resources.resx + + frmTestSite.cs + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/Src/A69WD/A69WD.csproj.user b/Src/A69WD/A69WD.csproj.user new file mode 100644 index 0000000..e482657 --- /dev/null +++ b/Src/A69WD/A69WD.csproj.user @@ -0,0 +1,6 @@ + + + + ShowAllFiles + + \ No newline at end of file diff --git a/Src/A69WD/App.cs b/Src/A69WD/App.cs index 5693afe..8c44b21 100644 --- a/Src/A69WD/App.cs +++ b/Src/A69WD/App.cs @@ -12,56 +12,56 @@ namespace A69WD { public static A69WD.DBTools DB = null; - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) { - try { - // Common settings: - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); + ///// + ///// The main entry point for the application. + ///// + //[STAThread] + //static void Main(string[] args) { + // try { + // // Common settings: + // Application.EnableVisualStyles(); + // Application.SetCompatibleTextRenderingDefault(false); - if ((args != null) && (args.Length > 0)) Retrive = false; - else Retrive = true; + // if ((args != null) && (args.Length > 0)) Retrive = false; + // else Retrive = true; - // Configura il logger dell'applicazione: - Logger.Configure(Cfg.Settings.PathFileLogs, Cfg.Settings.LogsFileSizeLimitKB, Cfg.Settings.LogsWinLoggerRef); + // // Configura il logger dell'applicazione: + // Logger.Configure(Cfg.Settings.PathFileLogs, Cfg.Settings.LogsFileSizeLimitKB, Cfg.Settings.LogsWinLoggerRef); - // Configura il DB dell'applicazione - DB = new A69WD.DBTools(); + // // Configura il DB dell'applicazione + // DB = new A69WD.DBTools(); - // Start application: - Logger.Information(" - - - START Application - - - "); - if (DB.DB_ok) { - Application.Run(new frmDownloader()); + // // Start application: + // Logger.Information(" - - - START Application - - - "); + // if (DB.DB_ok) { + // Application.Run(new frmDownloader()); - Logger.Information(" - - - STOP Application - - - "); + // Logger.Information(" - - - STOP Application - - - "); - while (Logger.LogMissing() > 0) { - System.Threading.Thread.Sleep(25); - } + // while (Logger.LogMissing() > 0) { + // System.Threading.Thread.Sleep(25); + // } - // MRK: TODO rivedere la chiusura precedente per farla funzionare senza il tempo ma con il controllo totale dei thread. + // // MRK: TODO rivedere la chiusura precedente per farla funzionare senza il tempo ma con il controllo totale dei thread. - } else { - Logger.Error("Collegamento al DB non riuscito"); - MessageBox.Show("Applicazione abortita perchè non riesco ad aprire il DB", "Error"); - } + // } else { + // Logger.Error("Collegamento al DB non riuscito"); + // MessageBox.Show("Applicazione abortita perchè non riesco ad aprire il DB", "Error"); + // } - } catch (Exception ex) { - Logger.Log(new object[] { "Error Code: ER00000", "Errore in Main()", ex }); - } finally { - // Chiudo DB in memoria riportando sul DB di sistema le modifiche occorse: - if (DB != null) { - DB.Dispose(); - DB = null; - } - // Attesa per svuotamento logger: - while (Logger.LogMissing() > 0) { System.Threading.Thread.Sleep(100); } - } - } + // } catch (Exception ex) { + // Logger.Log(new object[] { "Error Code: ER00000", "Errore in Main()", ex }); + // } finally { + // // Chiudo DB in memoria riportando sul DB di sistema le modifiche occorse: + // if (DB != null) { + // DB.Dispose(); + // DB = null; + // } + // // Attesa per svuotamento logger: + // while (Logger.LogMissing() > 0) { System.Threading.Thread.Sleep(100); } + // } + //} diff --git a/Src/A69WD/Form1.Designer.cs b/Src/A69WD/Form1.Designer.cs deleted file mode 100644 index 046104b..0000000 --- a/Src/A69WD/Form1.Designer.cs +++ /dev/null @@ -1,165 +0,0 @@ -namespace A69WD { - partial class Form1 { - /// - /// Variabile di progettazione necessaria. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Pulire le risorse in uso. - /// - /// ha valore true se le risorse gestite devono essere eliminate, false in caso contrario. - protected override void Dispose(bool disposing) { - if (disposing && (components != null)) { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Codice generato da Progettazione Windows Form - - /// - /// Metodo necessario per il supporto della finestra di progettazione. Non modificare - /// il contenuto del metodo con l'editor di codice. - /// - private void InitializeComponent() { - this.lblST = new System.Windows.Forms.Label(); - this.btnDownloadLink = new System.Windows.Forms.Button(); - this.btnDownloadAll = new System.Windows.Forms.Button(); - this.wb1 = new System.Windows.Forms.WebBrowser(); - this.btnHide = new System.Windows.Forms.Button(); - this.btnClose = new System.Windows.Forms.Button(); - this.lblPath = new System.Windows.Forms.Label(); - this.tbPath = new System.Windows.Forms.TextBox(); - this.btbPath = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // lblST - // - this.lblST.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.lblST.Dock = System.Windows.Forms.DockStyle.Bottom; - this.lblST.Location = new System.Drawing.Point(0, 84); - this.lblST.Name = "lblST"; - this.lblST.Size = new System.Drawing.Size(504, 22); - this.lblST.TabIndex = 0; - this.lblST.Text = "Status"; - this.lblST.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // btnDownloadLink - // - this.btnDownloadLink.Location = new System.Drawing.Point(12, 12); - this.btnDownloadLink.Name = "btnDownloadLink"; - this.btnDownloadLink.Size = new System.Drawing.Size(117, 33); - this.btnDownloadLink.TabIndex = 1; - this.btnDownloadLink.Text = "Download only Link"; - this.btnDownloadLink.UseVisualStyleBackColor = true; - this.btnDownloadLink.Click += new System.EventHandler(this.btnDownloadLink_Click); - // - // btnDownloadAll - // - this.btnDownloadAll.Location = new System.Drawing.Point(135, 12); - this.btnDownloadAll.Name = "btnDownloadAll"; - this.btnDownloadAll.Size = new System.Drawing.Size(117, 33); - this.btnDownloadAll.TabIndex = 2; - this.btnDownloadAll.Text = "Download All"; - this.btnDownloadAll.UseVisualStyleBackColor = true; - this.btnDownloadAll.Click += new System.EventHandler(this.btnDownloadAll_Click); - // - // wb1 - // - this.wb1.Location = new System.Drawing.Point(0, 1); - this.wb1.MinimumSize = new System.Drawing.Size(20, 20); - this.wb1.Name = "wb1"; - this.wb1.ScriptErrorsSuppressed = true; - this.wb1.ScrollBarsEnabled = false; - this.wb1.Size = new System.Drawing.Size(63, 44); - this.wb1.TabIndex = 3; - this.wb1.TabStop = false; - this.wb1.Visible = false; - // - // btnHide - // - this.btnHide.Location = new System.Drawing.Point(258, 12); - this.btnHide.Name = "btnHide"; - this.btnHide.Size = new System.Drawing.Size(117, 33); - this.btnHide.TabIndex = 4; - this.btnHide.Text = "Hide"; - this.btnHide.UseVisualStyleBackColor = true; - this.btnHide.Click += new System.EventHandler(this.btnHide_Click); - // - // btnClose - // - this.btnClose.Location = new System.Drawing.Point(381, 12); - this.btnClose.Name = "btnClose"; - this.btnClose.Size = new System.Drawing.Size(117, 33); - this.btnClose.TabIndex = 5; - this.btnClose.Text = "Close"; - this.btnClose.UseVisualStyleBackColor = true; - this.btnClose.Click += new System.EventHandler(this.btnClose_Click); - // - // lblPath - // - this.lblPath.Location = new System.Drawing.Point(12, 47); - this.lblPath.Name = "lblPath"; - this.lblPath.Size = new System.Drawing.Size(117, 33); - this.lblPath.TabIndex = 6; - this.lblPath.Text = "Destination Path:"; - this.lblPath.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // tbPath - // - this.tbPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbPath.Location = new System.Drawing.Point(132, 54); - this.tbPath.Name = "tbPath"; - this.tbPath.Size = new System.Drawing.Size(344, 20); - this.tbPath.TabIndex = 7; - this.tbPath.Text = "C:\\Temporary\\A69WD\\Dst\\"; - this.tbPath.TextChanged += new System.EventHandler(this.tbPath_TextChanged); - // - // btbPath - // - this.btbPath.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btbPath.Location = new System.Drawing.Point(478, 53); - this.btbPath.Name = "btbPath"; - this.btbPath.Size = new System.Drawing.Size(20, 20); - this.btbPath.TabIndex = 8; - this.btbPath.Text = "."; - this.btbPath.UseVisualStyleBackColor = true; - this.btbPath.Click += new System.EventHandler(this.btbPath_Click); - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(504, 106); - this.Controls.Add(this.btbPath); - this.Controls.Add(this.tbPath); - this.Controls.Add(this.lblPath); - this.Controls.Add(this.btnClose); - this.Controls.Add(this.btnHide); - this.Controls.Add(this.btnDownloadAll); - this.Controls.Add(this.btnDownloadLink); - this.Controls.Add(this.lblST); - this.Controls.Add(this.wb1); - this.Name = "Form1"; - this.Text = "A69 Downloader"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label lblST; - private System.Windows.Forms.Button btnDownloadLink; - private System.Windows.Forms.Button btnDownloadAll; - private System.Windows.Forms.WebBrowser wb1; - private System.Windows.Forms.Button btnHide; - private System.Windows.Forms.Button btnClose; - private System.Windows.Forms.Label lblPath; - private System.Windows.Forms.TextBox tbPath; - private System.Windows.Forms.Button btbPath; - } -} - diff --git a/Src/A69WD/Form1.cs b/Src/A69WD/Form1.cs deleted file mode 100644 index aa139a1..0000000 --- a/Src/A69WD/Form1.cs +++ /dev/null @@ -1,262 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using System.IO; - - - -namespace A69WD { - public partial class Form1 : Form { - - - List AllLinks = null; - List toDownload = null; - List Downloaded = null; - List RacLinks = null; - - DateTime dtStartTime; - - string[] Tipologie = { "altro", "bdsm", "gay", "incesto", "lesbo", "orge", "prime", "scambio", "tradimenti", "trans", "trio" }; - - const string BASE_URL = "https://www.annunci69.it/racconti-erotici/{Tip}.html"; - const string BASE_LINK_IDX = "https://www.annunci69.it/racconti-erotici/racconti_lista.php"; - const string BASE_LINK_RAC = "https://www.annunci69.it/racconti-erotici/"; - - const int MAXLINK = 1000; - int cnt = 0; - - bool aborting = false; - bool DownRac = false; - - - public string DstIdx { - get { - if (string.IsNullOrEmpty(dstIdx)) { - // creo path e verifico l'esistenza - dstIdx = Path.Combine(System.IO.Path.Combine(tbPath.Text, DateTime.Now.ToString("yyyy-MM-dd")), "Indici"); - if (!Directory.Exists(dstIdx)) Directory.CreateDirectory(dstIdx); - } - return dstIdx; - } - } - private string dstIdx = ""; - - - public string DstRac { - get { - if (string.IsNullOrEmpty(dstRac)) { - // creo path e verifico l'esistenza - dstRac = Path.Combine(System.IO.Path.Combine(tbPath.Text, DateTime.Now.ToString("yyyy-MM-dd")), "Testi"); - if (!Directory.Exists(dstRac)) Directory.CreateDirectory(dstRac); - } - return dstRac; - } - } - private string dstRac = ""; - - - - - // Mettere che alla chiusura del form, salvo i valori degli elenchi tramite serializzzazione - - - - public Form1() { - InitializeComponent(); - // Inizializzo gli archivi (dai file in memoria) - AllLinks = new List(); - toDownload = new List(); - Downloaded = new List(); - RacLinks = new List(); - - wb1.DocumentCompleted += Wb_DocumentCompleted; - // Per ora non serializzo gli archivi e quindi carico le pagine iniziali delle 11 tipologie: - foreach (string tipologia in Tipologie) { - toDownload.Add(BASE_URL.Replace("{Tip}", tipologia)); - AllLinks.Add(BASE_URL.Replace("{Tip}", tipologia)); - } - - } - - - - - - private void btnDownloadLink_Click(object sender, EventArgs e) { - dtStartTime = DateTime.Now; - - DownRac = false; - - UpdateST("Inizio lo scrap dei link dei racconti"); - if ((toDownload.Count > 0) && (cnt < MAXLINK)) { - // proseguo con il download: - string lk = toDownload.First(); - toDownload.Remove(lk); - wb1.Navigate(lk); - } - - btnDownloadLink.Enabled = false; - } - - - private void btnDownloadAll_Click(object sender, EventArgs e) { - dtStartTime = DateTime.Now; - - DownRac = true; - - UpdateST("Inizio lo scrap dei link dei racconti"); - if ((toDownload.Count > 0) && (cnt < MAXLINK)) { - // proseguo con il download: - string lk = toDownload.First(); - toDownload.Remove(lk); - wb1.Navigate(lk); - } - - btnDownloadLink.Enabled = false; - } - - - private void btnHide_Click(object sender, EventArgs e) { MessageBox.Show("Metodo ancora da fare"); } - - - private void btnClose_Click(object sender, EventArgs e) { aborting = true; } - - - private void btbPath_Click(object sender, EventArgs e) { MessageBox.Show("Metodo ancora da fare"); } - - - private void tbPath_TextChanged(object sender, EventArgs e) { - dstIdx = dstRac = ""; - } - - - - - - - private void Wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { - object obj = new Object(); - lock (obj) { - cnt++; - StringBuilder sb; - - WebBrowser wb = sender as WebBrowser; - string link = wb.Url.ToString(); - - // aggiorno UI - UpdateST(wb.Name + " - Donwloaded: " + link); - - // Se pagina è un racconto, lo salvo - if (IsRacLink(link)) { - sb = new StringBuilder(); - sb.Append(wb.DocumentText); - string fn = Path.Combine(DstRac, GetFileName(link)); - cTools.WriteTextFile(fn, sb); - } - - // Registro che ho eseguito il download del link - Downloaded.Add(link); - - // Ciclo su tutti i link estratti dalla pagina: - foreach (HtmlElement item in wb.Document.Links) { - link = item.GetAttribute("href"); - // Se link nuovo: - if (!AllLinks.Contains(link)) { - // Link nuovo, mi comporto di conseguenza alla tipologia: - if (IsRacLink(link)){ - // Link ad un racconto - AllLinks.Add(link); - if (DownRac) { toDownload.Add(link); } - RacLinks.Add(link); - } else { - if (IsIdxLink(link)){ - // Link ad un indice - AllLinks.Add(link); - toDownload.Add(link); - } else { - // Link non riconosciuto, lo scarto - ; - } - } - } - } // fine ciclo sui link estratti - - // Se ho raggiunto il massimo numero di link, o non vi sono link da downloadare, mi fermo: - if ((toDownload.Count > 0) && ((cnt < MAXLINK) || (DownRac)) && (!aborting)) { - // proseguo con il download: - string lk = toDownload.First(); - toDownload.Remove(lk); - wb.Navigate(lk); - } else { - // Finito download, salvo gli archivi: - SaveState(); - } - - }//lock - } - - - private void SaveState() { - StringBuilder sb; - - // Preparo il path di destinazione - string dstIdx = Path.Combine(System.IO.Path.Combine(tbPath.Text, DateTime.Now.ToString("yyyy-MM-dd")), "Indici"); - if (!Directory.Exists(dstIdx)) Directory.CreateDirectory(dstIdx); - string dstRac = Path.Combine(System.IO.Path.Combine(tbPath.Text, DateTime.Now.ToString("yyyy-MM-dd")), "Testi"); - if (!Directory.Exists(dstRac)) Directory.CreateDirectory(dstRac); - - // Finito download, salvo gli archivi: - string dt = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"); - - // Salvo archivio: AllLinks - sb = new StringBuilder(); - AllLinks.Sort(); - foreach (string lnk in AllLinks) { sb.AppendLine(lnk); } - cTools.WriteTextFile(Path.Combine(DstIdx, string.Format("_A69_AllLinks_{0}.tes", dt)), sb); - - // Salvo archivio: toDownload - sb = new StringBuilder(); - toDownload.Sort(); - foreach (string lnk in toDownload) { sb.AppendLine(lnk); } - cTools.WriteTextFile(Path.Combine(DstIdx, string.Format("_A69_toDownload_{0}.tes", dt)), sb); - - // Salvo archivio: Downloaded - sb = new StringBuilder(); - Downloaded.Sort(); - foreach (string lnk in Downloaded) { sb.AppendLine(lnk); } - cTools.WriteTextFile(Path.Combine(DstIdx, string.Format("_A69_Downloaded_{0}.tes", dt)), sb); - - // Salvo archivio: RacLinks - sb = new StringBuilder(); - RacLinks.Sort(); - foreach (string lnk in RacLinks) { sb.AppendLine(lnk); } - cTools.WriteTextFile(Path.Combine(DstIdx, string.Format("_A69_RacLinks_{0}.tes", dt)), sb); - - // avviso utente: - UpdateST(string.Format("Finito il download in {0}", DateTime.Now - dtStartTime)); - - // Riattivo UI: - btnDownloadLink.Enabled = true; - btnDownloadAll.Enabled = true; - - // Chiudo applicazione - this.Close(); - } - - - - - private void UpdateST(string Msg) { lblST.Text = string.Format("{0} - {1} - {2}", DateTime.Now.ToString("HH:mm:ss"), cnt.ToString("0000"), Msg); } - private string GetFileName(string url) { return url.Replace("https://www.annunci69.it/racconti-erotici/", "A69_").Replace("/", "_").Replace(":", "_").Replace(@"\", "_"); } - private bool IsIdxLink(string link) { return link.StartsWith(BASE_LINK_IDX); } - private bool IsRacLink(string link) { foreach (string tip in Tipologie) { if (link.StartsWith(BASE_LINK_RAC + tip + "/")) return true; } return false; } - - - - } -} diff --git a/Src/A69WD/Form1.resx b/Src/A69WD/Form1.resx deleted file mode 100644 index 29dcb1b..0000000 --- a/Src/A69WD/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Src/A69WD/Program.cs b/Src/A69WD/Program.cs deleted file mode 100644 index 4acf807..0000000 --- a/Src/A69WD/Program.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows.Forms; - -namespace A69WD { - static class Program { - ///// - ///// Punto di ingresso principale dell'applicazione. - ///// - //[STAThread] - //static void Main() { - // Application.EnableVisualStyles(); - // Application.SetCompatibleTextRenderingDefault(false); - // Application.Run(new Form1()); - //} - } -}