Vrs 0.1.6.0

Compilata da CSiCoAlm il 2021/11/07
- Corretto bug rilevato (ISSUE 01)
- Inserita solita icona per i tools.
- Sistemato la classe cTools inserendo tutti i tools trovati finora
This commit is contained in:
CSiCoAlm committed 2021-11-07 15:54:07 +01:00
1 parent 06440bcdbe
commit a6fdfd64b2
9 files changed
+508 -178

No files matched your search

+197
View File
@@ -0,0 +1,197 @@
#+SETUPFILE: ~/.MyCfg/emacs/templates/org-html-themes/theme-readtheorg-local.setup
#+TITLE: Web Scraper per A69
#+DESCRIPTION: Diario di bordo dell'applicazione per ricavare i racconti dal sito A69
#+KEYWORDS: ATDB, ATWD
* DONE Inserire nello stato i conteggio dei link
* TODO Inserire il conto dei link anche sul nome del file o fare report
Inserire sul nome dei file, oltre alla data anche il numero di link che contengono, oppure fare un report che riassuma quanto fatto e che torna utile per confrontare due download diversi ecc...
* DONE Verificare il formato di salvataggio, perchè le accentuate e alcuni segni vengono male.
* DONE Fare parser di un file di link che inserisce quelli nuovi sul toDownload o li inserisce sul DB con lo stato ToDownload.
* BUG:
** ISSUE 01: [2021-11-03 mer]
Quando riprendo uno scarico, riscarico anche quelli già scaricati.
Tutte le volte che riprendo un download, riscarico anche quelli già downloadati, e quindi
devo verificare che salvo tutti quelli già downloadati (lista all da verificare sia
all'inizio che alla fine).
* TODO Vrs 0.2.0.0 :WORKING:
Applicazione che salva tutto su SQLite, inoltre è del tutto automatizzata e quindi basta
avviarla e quando ha finito si spegne, altrimenti è sempre possibile fermarla a comando,
senza perdere traccia di quanto fatto.
Per serializzare i dati utilizzo SQLlite con la tabella che mi permetta di risalire
velocemente ai link fatti, e a quelli da fare
| URL | Tipo | Stato | Update |
|-----+------+-------+--------|
- URL :: indica l'url a cui vi è la pagina da downloadare (sia indice che racconto)
- Tipo :: indica la tipologia della pagina, cioè Idx per le pagine che sono indici/elenchi
di racconti
- Stato :: Indica lo stato associato al link che sarà definito in basee alla seguente
enumerazione *LinkStatusEnum*:
- ToDownload
- Downloading
- Downloaded
e quindi all'avvio, mi basta caricare l'elenco dei link che hanno stato diverso da
Downloaded e riprendere il download
- Update :: indica la data in cui eseguo l'ultimo update al record
* TODO Vrs 0.1.7.0 :WORKING:
- Definire un'icona in modo da migliorare estetica
- Gestire il ridursi ad icona sulla tray in modo da poterlo nascondere
- Inserire l'estrazione dei racconti
** Estrazione dei racconti
I file di racconto hanno una struttura del tipo:
#+begin_src html
...
<DIV class=targhetta_racconti style="BACKGROUND-COLOR: #8dbebc">Lui &amp; Lei</DIV>
...
<H1 class=titolone_nero>01 - Marco e Daniela - Voglia di nuove esperienze estreme</H1>
...
<SPAN class=text_grigio style="FONT-SIZE: 16px; COLOR: #999999; LINE-HEIGHT: 1.6em"><A href="/user/ombraerotica"><IMG class=img_border style="VERTICAL-ALIGN: middle; border-radius: 50%" border=0 src="https://img.annunci69.it/annunci/83/2808083/ombraerotica/icone/2808083.jpg?vers=1586358574" width=65 height=65></A> <STRONG>di <A href="/user/ombraerotica">ombraerotica</A></STRONG></SPAN>
...
<SPAN class=text_grigio style="FONT-SIZE: 13px; COLOR: #9999cc; LINE-HEIGHT: 1.6em">07.04.2020 &nbsp;&nbsp; | &nbsp;&nbsp; <I class="fa fa-eye"></I>8.850 &nbsp;&nbsp; | &nbsp;&nbsp; <I class="fa fa-comment"></I>6 <SPAN style="DISPLAY: none">9.2</SPAN> </SPAN>
...
<DIV class=testoracc>
<DIV class=citaz><EM>{Citazione}</EM></DIV>
{Trama}
<DIV style="FONT-SIZE: 11px; BORDER-TOP: #cccccc 1px solid; COLOR: #c8c2c2; PADDING-BOTTOM: 8px; PADDING-TOP: 8px; PADDING-LEFT: 8px; MARGIN-TOP: 20px; LINE-HEIGHT: normal; PADDING-RIGHT: 8px"><STRONG>Disclaimer</STRONG>! Tutti i diritti riservati all'autore del racconto - Fatti e persone sono<STRONG> puramente frutto della fantasia dell'autore</STRONG>. Annunci69.it non è responsabile dei contenuti in esso scritti ed è <STRONG>contro ogni tipo di violenza</STRONG>! <BR>Vi invitiamo comunque a <A href="/scrivici.php">segnalarci i racconti</A> che pensate non debbano essere pubblicati, sarà nostra premura riesaminare questo racconto.</DIV>
</DIV>
...
<DIV style="FLOAT: left"><STRONG>Votazione dei Lettori:</STRONG> 9.2</DIV>
...
#+end_src
che mi permette di ricavare tutte le informazioi utili.
Come note, oltre alla classica SrcFile, voglio inserire anche la SrcVot (votazione sul
sito) per poter fare un filtro o un ordinamento in base alla votazione del sito anche per
i racconti che non ho ancora letto.
Ogni racconto avrà quindi la struttura:
#+begin_example
- ID Rac: ...
- Title: ...
- SubTit: ...
- Autors: ... -|- ...
- Voto: Non Letto
- Tags: ... -|- ...
- Notes: SrcFile -|- ...
- Notes: SrcVot -|- ...
- Creato: YYYY/MM/DD
- Update: YYY/MM/DD
- Origin: ... -|- ...
- Trama: ...
#+end_example
In cui vi sono le relazioni:
- 1-->Molti Racconto-->Autori
- 1-->Molti Racconto-->Tags
- 1-->Molti Racconto-->Origine
- 1-->Molti Racconto-->Note
- 1-->1 Racconto-->Trama
- 1-->1 Racconto-->Voto
La nota SrcVoto mi permette di navigare evidenziando i racconti per votazione:
#+begin_src sql
--
-- Vista dei racconti con la relativa votazione:
--
SELECT * FROM Notes,Racconti,Links_Rac_Not
WHERE NKey='SrcVoto' AND Notes.IDnot=Links_Rac_Not.IDnot AND Links_Rac_Not.IDrac=Racconti.IDrac
ORDER BY NVal;
--
-- Conteggio dei racconti in base alla votazione:
--
SELECT Notes.NKey, Notes.NVal, Count(NVal) as Num
FROM Notes, Racconti, Links_Rac_Not
WHERE NKey='SrcVoto' AND Notes.IDnot=Links_Rac_Not.IDnot AND Links_Rac_Not.IDrac=Racconti.IDrac
GROUP BY Notes.NVal
ORDER BY Num ;
#+end_src
* DONE Vrs 0.1.6.0 :DONE:
Compilata da CSiCoAlm il 2021/11/07
- Corretto bug rilevato (ISSUE 01)
- Inserita solita icona per i tools.
- Sistemato la classe cTools inserendo tutti i tools trovati finora
* DONE Vrs 0.1.5.4 :DONE:
Compilata da CSiCoAlm il 2021/10/29
- Modificato path di salvataggio dei file per farlo analogo a ATWD.
* DONE Vrs 0.1.5.3 :DONE:
Compilata da CSiCoAlm il 2021/10/29
- Corretto salvataggio dei file di racconti, per evitare l'errore del formato (lettere accentate e caratteri particolari).
- Fatto anche dei test di salvataggio dei testi per trovare il corretto formato dell'encode.
* DONE Vrs 0.1.5.2 :DONE:
Modifica per:
- Inserire l'importazione di link (solo Idx o Rac di A69) da file di testo
- Correggere l'importazione ed esportazione degli elenchi dal DB
* Vrs 0.1.5.1 :DONE:
Breve modifica per:
- Corretto formato del numero di versione
- Razionalizzato il messaggio di update dell'engine.
- Inserito gli aggiornamenti dell'engine sul log degli eventi
* Vrs 0.1.5.0 :DONE:
Applicazione che serializza i dati su SQLite, ma continua ad usare liste internamente per
recuperare il codice già fatto.
Per serializzare i dati utilizzo SQLlite con la tabella che mi permetta di risalire
velocemente ai link fatti, e a quelli da fare
| URL | Tipo | Stato | Update |
|-----+------+-------+--------|
- URL :: indica l'url a cui vi è la pagina da downloadare (sia indice che racconto)
- Tipo :: indica la tipologia della pagina, cioè Idx per le pagine che sono indici/elenchi
di racconti
- Stato :: Indica lo stato associato al link che sarà definito in basee alla seguente
enumerazione *LinkStatusEnum*:
- ToDownload
- Downloading
- Downloaded
e quindi all'avvio, mi basta caricare l'elenco dei link che hanno stato diverso da
Downloaded e riprendere il download
- Update :: indica la data in cui eseguo l'ultimo update al record
All'avvio carico sulle liste interne i vari link con il metodo DBTools.LoadData e al
termine salvo lo stato delle liste aggiornando i record sul DB tramite il metodo
DBTools.SaveData. In questo modo posso iniziare un download e interrompere la procedura
per poi riprenderla in un secondo momento senza problemi.
* Test funzionamento in consol: :ABORT:
verifichiamo se è possibile operare come consol:
PURTROPPO NON FUNZIONA SE MESSO COME CONSOLE APPLICATION
* Vrs 0.1.0.0 :DONE:
- Compilata da CSiCoAlm il 2021/10/26
- Prima versione che permette di scaricare i file da A69 bypassando il controllo del browser.
- Manca:
- Serializzazione degli archivi per poter riprendere il download parziale dei racconti o
la scansione parziale dei link
- Gestione in thread paralleli dei download
- Riduzione ad icona per non visualizzare il tutto (privacy)
- Parametrizzazione del lavoro
- Loggin degli eventi
- Rendere l'applicativo consol, in modo che non vi sia interfaccia utente.
+8 -1
View File
@@ -14,7 +14,8 @@ Inserire sul nome dei file, oltre alla data anche il numero di link che contengo
* BUG: * BUG:
** [2021-11-03 mer] quando riprendo uno scarico, riscarico anche quelli già scaricati. ** ISSUE 01: [2021-11-03 mer]
Quando riprendo uno scarico, riscarico anche quelli già scaricati.
Tutte le volte che riprendo un download, riscarico anche quelli già downloadati, e quindi Tutte le volte che riprendo un download, riscarico anche quelli già downloadati, e quindi
devo verificare che salvo tutti quelli già downloadati (lista all da verificare sia devo verificare che salvo tutti quelli già downloadati (lista all da verificare sia
all'inizio che alla fine). all'inizio che alla fine).
@@ -119,6 +120,12 @@ La nota SrcVoto mi permette di navigare evidenziando i racconti per votazione:
#+end_src #+end_src
* DONE Vrs 0.1.6.0 :DONE:
Compilata da CSiCoAlm il 2021/11/07
- Corretto bug rilevato (ISSUE 01)
- Inserita solita icona per i tools.
- Sistemato la classe cTools inserendo tutti i tools trovati finora
* DONE Vrs 0.1.5.4 :DONE: * DONE Vrs 0.1.5.4 :DONE:
Compilata da CSiCoAlm il 2021/10/29 Compilata da CSiCoAlm il 2021/10/29
- Modificato path di salvataggio dei file per farlo analogo a ATWD. - Modificato path di salvataggio dei file per farlo analogo a ATWD.
+6 -1
View File
@@ -31,6 +31,9 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Tools.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@@ -106,7 +109,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup>
<Content Include="Tools.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
+13 -2
View File
@@ -169,7 +169,8 @@ namespace A69WD {
lock (obj) { lock (obj) {
int Res = 0; int Res = 0;
try { try {
// Carico tutti i racconti non ancora downloadati completamente:
System.Data.SQLite.SQLiteCommand cmd = new SQLiteCommand("SELECT [URL], [Tipo], [Status], [LastUp] FROM [LinksLog] WHERE [Tipo]='Rac' AND [Status]<>4", cn); // Donwloaded = 4 System.Data.SQLite.SQLiteCommand cmd = new SQLiteCommand("SELECT [URL], [Tipo], [Status], [LastUp] FROM [LinksLog] WHERE [Tipo]='Rac' AND [Status]<>4", cn); // Donwloaded = 4
SQLiteDataReader rdr = cmd.ExecuteReader(); SQLiteDataReader rdr = cmd.ExecuteReader();
while (rdr.Read()) { while (rdr.Read()) {
@@ -180,6 +181,16 @@ namespace A69WD {
Res++; Res++;
} }
// Carico ora tutti i racconti downloadati completamente per evitare doppioni:
cmd = new SQLiteCommand("SELECT [URL], [Tipo], [Status], [LastUp] FROM [LinksLog] WHERE [Tipo]='Rac' AND [Status]=4", cn); // Donwloaded = 4
rdr = cmd.ExecuteReader();
while (rdr.Read()) {
string url = rdr["URL"] as string;
allLinks.Add(url);
racLinks.Add(url);
Res++;
}
} catch (Exception ex) { } catch (Exception ex) {
Logger.Log(new object[] { "Error Code: DB07003", "Errore in Data.DBTools.LoadData()", ex }); Logger.Log(new object[] { "Error Code: DB07003", "Errore in Data.DBTools.LoadData()", ex });
if (Res > 0) Res = -1 * Res; if (Res > 0) Res = -1 * Res;
@@ -193,7 +204,7 @@ namespace A69WD {
lock (obj) { lock (obj) {
int Res = 0; int Res = 0;
try { try {
foreach (string link in racLinks) { LinkLogUpdtate(link, cA69Engine.LinkType(link), eLinkState.ToDownload); } foreach (string link in racLinks) { LinkLogUpdtate(link, cA69Engine.LinkType(link), eLinkState.Donwloaded); }
foreach (string link in toDownload) { LinkLogUpdtate(link, cA69Engine.LinkType(link), eLinkState.ToDownload); } foreach (string link in toDownload) { LinkLogUpdtate(link, cA69Engine.LinkType(link), eLinkState.ToDownload); }
foreach (string link in downloaded) { LinkLogUpdtate(link, cA69Engine.LinkType(link), eLinkState.Donwloaded); } foreach (string link in downloaded) { LinkLogUpdtate(link, cA69Engine.LinkType(link), eLinkState.Donwloaded); }
} catch (Exception ex) { } catch (Exception ex) {
+244 -144
View File
@@ -12,43 +12,16 @@ namespace A69WD {
public class cTools { public class cTools {
/// <summary> /*
/// Carica l'assemby da un array di byte *
/// </summary> * Versione 1.0 del 2021/11
/// <param name="binaries">Array di byte che definiscono l'assembly</param> *
/// <returns>Assembly decodificato dal'array di byte</returns> */
public static Assembly LoadAssemblyFromBinaries(byte[] binaries) {
Assembly asm = null;
try {
asm = Assembly.Load(binaries);
} catch { }
return asm;
}
/// <summary>
/// Carica l'assembly dal file indicato
/// </summary>
/// <param name="filename">Nome completo del file assembly da leggere</param>
/// <returns>Assembly decodificato dal file</returns>
public static Assembly LoadAssemblyFromFile(string filename) {
byte[] binaries = ReadFully(filename);
return LoadAssemblyFromBinaries(binaries);
}
/// <summary>
/// Legge il file e ne ritorna l'array di byte che lo compone #region Utility sui File:
/// </summary>
/// <param name="filename">Nome completo del file da leggere</param>
/// <returns>Array con i byte letti dal file</returns>
public static byte[] ReadFully(string filename) {
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
byte[] result = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();
return result;
}
/// <summary> /// <summary>
/// Scrive il testo in un file con append=false e Encoding UTF8 /// Scrive il testo in un file con append=false e Encoding UTF8
@@ -56,12 +29,16 @@ namespace A69WD {
/// <param name="FullFileName">Nome completo del file da creare/sovrascrivere</param> /// <param name="FullFileName">Nome completo del file da creare/sovrascrivere</param>
/// <param name="Text">StringBuilder con il testo da riportare nel file</param> /// <param name="Text">StringBuilder con il testo da riportare nel file</param>
public static void WriteTextFile(string FullFileName, StringBuilder Text) { public static void WriteTextFile(string FullFileName, StringBuilder Text) {
//System.IO.StreamWriter sw = new System.IO.StreamWriter(FullFileName, false, Encoding.UTF8);
//sw.Write(Text.ToString());
//sw.Flush();
//sw.Close();
WriteTextFile(FullFileName, Text, Encoding.UTF8); WriteTextFile(FullFileName, Text, Encoding.UTF8);
} }
/// <summary>
/// Scrive il testo in un file con append=false e Encoding UTF8
/// </summary>
/// <param name="FullFileName">Nome completo del file da creare/sovrascrivere</param>
/// <param name="Text">StringBuilder con il testo da riportare nel file</param>
/// <param name="code">Codifica usata nel testo</param>
public static void WriteTextFile(string FullFileName, StringBuilder Text, Encoding code) { public static void WriteTextFile(string FullFileName, StringBuilder Text, Encoding code) {
System.IO.StreamWriter sw = new System.IO.StreamWriter(FullFileName, false, code); System.IO.StreamWriter sw = new System.IO.StreamWriter(FullFileName, false, code);
sw.Write(Text.ToString()); sw.Write(Text.ToString());
@@ -69,6 +46,7 @@ namespace A69WD {
sw.Close(); sw.Close();
} }
/// <summary> /// <summary>
/// Metodo che legge un testo da file (UTF8) /// Metodo che legge un testo da file (UTF8)
/// </summary> /// </summary>
@@ -97,6 +75,7 @@ namespace A69WD {
return str; return str;
} }
/// <summary> /// <summary>
/// Metodo che legge un testo da file /// Metodo che legge un testo da file
/// </summary> /// </summary>
@@ -135,84 +114,25 @@ namespace A69WD {
return txt; return txt;
} }
/// <summary>
/// Esegue un comando dos dalla shell
/// </summary>
/// <param name="cmd">Comando da eseguire in shell</param>
public static void ExecDosCmd(string cmd) {
string argu = string.Format("/C \"{0}\"", cmd);
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.FileName = "cmd.exe";
info.Arguments = argu;
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
System.Diagnostics.Process.Start(info);
}
/// <summary> /// <summary>
/// Esegue un comando dos dalla shell e cattura il risultato /// Salva la stringa passata come file con path indicato.
/// </summary> /// </summary>
/// <param name="cmd">Comando da eseguire</param> /// <param name="fileName">Path del file da creare o sovrascrivere</param>
/// <param name="args">Argomenti da passare</param> /// <param name="testo">Testo da scrivere nel file</param>
/// <returns>Testo ritornato dal comando.</returns> /// <param name="encoding">Formato di codifica da adottare nel salvataggio. UTF8 per ottenere un corretto testo con editpad.</param>
public static string ExecDosCmd(string cmd, string args) { /// <returns>True se tutto ok, False altrimenti</returns>
System.Diagnostics.ProcessStartInfo ProcInfo = new System.Diagnostics.ProcessStartInfo(cmd, args); public static bool SaveStringToFile(string fileName, string testo, System.Text.Encoding encoding) {
ProcInfo.RedirectStandardOutput = true;
ProcInfo.UseShellExecute = false;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(ProcInfo);
System.IO.TextReader tr = p.StandardOutput;
string result = tr.ReadToEnd();
tr.Close();
return result;
}
public static bool EditPad(string file) {
try { try {
System.Diagnostics.Process proc = new System.Diagnostics.Process(); // Salva la stringa passata come file di testo.
// proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; StreamWriter sw = new StreamWriter(fileName, false, encoding);
// proc.StartInfo.Verb = "print"; sw.Write(testo);
proc.StartInfo.FileName = @"C:\Programmi\My_Tools\Editors\EditPad\EditPad.exe"; // Libero risorse:
proc.StartInfo.Arguments = String.Format(@" {0}", file); sw.Flush();
Logger.Log(proc.StartInfo.FileName + proc.StartInfo.Arguments); sw.Close();
proc.Start();
return true; return true;
} catch (Exception ex) { Logger.Log(new object[] { "Error Code: EG0284", ex }); return false; } } catch { return false; }
} }
// public class Pdf {
// public static Boolean PrintPDFs(string pdfFileName)
// {
// try
// {
// Process proc = new Process();
// proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
// proc.StartInfo.Verb = "print";
//
// //Define location of adobe reader/command line switches to launch adobe in "print" mode
// proc.StartInfo.FileName = @"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe";
// proc.StartInfo.Arguments = String.Format(@"/p /h {0}", pdfFileName);
// proc.StartInfo.UseShellExecute = false;
// proc.StartInfo.CreateNoWindow = true;
//
// proc.Start();
// proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
// if (proc.HasExited == false)
// {
// proc.WaitForExit(10000);
// }
//
// proc.EnableRaisingEvents = true;
//
// proc.Close();
// KillAdobe("AcroRd32");
// return true;
// }
// catch
// {
// return false;
// }
// }
/// <summary> /// <summary>
@@ -223,6 +143,7 @@ namespace A69WD {
/// <returns>Array dei path completi, dei file trovati</returns> /// <returns>Array dei path completi, dei file trovati</returns>
public static string[] ElencoFile(string path) { return ElencoFile(path, "*.*", SearchOption.TopDirectoryOnly); } public static string[] ElencoFile(string path) { return ElencoFile(path, "*.*", SearchOption.TopDirectoryOnly); }
/// <summary> /// <summary>
/// Genera l'elenco dei file nella directory indicata che soddisfano al filtro indicato /// Genera l'elenco dei file nella directory indicata che soddisfano al filtro indicato
/// </summary> /// </summary>
@@ -242,6 +163,215 @@ namespace A69WD {
public static string[] ElencoFile(string path, string filtro, SearchOption option) { return Directory.GetFiles(path, filtro, option); } public static string[] ElencoFile(string path, string filtro, SearchOption option) { return Directory.GetFiles(path, filtro, option); }
/// <summary>
/// Metodo che esegue una copia di backup del file indicato
/// </summary>
/// <param name="FilePath">Path completo del file da backuppare</param>
/// <returns>True se tutto ok, False altrimenti.</returns>
public static bool BackupFile(string FilePath) {
try {
string LinkDBPathBK = Path.GetFileNameWithoutExtension(FilePath) + "_BK_" + DateTime.Now.ToString("yyyy-MM-dd");
LinkDBPathBK = FilePath.Replace(Path.GetFileNameWithoutExtension(FilePath), LinkDBPathBK);
if (!File.Exists(LinkDBPathBK)) File.Move(FilePath, LinkDBPathBK);
return true;
} catch { return false; }
}
/// <summary>
/// Muove i file indicati, nella directory di destinazione indicata
/// </summary>
/// <param name="IndexFiles">Array con l'elenco dei file da spostare</param>
/// <param name="PathDestination">Path della directory in cui spostare i file</param>
/// <returns>True se tutto OK, False altrimenti.</returns>
public static bool MoveFiles(string[] Files, string PathDestination) {
// Sposta tutti i file indicati nella directory indicata:
try {
foreach (string file in Files) {
string dst = Path.Combine(PathDestination, Path.GetFileName(file));
if (System.IO.File.Exists(dst)) System.IO.File.Delete(dst);
File.Move(file, dst);
}
return true;
} catch { return false; }
}
/// <summary>
/// Legge il file e ne ritorna l'array di byte che lo compone
/// </summary>
/// <param name="filename">Nome completo del file da leggere</param>
/// <returns>Array con i byte letti dal file</returns>
public static byte[] ReadFully(string filename) {
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
byte[] result = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();
return result;
}
#endregion
#region Assembly Attribute Accessors
#region Assembly Property: Title, Version, Description, Product, Copyright, Company
public static string AssemblyTitle {
get {
object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyTitleAttribute), false);
if (attributes.Length > 0) {
System.Reflection.AssemblyTitleAttribute titleAttribute = (System.Reflection.AssemblyTitleAttribute)attributes[0];
if (titleAttribute.Title != "") {
return titleAttribute.Title;
}
}
return System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
}
}
public static string AssemblyVersion {
get {
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
public static string AssemblyDescription {
get {
object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyDescriptionAttribute), false);
if (attributes.Length == 0) {
return "";
}
return ((System.Reflection.AssemblyDescriptionAttribute)attributes[0]).Description;
}
}
public static string AssemblyProduct {
get {
object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyProductAttribute), false);
if (attributes.Length == 0) {
return "";
}
return ((System.Reflection.AssemblyProductAttribute)attributes[0]).Product;
}
}
public static string AssemblyCopyright {
get {
object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyCopyrightAttribute), false);
if (attributes.Length == 0) {
return "";
}
return ((System.Reflection.AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}
public static string AssemblyCompany {
get {
object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyCompanyAttribute), false);
if (attributes.Length == 0) {
return "";
}
return ((System.Reflection.AssemblyCompanyAttribute)attributes[0]).Company;
}
}
#endregion
/// <summary>
/// Carica l'assemby da un array di byte
/// </summary>
/// <param name="binaries">Array di byte che definiscono l'assembly</param>
/// <returns>Assembly decodificato dal'array di byte</returns>
public static Assembly LoadAssemblyFromBinaries(byte[] binaries) {
Assembly asm = null;
try {
asm = Assembly.Load(binaries);
} catch { }
return asm;
}
/// <summary>
/// Carica l'assembly dal file indicato
/// </summary>
/// <param name="filename">Nome completo del file assembly da leggere</param>
/// <returns>Assembly decodificato dal file</returns>
public static Assembly LoadAssemblyFromFile(string filename) {
byte[] binaries = ReadFully(filename);
return LoadAssemblyFromBinaries(binaries);
}
#endregion
#region Shell DOS:
/// <summary>
/// Esegue un comando dos dalla shell
/// </summary>
/// <param name="cmd">Comando da eseguire in shell</param>
public static void ExecDosCmd(string cmd) {
string argu = string.Format("/C \"{0}\"", cmd);
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.FileName = "cmd.exe";
info.Arguments = argu;
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
System.Diagnostics.Process.Start(info);
}
/// <summary>
/// Esegue un comando dos dalla shell e cattura il risultato
/// </summary>
/// <param name="cmd">Comando da eseguire</param>
/// <param name="args">Argomenti da passare</param>
/// <returns>Testo ritornato dal comando.</returns>
public static string ExecDosCmd(string cmd, string args) {
System.Diagnostics.ProcessStartInfo ProcInfo = new System.Diagnostics.ProcessStartInfo(cmd, args);
ProcInfo.RedirectStandardOutput = true;
ProcInfo.UseShellExecute = false;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(ProcInfo);
System.IO.TextReader tr = p.StandardOutput;
string result = tr.ReadToEnd();
tr.Close();
return result;
}
/// <summary>
/// Apre il file indicato in notepad e lo visualizza.
/// </summary>
/// <param name="file">File da aprire</param>
/// <returns>True se tutto ok, false altrimenti</returns>
public static bool ShowOnNotepad(string file) {
try {
System.Diagnostics.Process proc = new System.Diagnostics.Process();
// proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
// proc.StartInfo.Verb = "print";
proc.StartInfo.FileName = @"D:\MyTools\Npp\notepad++.exe";
proc.StartInfo.Arguments = String.Format(@" {0}", file);
Logger.Log(proc.StartInfo.FileName + proc.StartInfo.Arguments);
proc.Start();
return true;
} catch (Exception ex) { Logger.Log(new object[] { "Error Code: EG0284", ex }); return false; }
}
#endregion
/// <summary> /// <summary>
/// Metodo che analizza il file indicato ed inserisce nella lista tutti i link trovati. /// Metodo che analizza il file indicato ed inserisce nella lista tutti i link trovati.
/// </summary> /// </summary>
@@ -332,21 +462,6 @@ namespace A69WD {
} }
/// <summary>
/// Metodo che esegue una copia di backup del file indicato
/// </summary>
/// <param name="FilePath">Path completo del file da backuppare</param>
/// <returns>True se tutto ok, False altrimenti.</returns>
public static bool BackupFile(string FilePath) {
try {
string LinkDBPathBK = Path.GetFileNameWithoutExtension(FilePath) + "_BK_" + DateTime.Now.ToString("yyyy-MM-dd");
LinkDBPathBK = FilePath.Replace(Path.GetFileNameWithoutExtension(FilePath), LinkDBPathBK);
if (!File.Exists(LinkDBPathBK)) File.Move(FilePath, LinkDBPathBK);
return true;
} catch { return false; }
}
/// <summary> /// <summary>
/// Esegue una formattazione del testo ricavato da un file html per scremarlo delle parti html /// Esegue una formattazione del testo ricavato da un file html per scremarlo delle parti html
@@ -445,24 +560,6 @@ namespace A69WD {
/// <summary>
/// Muove i file indicati, nella directory di destinazione indicata
/// </summary>
/// <param name="IndexFiles">Array con l'elenco dei file da spostare</param>
/// <param name="PathDestination">Path della directory in cui spostare i file</param>
/// <returns>True se tutto OK, False altrimenti.</returns>
public static bool MoveFiles(string[] Files, string PathDestination) {
// Sposta tutti i file indicati nella directory indicata:
try {
foreach (string file in Files) {
string dst = Path.Combine(PathDestination, Path.GetFileName(file));
if (System.IO.File.Exists(dst)) System.IO.File.Delete(dst);
File.Move(file, dst);
}
return true;
} catch { return false; }
}
public static bool WriteStyleSheet(string FullFileName) { public static bool WriteStyleSheet(string FullFileName) {
try { try {
@@ -476,6 +573,9 @@ namespace A69WD {
} }
} }
} // class Tools } // class Tools
} // namespace A69WD } // namespace A69WD
+20 -20
View File
@@ -30,14 +30,14 @@
this.wb1 = new System.Windows.Forms.WebBrowser(); this.wb1 = new System.Windows.Forms.WebBrowser();
this.btnImportLinks = new System.Windows.Forms.Button(); this.btnImportLinks = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.btnTest = new System.Windows.Forms.Button(); this.btnShowLog = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnClose // btnClose
// //
this.btnClose.Location = new System.Drawing.Point(381, 12); this.btnClose.Location = new System.Drawing.Point(420, 12);
this.btnClose.Name = "btnClose"; this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(117, 33); this.btnClose.Size = new System.Drawing.Size(97, 33);
this.btnClose.TabIndex = 14; this.btnClose.TabIndex = 14;
this.btnClose.Text = "Close"; this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true; this.btnClose.UseVisualStyleBackColor = true;
@@ -45,9 +45,9 @@
// //
// btnHide // btnHide
// //
this.btnHide.Location = new System.Drawing.Point(258, 12); this.btnHide.Location = new System.Drawing.Point(317, 12);
this.btnHide.Name = "btnHide"; this.btnHide.Name = "btnHide";
this.btnHide.Size = new System.Drawing.Size(117, 33); this.btnHide.Size = new System.Drawing.Size(97, 33);
this.btnHide.TabIndex = 13; this.btnHide.TabIndex = 13;
this.btnHide.Text = "Hide"; this.btnHide.Text = "Hide";
this.btnHide.UseVisualStyleBackColor = true; this.btnHide.UseVisualStyleBackColor = true;
@@ -57,7 +57,7 @@
// //
this.btnDownloadAll.Location = new System.Drawing.Point(12, 12); this.btnDownloadAll.Location = new System.Drawing.Point(12, 12);
this.btnDownloadAll.Name = "btnDownloadAll"; this.btnDownloadAll.Name = "btnDownloadAll";
this.btnDownloadAll.Size = new System.Drawing.Size(117, 33); this.btnDownloadAll.Size = new System.Drawing.Size(97, 33);
this.btnDownloadAll.TabIndex = 11; this.btnDownloadAll.TabIndex = 11;
this.btnDownloadAll.Text = "Download All"; this.btnDownloadAll.Text = "Download All";
this.btnDownloadAll.UseVisualStyleBackColor = true; this.btnDownloadAll.UseVisualStyleBackColor = true;
@@ -69,7 +69,7 @@
this.lblST.Dock = System.Windows.Forms.DockStyle.Bottom; this.lblST.Dock = System.Windows.Forms.DockStyle.Bottom;
this.lblST.Location = new System.Drawing.Point(0, 52); this.lblST.Location = new System.Drawing.Point(0, 52);
this.lblST.Name = "lblST"; this.lblST.Name = "lblST";
this.lblST.Size = new System.Drawing.Size(504, 22); this.lblST.Size = new System.Drawing.Size(524, 22);
this.lblST.TabIndex = 9; this.lblST.TabIndex = 9;
this.lblST.Text = "Status"; this.lblST.Text = "Status";
this.lblST.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.lblST.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -88,9 +88,9 @@
// //
// btnImportLinks // btnImportLinks
// //
this.btnImportLinks.Location = new System.Drawing.Point(135, 12); this.btnImportLinks.Location = new System.Drawing.Point(115, 12);
this.btnImportLinks.Name = "btnImportLinks"; this.btnImportLinks.Name = "btnImportLinks";
this.btnImportLinks.Size = new System.Drawing.Size(117, 33); this.btnImportLinks.Size = new System.Drawing.Size(97, 33);
this.btnImportLinks.TabIndex = 15; this.btnImportLinks.TabIndex = 15;
this.btnImportLinks.Text = "Import Links"; this.btnImportLinks.Text = "Import Links";
this.btnImportLinks.UseVisualStyleBackColor = true; this.btnImportLinks.UseVisualStyleBackColor = true;
@@ -101,22 +101,22 @@
this.openFileDialog1.FileName = "openFileDialog1"; this.openFileDialog1.FileName = "openFileDialog1";
this.openFileDialog1.Filter = "File Testo|*.tes|Tutti i file|*.*"; this.openFileDialog1.Filter = "File Testo|*.tes|Tutti i file|*.*";
// //
// btnTest // btnShowLog
// //
this.btnTest.Location = new System.Drawing.Point(258, 1); this.btnShowLog.Location = new System.Drawing.Point(218, 12);
this.btnTest.Name = "btnTest"; this.btnShowLog.Name = "btnShowLog";
this.btnTest.Size = new System.Drawing.Size(51, 33); this.btnShowLog.Size = new System.Drawing.Size(97, 33);
this.btnTest.TabIndex = 16; this.btnShowLog.TabIndex = 17;
this.btnTest.Text = "Test"; this.btnShowLog.Text = "Show Log";
this.btnTest.UseVisualStyleBackColor = true; this.btnShowLog.UseVisualStyleBackColor = true;
this.btnTest.Click += new System.EventHandler(this.btnTest_Click); this.btnShowLog.Click += new System.EventHandler(this.btnShowLog_Click);
// //
// frmDownloader // frmDownloader
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(504, 74); this.ClientSize = new System.Drawing.Size(524, 74);
this.Controls.Add(this.btnTest); this.Controls.Add(this.btnShowLog);
this.Controls.Add(this.btnImportLinks); this.Controls.Add(this.btnImportLinks);
this.Controls.Add(this.btnClose); this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnHide); this.Controls.Add(this.btnHide);
@@ -138,6 +138,6 @@
private System.Windows.Forms.WebBrowser wb1; private System.Windows.Forms.WebBrowser wb1;
private System.Windows.Forms.Button btnImportLinks; private System.Windows.Forms.Button btnImportLinks;
private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.Button btnTest; private System.Windows.Forms.Button btnShowLog;
} }
} }
+6 -8
View File
@@ -16,6 +16,7 @@ namespace A69WD {
public frmDownloader() { public frmDownloader() {
InitializeComponent(); InitializeComponent();
this.Text = String.Format("A69WD - Dowloader Testi Vrs {0}", cTools.AssemblyVersion);
engine = new cA69Engine(this.wb1); engine = new cA69Engine(this.wb1);
engine.Updating += Engine_Updating; engine.Updating += Engine_Updating;
} }
@@ -39,6 +40,10 @@ namespace A69WD {
engine.Start(true); engine.Start(true);
} }
private void btnShowLog_Click(object sender, EventArgs e) {
cTools.ShowOnNotepad(Cfg.Settings.PathFileLogs);
}
private void btnHide_Click(object sender, EventArgs e) { private void btnHide_Click(object sender, EventArgs e) {
if (MessageBox.Show("Metodo ancora da terminare, la finestra non sarà più visibile, killare il processo", "ATTENZIONE", MessageBoxButtons.OKCancel) == DialogResult.OK){ if (MessageBox.Show("Metodo ancora da terminare, la finestra non sarà più visibile, killare il processo", "ATTENZIONE", MessageBoxButtons.OKCancel) == DialogResult.OK){
this.Hide(); this.Hide();
@@ -76,14 +81,7 @@ namespace A69WD {
private void btnTest_Click(object sender, EventArgs e) {
ProcessStartInfo startInfo = new ProcessStartInfo(@"D:\MyTools\Npp\notepad++.exe");
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = @"C:\Temporary\ArchivioTesti\Logs\Log.tes";
Process ieProcess = Process.Start(startInfo);
}
+14 -2
View File
@@ -32,8 +32,20 @@ using System.Runtime.InteropServices;
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build // È 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: // usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.5.4")] [assembly: AssemblyVersion("0.1.6.0")]
[assembly: AssemblyFileVersion("0.1.5.4")] [assembly: AssemblyFileVersion("0.1.6.0")]
/*
*
* Vrs 0.1.6.0
*
* Compilata da CSiCoAlm il 2021/11/07
* - Corretto bug rilevato (ISSUE 01)
* - Inserita solita icona per i tools.
* - Sistemato la classe cTools inserendo tutti i tools trovati finora
*
*/
/* /*
Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB