From cb54dc4d5fc17af22f8917726af6b7501acad3dc Mon Sep 17 00:00:00 2001 From: CSiCoAlm Date: Sat, 27 Dec 2025 12:28:13 +0100 Subject: [PATCH] Vrs 0.4.0.0 Compilata da CSiCoAlm il 2025/12/27 Gestione dell'autenticazione sul sito A69 Impostato lavoro in parallelo ToDo: - Aggiungere gestione parallela della FIFO secondo vecchi modello per aumentare il feedback alla UI - Inserire anche l'estrazione dei racconti --- Src/A69WD/General/Cfg.cs | 6 +++ Src/A69WD/Net/cLink_A69.cs | 32 ++++++------ Src/A69WD/Properties/AssemblyInfo.cs | 19 ++++++- Src/A69WD/Service/Service_Crawler.cs | 18 ++++--- Src/A69WD/Settings.cfg | 3 ++ Src/A69WD/UI/frmDownloader.Designer.cs | 71 ++++++-------------------- Src/A69WD/UI/frmDownloader.cs | 4 +- 7 files changed, 70 insertions(+), 83 deletions(-) diff --git a/Src/A69WD/General/Cfg.cs b/Src/A69WD/General/Cfg.cs index 78545b6..9109ac0 100644 --- a/Src/A69WD/General/Cfg.cs +++ b/Src/A69WD/General/Cfg.cs @@ -144,6 +144,12 @@ namespace A69WD { public virtual string TextEditor { get { return textEditor; } set { textEditor = value; } } private string textEditor; + /// + /// Numero di thread secondari + /// + public virtual int nThread { get { return nthread; } set { nthread = value; } } + private int nthread; + #endregion diff --git a/Src/A69WD/Net/cLink_A69.cs b/Src/A69WD/Net/cLink_A69.cs index 08249b0..49c8bb7 100644 --- a/Src/A69WD/Net/cLink_A69.cs +++ b/Src/A69WD/Net/cLink_A69.cs @@ -84,22 +84,22 @@ namespace A69WD.Net { public static bool InsertStartLink(Service_Crawler service) { - //int i = 1; - //try { - // foreach (string cat in categorie) { - // string url = LinkIdxBase.Replace("{Categoria}", cat).Replace("{ID}", i.ToString()); - // string name = string.Format("_A69_{0}_{1}.html", cat, i.ToString("0000")); - // service.EnqueueUrl(new cLink_A69(url, name)); - // } - // return true; - //} catch (Exception ex) { - // Logger.Error("Errore inserendo A69 Start Link - " + ex.Message); - // return false; - //} - 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"; - service.EnqueueUrl(new cLink_A69(url, name)); - return true; + //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"; + //service.EnqueueUrl(new cLink_A69(url, name)); + //return true; + int i = 1; + try { + foreach (string cat in categorie) { + string url = LinkIdxBase.Replace("{Categoria}", cat).Replace("{ID}", i.ToString()); + string name = string.Format("_A69_{0}_{1}.html", cat, i.ToString("0000")); + service.EnqueueUrl(new cLink_A69(url, name)); + } + return true; + } catch (Exception ex) { + Logger.Error("Errore inserendo A69 Start Link - " + ex.Message); + return false; + } } }//class cLink_A69 diff --git a/Src/A69WD/Properties/AssemblyInfo.cs b/Src/A69WD/Properties/AssemblyInfo.cs index c018051..61070cc 100644 --- a/Src/A69WD/Properties/AssemblyInfo.cs +++ b/Src/A69WD/Properties/AssemblyInfo.cs @@ -32,8 +32,23 @@ using System.Runtime.InteropServices; // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build // usando l'asterisco '*' come illustrato di seguito: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.1.2")] -[assembly: AssemblyFileVersion("0.3.1.2")] +[assembly: AssemblyVersion("0.4.0.0")] +[assembly: AssemblyFileVersion("0.4.0.0")] + + +/* + * + * Vrs 0.4.0.0 + * + * Compilata da CSiCoAlm il 2025/12/27 + * Gestione dell'autenticazione sul sito A69 + * Impostato lavoro in parallelo + * + * ToDo: + * - Aggiungere gestione parallela della FIFO secondo vecchi modello per aumentare il feedback alla UI + * - Inserire anche l'estrazione dei racconti + * + */ /* diff --git a/Src/A69WD/Service/Service_Crawler.cs b/Src/A69WD/Service/Service_Crawler.cs index d33bcf2..adc3e8f 100644 --- a/Src/A69WD/Service/Service_Crawler.cs +++ b/Src/A69WD/Service/Service_Crawler.cs @@ -22,7 +22,7 @@ namespace A69WD.Service { private readonly BlockingCollection _urlQueue = new BlockingCollection(new ConcurrentQueue()); // Semaforo per limitare il numero massimo di download simultanei - private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(9); + private readonly SemaphoreSlim _semaphore = null; // Contatori private int _inCorso = 0; @@ -33,8 +33,10 @@ namespace A69WD.Service { private iSiteType _site; - public Service_Crawler(Label lblInCorso) { + public Service_Crawler(Label lblInCorso, ProgressBar pbStatus) { + _semaphore = new SemaphoreSlim(Cfg.Settings.nThread); _lblInCorso = lblInCorso; + _progressBar = pbStatus; } @@ -47,7 +49,7 @@ namespace A69WD.Service { //private readonly Label _lblCompletati; //private readonly Label _lblDaFare; //private readonly Label _lblErrori; - //private readonly ProgressBar _progressBar; + private readonly ProgressBar _progressBar; @@ -128,11 +130,11 @@ namespace A69WD.Service { _lblInCorso.Text = $"In corso: {_inCorso} - Completati: {_completati} - Errori: {_errori} - Da fare: {daFare}"; - //int totale = _inCorso + _completati + _errori + daFare; - //int fatti = _completati + _errori; - // - //_progressBar.Maximum = totale > 0 ? totale : 1; - //_progressBar.Value = fatti; + int totale = _inCorso + _completati + _errori + daFare; + int fatti = _completati + _errori; + + _progressBar.Maximum = totale > 0 ? totale : 1; + _progressBar.Value = fatti; } diff --git a/Src/A69WD/Settings.cfg b/Src/A69WD/Settings.cfg index 4a801ed..7b4bc86 100644 --- a/Src/A69WD/Settings.cfg +++ b/Src/A69WD/Settings.cfg @@ -19,5 +19,8 @@ C:\Program Files\Notepad++\notepad++.exe + + 9 + \ No newline at end of file diff --git a/Src/A69WD/UI/frmDownloader.Designer.cs b/Src/A69WD/UI/frmDownloader.Designer.cs index e7416ac..b6a13a8 100644 --- a/Src/A69WD/UI/frmDownloader.Designer.cs +++ b/Src/A69WD/UI/frmDownloader.Designer.cs @@ -24,20 +24,17 @@ /// private void InitializeComponent() { this.btnClose = new System.Windows.Forms.Button(); - this.btnHide = new System.Windows.Forms.Button(); this.btnDownloadAll = new System.Windows.Forms.Button(); this.lblST = new System.Windows.Forms.Label(); this.btnImportLinks = new System.Windows.Forms.Button(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.btnShowLog = new System.Windows.Forms.Button(); - this.cbSoloFileIndice = new System.Windows.Forms.CheckBox(); - this.tbNumThred = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); + this.pbST = new System.Windows.Forms.ProgressBar(); this.SuspendLayout(); // // btnClose // - this.btnClose.Location = new System.Drawing.Point(436, 12); + this.btnClose.Location = new System.Drawing.Point(263, 12); this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(79, 33); this.btnClose.TabIndex = 14; @@ -45,24 +42,13 @@ this.btnClose.UseVisualStyleBackColor = true; this.btnClose.Click += new System.EventHandler(this.btnClose_Click); // - // btnHide - // - this.btnHide.Location = new System.Drawing.Point(317, 19); - this.btnHide.Name = "btnHide"; - this.btnHide.Size = new System.Drawing.Size(97, 33); - this.btnHide.TabIndex = 13; - this.btnHide.Text = "Hide"; - this.btnHide.UseVisualStyleBackColor = true; - this.btnHide.Visible = false; - this.btnHide.Click += new System.EventHandler(this.btnHide_Click); - // // btnDownloadAll // this.btnDownloadAll.Location = new System.Drawing.Point(12, 12); this.btnDownloadAll.Name = "btnDownloadAll"; this.btnDownloadAll.Size = new System.Drawing.Size(79, 33); this.btnDownloadAll.TabIndex = 11; - this.btnDownloadAll.Text = "Download All"; + this.btnDownloadAll.Text = "Start A69"; this.btnDownloadAll.UseVisualStyleBackColor = true; this.btnDownloadAll.Click += new System.EventHandler(this.btnDownloadAll_Click); // @@ -70,20 +56,21 @@ // this.lblST.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lblST.Dock = System.Windows.Forms.DockStyle.Bottom; - this.lblST.Location = new System.Drawing.Point(0, 52); + this.lblST.Location = new System.Drawing.Point(0, 73); this.lblST.Name = "lblST"; - this.lblST.Size = new System.Drawing.Size(524, 22); + this.lblST.Size = new System.Drawing.Size(352, 22); this.lblST.TabIndex = 9; this.lblST.Text = "Status"; this.lblST.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // btnImportLinks // + this.btnImportLinks.Enabled = false; this.btnImportLinks.Location = new System.Drawing.Point(97, 12); this.btnImportLinks.Name = "btnImportLinks"; this.btnImportLinks.Size = new System.Drawing.Size(79, 33); this.btnImportLinks.TabIndex = 15; - this.btnImportLinks.Text = "Import Links"; + this.btnImportLinks.Text = "From DB"; this.btnImportLinks.UseVisualStyleBackColor = true; this.btnImportLinks.Click += new System.EventHandler(this.btnImportLinks_Click); // @@ -102,65 +89,39 @@ this.btnShowLog.UseVisualStyleBackColor = true; this.btnShowLog.Click += new System.EventHandler(this.btnShowLog_Click); // - // cbSoloFileIndice + // pbST // - this.cbSoloFileIndice.AutoSize = true; - this.cbSoloFileIndice.Location = new System.Drawing.Point(263, 20); - this.cbSoloFileIndice.Name = "cbSoloFileIndice"; - this.cbSoloFileIndice.Size = new System.Drawing.Size(76, 17); - this.cbSoloFileIndice.TabIndex = 18; - this.cbSoloFileIndice.Text = "Solo Index"; - this.cbSoloFileIndice.UseVisualStyleBackColor = true; - // - // tbNumThred - // - this.tbNumThred.Location = new System.Drawing.Point(345, 18); - this.tbNumThred.Name = "tbNumThred"; - this.tbNumThred.Size = new System.Drawing.Size(22, 20); - this.tbNumThred.TabIndex = 19; - this.tbNumThred.Text = "3"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(369, 22); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(66, 13); - this.label1.TabIndex = 20; - this.label1.Text = "Num Thread"; + 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.TabIndex = 18; // // frmDownloader // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(524, 74); - this.Controls.Add(this.label1); - this.Controls.Add(this.tbNumThred); - this.Controls.Add(this.cbSoloFileIndice); + this.ClientSize = new System.Drawing.Size(352, 95); + this.Controls.Add(this.pbST); this.Controls.Add(this.btnShowLog); this.Controls.Add(this.btnImportLinks); this.Controls.Add(this.btnClose); - this.Controls.Add(this.btnHide); this.Controls.Add(this.btnDownloadAll); this.Controls.Add(this.lblST); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Name = "frmDownloader"; this.Text = "frmDownloader"; this.ResumeLayout(false); - this.PerformLayout(); } #endregion private System.Windows.Forms.Button btnClose; - private System.Windows.Forms.Button btnHide; private System.Windows.Forms.Button btnDownloadAll; private System.Windows.Forms.Label lblST; private System.Windows.Forms.Button btnImportLinks; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.Button btnShowLog; - private System.Windows.Forms.CheckBox cbSoloFileIndice; - private System.Windows.Forms.TextBox tbNumThred; - private System.Windows.Forms.Label label1; + private System.Windows.Forms.ProgressBar pbST; } } \ No newline at end of file diff --git a/Src/A69WD/UI/frmDownloader.cs b/Src/A69WD/UI/frmDownloader.cs index 3f2ba44..1fc7f7b 100644 --- a/Src/A69WD/UI/frmDownloader.cs +++ b/Src/A69WD/UI/frmDownloader.cs @@ -32,7 +32,7 @@ namespace A69WD { public frmDownloader() { InitializeComponent(); - this.Text = String.Format("A69WD - Dowloader Testi Vrs {0}", cTools.AssemblyVersion); + this.Text = String.Format("A69WD - Dowloader Testi Vrs {0}", cTools.AssemblyVersion); //engine = new cA69Engine(); //engine.Updating += Engine_Updating; } @@ -99,7 +99,7 @@ namespace A69WD { // Preparo il servizio - service = new Service_Crawler(lblST); + service = new Service_Crawler(lblST, pbST); // Inserisco i link iniziali nella coda if (!cLink_A69.InsertStartLink(service)) { lblST.Text = "Inserimento A69 start link fault.";