/** * Verplaatst de logs van de oorspronkelijke omgeving naar een centrale plek (bestemming) * lokaal op de schijf in de bestemming */ private static void verplaatsenLogs(string pad) { // TODO hier nog uit het stuurbestand halen string bestemming = @"D:\huub_van_amelsvoort\data\iis_advancedlog"; string[] logBestandsNamen; try { logBestandsNamen = Directory.GetFiles(pad, "*.log", SearchOption.AllDirectories); foreach (string bestandNaam in logBestandsNamen) { if (File.Exists(bestandNaam)) { IISLogBestandObject iisLogBestand = new IISLogBestandObject(); iisLogBestand.CompleteNaam = bestandNaam; iisLogBestand.Naam = Path.GetFileName(bestandNaam); iisLogBestand.BestandsLengte = new FileInfo(bestandNaam).Length; iisLogBestanden.Add(iisLogBestand); } } } catch (Exception e) { DeFuncties.HuubLog("Fout in bepalenBestanden : " + e, true); DeFuncties.HuubLog("Fout in bepalenBestanden : " + e, false); } foreach (IISLogBestandObject bestand in iisLogBestanden) { try { string deBestemming = bestemming + @"\" + bestand.Naam; if (!File.Exists(deBestemming)) { DeFuncties.HuubLog(String.Format("Verplaats : {0} naar : {1}", bestand.CompleteNaam, deBestemming), true); DeFuncties.HuubLog(String.Format("Verplaats : {0} naar : {1}", bestand.CompleteNaam, deBestemming), false); File.Move(bestand.CompleteNaam, deBestemming); } } catch (Exception e) { DeFuncties.HuubLog(String.Format("Verplaats fout : {0} ; naam : {1}", e.Message, bestand), true); DeFuncties.HuubLog(String.Format("Verplaats fout : {0} ; naam : {1}", e.Message, bestand), false); } } }
/** * Hier start de applicatie vanuit Program.cs */ internal void doen() { deFuncties.wijzigConfig(); String startDatum = DateTime.Now.ToString("yyyyMMdd HH:mm:ss tt"); string pad = DeFuncties.stuurBestand.InputFolder; try { logBestandsNamen = Directory.GetFiles(pad, "*.log", System.IO.SearchOption.AllDirectories); int aantal = Directory.GetFiles(pad, "*.log", System.IO.SearchOption.AllDirectories).Length; foreach (string bestandNaam in logBestandsNamen) { string datum = DeFuncties.behandelDatum.ToString("yyyyMMdd"); bool bestaatBestand = File.Exists(bestandNaam); // zou eigenlijk altijd zo moeten zijn if (bestaatBestand && bestandNaam.Contains(".log") && bestandNaam.Contains(datum)) { IISLogBestandObject iisLogBestand = new IISLogBestandObject(); iisLogBestand.CompleteNaam = bestandNaam; iisLogBestand.BestandsLengte = new FileInfo(bestandNaam).Length; iisLogBestanden.Add(iisLogBestand); DeFuncties.HuubLog(String.Format("zoekBestanden lengte : {0,10:######} ; naam : {1}", iisLogBestand.BestandsLengte, iisLogBestand.CompleteNaam.Replace(pad, ""))); } } } catch (Exception e) { DeFuncties.HuubLog("Fout in zoekBestanden : " + e); } swGoedeRegel = false; string regel; foreach (IISLogBestandObject iisLogBestand in iisLogBestanden) { try { StreamReader bestand = new StreamReader(iisLogBestand.CompleteNaam); DeFuncties.HuubLog("Verwerk bestand : " + iisLogBestand.CompleteNaam, false); DeFuncties.HuubLog("Verwerk bestand : " + iisLogBestand.CompleteNaam); while ((regel = bestand.ReadLine()) != null) { if (regel.Contains("#Fields")) { int vergelijk = DeFuncties.stuurBestand.LogKop.CompareTo(regel); if (vergelijk == 0) { swGoedeRegel = true; } else { swGoedeRegel = false; DeFuncties.HuubLog("De kopregel voldoet niet aan de standaard !! " + regel, false); DeFuncties.HuubLog("De kopregel voldoet niet aan de standaard !! " + regel, true); } } else { if (swGoedeRegel && voorSelectieRegel(regel)) { deFuncties.verwerkGoedeRegel(regel); } } } bestand.Close(); } catch (Exception e) { DeFuncties.HuubLog("Fout tijdens openenen bestand : " + e.Message, false); DeFuncties.HuubLog("Fout tijdens openenen bestand : " + e.Message); } } DeFuncties.HuubLog("Start verwerking MySQL: " + DateTime.Now.ToString("yyyyMMdd HH:mm:ss tt"), true); DeFuncties.verwerkDeLogsObjecten(); DeFuncties.HuubLog("Einde verwerking MySQL: " + DateTime.Now.ToString("yyyyMMdd HH:mm:ss tt"), true); DeFuncties.HuubLog("Start verwerking: " + startDatum, false); DeFuncties.HuubLog("Einde verwerking: " + DateTime.Now.ToString("yyyyMMdd HH:mm:ss tt"), false); DeFuncties.HuubLog("Start verwerking: " + startDatum, true); DeFuncties.HuubLog("Einde verwerking: " + DateTime.Now.ToString("yyyyMMdd HH:mm:ss tt"), true); }