- Autocommit - 2021/10/26 20:01:12

This commit is contained in:
CSiCoAlm committed 2021-10-26 20:01:12 +02:00
1 parent 6d05279201
commit 6ea341fc11
12 files changed
+1643 -27

No files matched your search

+20 -1
View File
@@ -8,13 +8,32 @@
* 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...
* TODO Verificare il formato di salvataggio, perchè le accentuate e alcuni segni vengono male.
* TODO Fare parser di un file di link che inserisce quelli nuovi sul toDownload o li inserisce sul DB con lo stato ToDownload.
* 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
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
* Test funzionamento in consol: :ABORT:
verifichiamo se è possibile operare come consol:
+18 -1
View File
@@ -44,18 +44,31 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="cTools.cs" />
<Compile Include="App.cs" />
<Compile Include="frmDownloader.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmDownloader.Designer.cs">
<DependentUpon>frmDownloader.cs</DependentUpon>
</Compile>
<Compile Include="Net\eLinkState.cs" />
<Compile Include="General\Cfg.cs" />
<Compile Include="General\cTools.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Logger.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmDownloader.resx">
<DependentUpon>frmDownloader.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -74,7 +87,11 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="Settings.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
+21
View File
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace A69WD {
public class App {
public static bool Retrive = true;
//public static ATLib.TextAppender RaccReport = null;
//public static ATLib.Data.DBTools DB = null;
//public static ATLib.Plugin.iPlugin[] Plugs = null;
}//class App
}//namespace A69WD
+328
View File
@@ -0,0 +1,328 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.Serialization;
namespace A69WD {
/// <summary>
/// Classe per gestire le configurazioni dei plugin.
/// La classe con le configurazioni dell'applicativo, deve derivare da questa.
/// </summary>
[Serializable]
public class Cfg {
#region Costruttore statico
public static Cfg Settings {
get {
if (settings == null) {
settings = new Cfg();
settings.Deserialize();
}
return settings;
}
}
[NonSerialized]
private static Cfg settings = null;
[NonSerialized]
private string SettingsFilePath = "Settings.cfg";
/// <summary>
/// Costruttore per la serializzazione
/// </summary>
public Cfg() {; }
#endregion
#region Gestione della Serializzazione
public void Serialize() {
XmlTextWriter writer = null;
try {
// Creo un flusso per l'operazione di scrittura dei dati su file
writer = new XmlTextWriter(SettingsFilePath, Encoding.UTF8);
// write a readable file
writer.Formatting = Formatting.Indented;
writer.Indentation = 4;
// Occorre un'istanza della classe XmlSerializer
XmlSerializer serializer = new XmlSerializer(typeof(Cfg));
// e questo é tutto ciò che serve per persistere i dati
serializer.Serialize(writer, Settings);
} catch (Exception ex) {
throw new ApplicationException("Serialize: " + ex.Message);
} finally {
// Chiudere sempre i flussi non appena possibile
writer.Close();
}
}
public void Deserialize() {
//if (File.Exists(SettingsFilePath)) {
XmlTextReader reader = null;
try {
// Creo un flusso per l'operazione di lettura dei dati dal file
reader = new XmlTextReader(SettingsFilePath);
// Occorre un'istanza della classe XmlSerializer
XmlSerializer serializer = new XmlSerializer(typeof(Cfg));
// Collego l'istanza XmlSerializer al gestore dell'evento
serializer.UnknownElement += new XmlElementEventHandler(serializer_UnknownElement);
// e questo é tutto ciò che serve per leggere i dati dal formato XML
settings = (Cfg)serializer.Deserialize(reader);
} catch (FileNotFoundException) {
throw new ApplicationException("File inesistente");
} finally {
reader.Close();
}
//}
}
///<summary>
///Metodo: Gestore dell'evento UnknownElement
///</summary>
private void serializer_UnknownElement(object sender, XmlElementEventArgs e) {
string msg = "Unknown Element";
msg += "\t" + e.Element.Name + " " + e.Element.InnerXml;
msg += "\t LineNumber: " + e.LineNumber;
msg += "\t LinePosition: " + e.LinePosition;
Cfg x = (Cfg)e.ObjectBeingDeserialized;
}
#endregion
#region Settings:
#region Serializzati nel file di configurazione:
/// <summary>
/// Path root dell'applicazione. Da questo derivano tutti gli altri path.
/// </summary>
public virtual string PathApplicationRoot { get { return applicationRootPath; } set { applicationRootPath = value; } }
private string applicationRootPath;
/// <summary>
/// Nome del database usato dall'applicazione [DEPRECATE].
/// </summary>
public virtual string DBName { get { return dbName; } set { dbName = value; } }
private string dbName;
/// <summary>
/// Dimensione massima dei singoli file di log espressa in KB.
/// </summary>
public int LogsFileSizeLimitKB { get { return logsFileSizeLimitKB; } set { logsFileSizeLimitKB = value; } }
private int logsFileSizeLimitKB;
/// <summary>
/// Nome di riferimento per gli eventi inseriti nell'event logger di windows.
/// Se lasciato nullo o vuoto, disabilita l'inserimento dei log nell'event logger di windows.
/// </summary>
public virtual string LogsWinLoggerRef { get { return logsWinLoggerRef; } set { logsWinLoggerRef = value; } }
private string logsWinLoggerRef;
#endregion
#region Ricavati indirettamente dal file di configurazione
/// <summary>
/// Path del database usato dall'applicazione.
/// Vecchia versione:
/// public virtual string PathDB { get { return dbPath; } set { dbPath = value; } } private string dbPath;
/// </summary>
public virtual string PathDB { get { return Path.Combine(PathApplicationRoot, "DB"); } }
/// <summary>
/// Stringa di connessione al database dell'applicazione [DEPRECATE].
/// </summary>
public virtual string DBConnectionString { get { return string.Format("data source=\"{0}\"", Path.Combine(PathDB, dbName)); } }
/// <summary>
/// Path completo del file di log
/// Vecchia versione:
/// public virtual string PathFileLogs { get { return logsFilePath; } set { logsFilePath = value; } } private string logsFilePath;
/// </summary>
public virtual string PathFileLogs { get { return Path.Combine(Path.Combine(PathApplicationRoot, "Logs"), "Log.tes"); } }
/// <summary>
/// Path della directory su cui memorizzo in modo temporaneo i file downloadati.
/// </summary>
public virtual string PathDownloadWorking { get { return Path.Combine(PathApplicationRoot, "Down"); } }
/// <summary>
/// Path della directory su cui riporto i file di indice correttamente analizzati.
/// </summary>
public virtual string PathAnalizadedIndexFile {
get {
if (string.IsNullOrEmpty(pathAnalizadedIndexFile)) {
// creo path e verifico l'esistenza
pathAnalizadedIndexFile = Path.Combine(Path.Combine(PathDownloadWorking, DateTime.Now.ToString("yyyy-MM-dd")), "Index");
if (!Directory.Exists(pathAnalizadedIndexFile)) Directory.CreateDirectory(pathAnalizadedIndexFile);
}
return pathAnalizadedIndexFile;
}
}
private string pathAnalizadedIndexFile = "";
/// <summary>
/// Path della directory su cui riporto i file di indice correttamente analizzati.
/// </summary>
public virtual string PathAnalizadedRaccFile {
get {
if (string.IsNullOrEmpty(pathAnalizadedRaccFile)) {
// creo path e verifico l'esistenza
pathAnalizadedRaccFile = Path.Combine(Path.Combine(PathDownloadWorking, DateTime.Now.ToString("yyyy-MM-dd")), "Testi");
if (!Directory.Exists(pathAnalizadedRaccFile)) Directory.CreateDirectory(pathAnalizadedRaccFile);
}
return pathAnalizadedRaccFile;
}
}
private string pathAnalizadedRaccFile = "";
#endregion
/*
/// <summary>
/// Path, relativo al plugin, del file con l'elenco dei link ai file di indice.
/// </summary>
public string FileIndexLinkPath { get { return fileIndexLinkPath; } set { fileIndexLinkPath = value; } }
private string fileIndexLinkPath;
/// <summary>
/// Path completo dell'applicazione esterna da usare per il download dei file dal web
/// </summary>
public string DownloaderPrg { get { return downloaderPrg; } set { downloaderPrg = value; } }
private string downloaderPrg;
/// <summary>
/// Path, relativo al plugin, del file di log per l'applicativo di download.
/// </summary>
public string FileDownloadLogPath { get { return fileDownloadLogPath; } set { fileDownloadLogPath = value; } }
private string fileDownloadLogPath;
/// <summary>
/// Directory, relativa al plugin, su cui vengono messi i file indice downloadati dal downloader.
/// </summary>
public string DownloadFolderIndex { get { return downloadFolderIndex; } set { downloadFolderIndex = value; } }
private string downloadFolderIndex;
/// <summary>
/// Directory, relativa al plugin, su cui vengono archiviati i file indice dopo l'analisi.
/// </summary>
public string ArchiveFolderIndex { get { return archiveFolderIndex; } set { archiveFolderIndex = value; } }
private string archiveFolderIndex;
/// <summary>
/// Path, relativo al plugin, del file con l'elenco dei link ai file dei singoli racconti.
/// </summary>
public string FileRaccLinkPath { get { return fileRaccLinkPath; } set { fileRaccLinkPath = value; } }
private string fileRaccLinkPath;
/// <summary>
/// Numero massimo di racconti da raccogliere su ciascun file di testo.
/// </summary>
public int NumRaccontiForFile { get { return numRaccontiForFile; } set { numRaccontiForFile = value; } }
private int numRaccontiForFile;
/// <summary>
/// Directory, relativa al plugin, su cui vengono archiviati i file dei racconti dopo l'analisi.
/// </summary>
public string ArchiveFolderRacc { get { return archiveFolderRacc; } set { archiveFolderRacc = value; } }
private string archiveFolderRacc;
/// <summary>
/// Struttura, relativa al plugin, del path dei file su cui raccolgo i racconti estratti.
/// </summary>
public string RaccontiExtractedFileName { get { return raccontiExtractedFileName; } set { raccontiExtractedFileName = value; } }
private string raccontiExtractedFileName;
/// <summary>
/// Path del file da usare come log temporaneo del programma di download
/// </summary>
public string TmpLogPath { get { return tmpLogPath; } set { tmpLogPath = value; } }
private string tmpLogPath;
/// <summary>
/// Path del file con i link agli indici dei racconti, pronto per essere downloadato con _Down1.
/// </summary>
public string IndexLinkPath { get { return indexLinkPath; } set { indexLinkPath = value; } }
private string indexLinkPath;
/// <summary>
/// Path del file su cui memorizzo il DB dei link finora trovati.
/// </summary>
public string LinkDBPath { get { return linkDBPath; } set { linkDBPath = value; } }
private string linkDBPath;
/// <summary>
/// Path del file su cui scrivo i link dei racconti non precedentemente contenuti nel DB.
/// </summary>
public string LinkNewPath { get { return linkNewPath; } set { linkNewPath = value; } }
private string linkNewPath;
/// <summary>
/// Directory su cui voglio spostare i file degli indici downloadati.
/// </summary>
public string IndexDstFolder { get { return indexDstFolder; } set { indexDstFolder = value; } }
private string indexDstFolder;
/// <summary>
/// Directory contenente i file html, dei racconti, downloadati
/// </summary>
public string RaccontiSrcFolder { get { return raccontiSrcFolder; } set { raccontiSrcFolder = value; } }
private string raccontiSrcFolder;
/// <summary>
/// Directory su cui riporto i racconti estratti automaticamente dai file html
/// </summary>
public string RaccontiExtractFolder { get { return raccontiExtractFolder; } set { raccontiExtractFolder = value; } }
private string raccontiExtractFolder;
/// <summary>
/// Nome principale per i file su cui riporto i racconti estratti automaticamente.
/// </summary>
public string RaccontiExtractedFileName { get { return raccontiExtractedFileName; } set { raccontiExtractedFileName = value; } }
private string raccontiExtractedFileName;
/// <summary>
/// Numero di racconti massimo contenuti nel file di esportazione dei racconti estratti automaticamente.
/// </summary>
public int NumRaccontiForFile { get { return numRaccontiForFile; } set { numRaccontiForFile = value; } }
private int numRaccontiForFile;
//*/
#endregion
} // class Cfg
} // namespace A69WD
+475
View File
@@ -0,0 +1,475 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
namespace A69WD {
public class cTools {
/// <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);
}
/// <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;
}
/// <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>
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();
}
/// <summary>
/// Metodo che legge un testo da file (UTF8)
/// </summary>
/// <param name="sPath">Path del file da leggere</param>
/// <returns>Testo del file</returns>
public static string ReadTextFile(string sPath) {
//string str = "";
//try {
// if (File.Exists(sPath)) {
// StreamReader reader = File.OpenText(sPath);
// str = reader.ReadToEnd();
// reader.Close();
// reader.Dispose();
// }
//} catch (Exception exception) {
// str = "ERRORE: " + exception.Message;
//}
//return str;
string str = "";
if (File.Exists(sPath)) {
StreamReader reader = File.OpenText(sPath);
str = reader.ReadToEnd();
reader.Close();
reader.Dispose();
}
return str;
}
/// <summary>
/// Metodo che legge un testo da file
/// </summary>
/// <param name="FilePath">Path del file da leggere</param>
/// <param name="encoding">Codifica usata nel testo</param>
/// <returns>Testo del file</returns>
public static string ReadTextFile(string FilePath, Encoding encoding) {
System.IO.StreamReader sr = null;
//StringBuilder sb = null;
string txt = "";
try {
//Pass the file path and file name to the StreamReader constructor
sr = new System.IO.StreamReader(FilePath, encoding);
////Read the first line of text
//sb = new StringBuilder();
//string line = sr.ReadLine();
////Continue to read until you reach end of file
//while (line != null) {
// sb.AppendLine(line);
// //Read the next line
// line = sr.ReadLine();
//}
txt = sr.ReadToEnd();
} catch (Exception e) {
throw new Exception("Errore nell'esecuzione di WebTools.Library.Tools.ReadTextFile(string FilePath, Encoding encoding):\n" + e.Message);
//sb = new StringBuilder();
} finally {
//close the file
if (sr != null) {
sr.Close();
sr.Dispose();
sr = null;
}
}
//return sb.ToString();
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>
/// 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;
}
public static bool EditPad(string file) {
try {
System.Diagnostics.Process proc = new System.Diagnostics.Process();
// proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
// proc.StartInfo.Verb = "print";
proc.StartInfo.FileName = @"C:\Programmi\My_Tools\Editors\EditPad\EditPad.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; }
}
// 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>
/// Genera l'elenco dei file nella directory indicata che soddisfano al filtro indicato
/// </summary>
/// <param name="path">directory da analizzare</param>
/// <param name="filtro">Filtro da usare</param>
/// <returns>Array dei path completi, dei file trovati</returns>
public static string[] ElencoFile(string path) { return ElencoFile(path, "*.*", SearchOption.TopDirectoryOnly); }
/// <summary>
/// Genera l'elenco dei file nella directory indicata che soddisfano al filtro indicato
/// </summary>
/// <param name="path">directory da analizzare</param>
/// <param name="filtro">Filtro da usare</param>
/// <returns>Array dei path completi, dei file trovati</returns>
public static string[] ElencoFile(string path, string filtro) { return ElencoFile(path, filtro, SearchOption.TopDirectoryOnly); }
/// <summary>
/// Genera l'elenco dei file nella directory indicata che soddisfano al filtro indicato
/// </summary>
/// <param name="path">directory da analizzare</param>
/// <param name="filtro">Filtro da usare</param>
/// <param name="option"></param>
/// <returns>Array dei path completi, dei file trovati</returns>
public static string[] ElencoFile(string path, string filtro, SearchOption option) { return Directory.GetFiles(path, filtro, option); }
/// <summary>
/// Metodo che analizza il file indicato ed inserisce nella lista tutti i link trovati.
/// </summary>
/// <param name="FileSrcPath">Path del file da analizzare</param>
/// <param name="URLs">Lista di tutti i link trovati</param>
/// <returns>True se tutto Ok, False altrimenti</returns>
public static bool EstraiLink(string FileSrcPath, List<string> links) {
try {
Regex regex = new Regex("(?<=href=\")\\S+?(?=\")");
string input = ReadTextFile(FileSrcPath);
Match matchObj = regex.Match(input);
while (matchObj.Success) {
links.Add(matchObj.Value);
if (matchObj.Groups.Count > 1) {
for (int i = 1; i < matchObj.Groups.Count; i++) {
Group group = matchObj.Groups[i];
if (group.Success) {
links.Add(group.Value);
}
}
}
matchObj = matchObj.NextMatch();
}
return true;
} catch { return false; }
}
/// <summary>
/// Metodo che analizza il file indicato e restituisce l'insieme di tutti i link trovati ordinato e privo di doppioni
/// </summary>
/// <param name="FileSrcPath">Path del file da analizzare</param>
/// <returns>Insieme con i vari link trovati</returns>
public static List<string> GetOrderLink(string FileSrcPath) {
List<string> links = new List<string>();
try {
// Estraggo tutti i link:
if (!EstraiLink(FileSrcPath, links)) return new List<string>();
// Verifico di aver trovato dei link:
if (links.Count == 0) return links;
// Ordino i link estratti:
links.Sort();
// Elimino i duplicati:
string[] tmp = links.ToArray();
links.Clear();
string oldLink = tmp[0];
links.Add(oldLink);
for (int i = 1; i < tmp.Length; i++) {
if (tmp[i] != oldLink) {
oldLink = tmp[1];
links.Add(oldLink);
}
}
return links;
} catch (Exception ex) {
Logger.Log(ex);
return links;
}
}
/// <summary>
/// Metodo che legge il DB dei link dal file di testo in cui è stato salvato.
/// </summary>
/// <returns>Elenco ordinato di tutti i link del DB</returns>
public static List<string> ReadLinkDB(string PathLinkBD) {
StreamReader reader = null;
try {
List<string> buffer = new List<string>();
string row;
reader = new StreamReader(PathLinkBD);
do {
row = reader.ReadLine().Trim();
if (row.StartsWith("http://")) {
buffer.Add(row);
}
} while (!reader.EndOfStream);
reader.Close();
reader = null;
// Ordino
buffer.Sort();
return buffer;
} catch {
if (reader != null) {
reader.Close();
reader = null;
}
return new List<string>();
}
}
/// <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>
/// Esegue una formattazione del testo ricavato da un file html per scremarlo delle parti html
/// </summary>
/// <param name="txt">Testo da formattare</param>
/// <param name="eliminaTagHtml">Abilitare l'eliminazione di tutti i generici tag </param>
/// <returns>Testo formattato</returns>
public static string FormattaTesto(string txt, bool eliminaTagHtml) {
try {
// Analisi dei tag prima di levarli:
string testo = Regex.Replace(txt, @"<P>", "\n", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"</P>", "\n", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"<P />", "\n", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"<B>", "\n", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"</B>", "\n", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"<B />", "\n", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"<BR>", "\n", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"</BR>", "\n", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"<br />", "\n", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"</div>", "\n", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"<div />", "\n", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"<<", "«", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @">>", "»", RegexOptions.IgnoreCase);
// Se richiesto, elimino i tag html:
if (eliminaTagHtml) {
// Preparo la Regex:
string htmlPattern = @"\<[^\>]*\>";
Regex re = new Regex(htmlPattern, RegexOptions.IgnoreCase);
// Applico l'espressione regolare per togliere tutti i tag:
testo = re.Replace(testo, "");
}
// Correggo risultato togliendo doppie linee e caratteri html:
testo = Regex.Replace(testo, @"&nbsp;", " ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&bull;", " * ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&lsaquo;", " < ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&lt;", "<", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&rsaquo;", " > ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&gt;", ">", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&trade;", "(tm)", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&copy;", "(c)", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&reg;", "(r)", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&frasl;", "/", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&agrave;", "à", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&egrave;", "è", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&igrave;", "ì", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&ograve;", "ò", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&ugrave;", "ù", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8211;", "–", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8212;", "—", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8216;", "‘", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8217;", "’", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8220;", "“", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8221;", "”", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8230;", "…", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#268;", "Č", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#269;", "č", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#282;", "Ě", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#283;", "ě", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8232;", " ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#61516;", " ", RegexOptions.IgnoreCase);
// // Remove all others. More can be added, see
// // http://hotwired.lycos.com/webmonkey/reference/special_characters/
// testo = Regex.Replace(testo, @"&(.{2,6});", string.Empty, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//// Correggo accenti per formati sbagliati:
//while (testo.Contains("à")) { testo = testo.Replace("à", "à"); }
//while (testo.Contains("è")) { testo = testo.Replace("è", "è"); }
//while (testo.Contains("é")) { testo = testo.Replace("é", "é"); }
//while (testo.Contains("ì")) { testo = testo.Replace("ì", "ì"); }
//while (testo.Contains("ò")) { testo = testo.Replace("ò", "ò"); }
//while (testo.Contains("ù")) { testo = testo.Replace("ù", "ù"); }
//while (testo.Contains("’")) { testo = testo.Replace("’", "'"); }
// Correggo scritto:
testo = testo.Replace("\r", "");
while (testo.Contains("\t")) { testo = testo.Replace("\t", " "); }
while (testo.Contains("...")) { testo = testo.Replace("...", "…"); }
while (testo.Contains("….")) { testo = testo.Replace("….", "…"); }
while (testo.Contains("……")) { testo = testo.Replace("……", "…"); }
while (testo.Contains(" ")) { testo = testo.Replace(" ", " "); }
while (testo.Contains(" \n")) { testo = testo.Replace(" \n", "\n"); }
while (testo.Contains("\n ")) { testo = testo.Replace("\n ", "\n"); }
while (testo.Contains("\n\n")) { testo = testo.Replace("\n\n", "\n"); }
return testo;
} catch (Exception ex) { return string.Format(" Errore: Errore durante la formattazione del testo:\n{0}\n\n", ex.Message); }
}
/// <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) {
try {
StringBuilder sb = new StringBuilder();
sb.Append("BODY{\n\tmargin-left : 5px;\n\tmargin-right : 5px;\n\tcolor : #000099;\n\tfont-family : Verdana,Arial,Helvetica;\n\tbackground-color : #F4F4F4;\n}\n.Title {\n\ttext-align : center; \n\tfont-family : \"Helvetica\";\n\tfont-size : x-large;\n}\n.SubTitle {\n\ttext-align : center; \n\ttext-indent : 16px;\n\tfont-family : \"Helvetica\";\n\tfont-size : large;\n\tfont-style : italic;\n}\n.Property {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.Origine {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.Autore {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.Data {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.Trama {\n\ttext-align : justify; \n\ttext-indent : 12px;\n\tcolor : #000000;\n}\n.Menu {\n\ttext-align : right; \n\ttext-indent : 12px;\n\tcolor : #000000;\n}\n.MsgTitle {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.MsgText {\n\ttext-align : justify; \n\ttext-indent : 12px;\n\tcolor : #000000;\n}\n.ReportTitle {\n\ttext-align : center; \n\tfont-family : \"Helvetica\";\n\tfont-size : x-large;\n}\n.ReportText {\n\ttext-align : justify; \n\ttext-indent : 25px;\n\tfont-style : italic;\n}\n.Menu_Row {\n\tfont-size:70%;\n\twhite-space:nowrap;\n}\n.Menu_sx {\n\ttext-align:left; width:50%; float: left;\n}\n.Menu_dx {\n\ttext-align:right; width:50%; float: right;\n}\n");
WriteTextFile(FullFileName, sb);
return true;
} catch (Exception ex) {
Logger.Log(new object[] { "Error Code: eBook000", "Errore in ATlib.Tools.WriteStyleS(FullFileName)", ex });
return false;
}
}
} // class Tools
} // namespace A69WD
+407
View File
@@ -0,0 +1,407 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Threading;
//using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
namespace A69WD {
/// <summary>
/// Particolare tipo di logger che salva il log su un file di testo tramite un thread secondario.
/// </summary>
internal class FileLogger {
/// <summary>
/// Istanza del FileLogger che esegue il logger vero e propio
/// </summary>
public static readonly FileLogger Instance = new FileLogger();
/// <summary>
/// Costruttore privato dell'istanza del FileLogger.
/// </summary>
private FileLogger() {
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
AppDomain.CurrentDomain.DomainUnload += new EventHandler(CurrentDomain_DomainUnload);
workingThread = new Thread(new ThreadStart(Writer));
workingThread.IsBackground = true;
workingThread.Start();
}
#region FileLogger Fields:
/// <summary>
/// Thread secondario che gestisce il FileLogger.
/// </summary>
private Thread workingThread;
/// <summary>
/// Indica se sono o no in esecuzione.
/// </summary>
private bool running = true;
/// <summary>
/// Coda con cui gestisco le richieste di log dell'applicativo.
/// </summary>
private Queue fifo = new Queue();
/// <summary>
/// Stream usato per scrivere i log sul file.
/// </summary>
private StreamWriter _output;
/// <summary>
/// Memorizza il nome del file di log.
/// </summary>
private string fileName = "..\\Logs\\Log.tes";
/// <summary>
/// Memorizza il path del file di log.
/// </summary>
private string filePath = "";
/// <summary>
/// Dimensione limite del file per il rolling size
/// </summary>
private int sizeLimitKB = 1000;
/// <summary>
/// memoria della dimensione attuale del file, necessaria per il rolling size
/// </summary>
private long lastSize = 0;
/// <summary>
/// memoria della data attuale del file, necessaria per il rolling date
/// </summary>
private DateTime lastFileDate;
/// <summary>
/// Interfaccia con l'EventLogger di windows
/// </summary>
private EventLog WinLogger = null;
#endregion
/// <summary>
/// Inizializza il FileLogger
/// </summary>
/// <param name="FileName">Path completo o relativo del file di log.</param>
/// <param name="SizeLimitKB">Limite della dimensione del file prima di spezzare il log in file successivi.</param>
/// <param name="WinLogName">Nome da associare agli eventi nel event logger di windows. Se nullo,, disabilita l'aggiunta nell'event logger di windows.</param>
public void Init(string FileName, int SizeLimitKB, string WinLogName) {
sizeLimitKB = SizeLimitKB;
fileName = FileName;
// handle folder names as well -> create dir etc.
filePath = Path.GetDirectoryName(FileName);
if (filePath != "") {
filePath = Directory.CreateDirectory(filePath).FullName;
if (filePath.EndsWith("\\") == false)
filePath += "\\";
}
if (File.Exists(FileName)) {
_output = new StreamWriter(FileName, true, Encoding.UTF8);
} else {
_output = new StreamWriter(FileName, true, Encoding.UTF8);
_output.WriteLine(LogEvent.HeadRow);
}
FileInfo fi = new FileInfo(FileName);
lastSize = fi.Length;
lastFileDate = fi.LastWriteTime;
if (!string.IsNullOrEmpty(WinLogName)) {
WinLogger = new EventLog("Application", ".", WinLogName);
}
}
void CurrentDomain_ProcessExit(object sender, EventArgs e) { shutdown(); }
void CurrentDomain_DomainUnload(object sender, EventArgs e) { shutdown(); }
//private void shutdown() { running = false; workingThread.Abort(); }
private void shutdown() { running = false; }
/// <summary>
/// Programma di gestione del FileLogger eseguito in un thread separato.
/// </summary>
private void Writer() {
// Loop infinito per il ciclo di gestione del logger.
while (running) {
while (fifo.Count > 0) {
LogEvent o = fifo.Dequeue() as LogEvent;
// Inserisco l'evento nel file di log:
if (_output != null && o != null) {
if (sizeLimitKB > 0) {
// implement size limited logs
// implement rolling logs
#region [ rolling size limit ]
lastSize += o.ToString().Length;
if (lastSize > sizeLimitKB * 1000) {
_output.Flush();
_output.Close();
int count = 1;
while (File.Exists(filePath + Path.GetFileNameWithoutExtension(fileName) + "." + count.ToString("0000")))
count++;
File.Move(fileName, filePath + Path.GetFileNameWithoutExtension(fileName) + "." + count.ToString("0000"));
_output = new StreamWriter(fileName, true, Encoding.UTF8);
_output.WriteLine(LogEvent.HeadRow);
lastSize = 0;
}
#endregion
}
if (DateTime.Now.Subtract(lastFileDate).Days > 0) {
// implement date logs
#region [ rolling dates ]
_output.Flush();
_output.Close();
int count = 1;
while (File.Exists(filePath + Path.GetFileNameWithoutExtension(fileName) + "." + count.ToString("0000"))) {
File.Move(filePath + Path.GetFileNameWithoutExtension(fileName) + "." + count.ToString("0000"),
filePath +
Path.GetFileNameWithoutExtension(fileName) +
"." + count.ToString("0000") +
"." + lastFileDate.ToString("yyyy-MM-dd"));
count++;
}
File.Move(fileName,
filePath +
Path.GetFileNameWithoutExtension(fileName) +
"." + count.ToString("0000") +
"." + lastFileDate.ToString("yyyy-MM-dd"));
_output = new StreamWriter(fileName, true, Encoding.UTF8);
_output.WriteLine(LogEvent.HeadRow);
lastFileDate = DateTime.Now;
lastSize = 0;
#endregion
}
_output.WriteLine(o.ToString());
//_output.WriteLine(o.ToXml());
}
// Inserisco l'evento nell'event logger di windows:
if ((WinLogger != null) && (o != null)) {
try { WinLogger.WriteEntry(o.Message, o.Type); } catch {; }
}
}
if (_output != null)
_output.Flush();
Thread.Sleep(500);
}
// Uscita dal loop infinito:
_output.Flush();
_output.Close();
}
/// <summary>
/// Gestisce una richiesta di log, inserendola nella coda che verrà poi smaltita dal thread secondario.
/// </summary>
public void AddLog(LogEvent log) { fifo.Enqueue(log); }
/// <summary>
/// Numero di eventi di log non ancora riportati sul file.
/// </summary>
public int LogMissing() { return fifo.Count; }
} // class FileLogger
/// <summary>
/// Classe per descrivere un evento da loggare:
/// </summary>
internal class LogEvent {
public DateTime Dt { get { return dt; } }
private DateTime dt;
public string Message { get { return message; } }
private string message;
public EventLogEntryType Type { get { return type; } }
private EventLogEntryType type;
public LogEvent(DateTime Dt, EventLogEntryType Type, string Message) {
this.dt = Dt;
this.message = Message;
this.type = Type;
}
public LogEvent(EventLogEntryType Type, string Message) {
this.dt = DateTime.Now;
this.message = Message;
this.type = Type;
}
public override string ToString() {
StringBuilder sb = new StringBuilder();
sb.Append("|\t" + Dt.ToString("yyyy/MM/dd HH:mm:ss"));
sb.Append("\t|\t" + Type.ToString());
message = Message.Replace("\r\n", "\n"); // Sostituisco fine riga con un newline.
message = Message.Replace("\r", "\n"); // Sostituisco acapo con un newline.
message = Message.Replace("\n", "\n\t \t\t"); // Sostituisco newline con una newline e l'offset della data.
sb.Append("\t|\t" + Message + "\t|");
return sb.ToString();
}
public string ToXml() {
StringBuilder sb = new StringBuilder();
sb.AppendFormat("\t<log type='{0}' data='{1}'>\n", Type.ToString(), Dt.ToString("yyyy/MM/dd HH:mm:ss"));
sb.Append(Message + "\n");
sb.Append("\t</log>\n");
return sb.ToString();
}
public static string HeadRow { get { return "|\tDateTime\t|\tEventLogEntryType\t|\tMessage\t|"; } }
} // class LogEvent
/// <summary>
/// Particolare tipo di logger, gestisce in parallelo un log su file e quello di windows se posto parametro a true.
/// </summary>
public class Logger {
/// <summary>
/// Configura il log per permettere di usarlo.
/// </summary>
/// <param name="FileName">Path completo o relativo del file di log.</param>
/// <param name="SizeLimitKB">Limite della dimensione del file prima di spezzare il log in file successivi.</param>
/// <param name="EnableWinLog">Abilitare o no la registrazione degli eventi sull'eventlogger di windows.</param>
public static void Configure(string FileName, int SizeLimitKB, string WinLogName) { FileLogger.Instance.Init(FileName, SizeLimitKB, WinLogName); }
/// <summary>
/// Inserisce un log generico (Information o Error) di report degli oggetti passati.
/// </summary>
/// <param name="logs">Oggetti su cui assegnare l'evento</param>
public static void Log(params object[] logs) {
DateTime dt = DateTime.Now;
string text = String.Empty;
EventLogEntryType type = EventLogEntryType.Information;
//try {
// foreach (object log in logs) {
// if (log is Exception) { type = EventLogEntryType.Error; text += ExceptionLog(log as Exception); } else text += ObjectLog(log);
// }
//} catch (Exception ex) { text = "Exception Logging: " + ex.Message; }
try {
foreach (object log in logs) {
//if (log is Exception) { type = EventLogEntryType.Error; text += ExceptionLog(log as Exception); } else text += ObjectLog(log);
if (log is Exception) { type = EventLogEntryType.Error; }
text += ObjectLog(log);
}
} catch (Exception ex) { text = "Exception Logging: " + ex.Message; }
string message = "";
//try { message = text + "\r\n§§§" + UnwrapStackTrace(new StackTrace(true)) + "§§§"; } catch { message = text; }
message = text;
FileLogger.Instance.AddLog(new LogEvent(dt, type, message));
}
/// <summary>
/// An error event. This indicates a significant problem the user should know
/// about; usually a loss of functionality or data.
/// </summary>
public static void Error(string message) { FileLogger.Instance.AddLog(new LogEvent(DateTime.Now, EventLogEntryType.Error, message)); }
/// <summary>
/// A warning event. This indicates a problem that is not immediately significant,
/// but that may signify conditions that could cause future problems.
/// </summary>
public static void Warning(string message) { FileLogger.Instance.AddLog(new LogEvent(DateTime.Now, EventLogEntryType.Warning, message)); }
/// <summary>
/// An information event. This indicates a significant, successful operation.
/// </summary>
public static void Information(string message) { FileLogger.Instance.AddLog(new LogEvent(DateTime.Now, EventLogEntryType.Information, message)); }
/// <summary>
/// A success audit event. This indicates a security event that occurs when an
/// audited access attempt is successful; for example, logging on successfully.
/// </summary>
public static void SuccessAudit(string message) { FileLogger.Instance.AddLog(new LogEvent(DateTime.Now, EventLogEntryType.SuccessAudit, message)); }
/// <summary>
/// A failure audit event. This indicates a security event that occurs when an
/// audited access attempt fails; for example, a failed attempt to open a file.
/// </summary>
public static void FailureAudit(string message) { FileLogger.Instance.AddLog(new LogEvent(DateTime.Now, EventLogEntryType.FailureAudit, message)); }
/// <summary>
/// Numero di eventi di log non ancora riportati sul file.
/// </summary>
public static int LogMissing() {
object obj = new object();
lock (obj) {
return FileLogger.Instance.LogMissing();
}
}
/// <summary>
/// Concatena i testi descrittivi dello stack
/// </summary>
private static string UnwrapStackTrace(StackTrace st) {
string stackIndent = "", rv = "";
for (int i = 0; i < st.FrameCount; i++) {
StackFrame sf = st.GetFrame(i);
rv += stackIndent + string.Format(" Method: {0}", sf.GetMethod()) + endl;
rv += stackIndent + string.Format(" File: {0}", sf.GetFileName()) + endl;
rv += stackIndent + string.Format(" Line Number: {0}", sf.GetFileLineNumber()) + endl;
rv += stackIndent + string.Format(" Column Number: {0}", sf.GetFileColumnNumber()) + endl;
stackIndent += " ";
}
return rv;
}
/// <summary>
/// Concatena i testi dell'eccezzione
/// </summary>
private static string ExceptionLog(Exception ex) {
string text = "Exc - ";
if (ex.Message != null) text += ex.Message;
if (ex.Source != null) text += ex.Source;
if (ex.StackTrace != null) text += ex.StackTrace;
if (ex.TargetSite != null) text += ex.TargetSite.Name;
if (ex.InnerException != null) text += ExceptionLog(ex.InnerException);
return "\r\n#" + text + "#";
}
/// <summary>
/// Concatena i testi degli oggetti passati
/// </summary>
private static string ObjectLog(object o) {
if (o == null) return "<null>";
if (typeof(ICollection).IsInstanceOfType(o)) {
string rv = "[" + o.GetType().ToString() + "]=>{";
ICollection c = o as ICollection;
IEnumerator e = c.GetEnumerator();
while (e.MoveNext()) rv += "," + e.Current.ToString();
return rv + "}";
}
return "\r\n#" + o.ToString() + "#";
}
/// <summary>
/// Indicatore di fine riga
/// </summary>
private static string endl = Environment.NewLine;
} // class logger
} // namespace A69WD
+70
View File
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace A69WD {
/// <summary>
/// Enumerazione di tutti i bossibili stati di un link:
/// </summary>
public enum ATLinkState {
/// <summary>
/// Indica un link che deve venir testato per capire se è o meno da downloadare
/// </summary>
ToCheck = 1,
/// <summary>
/// Indica un link che deve venir downloadato
/// </summary>
ToDownload = 2,
/// <summary>
/// Indica un ATLink che è in download
/// </summary>
OnDownload = 3,
/// <summary>
/// Indica un ATLink correttamente downloadato
/// </summary>
Donwloaded = 4,
///// <summary>
///// Indica un link che deve venir downloadato
///// </summary>
//ToAnalize = 5,
///// <summary>
///// Indica un ATLink che è in analizzazione
///// </summary>
//OnAnalize = 6,
///// <summary>
///// Indica un ATLink correttamente downloadato
///// </summary>
//Analized = 7,
///// <summary>
///// Indica un ATLink in cui si è concluso il lavoro.
///// </summary>
//End = 8,
///// <summary>
///// Indica un ATLink il cui download ha avuto un errore
///// </summary>
//ErrorDownload = 9,
///// <summary>
///// Indica un ATLink la cui analisi ha avuto un errore
///// </summary>
//ErrorAnalize = 10,
///// <summary>
///// Indica un ATLink il cui download è stato abortito
///// </summary>
//AbortDownload = 11,
///// <summary>
///// Indica un ATLink la cui analisi è stata abortita
///// </summary>
//AbortAnalize = 12,
///// <summary>
///// Indica un ATLink il cui download è stato cancellato
///// </summary>
//CancelDownload = 13,
///// <summary>
///// Indica un ATLink la cui analisi è stata cancellata
///// </summary>
//CancelAnalize = 14,
} // enum ATLinkState
}//namespace A69WD
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Cfg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- Path root dell'applicazione. Da questo derivano tutti gli altri path. -->
<PathApplicationRoot>C:\Temporary\A69WD</PathApplicationRoot>
<!-- Nome del database usato dall'applicazione. -->
<DBName>A69DB.db</DBName>
<!-- Dimensione massima dei singoli file di log espressa in KB. -->
<LogsFileSizeLimitKB>1000</LogsFileSizeLimitKB>
<!-- Nome di riferimento per gli eventi inseriti nell'event logger di windows. -->
<!-- Se lasciato nullo o vuoto, disabilita l'inserimento dei log nell'event logger di windows. -->
<LogsWinLoggerRef>A69WD</LogsWinLoggerRef>
</Cfg>
-25
View File
@@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace A69WD {
public class cTools {
/// <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>
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();
}
}
}
+148
View File
@@ -0,0 +1,148 @@
namespace A69WD {
partial class frmDownloader {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.btbPath = new System.Windows.Forms.Button();
this.tbPath = new System.Windows.Forms.TextBox();
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.wb1 = new System.Windows.Forms.WebBrowser();
this.btnDownloadLink = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// 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(-39, 53);
this.btbPath.Name = "btbPath";
this.btbPath.Size = new System.Drawing.Size(20, 20);
this.btbPath.TabIndex = 17;
this.btbPath.Text = ".";
this.btbPath.UseVisualStyleBackColor = true;
//
// 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(0, 20);
this.tbPath.TabIndex = 16;
this.tbPath.Text = "C:\\Temporary\\A69WD\\Dst\\";
//
// 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 = 14;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
//
// 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 = 13;
this.btnHide.Text = "Hide";
this.btnHide.UseVisualStyleBackColor = true;
//
// 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 = 11;
this.btnDownloadAll.Text = "Download All";
this.btnDownloadAll.UseVisualStyleBackColor = true;
//
// 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, 52);
this.lblST.Name = "lblST";
this.lblST.Size = new System.Drawing.Size(504, 22);
this.lblST.TabIndex = 9;
this.lblST.Text = "Status";
this.lblST.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// 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 = 12;
this.wb1.TabStop = false;
this.wb1.Visible = false;
//
// 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 = 10;
this.btnDownloadLink.Text = "Download only Link";
this.btnDownloadLink.UseVisualStyleBackColor = true;
//
// frmDownloader
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(504, 74);
this.ControlBox = false;
this.Controls.Add(this.btbPath);
this.Controls.Add(this.tbPath);
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.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "frmDownloader";
this.Text = "frmDownloader";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btbPath;
private System.Windows.Forms.TextBox tbPath;
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.WebBrowser wb1;
private System.Windows.Forms.Button btnDownloadLink;
}
}
+16
View File
@@ -0,0 +1,16 @@
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;
namespace A69WD {
public partial class frmDownloader : Form {
public frmDownloader() {
InitializeComponent();
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>