Beispiel #1
0
        /**
         * Controleer of de datum wordt meegegeven
         */
        internal bool CheckArgs(string[] args)
        {
            DeFuncties.automatisch = false;
            string tekstdatum = "";

            if (args.Length > 1)
            {
                return(false);
            }

            if (args.Length == 0)
            {
                // Zonder argumenten worden alle logs verplaatst
                // en wordt 2 dagen terug verwerkt
                DeFuncties.automatisch   = true;
                DeFuncties.behandelDatum = DateTime.Now;
                // Altijd de logs van 2 dagen terug, omdat die pas beschikbaar zijn
                DeFuncties.behandelDatum = DeFuncties.behandelDatum.AddDays(-2);
            }
            else
            {
                tekstdatum = args[0];
                try {
                    int jaar  = Int32.Parse(tekstdatum.Substring(0, 4));
                    int maand = Int32.Parse(tekstdatum.Substring(4, 2));
                    int dag   = Int32.Parse(tekstdatum.Substring(6, 2));

                    DeFuncties.behandelDatum = new DateTime(jaar, maand, dag, 0, 0, 0);
                } catch (Exception e) {
                    Debug.WriteLine("Datumfout : " + e.Message);
                    Console.WriteLine("Datumfout : " + e.Message);
                    return(false);
                }
            }
            DeFuncties.LogBestandNaam = String.Format("{0}\\VerwerkIISLogNaarDb3Onderdelen_{1}{2}.log", DeFuncties.stuurBestand.LogBestand
                                                      , DeFuncties.behandelDatum.ToString("yyyyMMdd"), DeFuncties.automatisch);

            DeFuncties.HuubLog("De log wordt geschreven naar : " + DeFuncties.LogBestandNaam, false);
            try {
                DeFuncties.logBestand = new StreamWriter(DeFuncties.LogBestandNaam, false);
            }
            catch (Exception e) {
                Debug.WriteLine("Openen logbestand fout : " + e.Message);
                Console.WriteLine("Openen logbestand fout : " + e.Message);
                System.Environment.Exit(-329561);
            }

            if (DeFuncties.automatisch)
            {
                DeFuncties.verplaatsDeLogs();
            }

            return(true);
        }
Beispiel #2
0
        /**
         * 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);
                }
            }
        }
Beispiel #3
0
        /**
         * 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);
        }
Beispiel #4
0
 /**
  * Indien geen of verkeerde argumenten zijn meegegeven.
  */
 internal void GeefGebruik()
 {
     DeFuncties.HuubLog("Gebruik programma : <verwerkdatum>", false);
     DeFuncties.HuubLog("of zonder argument automatische verwerking laatste dag !!!!", false);
 }
Beispiel #5
0
 /**
  * Instantie met DeFuncties
  */
 public Verwerk(DeFuncties deFuncties)
 {
     this.deFuncties = deFuncties;
 }