Serializzazione dei racconti in XML e importazione sito Old Milu #7

Merged
Mrk merged 2 commits from mrk/Export XML AGit into master 2026-01-04 18:55:15 +01:00
9 changed files with 819 additions and 32 deletions

No files matched your search

+1
View File
@@ -74,6 +74,7 @@
<Compile Include="General\Logger.cs" />
<Compile Include="Net\iLink.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Service\Service_Import_Milu.cs" />
<Compile Include="UI\frmReader.cs">
<SubType>Form</SubType>
</Compile>
+1 -1
View File
@@ -1947,7 +1947,7 @@ namespace A69WD {
#region Reader function: GetReport, GetRandomIDrac
private long GetNumRacs(string TagFilter = "") {
public long GetNumRacs(string TagFilter = "") {
string query = "SELECT count (IDrac) FROM Racconti";
if (TagFilter != "") { query = "SELECT count (Racconti.IDrac) AS NUM FROM Racconti, Links_Rac_Vot, Voti WHERE Racconti.IDrac=Links_Rac_Vot.IDrac AND Links_Rac_Vot.IDvot=Voti.IDvot AND Voti.Voto='" + TagFilter + "'"; }
return Helper.ExecuteScalar(cn,query,objLock);
+4
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace A69WD.Data {
@@ -11,7 +12,10 @@ namespace A69WD.Data {
/// </summary>
public class cNota {
[XmlAttribute]
public string Key { get; set; }
[XmlAttribute]
public string Description { get; set; }
/// <summary>
+56 -5
View File
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace A69WD.Data {
@@ -83,6 +84,8 @@ namespace A69WD.Data {
/// Default: null
/// Mappa la relazione tramite [Links_Rac_Aut] con la tabella [Autori].
/// </summary>
[XmlArray("Autori")]
[XmlArrayItem("Autore")]
public List<string> Autori { get; set; } = new List<string>();
/// <summary>
@@ -90,6 +93,8 @@ namespace A69WD.Data {
/// Default: null
/// Mappa la relazione tramite [Links_Rac_Tag] con la tabella [Tags].
/// </summary>
[XmlArray("Tags")]
[XmlArrayItem("Tag")]
public List<string> Tags { get; set; } = new List<string>();
/// <summary>
@@ -97,6 +102,8 @@ namespace A69WD.Data {
/// Default: null
/// Mappa la relazione tramite [Links_Rac_Ori] con la tabella [Origini].
/// </summary>
[XmlArray("Origini")]
[XmlArrayItem("Origine")]
public List<string> Origini { get; set; } = new List<string>();
/// <summary>
@@ -108,6 +115,8 @@ namespace A69WD.Data {
/// Mappa la relazione tramite [Links_Rac_Not] con la tabella [Notes].
/// </summary>
//public Dictionary<string, string> Note { get; set; } = new Dictionary<string, string>();
[XmlArray("Notes")]
[XmlArrayItem("Nota")]
public List<cNota> Notes { get; set; } = new List<cNota>();
#endregion
@@ -235,11 +244,11 @@ namespace A69WD.Data {
}
} catch (Exception ex) { Logger.Log(new object[] { "Error Code:val001", "Errore in ATWD.Rac.Validate", ex }); }
try {
//if (!isValid) {
// Logger.Warning("NOT VALIDATE: " + strIDrac + " - " + fullTitle);
//}
} catch (Exception ex) { Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER375278", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); }
//try {
// //if (!isValid) {
// // Logger.Warning("NOT VALIDATE: " + strIDrac + " - " + fullTitle);
// //}
//} catch (Exception ex) { Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER375278", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message)); }
return isValid;
}
@@ -278,7 +287,49 @@ namespace A69WD.Data {
#endregion
#region Serializzazione su file XML
/// <summary>
/// Serializza l'oggetto cRac in xml
/// </summary>
/// <returns>Testo xml che serializza il cRac</returns>
public string ToXml() {
XmlSerializer serializer = new XmlSerializer(typeof(cRac));
StringWriter sw = new StringWriter();
serializer.Serialize(sw, this);
return sw.ToString();
}
/// <summary>
/// Deserializza l'oggetto cRac dal formato xml
/// </summary>
/// <param name="xml">Testo xml che serializza il cRac</param>
/// <returns>cRac che rappresenta il racconto ricavato dal testo xml</returns>
public static cRac FromXml(string xml) {
XmlSerializer serializer = new XmlSerializer(typeof(cRac));
StringReader sr = new StringReader(xml);
return (cRac)serializer.Deserialize(sr);
}
/// <summary>
/// Salva il cRac come file xml
/// </summary>
/// <param name="path">Path dove salvare</param>
public void SaveToXmlFile(string path) {
File.WriteAllText(path, ToXml());
}
/// <summary>
/// Carica il cRac dal file XML indicato
/// </summary>
/// <param name="path">Path da dove caricare</param>
/// <returns>cRac che rappresenta il racconto ricavato dal file xml</returns>
public static cRac LoadFromXmlFile(string path) {
string xml = File.ReadAllText(path);
return FromXml(xml);
}
#endregion
/// <summary>
/// Crea il file html che rappresenta il racconto.
+18 -2
View File
@@ -32,8 +32,24 @@ using System.Runtime.InteropServices;
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.3.0")]
[assembly: AssemblyFileVersion("0.5.3.0")]
[assembly: AssemblyVersion("0.5.3.1")]
[assembly: AssemblyFileVersion("0.5.3.1")]
/*
*
* Vrs 0.5.3.1
*
* Compilata da CSiCoAlm il 2026/01/04
* Inserito importazione dei file del vecchio sito Milu che sono completamente non compatibili con i formati attuali.
*
*
* ToDo:
* - Aggiungere gestione parallela della FIFO secondo vecchi modello per aumentare il feedback alla UI
* - Inserire anche l'estrazione dei racconti
* - Inserire funzionalità avanzate sul lettore
*
*/
/*
+622
View File
@@ -0,0 +1,622 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using A69WD.Data;
using A69WD.Net;
using HtmlAgilityPack;
namespace A69WD.Service {
public class Service_Import_Milu {
// Thread worker che consuma la coda
private Thread _workerThread;
private readonly StatusStrip _sb;
private string _path;
// Contatori
private int _totali = 0;
private int _completati = 0;
private int _duplicati = 0;
private int _errori = 0;
public Service_Import_Milu(StatusStrip sb) {
_sb = sb;
}
public void StartWorker(string path) {
_path = path;
_workerThread = new Thread(ProcessWorking) { IsBackground = true };
_workerThread.Start();
}
public void StopWorker() {
;
}
private async void ProcessWorking() {
// Seleziono 1000 file in modo casuale dalla directory indicata:
// - Ottieni tutti i file nel percorso
string[] files = System.IO.Directory.GetFiles(Cfg.Settings.PathImport, "*chapter=all");
int MaxNFile = files.Length < Cfg.Settings.MaxNumFile ? files.Length : Cfg.Settings.MaxNumFile;
// - Mescola l'elenco dei file in modo casuale e seleziona i primi MaxNFile
// Usiamo LINQ per mescolare (Shuffle) l'array e prendere i primi MaxNFile
// Si noti che mescolare casualmente l'intero array può essere costoso per molte migliaia di file.
// Alternativamente, si può usare un algoritmo di campionamento casuale (come Fisher-Yates) se l'efficienza è cruciale,
// ma per 10 elementi da un elenco ragionevole, questo è semplice ed efficace.
Random rng = new Random();
var fileCasuali = files
.OrderBy(f => rng.Next()) // Ordina in base a un numero casuale
.Take(MaxNFile) // Prendi i primi MaxNFile
.ToList(); // Converti in List<string> (opzionale, ma utile)
// aggiorno contatori
_totali = fileCasuali.Count;
_completati = 0;
_duplicati = 0;
_errori = 0;
UpdateCounters();
// Verifico cartelle di destinazione
string pathExport = System.IO.Path.Combine(Cfg.Settings.PathApplicationRoot, "Export");
if (!Directory.Exists(pathExport)) Directory.CreateDirectory(pathExport);
if (!Directory.Exists(Cfg.Settings.PathSrcDone)) Directory.CreateDirectory(Cfg.Settings.PathSrcDone);
if (!Directory.Exists(Cfg.Settings.PathSrcErrOnExtract)) Directory.CreateDirectory(Cfg.Settings.PathSrcErrOnExtract);
if (!Directory.Exists(Cfg.Settings.PathSrcErrOnSave)) Directory.CreateDirectory(Cfg.Settings.PathSrcErrOnSave);
// Ciclo su ciascun file
foreach (string file in fileCasuali) {
string name = System.IO.Path.GetFileName(file);
Logger.Warning($"Import - Start estrazione racconto: {name}");
List<cRac> racs = await EstraiRacs(file);
if (racs != null) {
bool saveErr = false;
foreach (cRac rac in racs) {
if (rac.Validate()) {
// racconto valido:
// // - lo esporto come xml
// string nam = $"Milu_Rac_{rac.strIDrac}.xml";
// rac.SaveToXmlFile(System.IO.Path.Combine(pathExport, nam));
// - lo salvo sul DB
int res = App.DB.ImportRac(rac); // res=id del racconto nel DB
if (res < 1) {
// errore nel salvataggio
saveErr = true;
break;
} else {
// salvataggio ok
//saveErr = false;
}
} else {
Logger.Warning($"Import - estrazione errata: {name}");
saveErr = true;
break;
}
}
if (saveErr) {
// errore nel salvataggio dei racconti estratti dal file
Logger.Warning($"Import - errore nel salvataggio: {name}");
Interlocked.Increment(ref _errori);
// - Sposto il file
System.IO.File.Move(file, System.IO.Path.Combine(Cfg.Settings.PathSrcErrOnSave, System.IO.Path.GetFileName(file)));
} else {
// salvataggio ok
Logger.Warning($"Import - racconti salvati: {name}");
Interlocked.Increment(ref _completati);
// - Sposto il file
System.IO.File.Move(file, System.IO.Path.Combine(Cfg.Settings.PathSrcDone, System.IO.Path.GetFileName(file)));
}
} else {
Logger.Warning($"Import - estrazione errata: {name}");
Interlocked.Increment(ref _errori);
// - Sposto il file
System.IO.File.Move(file, System.IO.Path.Combine(Cfg.Settings.PathSrcErrOnExtract, System.IO.Path.GetFileName(file)));
}
UpdateCounters();
}
UpdateCounters();
}
private void UpdateCounters() {
if (_sb.InvokeRequired) {
_sb.Invoke(new Action(UpdateCounters));
return;
}
int daFare = _totali - _completati - _errori;
_sb.Items["sbStatusLabel"].Text = $"{_totali}|{_completati}|{_errori}";
_sb.Items["sbStatusLabel"].ToolTipText = "Totali | Completati | Error";
(_sb.Items["sbProgressBar"] as ToolStripProgressBar).Maximum = _totali > 0 ? _totali : 1;
(_sb.Items["sbProgressBar"] as ToolStripProgressBar).Value = _completati + _errori;
}
public async Task<List<cRac>> EstraiRacs(string FileFullPath) {
/*
* Analisi file dei racconti Milu con il vecchio formato:
*
* - I file con un racconto valido hanno la seguente struttura:
*
* {...}
* <div id="pagetitle">
* <a href="viewstory.php?sid={IDrac}">{Titolo}</a>
* by
* <a href="viewuser.php?uid={IDaut}">{Autor}</a>
* </div>
* <div class="infobox">
* <div class="content">
* <span class="label">Summary: </span>{Riassunto}<br />
* <span class="label">Categories:</span>
* <a href='browse.php?type=categories&amp;catid={IDcat}'>{categoria}</a>
* <span class="label">Characters: </span> {Characters}<br />
* <span class='label'>Genres: </span> {Genres}<br />
* <span class='label'>Warnings: </span> {Warnings}<br />
* <span class="label">Challenges:</span> {Challenges}<br />
* <span class="label">Series:</span> {Series}<br />
* <span class="label">Chapters: </span> {Chapters}
* <span class="label">Completed:</span> {Completed}
* <span class="label">Word count:</span> {WordCount}
* <span class="label">Read:</span> {Read}
* <span class="label"> Published: </span>{Published}
* <span class="label">Updated:</span> }Updated}
* </div>
* </div>
* <p><b>1.</b> <a href='#1'>{Tit1}</a> by {Autor}</p>
* <p><b>2.</b> <a href='#2'>{Tit2}</a> by {Autor}</p>
* <p><b>3.</b> <a href='#3'>{Tit3}</a> by {Autor}</p>
* <div class='chaptertitle'><a name='1'></a>{Tit1} by {Autor}</div>
* <div class='chapter'>{Trama1}</div>
* <div class='toplink'><a href='#1'>Torna all'indice</a></div>
* <div class='chaptertitle'><a name='2'></a>{Tit2} by {Autor}</div>
* <div class='chapter'>{Trama2}</div>
* <div class='toplink'><a href='#1'>Torna all'indice</a></div>
* <div class='chaptertitle'><a name='3'></a>{Tit3} by {Autor}</div>
* <div class='chapter'>{Trama3}</div>
* <div class='toplink'><a href='#1'>Torna all'indice</a></div>
* {...}
* <div id="archivedat">Questo racconto è attualmente archiviato su <a href="{URLrac}">{URLrac}</a></div>
*
* Quindi per ricavare i dati del racconto:
* - Ricavo tag pagetitle
* - Se pagetitle vuoto o size<=2kb racconto nullo, inserisco log e proseguo
* - Se pagetitle non nullo allora ho un racconto valido e proseguo l'estrazione.
* - Da pagetitle ricavo il titolo del racconto.
* - dal testo del tag infobox.content ricavo filtrando i vari parametri del racconto
* - Dall'elenco dei tag chaptertitle ricavo i sottotitoli dei singoli racconti ATDB
* - Dall'elenco dei tag chapter ricavo le trame dei singoli racconti.
* - Occorre verificare per bene che l'ordine venga rispettato in modo da ordinarli correttamente.
* - Infine dal tag archivedat.a ricavo l'URL del racconto per verifica che sia come il link.
* - Ricavati tutti i dati inserisco sul DB tutti i singoli capitoli come singoli racconti ATDB assegnando le parti comuni a tutti i racconti.
*
*
*/
cRac rac = new cRac();
List<cRac> racs = new List<cRac>();
HtmlNodeCollection nodes;
try {
Console.WriteLine($"Old Milu - Importo: {FileFullPath}");
string filePathName = System.IO.Path.GetFileName(FileFullPath);
// Ricavo il nodo radice del racconto:
HtmlAgilityPack.HtmlDocument tdoc = new HtmlAgilityPack.HtmlDocument();
tdoc.Load(FileFullPath);
HtmlNode root = tdoc.DocumentNode;
if (root == null) {
// racconto non presente
return null;
}
List<string> origini = null;
List<string> tags = null;
string titolo = string.Empty;
string autore = string.Empty;
DateTime creato = DateTime.Now;
#region Info comuni a tutti i capitoli del racconto:
#region Origine
// Origine fissa:
origini = new List<string> { "Old Milu" };
#endregion
#region Titolo & Autore
// Titolo e autore si ricavano assieme: <div id="pagetitle"><a href="viewstory.php?sid={IDrac}">{Titolo}</a> by <a href="viewuser.php?uid={IDaut}">{Autor}</a></div>
try {
nodes = root.SelectNodes("//div[@id='pagetitle']//a[@href]");
foreach (HtmlNode nd in nodes) {
string href = nd.Attributes["href"].Value;
if (href.StartsWith("viewstory.php?sid=")) {
titolo = cTools.FormattaTesto(nd.InnerText.Trim(), false);
} else {
if (href.StartsWith("viewuser.php?uid=")) {
autore = cTools.FormattaTesto(nd.InnerText.Trim(), false);
}
}
}
if (string.IsNullOrEmpty(titolo)) {
Logger.Error($"Old Milu - Import - No Title - {filePathName}");
return null;
} else {
if (string.IsNullOrEmpty(autore)) {
Logger.Error($"Old Milu - Import - No Autor - {filePathName}");
return null;
}
}
} catch (Exception ex) { Logger.Error(string.Format("Fallita estrazione titolo/autore dal file {0}\r\n{1}", filePathName, ex.Message)); return null; }
#endregion
#region Tags: --> Testo dei nodi <div class="infobox">< div class="content"><a href='browse.php?type=categories&amp;catid={IDcat}'>{categoria}</a>
try {
nodes = root.SelectNodes("//div[@class='infobox']//div[@class='content']//a");
List<string> items = new List<string>();
foreach (HtmlNode nd in nodes) {
string href = nd.Attributes["href"].Value;
if (href.StartsWith("browse.php?type=categories")) {
items.Add(cTools.FormattaTesto(nd.InnerText.Replace("genere", "").Trim(), false));
}
}
//items.Sort();
items = items
.OrderBy(s => s) // ordina alfabeticamente
.Distinct() // elimina duplicati
.ToList();
tags = items;
if (tags.Count<1) {
Logger.Error($"Old Milu - Import - No Tags - {filePathName}");
return null;
}
} catch (Exception ex) { Logger.Warning(string.Format("Fallita estrazione Tags dal file {0}\r\n{1}", filePathName, ex.Message)); return null; }
#endregion
#region Creato
// Data estreatta dal testo del nodo <div class="infobox">< div class="content"> fra "Published{Published}Updated:
try {
nodes = root.SelectNodes("//div[@class='infobox']//div[@class='content']");
foreach (HtmlNode nd in nodes) {
string txt = nd.InnerText.Trim().Replace("&nbsp;", "");
int start = txt.LastIndexOf(" Published: ");
int stop = txt.LastIndexOf(" Updated: ");
string strData = txt.Substring(start + 11, stop - start - 11);
CultureInfo culture = CultureInfo.CreateSpecificCulture("it-IT");
DateTimeStyles styles = DateTimeStyles.None;
DateTime tmpDT = DateTime.Now;
if (!DateTime.TryParse(strData.Trim(), culture, styles, out creato)) {
Logger.Error($"Old Milu - Import - No data - {filePathName}");
}
}
} catch (Exception ex) { Logger.Warning(string.Format("Data non riconosciuta nel file {0}\r\n{1}", filePathName, ex.Message)); return null; }
#endregion
// I vari capitoli dei racconti sono descritti dai nodi <div class='chaptertitle'> e <div class='chapter'> in successione.
try {
HtmlNodeCollection capTitles = root.SelectNodes("//div[@class='chaptertitle']");
HtmlNodeCollection capText = root.SelectNodes("//div[@class='chapter']");
if ((capTitles.Count > 0) && (capTitles.Count == capText.Count)) {
// Trovato capitoli congruenti
for (int i = 0; i < capTitles.Count; i++) {
// Creo i racconti:
rac = new cRac();
rac.Title = titolo;
rac.SubTitle = capTitles[i].InnerText.Trim().Replace($"by {autore}","").Trim();
rac.Creato = creato;
rac.Updated = DateTime.Now;
//rac.Trama = cTools.FormattaTesto(capText[i].InnerHtml.Trim(), false);
rac.Trama = cTools.FormattaTesto(capText[i].InnerHtml.Trim(), true);
rac.Voto = "Non Letto";
rac.Autori = new List<string>();
rac.Autori.Add(autore);
rac.Tags = tags;
rac.Origini = origini;
rac.Notes = new List<Data.cNota>();
rac.Notes.Add(new Data.cNota("SrcFile", System.IO.Path.GetFileName(filePathName)));
// Inserisco il racconto nella collezione
if (rac.Validate()) { racs.Add(rac); }
}
} else {
// Capitoli non trovati o non congruenti
Logger.Error($"Old Milu - Import - No Capitoli - {filePathName}");
return null;
}
} catch (Exception ex) { Logger.Warning(string.Format("Fallita estrazione capitolo {0}\r\n{1}", filePathName, ex.Message)); return null; }
#endregion
Logger.Information($"Terminato estrazione racconti dal file: {filePathName}");
} catch (Exception ex) {
Logger.Error($"Old Milu - Import Error - {FileFullPath}: {ex.Message}");
Console.WriteLine($"Old Milu - Import Error - {FileFullPath}: {ex.Message}");
return null;
}
return racs;
}
protected virtual void Format_Insert_Tags(Data.cRac rac, List<string> items) {
// Per ora riporto tutti i tag rilevati, mentre in futuro dovrò:
// - parsare la lista e formattare correttamente i tag
// - ordinare la lista dei tag formattati ed eliminare i duplicati
// - se non sono rimasti tag, inserisco il tag generale per indicare che non vi sono tag
// - altrimenti inserisco tutti i tag rimasti.
rac.Tags = new List<string>();
try {
items.Sort();
string tmp = "";
foreach (string item in items) {
string it = item.Trim().ToLower();
if (tmp != it) {
#region switch per formattare il testo
switch (it) {
//case "racconti 69":
// rac.Tags.Add("69");
// break;
//case "abusi":
// rac.Tags.Add("Abusi");
// break;
//case "camgirl":
//case "chat e siti di incontri…":
//case "fiche":
// rac.Tags.Add("Altro");
// break;
//case "amatoriali":
// rac.Tags.Add("Amatoriali");
// break;
//case "anale":
// rac.Tags.Add("Anale");
// break;
//case "audio libri erotici":
//case "audio racconti erotici":
// rac.Tags.Add("Audio");
// break;
//case "bdsm":
// rac.Tags.Add("BDMS");
// break;
//case "bisex":
//case "bisex ♀":
//case "bisex ♂":
// rac.Tags.Add("Bisex");
// break;
//case "bondage":
// rac.Tags.Add("Bondage");
// break;
//case "bondage e sadomaso":
// rac.Tags.Add("Bondage");
// rac.Tags.Add("Sadomaso");
// break;
//case "bukkake":
// rac.Tags.Add("Bukkake");
// break;
//case "comici":
//case "comunità":
// rac.Tags.Add("Comico");
// break;
//case "concorso estate 2019":
//case "concorso natale 2018":
//case "decameron 2020":
// rac.Tags.Add("Concorso");
// break;
//case "confessioni":
// rac.Tags.Add("Confessioni");
// break;
//case "coppie":
//case "scambio di coppia":
//case "scambio di coppie":
// rac.Tags.Add("Coppie");
// break;
//case "cuckold":
//case "racconti cuckold":
// rac.Tags.Add("Cuckold");
// break;
//case "curiosità":
//case "curiosità sul sesso":
// rac.Tags.Add("Curiosità");
// break;
//case "dominazione":
//case "racconti di dominazione":
//case "schiavi&amp;padroni":
// rac.Tags.Add("Dominazione");
// break;
//case "doppia penetrazione":
// rac.Tags.Add("Doppia Penetrazione");
// break;
//case "esibizionismo":
// rac.Tags.Add("Esibizionismo");
// break;
//case "etero":
//case "lui & lei":
//case "racconti erotici etero":
// rac.Tags.Add("Etero");
// break;
//case "feticismo":
// rac.Tags.Add("Feticismo");
// break;
//case "fisting":
// rac.Tags.Add("Fisting");
// break;
//case "gang bang":
// rac.Tags.Add("Gang Bang");
// break;
//case "gay":
//case "racconti gay":
// rac.Tags.Add("Gay");
// break;
//case "gay & bisex":
//case "gay e bisex":
// rac.Tags.Add("Gay");
// rac.Tags.Add("Bisex");
// break;
//case "gay - travestiti":
// rac.Tags.Add("Gay");
// rac.Tags.Add("Trans");
// break;
//case "incesti":
//case "incesto":
//case "racconti erotici sull'incesto":
// rac.Tags.Add("Incesto");
// break;
//case "interviste":
//case "interviste erotiche":
// rac.Tags.Add("Intervista");
// break;
//case "lesbo":
//case "racconti erotici lesbo":
//case "saffico":
// rac.Tags.Add("Lesbo");
// break;
//case "autoerotismo":
//case "masturbazione":
//case "masturbazioni":
//case "racconti sull'autoerotismo":
// rac.Tags.Add("Masturbazione");
// break;
//case "milf":
// rac.Tags.Add("MILF");
// break;
//case "nudismo":
// rac.Tags.Add("Nudismo");
// break;
//case "orge":
//case "orgia":
//case "sesso di gruppo":
// rac.Tags.Add("Orge");
// break;
//case "pissing":
// rac.Tags.Add("Pissing");
// break;
//case "lirica erotica":
//case "poesia erotica":
//case "poesie":
//case "poesie erotiche":
// rac.Tags.Add("Poesia");
// break;
//case "pompini":
// rac.Tags.Add("Pompini");
// break;
//case "giochi erotici":
//case "prime esperienze":
//case "prime volte":
// rac.Tags.Add("Prime Esperienze");
// break;
//case "pulp":
// rac.Tags.Add("Pulp");
// break;
//case "sadomaso":
// rac.Tags.Add("Sadomaso");
// break;
//case "sensazioni":
//case "sentimentali":
// rac.Tags.Add("Sentimentali");
// break;
//case "cornuti":
//case "tradimenti":
//case "tradimento":
// rac.Tags.Add("Tradimento");
// break;
//case "racconti con trans":
//case "racconti trans":
//case "trans":
//case "trans e travestiti":
// rac.Tags.Add("Trans");
// break;
//case "trasgressivo":
// rac.Tags.Add("Trasgressivo");
// break;
//case "trio":
// rac.Tags.Add("Trio");
// break;
//case "uncategorized":
// rac.Tags.Add("Uncategorized");
// break;
//case "voyeur":
//case "voyeurismo":
// rac.Tags.Add("Voyeur");
// break;
//case "animali":
//case "zoofilia":
// rac.Tags.Add("Zoofilia");
// break;
//case "Gay":
// rac.Tags.Add("Gay");
// break;
//case "Racconti bisex":
// rac.Tags.Add("Bisex");
// break;
//case "Racconti etero":
// rac.Tags.Add("Etero");
// break;
//case "Racconti fetish":
// rac.Tags.Add("Feticismo");
// break;
//case "Racconti incesto":
// rac.Tags.Add("Incesto");
// break;
//case "Racconti lesbo":
// rac.Tags.Add("Lesbo");
// break;
//case "Racconti masturbazione":
// rac.Tags.Add("Masturbazione");
// break;
//case "Racconti mature":
// rac.Tags.Add("Mature");
// break;
//case "Racconti orge":
// rac.Tags.Add("Orge");
// break;
//case "Racconti prima volta":
// rac.Tags.Add("Prime Esperienze");
// break;
//case "Racconti ricatto":
// rac.Tags.Add("Ricatto");
// break;
//case "Racconti scambio di coppia":
// rac.Tags.Add("Coppie");
// break;
//case "Racconti sottomissione":
// rac.Tags.Add("Dominazione");
// break;
//case "Racconti tradimenti":
// rac.Tags.Add("Tradimento");
// break;
//case "Racconti trav":
//case "Trans":
// rac.Tags.Add("Trans");
// break;
default:
rac.Tags.Add(item);
break;
}
#endregion
tmp = it;
}//if
}//foreach
} catch (Exception ex) {
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
} finally {
if (rac.Tags.Count == 0) rac.Tags.Add("_None_");
}
}//function
}//class Service_Import_Milu
}//namespace A69WD.Service
+1 -1
View File
@@ -10,7 +10,7 @@
<PathImport>C:\Commesse\_zPrivate\A69WD\Test\Import</PathImport>
<!-- Numero di file massimo da gestire. -->
<MaxNumFile>1000</MaxNumFile>
<MaxNumFile>5</MaxNumFile>
<!-- Nome del database usato dall'applicazione. -->
<DBName>A69DB.db</DBName>
+54 -2
View File
@@ -30,6 +30,10 @@
this.sbStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.btnTest1 = new System.Windows.Forms.Button();
this.pnlTop = new System.Windows.Forms.Panel();
this.btnTest2 = new System.Windows.Forms.Button();
this.btnTest4 = new System.Windows.Forms.Button();
this.btnTest3 = new System.Windows.Forms.Button();
this.btnTest5 = new System.Windows.Forms.Button();
this.sb.SuspendLayout();
this.pnlTop.SuspendLayout();
this.SuspendLayout();
@@ -97,14 +101,18 @@
//
this.btnTest1.Location = new System.Drawing.Point(11, 5);
this.btnTest1.Name = "btnTest1";
this.btnTest1.Size = new System.Drawing.Size(62, 32);
this.btnTest1.Size = new System.Drawing.Size(99, 32);
this.btnTest1.TabIndex = 4;
this.btnTest1.Text = "Test";
this.btnTest1.Text = "Serializza";
this.btnTest1.UseVisualStyleBackColor = true;
this.btnTest1.Click += new System.EventHandler(this.btnTest1_Click);
//
// pnlTop
//
this.pnlTop.Controls.Add(this.btnTest5);
this.pnlTop.Controls.Add(this.btnTest4);
this.pnlTop.Controls.Add(this.btnTest3);
this.pnlTop.Controls.Add(this.btnTest2);
this.pnlTop.Controls.Add(this.btnTest1);
this.pnlTop.Dock = System.Windows.Forms.DockStyle.Top;
this.pnlTop.Location = new System.Drawing.Point(0, 0);
@@ -112,6 +120,46 @@
this.pnlTop.Size = new System.Drawing.Size(700, 42);
this.pnlTop.TabIndex = 0;
//
// btnTest2
//
this.btnTest2.Location = new System.Drawing.Point(113, 5);
this.btnTest2.Name = "btnTest2";
this.btnTest2.Size = new System.Drawing.Size(99, 32);
this.btnTest2.TabIndex = 5;
this.btnTest2.Text = "Deserializza";
this.btnTest2.UseVisualStyleBackColor = true;
this.btnTest2.Click += new System.EventHandler(this.btnTest2_Click);
//
// btnTest4
//
this.btnTest4.Location = new System.Drawing.Point(337, 5);
this.btnTest4.Name = "btnTest4";
this.btnTest4.Size = new System.Drawing.Size(99, 32);
this.btnTest4.TabIndex = 7;
this.btnTest4.Text = "Deserializza ALL";
this.btnTest4.UseVisualStyleBackColor = true;
this.btnTest4.Click += new System.EventHandler(this.btnTest4_Click);
//
// btnTest3
//
this.btnTest3.Location = new System.Drawing.Point(235, 5);
this.btnTest3.Name = "btnTest3";
this.btnTest3.Size = new System.Drawing.Size(99, 32);
this.btnTest3.TabIndex = 6;
this.btnTest3.Text = "Serializza ALL";
this.btnTest3.UseVisualStyleBackColor = true;
this.btnTest3.Click += new System.EventHandler(this.btnTest3_Click);
//
// btnTest5
//
this.btnTest5.Location = new System.Drawing.Point(459, 5);
this.btnTest5.Name = "btnTest5";
this.btnTest5.Size = new System.Drawing.Size(99, 32);
this.btnTest5.TabIndex = 9;
this.btnTest5.Text = "Import Milu";
this.btnTest5.UseVisualStyleBackColor = true;
this.btnTest5.Click += new System.EventHandler(this.btnTest5_Click);
//
// frmReader
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -141,5 +189,9 @@
private System.Windows.Forms.ToolStripStatusLabel sbStatusLabel;
private System.Windows.Forms.Button btnTest1;
private System.Windows.Forms.Panel pnlTop;
private System.Windows.Forms.Button btnTest2;
private System.Windows.Forms.Button btnTest4;
private System.Windows.Forms.Button btnTest3;
private System.Windows.Forms.Button btnTest5;
}
}
+62 -21
View File
@@ -61,9 +61,9 @@ namespace A69WD.UI {
mImpStart.Enabled = true;
mImpStop.Enabled = false;
// Update UI
pnlTop.Enabled = false;
pnlTop.Visible = false;
// TEST // Update UI
// TEST pnlTop.Enabled = false;
// TEST pnlTop.Visible = false;
}
@@ -697,7 +697,6 @@ namespace A69WD.UI {
// avvio il servizio
serviceCrawler.StartWorker();
}
void MenuItem_Skraping_Stop_Click(object sender, EventArgs e) {
// Update menu
mSkrStart.Enabled = false;
@@ -707,7 +706,6 @@ namespace A69WD.UI {
if (serviceCrawler != null) { serviceCrawler.StopWorker(); }
}
void MenuItem_Importer_Start_Click(object sender, EventArgs e) {
// Update menu
mSkrStart.Enabled = false;
@@ -719,7 +717,7 @@ namespace A69WD.UI {
ServiceImporter = new Service_Importer(sb);
// Per ora uso la directory di default, poi metteremo selezione
string path = Cfg.Settings.PathDownloadWorking;
string path = Cfg.Settings.PathImport;
// avvio il servizio
ServiceImporter.StartWorker(path);
@@ -735,35 +733,78 @@ namespace A69WD.UI {
if (ServiceImporter != null) { ServiceImporter.StopWorker(); }
}
void MenuItem_ShowLog_Click(object sender, EventArgs e) {
cTools.ShowOnNotepad(Cfg.Settings.PathFileLogs);
}
private void btnTest1_Click(object sender, EventArgs e) {
// Test skraping eRac
// Test serializzazione su file xml
// - Verifico path per il download
if (!System.IO.Directory.Exists(Cfg.Settings.PathDownloadWorking)) System.IO.Directory.CreateDirectory(Cfg.Settings.PathDownloadWorking);
// Preparo il servizio
serviceCrawler = new Service_Crawler(sb);
// Inserisco i link iniziali nella coda
if (!cLink_eRac.InsertStartLink(serviceCrawler)) {
Logger.Warning("eRac - Insert start link Fault");
sbStatusLabel.Text = "eRac fault.";
return;
// Serializzo 5 racconti casuali
for (int i = 0; i < 5; i++) {
cRac rac = App.DB.GetRacById(App.DB.GetRandomIDrac());
string path = System.IO.Path.Combine(Cfg.Settings.PathDownloadWorking, $"ATDB_Rac_{rac.strIDrac}.xml");
rac.SaveToXmlFile(path);
}
//// Inserisco link di un racconto:
//string url = "https://www.eroticiracconti.it/racconto/105286-nicole-gis-il-culto-della-terza-notte"; // "https://www.eroticiracconti.it/racconto/112763-elara-capitolo-2-il-cambiamento";
//string name = "eRac_112763-elara-capitolo-2-il-cambiamento.html";
//serviceCrawler.EnqueueUrl(new cLink_eRac(url, name));
}
private void btnTest2_Click(object sender, EventArgs e) {
// Test deserializzazione da file xml
string[] files = System.IO.Directory.GetFiles(Cfg.Settings.PathImport, "ATDB_*.xml");
foreach (string file in files) {
cRac rac = cRac.LoadFromXmlFile(file);
var res = App.DB.ImportRac(rac);
}
}
private void btnTest3_Click(object sender, EventArgs e) {
// Test serializzazione su file xml di tutti i racconti:
// - Verifico path per il download
if (!System.IO.Directory.Exists(Cfg.Settings.PathDownloadWorking)) System.IO.Directory.CreateDirectory(Cfg.Settings.PathDownloadWorking);
// - Ricavo il numero totale di racconti:
long nRac = App.DB.GetNumRacs();
// - Serializzo i racconti
for (long i = 0; i <= nRac; i++) {
cRac rac = App.DB.GetRacById(i);
if (rac == null) continue;
string path = System.IO.Path.Combine(Cfg.Settings.PathDownloadWorking, $"ATDB_Rac_{rac.strIDrac}.xml");
rac.SaveToXmlFile(path);
}
}
private void btnTest4_Click(object sender, EventArgs e) {
// Test deserializzazione da file xml
string[] files = System.IO.Directory.GetFiles(Cfg.Settings.PathImport, "ATDB_*.xml");
foreach (string file in files) {
cRac rac = cRac.LoadFromXmlFile(file);
var res = App.DB.ImportRac(rac);
}
}
private void btnTest5_Click(object sender, EventArgs e) {
// Test importer dal vecchio formato di Milu:
// - Preparo il servizio
ServiceImportMilu = new Service_Import_Milu(sb);
// - Per ora uso la directory di default, poi metteremo selezione
string path = Cfg.Settings.PathImport;
// avvio il servizio
serviceCrawler.StartWorker();
ServiceImportMilu.StartWorker(path);
}
Service_Import_Milu ServiceImportMilu = null;
}