Beispiel #1
0
        public DateTime checkBegDate(string year, string month, string day, iniFile myIni)
        {
            int      result;
            DateTime begDateCorrected = new DateTime();

            if (year == "" || year == null || year.Substring(0, 1) != "2" || year.Length != 4 || Convert.ToInt32(year) > DateTime.Today.Year)
            {
                if (String.IsNullOrEmpty(myIni.Read("logDays")) || !Int32.TryParse(myIni.Read("logDays"), out result))
                {
                    year = DateTime.Today.AddDays(-7).Year.ToString();
                }
            }
            if (month == "" || month == null || month.Length > 2 || Convert.ToInt32(month) > 12)
            {
                month = DateTime.Today.AddDays(-7).Month.ToString();
            }
            if (day == "" || day == null || day.Length > 2 || Convert.ToInt32(day) > 31)
            {
                day = DateTime.Today.AddDays(-7).Day.ToString();
            }


            begDateCorrected = new DateTime(Convert.ToInt32(year), Convert.ToInt32(month), Convert.ToInt32(day));
            return(begDateCorrected);
        }
Beispiel #2
0
        public registry checkMachineType()
        {
            registry atmMachineType = new registry();

            iniFile myIni = new iniFile();

            if (Environment.Is64BitOperatingSystem)
            {
                machineType = machineType64;
            }

            if (machineType.GetValue("MachineType").ToString() == "" || machineType.GetValue("MachineType").ToString() == null)
            {
                myIni.Write("CRMLog", "false");
            }

            if (machineType.GetValue("MachineType").ToString().Substring(0, 3) == "H34")
            {
                applicationLog.WriteDebugLog("ATM Machine type is " + machineType.GetValue("MachineType").ToString());
                atmMachineType.type = "H34N";
            }
            else if (machineType.GetValue("MachineType").ToString().Substring(0, 3) == "H68")
            {
                string val = machineType.GetValue("MachineType").ToString().Substring(3, 1);

                if (machineType.GetValue("MachineType").ToString().Substring(3, 1) == "V")
                {
                    applicationLog.WriteDebugLog("ATM Machine type is " + machineType.GetValue("MachineType").ToString());
                    atmMachineType.type = "H68V";
                }
                else if (machineType.GetValue("MachineType").ToString().Substring(3, 1) == "N")
                {
                    applicationLog.WriteDebugLog("ATM Machine type is " + machineType.GetValue("MachineType").ToString());
                    atmMachineType.type = "H68N";
                }
            }

            else if (machineType.GetValue("MachineType").ToString().Substring(0, 3) != "H34" || machineType.GetValue("MachineType").ToString().Substring(0, 3) != "H68")
            {
                atmMachineType.type = "";
                myIni.Write("CRMLog", "false");
                applicationLog.WriteDebugLog("ATM Machine type is " + machineType.ToString());
            }
            return(atmMachineType);
        }
Beispiel #3
0
        public DateTime checkEndDate(string year, string month, string day, iniFile myIni)
        {
            DateTime begEndCorrected = new DateTime();

            if (year == "" || year == null || year.Substring(0, 1) != "2" || year.Length != 4 || Convert.ToInt32(year) > DateTime.Today.Year)
            {
                year = DateTime.Today.Year.ToString();
                //myIni.Write("logDateEndYear", DateTime.Today.Year.ToString());
            }
            if (month == "" || month == null || month.Length > 2 || Convert.ToInt32(month) > 12)
            {
                month = DateTime.Today.Month.ToString();
                //myIni.Write("logDateEndMonth", DateTime.Today.Month.ToString());
            }
            if (day == "" || day == null || day.Length > 2 || Convert.ToInt32(day) > 31)
            {
                day = DateTime.Today.Day.ToString();
                //myIni.Write("logDateEndDay", DateTime.Today.Day.ToString());
            }
            begEndCorrected = new DateTime(Convert.ToInt32(year), Convert.ToInt32(month), Convert.ToInt32(day));
            return(begEndCorrected);
        }
Beispiel #4
0
        public void checkRegistryKeys(string registryPath, string machineType, iniFile configIniFile)
        {
            RegistryKey regKeyPath = Registry.LocalMachine.OpenSubKey(registryPath, true);

            string[] valueNames = regKeyPath.GetValueNames();


            if (!valueNames.Contains("ReadDevLogDays"))
            {
                try
                {
                    regKeyPath.SetValue("ReadDevLogDays", configIniFile.Read("CRMLogDays"));
                    applicationLog.WriteDebugLog("ReadDevLogDays Registry Value Not Found, created for " + machineType);
                }
                catch (Exception ex)
                {
                    applicationLog.WriteDebugLog(ex.ToString());
                }
            }
            else if (valueNames.Contains("ReadDevLogDays"))
            {
                readDevLogDays = regKeyPath.GetValue("ReadDevLogDays").ToString();
                applicationLog.WriteDebugLog("readDevLogDays registry key found. And the value is " + regKeyPath.GetValue("ReadDevLogDays"));
            }



            if (!valueNames.Contains("ReadDevLogPath"))
            {
                try
                {
                    regKeyPath.SetValue("ReadDevLogPath", configIniFile.Read("CRMLogPath"));
                    applicationLog.WriteDebugLog("ReadDevLogPath Registry Value Not Found, created for " + machineType);
                }
                catch (Exception ex)
                {
                    applicationLog.WriteDebugLog(ex.ToString());
                }
            }

            else if (valueNames.Contains("ReadDevLogPath"))
            {
                readDevLogPath = regKeyPath.GetValue("ReadDevLogPath").ToString();
                applicationLog.WriteDebugLog("readDevLogPath registry key found. And the value is " + regKeyPath.GetValue("ReadDevLogPath"));
            }



            if (!valueNames.Contains("ReadDevLogReturn"))
            {
                try
                {
                    regKeyPath.SetValue("ReadDevLogReturn", "0");
                    applicationLog.WriteDebugLog("ReadDevLogReturn Registry Value Not Found, created for " + machineType);
                }
                catch (Exception ex)
                {
                    applicationLog.WriteDebugLog(ex.ToString());
                }
            }
            else if (valueNames.Contains("ReadDevLogReturn"))
            {
                readDevLogReturn = regKeyPath.GetValue("ReadDevLogReturn").ToString();

                applicationLog.WriteDebugLog("readDevLogDays registry key found. And the value is " + regKeyPath.GetValue("ReadDevLogReturn"));
            }
            //if (machineType == "H34")
            //{


            //    readValues = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCDM_CDM8240_XFS30");
            //    writeValues = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCDM_CDM8240_XFS30", true);

            //    //checkRegistryKeys(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCDM_CDM8240_XFS30", "H34", myIni);


            //    readDevLogReturn = readValues.GetValue("ReadDevLogReturn").ToString();
            //    readDevLogDays = readValues.GetValue("ReadDevLogDays").ToString();
            //    readDevLogPath = readValues.GetValue("ReadDevLogPath").ToString();


            //}
            //else if (machineType == "H68")
            //{
            //    readValues = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCRM_CRM9250_XFS30");
            //    writeValues = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCRM_CRM9250_XFS30", true);

            //    //checkRegistryKeys(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCRM_CRM9250_XFS30", "H68", myIni);

            //    readDevLogReturn = readValues.GetValue("ReadDevLogReturn").ToString();
            //    readDevLogDays = readValues.GetValue("ReadDevLogDays").ToString();
            //    readDevLogPath = readValues.GetValue("ReadDevLogPath").ToString();



            //}
        }
Beispiel #5
0
        public string returnPath()
        {
            var retVal = new iniFile();

            return(retVal.Path);
        }
Beispiel #6
0
        public void checkIniFile(iniFile copyLogConsoleIniFile)
        {
            try
            {
                atm    cashDevType = new atm();
                string atmType     = cashDevType.checkAtmType();
                var    list        = new List <string>();


                using (var sr = new StreamReader(copyLogConsoleIniFile.Path))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        list.Add(line);
                    }
                }


                List <string> iniContents = list;


                string ad = System.Reflection.Assembly.GetEntryAssembly().Location;
                ad = ad.Replace(".exe", ".ini");

                if (iniContents.Count() != 61)
                {
                    createIniFile(ad, 1);
                    applicationLog.WriteDebugLog("There is an inconsistency in the configuration file, please use the newly created one: copyLogConsole.ini.");
                }

                registry newReg     = new registry();
                string   CRMLogPath = newReg.readDevLogPath;
                if (String.IsNullOrEmpty(iniContents[0]))
                {
                    iniContents[0] = "[copyLogsConsole]";
                }
                bool outresult;
                if (iniContents[1].EndsWith("=") || !Boolean.TryParse(iniContents[1].Split('=')[1], out outresult))
                {
                    iniContents[1] = "sp4Log=true";
                }
                if (String.IsNullOrEmpty(iniContents[2]))
                {
                    iniContents[2] = "//do you want to copy SP4 logs - true=yes false=no";
                }
                if (iniContents[3].EndsWith("="))
                {
                    iniContents[3] = @"sp4LogPath=C:\GrgBanking\Log";
                }
                if (String.IsNullOrEmpty(iniContents[4]))
                {
                    iniContents[4] = "//where are the SP4 logs located?";
                }
                if (iniContents[5].EndsWith("="))
                {
                    iniContents[5] = "sp4LogName=grgsp.grglog";
                }
                if (String.IsNullOrEmpty(iniContents[6]))
                {
                    iniContents[6] = "//name of the actual SP4 log file";
                }
                if (iniContents[7] == "" || !Boolean.TryParse(iniContents[7].Split('=')[1], out outresult))
                {
                    iniContents[7] = "sp5Log=false";
                }
                if (String.IsNullOrEmpty(iniContents[8]))
                {
                    iniContents[8] = "//do you want to copy SP5 logs - true=yes false=no";
                }
                if (iniContents[9].EndsWith("="))
                {
                    iniContents[9] = @"sp5LogPath=C:\GrgBanking\Log";
                }
                if (String.IsNullOrEmpty(iniContents[10]))
                {
                    iniContents[10] = "//where is the SP5 log located?";
                }
                if (iniContents[11].EndsWith("="))
                {
                    iniContents[11] = "sp5LogName=GrgLog.dxdb";
                }
                if (String.IsNullOrEmpty(iniContents[12]))
                {
                    iniContents[12] = "//name of the SP5 log file";
                }
                if (iniContents[13] == "" || !Boolean.TryParse(iniContents[13].Split('=')[1], out outresult))
                {
                    iniContents[13] = "CRMLog=true";
                }
                if (String.IsNullOrEmpty(iniContents[14]))
                {
                    iniContents[14] = "//do you want to copy CRM logs?	- true=yes false=no";
                }
                if (iniContents[15].EndsWith("="))
                {
                    iniContents[15] = @"CRMLogPath=C:\GrgBanking\log\CRMLog";
                }
                if (String.IsNullOrEmpty(iniContents[16]))
                {
                    iniContents[16] = "//where are the CRM logs located?";
                }
                if (iniContents[17].EndsWith("="))
                {
                    iniContents[17] = "CRMLogName=";
                }
                if (String.IsNullOrEmpty(iniContents[18]))
                {
                    iniContents[18] = "//name of the CRM log files";
                }
                if (iniContents[19] == "" || !Boolean.TryParse(iniContents[19].Split('=')[1], out outresult))
                {
                    iniContents[19] = "driverLog=false";
                }
                if (String.IsNullOrEmpty(iniContents[20]))
                {
                    iniContents[20] = "//do you want to copy driverlogs? - true=yes false=no";
                }
                if (iniContents[21].EndsWith("="))
                {
                    iniContents[21] = @"driverLogPath=C:\Program Files\GrgBanking\GRGXFSSP\DevDriverLog\";
                }
                if (String.IsNullOrEmpty(iniContents[22]))
                {
                    iniContents[22] = "//where are the driver logs located?";
                }
                if (iniContents[23].EndsWith("="))
                {
                    iniContents[23] = "driverLogName=";
                }
                if (String.IsNullOrEmpty(iniContents[24]))
                {
                    iniContents[24] = "//name of the driver log file";
                }
                if (iniContents[25] == "" || !Boolean.TryParse(iniContents[25].Split('=')[1], out outresult))
                {
                    iniContents[25] = "duniteLog=false";
                }
                if (String.IsNullOrEmpty(iniContents[26]))
                {
                    iniContents[26] = "//do you want to copy dunite logs? - true=yes false=no";
                }
                if (iniContents[27].EndsWith("="))
                {
                    iniContents[27] = @"duniteLogPath=C:\GrgBanking\log\hardware\";
                }
                if (String.IsNullOrEmpty(iniContents[28]))
                {
                    iniContents[28] = "//where are the dunite logs located?";
                }
                if (iniContents[29].EndsWith("="))
                {
                    iniContents[29] = "duniteLogName=";
                }
                if (String.IsNullOrEmpty(iniContents[30]))
                {
                    iniContents[30] = "//what is the name of the dunitelog";
                }
                if (iniContents[31] == "" || !Boolean.TryParse(iniContents[31].Split('=')[1], out outresult))
                {
                    iniContents[31] = "XFSManLog=false";
                }
                if (String.IsNullOrEmpty(iniContents[32]))
                {
                    iniContents[32] = "//do you want to copy XFS manager logs? - true=yes false=no";
                }
                if (iniContents[33].EndsWith("="))
                {
                    iniContents[33] = @"XFSManLogPath=C:\GrgBanking\log\GrgXfsManager\";
                }
                if (String.IsNullOrEmpty(iniContents[34]))
                {
                    iniContents[34] = "//where are the XFSMan logs located?";
                }
                if (iniContents[35].EndsWith("="))
                {
                    iniContents[35] = "XFSMANLogName=GrgXfsManager.log";
                }
                if (String.IsNullOrEmpty(iniContents[36]))
                {
                    iniContents[36] = "//name of the XFSMan log";
                }
                if (iniContents[37] == "" || !Boolean.TryParse(iniContents[37].Split('=')[1], out outresult))
                {
                    iniContents[37] = "YDCLog=false";
                }
                if (String.IsNullOrEmpty(iniContents[38]))
                {
                    iniContents[38] = "//Do you want to copy YDC logs? - true=yes false=no";
                }
                if (iniContents[39] == "" || !Boolean.TryParse(iniContents[39].Split('=')[1], out outresult))
                {
                    iniContents[39] = "winSystemLog=false";
                }
                if (String.IsNullOrEmpty(iniContents[40]))
                {
                    iniContents[40] = "//Do you wantto export the Windows system log? - true=yes false=no";
                }
                if (iniContents[41] == "" || !Boolean.TryParse(iniContents[41].Split('=')[1], out outresult))
                {
                    iniContents[41] = "logDateCriteria=false";
                }
                if (String.IsNullOrEmpty(iniContents[42]))
                {
                    iniContents[42] = "//True for date criteria, logDateBeg and logDateEnd will be used";
                }

                try
                {
                    string year  = iniContents[43].Split('=')[1];
                    string month = iniContents[44].Split('=')[1];
                    string day   = iniContents[45].Split('=')[1];



                    DateTime begindate = new DateTime(Convert.ToInt32(year), Convert.ToInt32(month), Convert.ToInt32(day));
                }
                catch (Exception ex)
                {
                    applicationLog.WriteDebugLog(ex.ToString());
                    iniContents[43] = "logDateBegYear=" + DateTime.Today.AddDays(-7).Year.ToString();
                    iniContents[44] = "logDateBegMonth=" + DateTime.Today.AddDays(-7).Month.ToString();
                    iniContents[45] = "logDateBegDay=" + DateTime.Today.AddDays(-7).Day.ToString();
                    copyLogConsoleIniFile.Write("logDateBegYear", DateTime.Today.AddDays(-7).Year.ToString());
                    copyLogConsoleIniFile.Write("logDateBegMonth", DateTime.Today.AddDays(-7).Month.ToString());
                    copyLogConsoleIniFile.Write("logDateBegDay", DateTime.Today.AddDays(-7).Day.ToString());

                    iniContents[47] = "logDateEndYear=" + DateTime.Today.Year.ToString();
                    iniContents[48] = "logDateEndMonth=" + DateTime.Today.Month.ToString();
                    iniContents[49] = "logDateEndDay=" + DateTime.Today.Day.ToString();

                    copyLogConsoleIniFile.Write("logDateEndYear", DateTime.Today.Year.ToString());
                    copyLogConsoleIniFile.Write("logDateEndMonth", DateTime.Today.Month.ToString());
                    copyLogConsoleIniFile.Write("logDateEndDay", DateTime.Today.Day.ToString());
                    applicationLog.WriteDebugLog("There was a problem with the dates. Corrected to last 7 days.");
                }


                //if (iniContents[43].EndsWith("=")  || iniContents[43].Split('=')[1].Substring(0, 1) != "2" || iniContents[43].Split('=')[1].Length != 4)
                //{ iniContents[43] = "logDateBegYear=" + DateTime.Today.AddDays(-7).Year.ToString(); }

                //if (iniContents[44].EndsWith("=") || iniContents[44].Split('=')[1].Length > 2)
                //{ iniContents[44] = "logDateBegMonth=" + DateTime.Today.AddDays(-7).Month.ToString(); }

                //if (iniContents[45].EndsWith("=") || iniContents[45].Split('=')[1].Length > 2 )
                //{ iniContents[45] = "logDateBegDay=" + DateTime.Today.AddDays(-7).Day.ToString(); }


                if (String.IsNullOrEmpty(iniContents[46]))
                {
                    iniContents[46] = "//SP4 logs'will be copied based on the date criteria, this parameter will be the first day";
                }


                //if (iniContents[47].EndsWith("=") || iniContents[47].Split('=')[1].Substring(0, 1) != "2" || iniContents[47].Split('=')[1].Length != 4)
                //{ iniContents[47] = "logDateEndYear=" + DateTime.Today.Year.ToString(); }

                //if (iniContents[48].EndsWith("=") ||  iniContents[48].Split('=')[1].Length != 2)
                //{ iniContents[48] = "logDateEndMonth=" + DateTime.Today.Month.ToString(); }

                //if (iniContents[49].EndsWith("=") || Convert.ToInt32(iniContents[49].Split('=')[1]) > 31)
                //{ iniContents[49] = "logDateEndDay=" + DateTime.Today.Day.ToString(); }


                if (String.IsNullOrEmpty(iniContents[50]))
                {
                    iniContents[50] = "//SP4 logs'will be copied based on the date criteria, this parameter will be the last day";
                }

                if (iniContents[51] == "" || !Boolean.TryParse(iniContents[51].Split('=')[1], out outresult))
                {
                    iniContents[51] = "logIntervalCriteria=true";
                }
                if (String.IsNullOrEmpty(iniContents[52]))
                {
                    iniContents[52] = "//True for interval criteria, the logs will be copied based on the days criteria";
                }
                if (iniContents[53].EndsWith("="))
                {
                    iniContents[53] = "logDays=7";
                }
                if (String.IsNullOrEmpty(iniContents[54]))
                {
                    iniContents[54] = "//for ex. 10 means the the latest 10 days' SP4 logs will be copied. ";
                }
                if (iniContents[55].EndsWith("="))
                {
                    iniContents[55] = @"outputDirectory=c:\GRGLogs";
                }
                if (String.IsNullOrEmpty(iniContents[56]))
                {
                    iniContents[56] = "//where all the logs will be copied";
                }
                if (iniContents[57].EndsWith("="))
                {
                    iniContents[57] = "CRMLogDays=1";
                }
                if (String.IsNullOrEmpty(iniContents[58]))
                {
                    iniContents[58] = "//for SP package registry values, how many days for the CRM log will be generated";
                }
                if (iniContents[59].EndsWith("="))
                {
                    iniContents[59] = "atmType=" + atmType;
                }
                if (String.IsNullOrEmpty(iniContents[60]))
                {
                    iniContents[60] = "//What is the ATM type (H68 or H34)";
                }

                #region comment
                //if (copyLogConsoleIniFile.Read("sp4Log") == "" || copyLogConsoleIniFile.Read("sp4Log") != "true" || copyLogConsoleIniFile.Read("sp4Log") != "false")
                //{
                //    copyLogConsoleIniFile.Write("sp4Log", "true");

                //}
                //if (copyLogConsoleIniFile.Read("sp4LogPath") == "")
                //    copyLogConsoleIniFile.Write("sp4LogPath", @"C:\GrgBanking\Log");
                //if (copyLogConsoleIniFile.Read("sp5Log") == "" || copyLogConsoleIniFile.Read("sp5Log") != "true" || copyLogConsoleIniFile.Read("sp5Log") != "false")
                //    copyLogConsoleIniFile.Write("sp5Log", "sp5Log");
                //if (copyLogConsoleIniFile.Read("sp5LogName") == "")
                //    copyLogConsoleIniFile.Write("sp5LogName", "GrgLog.dxdb");
                //if (copyLogConsoleIniFile.Read("sp5LogPath") == "")
                //    copyLogConsoleIniFile.Write("sp5LogPath", @"C:\GrgBanking\Log");
                //if (copyLogConsoleIniFile.Read("CRMLog") == "" || copyLogConsoleIniFile.Read("CRMLog") != "true" || copyLogConsoleIniFile.Read("CRMLog") != "false")
                //    copyLogConsoleIniFile.Write("CRMLog", "true");
                //if (copyLogConsoleIniFile.Read("CRMLogPath") == "")
                //    copyLogConsoleIniFile.Write("CRMLogPath", CRMLogPath);
                //if (copyLogConsoleIniFile.Read("CRMLogName") == "")
                //    copyLogConsoleIniFile.Write("CRMLogName", "");
                //if (copyLogConsoleIniFile.Read("driverLog") == "" || copyLogConsoleIniFile.Read("driverLog") != "true" || copyLogConsoleIniFile.Read("driverLog") != "false")
                //    copyLogConsoleIniFile.Write("driverLog", "false");
                //if (copyLogConsoleIniFile.Read("driverLogPath") == "")
                //    copyLogConsoleIniFile.Write("driverLogPath", @"C:\Program Files\GrgBanking\GRGXFSSP\DevDriverLog\");
                //if (copyLogConsoleIniFile.Read("driverLogName") == "")
                //    copyLogConsoleIniFile.Write("driverLogName", "");
                //if (copyLogConsoleIniFile.Read("duniteLog") == "" || copyLogConsoleIniFile.Read("duniteLog") != "true" || copyLogConsoleIniFile.Read("duniteLog") != "false")
                //    copyLogConsoleIniFile.Write("duniteLog", "false");
                //if (copyLogConsoleIniFile.Read("duniteLogPath") == "")
                //    copyLogConsoleIniFile.Write("duniteLogPath", @"C:\GrgBanking\log\hardware\");
                //if (copyLogConsoleIniFile.Read("duniteLogName") == "")
                //    copyLogConsoleIniFile.Write("duniteLogName", "");
                //if (copyLogConsoleIniFile.Read("XFSManLog") == "" || copyLogConsoleIniFile.Read("XFSManLog") != "true" || copyLogConsoleIniFile.Read("XFSManLog") != "false")
                //    copyLogConsoleIniFile.Write("XFSManLog", "false");
                //if (copyLogConsoleIniFile.Read("XFSManLogPath") == "")
                //    copyLogConsoleIniFile.Write("XFSManLogPath", @"C:\GrgBanking\log\GrgXfsManager\");
                //if (copyLogConsoleIniFile.Read("XFSMANLogName") == "")
                //    copyLogConsoleIniFile.Write("XFSMANLogName", "GrgXfsManager.log");
                //if (copyLogConsoleIniFile.Read("YDCLog") == "" || copyLogConsoleIniFile.Read("YDCLog") != "true" || copyLogConsoleIniFile.Read("YDCLog") != "false")
                //    copyLogConsoleIniFile.Write("YDCLog", "false");
                //if (copyLogConsoleIniFile.Read("winSystemLog") == "" || copyLogConsoleIniFile.Read("winSystemLog") != "true" || copyLogConsoleIniFile.Read("winSystemLog") != "false")
                //    copyLogConsoleIniFile.Write("winSystemLog", "false");
                //if (copyLogConsoleIniFile.Read("logDateCriteria") == "" || copyLogConsoleIniFile.Read("logDateCriteria") != "true" || copyLogConsoleIniFile.Read("logDateCriteria") != "false")
                //    copyLogConsoleIniFile.Write("logDateCriteria", "false");
                //if (copyLogConsoleIniFile.Read("logDateBegYear") == "")
                //    copyLogConsoleIniFile.Write("logDateBegYear", DateTime.Today.Year.ToString());
                //if (copyLogConsoleIniFile.Read("logDateBegMonth") == "")
                //    copyLogConsoleIniFile.Write("logDateBegMonth", DateTime.Today.AddDays(-7).Month.ToString());
                //if (copyLogConsoleIniFile.Read("logDateBegDay") == "")
                //    copyLogConsoleIniFile.Write("logDateBegDay", DateTime.Today.AddDays(-7).Day.ToString());
                //if (copyLogConsoleIniFile.Read("logDateEndYear") == "")
                //    copyLogConsoleIniFile.Write("logDateEndYear", DateTime.Today.Year.ToString());
                //if (copyLogConsoleIniFile.Read("logDateEndMonth") == "")
                //    copyLogConsoleIniFile.Write("logDateEndMonth", DateTime.Today.Month.ToString());
                //if (copyLogConsoleIniFile.Read("logDateEndDay") == "")
                //    copyLogConsoleIniFile.Write("logDateEndDay", DateTime.Today.Day.ToString());
                //if (copyLogConsoleIniFile.Read("logIntervalCriteria") == "" || copyLogConsoleIniFile.Read("logIntervalCriteria") != "true" || copyLogConsoleIniFile.Read("logIntervalCriteria") != "false")
                //    copyLogConsoleIniFile.Write("logIntervalCriteria", "true");
                //if (copyLogConsoleIniFile.Read("logDays") == "")
                //    copyLogConsoleIniFile.Write("logDays", "7");
                //if (copyLogConsoleIniFile.Read("outputDirectory") == "")
                //    copyLogConsoleIniFile.Write("outputDirectory", @"C:\GrgLogs");
                //if (copyLogConsoleIniFile.Read("CRMLogDays") == "")
                //    copyLogConsoleIniFile.Write("CRMLogDays", "1");
                //if (copyLogConsoleIniFile.Read("CRM/CDM") == "")
                //    copyLogConsoleIniFile.Write("CRM/CDM", "");
                #endregion



                if (!Directory.Exists(iniContents[3]))
                {
                    iniContents[3] = @"sp4LogPath=C:\GrgBanking\Log";
                }


                if (!Directory.Exists(iniContents[9]))
                {
                    iniContents[9] = @"sp5LogPath=C:\GrgBanking\Log";
                }


                if (!Directory.Exists(iniContents[15]))
                {
                    iniContents[15] = @"CRMLogPath=C:\GrgBanking\log\CRMLog";
                }


                if (!Directory.Exists(iniContents[21]))
                {
                    iniContents[21] = @"driverLogPath=C:\Program Files\GrgBanking\GRGXFSSP\DevDriverLog\";
                }


                if (!Directory.Exists(iniContents[27]))
                {
                    iniContents[27] = @"duniteLogPath=C:\GrgBanking\log\hardware\";
                }


                if (!Directory.Exists(iniContents[33]))
                {
                    iniContents[33] = @"XFSManLogPath=C:\GrgBanking\log\GrgXfsManager\";
                }

                string regexFolder = @"^.\:\\$";

                if (System.Text.RegularExpressions.Regex.IsMatch(copyLogConsoleIniFile.Read("outputDirectory"), regexFolder))
                {
                    copyLogConsoleIniFile.Write("outputDirectory", @"C:\GrgLogs");
                }

                try
                {
                    Directory.CreateDirectory(copyLogConsoleIniFile.Read("outputDirectory"));
                }
                catch (Exception ex)
                {
                    copyLogsConsole.applicationLog.WriteDebugLog(ex.ToString());
                    copyLogConsoleIniFile.Write("outputDirectory", @"C:\GrgLogs");
                }

                File.WriteAllText(copyLogConsoleIniFile.Path, String.Empty);

                for (int i = 0; i < iniContents.Count(); i++)
                {
                    File.AppendAllText(copyLogConsoleIniFile.Path, iniContents[i] + "\r\n");
                }
            }
            catch (Exception ex)
            {
                applicationLog.WriteDebugLog(ex.ToString());
            }
        }
Beispiel #7
0
        static int Main(string[] args)
        {
            #region preparation

            string logStatusReturned = applicationLog.checkLogFileSize();

            copyLogsConsole.applicationLog.WriteDebugLog("<-------------------------Start-of-log-file------------------------->");

            copyLogsConsole.applicationLog.WriteDebugLog("This package is developed for GarantiBBVABank. Supports H34,H68N and H68V series. With zip option. For both 32 and 64 bit Windows Operating Systems.");


            copyLogsConsole.applicationLog.WriteDebugLog(logStatusReturned);

            copyLogsConsole.applicationLog.WriteDebugLog("Begin.");

            var      watch        = System.Diagnostics.Stopwatch.StartNew();
            iniFile  myIni        = new iniFile();
            registry checkRegKeys = new registry();
            atm      newATM       = new atm();
            try
            {
                if (Environment.Is64BitOperatingSystem)
                {
                    applicationLog.WriteDebugLog("OS is 64 bit");
                }
                else
                {
                    applicationLog.WriteDebugLog("OS is 32 bit");
                }
            }
            catch (Exception ex)
            {
                applicationLog.WriteDebugLog(ex.ToString());
            }

            copyLogsConsole.applicationLog.WriteDebugLog("Checking ATM type...");

            string cashDevType = newATM.checkAtmType();
            copyLogsConsole.applicationLog.WriteDebugLog("ATM is " + cashDevType);
            //set timer
            try
            {
                copyLogsConsole.applicationLog.WriteDebugLog("Checking if ini file exists...");
                string ad = System.Reflection.Assembly.GetEntryAssembly().Location;
                ad = ad.Replace(".exe", ".ini");
                myIni.IniFile(ad);
                if (!File.Exists(ad))
                {
                    myIni.createIniFile(ad);
                    copyLogsConsole.applicationLog.WriteDebugLog("Ini file not found, created");
                }
                else if (File.Exists(ad))
                {
                    //myIni.checkIniFile(myIni);

                    applicationLog.WriteDebugLog("Ini file has found");
                }
            }
            catch (Exception ex)
            {
                applicationLog.WriteDebugLog(ex.ToString());
            }

            try
            {
                applicationLog.WriteDebugLog("Checking registry keys for CRM/CDM log keys...");
                if (cashDevType == "H68N")
                {
                    if (Environment.Is64BitOperatingSystem)
                    {
                        checkRegKeys.checkRegistryKeys(@"SOFTWARE\WOW6432Node\XFS\PHYSICAL_SERVICES\GrgCRM_CRM9250_XFS30", "H68N", myIni); applicationLog.WriteDebugLog("ATM type is H68N, checking SOFTWARE\\WOW6432Node\\XFS\\PHYSICAL_SERVICES\\GrgCRM_CRM9250_XFS30 keys.");
                    }
                    else
                    {
                        checkRegKeys.checkRegistryKeys(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCRM_CRM9250_XFS30", "H68N", myIni); applicationLog.WriteDebugLog("ATM type is H68N, checking SOFTWARE\\XFS\\PHYSICAL_SERVICES\\GrgCRM_CRM9250_XFS30 keys.");
                    }

                    //checkRegKeys.checkRegistryKeys(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCRM_CRM9250_XFS30", "H68N", myIni);
                    myIni.Write("atmType", "H68N");
                    applicationLog.WriteDebugLog("ATM type is H68N, checking SOFTWARE\\XFS\\PHYSICAL_SERVICES\\GrgCRM_CRM9250_XFS30 keys.");
                }
                if (cashDevType == "H34")
                {
                    if (Environment.Is64BitOperatingSystem)
                    {
                        checkRegKeys.checkRegistryKeys(@"SOFTWARE\WOW6432Node\XFS\PHYSICAL_SERVICES\GrgCDM_CDM8240_XFS30", "H34", myIni); applicationLog.WriteDebugLog("ATM type is H34, checking SOFTWARE\\WOW6432Node\\XFS\\PHYSICAL_SERVICES\\GrgCDM_CDM8240_XFS30 keys.");
                    }
                    else
                    {
                        checkRegKeys.checkRegistryKeys(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCDM_CDM8240_XFS30", "H34", myIni); applicationLog.WriteDebugLog("ATM type is H34, checking SOFTWARE\\XFS\\PHYSICAL_SERVICES\\GrgCDM_CDM8240_XFS30 keys.");
                    }

                    //checkRegKeys.checkRegistryKeys(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCDM_CDM8240_XFS30", "H34", myIni);
                    myIni.Write("atmType", "H34");
                }
                if (cashDevType == "H68V")
                {
                    applicationLog.WriteDebugLog("ATM type is H68V, no need to check the registry keys.");
                }
            }
            catch (Exception ex)
            {
                copyLogsConsole.applicationLog.WriteDebugLog(ex.ToString());
            }


            string targetPath = "";

            //check that ini file has the outputDirectory
            if (myIni.Read("outputDirectory") == "")
            {
                targetPath = @"C:\GrgLogs";
                applicationLog.WriteDebugLog("Target path is: " + targetPath);
            }
            else if (myIni.Read("outputDirectory") != "")
            {
                targetPath = myIni.Read("outputDirectory");
                applicationLog.WriteDebugLog("Target path is: " + targetPath);
            }

            //delete and recreate output directory
            if (System.IO.Directory.Exists(targetPath))
            {
                applicationLog.WriteDebugLog("Delete the contents of the target directory: " + targetPath);

                try
                {
                    System.IO.DirectoryInfo di = new DirectoryInfo(targetPath);
                    Thread.Sleep(3000);
                    foreach (FileInfo file in di.GetFiles())
                    {
                        file.Delete();
                    }
                    foreach (DirectoryInfo dir in di.GetDirectories())
                    {
                        dir.Delete(true);
                    }

                    //System.IO.Directory.Delete(targetPath, true);
                    //Thread.Sleep(3000);
                    applicationLog.WriteDebugLog("The contents of the target log folder have been deleted.");
                }
                catch (Exception ex)
                {
                    applicationLog.WriteDebugLog(ex.ToString());
                }
            }

            if (!System.IO.Directory.Exists(targetPath))
            {
                try
                {
                    System.IO.Directory.CreateDirectory(targetPath);
                    applicationLog.WriteDebugLog("Target log folder: " + targetPath + "has been created.");
                }
                catch (Exception ex)
                {
                    applicationLog.WriteDebugLog(ex.ToString());
                    applicationLog.WriteDebugLog("Target path: " + targetPath + " cannot be created");

                    targetPath = @"C:\GrgLogs";
                    applicationLog.WriteDebugLog("Target path: is C:\\GrgLogs");
                    System.IO.Directory.CreateDirectory(targetPath);
                }
            }

            applicationLog.WriteDebugLog("Log Copy begins.");
            applicationLog.WriteDebugLog("Reading date information from ini file...");
            string begDateYear  = myIni.Read("logDateBegYear");
            string begDateMonth = myIni.Read("logDateBegMonth");
            string begDateDay   = myIni.Read("logDateBegDay");
            string endDateYear  = myIni.Read("logDateEndYear");
            string endDateMonth = myIni.Read("logDateEndMonth");
            string endDateDay   = myIni.Read("logDateEndDay");

            date dateCheck = new date();
            applicationLog.WriteDebugLog("Checking beginning and ending days validity...");

            DateTime begDate = dateCheck.checkBegDate(begDateYear, begDateMonth, begDateDay, myIni);
            DateTime endDate = dateCheck.checkEndDate(endDateYear, endDateMonth, endDateDay, myIni);


            try
            {
                begDate = new DateTime(Convert.ToInt32(begDateYear), Convert.ToInt32(begDateMonth), Convert.ToInt32(begDateDay));
                endDate = new DateTime(Convert.ToInt32(endDateYear), Convert.ToInt32(endDateMonth), Convert.ToInt32(endDateDay));
            }
            catch (Exception ex)
            {
                applicationLog.WriteDebugLog(ex.ToString());
                begDate = DateTime.Today.AddDays(-7);
                endDate = DateTime.Today;
            }
            #endregion

            #region getLogDatesArray
            date logDates = new date();
            applicationLog.WriteDebugLog("Entered getLogDatesArray section. Creating log days array...");

            List <DateTime> logDaysArray = new List <DateTime>();
            try
            {
                if (Convert.ToBoolean(myIni.Read("logDateCriteria")) == true)
                {
                    logDaysArray = logDates.getlogDates(begDate, endDate);
                }
                else if (Convert.ToBoolean(myIni.Read("logIntervalCriteria")) == true)
                {
                    logDaysArray = logDates.getlogDates(Convert.ToInt32(myIni.Read("logDays")));
                }
                else if (myIni.Read("logDateCriteria") == "" && "logIntervalCriteria" == "")
                {
                    logDaysArray = logDates.getlogDates(Convert.ToInt32(myIni.Read("logDays")));
                }
            }
            catch (Exception ex)
            {
                copyLogsConsole.applicationLog.WriteDebugLog(ex.ToString());
            }


            applicationLog.WriteDebugLog("Exited getLogDaysArray section.");
            #endregion

            #region sp4LogCopy
            applicationLog.WriteDebugLog("Entered sp4Log section.");

            try
            {
                if (myIni.Read("sp4Log") == "true")
                {
                    log             sp4Log      = new copyLogsConsole.log();
                    List <FileInfo> sp4LogFiles = sp4Log.getLogFiles(Convert.ToBoolean(myIni.Read("sp4Log")), myIni.Read("sp4LogPath"));

                    List <FileInfo> sp4LogFilesDateFiltered = sp4Log.selectLogs(logDaysArray, sp4LogFiles, "^\\d{8}_\\d{6}_\\d{8}_\\d{6}$");

                    if (sp4LogFilesDateFiltered.Count() > 0)
                    {
                        sp4Log.createSubFolder(Convert.ToBoolean(myIni.Read("sp4Log")), targetPath, "sp4");
                    }
                    sp4Log.copyLogs(sp4LogFilesDateFiltered, targetPath + "\\sp4", "SP4");

                    List <FileInfo> sp4ActualLogFile = sp4Log.getLogFiles(Convert.ToBoolean(myIni.Read("sp4Log")), myIni.Read("sp4LogPath"), "grgsp.grglog");
                    if (sp4ActualLogFile.Count > 0 && logDaysArray.Contains(DateTime.Today))
                    {
                        sp4Log.copyLogs(sp4ActualLogFile, targetPath + "\\sp4", "SP4 actual");
                    }
                    else if (!logDaysArray.Contains(DateTime.Today))
                    {
                        applicationLog.WriteDebugLog("Log dates does not contain today, so no actual sp4 log will be copied");
                    }
                }
                else if (myIni.Read("sp4Log") == "false")
                {
                    applicationLog.WriteDebugLog("Sp4Logs criteria is false. No Sp4Logs will be copied");
                }
            }
            catch (Exception ex)
            {
                copyLogsConsole.applicationLog.WriteDebugLog(ex.ToString());
            }


            applicationLog.WriteDebugLog("Exited sp4Log section");
            #endregion

            #region sp5LogCopy
            applicationLog.WriteDebugLog("Entered sp5Log section");

            try
            {
                if (myIni.Read("sp5Log") == "true")
                {
                    log             sp5Log      = new log();
                    List <FileInfo> sp5LogFiles = sp5Log.getLogFiles(Convert.ToBoolean(myIni.Read("sp5Log")), myIni.Read("sp5LogPath"), myIni.Read("sp5LogName"));
                    if (sp5LogFiles.Count() > 0)
                    {
                        sp5Log.createSubFolder(Convert.ToBoolean(myIni.Read("sp5Log")), targetPath, "sp5");
                    }

                    sp5Log.copyLogs(sp5LogFiles, targetPath + "\\sp5", "SP5");
                }
                else if (myIni.Read("sp5Log") == "false")
                {
                    applicationLog.WriteDebugLog("Sp5Logs criteria is false. No Sp5Logs will be copied");
                }
            }
            catch (Exception ex)
            {
                copyLogsConsole.applicationLog.WriteDebugLog(ex.ToString());
            }
            applicationLog.WriteDebugLog("Exited sp5Log section");

            #endregion

            #region CRMLogs
            applicationLog.WriteDebugLog("Entered CRM/CDM log section.");

            if (myIni.Read("CRMLog") == "true")
            {
                List <FileInfo> crmLogFilesDateFiltered = new List <FileInfo>();
                log             crmLog = new log();
                registry        reg    = new registry();

                try
                {//myIni.Read("atmType")
                    if (cashDevType == "H34")
                    {
                        string regKeyValue = "";
                        if (Environment.Is64BitOperatingSystem)
                        {
                            regKeyValue = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\XFS\PHYSICAL_SERVICES\GrgCDM_CDM8240_XFS30").GetValue("ReadDevLogPath").ToString();
                        }
                        else
                        {
                            regKeyValue = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCDM_CDM8240_XFS30").GetValue("ReadDevLogPath").ToString();
                        }

                        List <FileInfo> crmLogs = crmLog.getLogFiles(Convert.ToBoolean(myIni.Read("CRMLog")), regKeyValue);

                        crmLogFilesDateFiltered = crmLog.selectCrmLogs(logDaysArray, crmLogs, "^GRGCDM8240DevLog_\\d{8}_\\d{6}", "H34");
                        applicationLog.WriteDebugLog("Cash device type is: " + cashDevType);
                    }//myIni.Read("atmType")
                    else if (cashDevType == "H68N")
                    {
                        string regKeyValue = "";
                        if (Environment.Is64BitOperatingSystem)
                        {
                            regKeyValue = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\XFS\PHYSICAL_SERVICES\GrgCRM_CRM9250_XFS30").GetValue("ReadDevLogPath").ToString();
                        }
                        else
                        {
                            regKeyValue = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\XFS\PHYSICAL_SERVICES\GrgCRM_CRM9250_XFS30").GetValue("ReadDevLogPath").ToString();
                        }
                        List <FileInfo> crmLogs = crmLog.getLogFiles(Convert.ToBoolean(myIni.Read("CRMLog")), regKeyValue);
                        crmLogFilesDateFiltered = crmLog.selectCrmLogs(logDaysArray, crmLogs, "^CRM9250DevLog_\\d{8}_\\d{6}", "H68N");
                        applicationLog.WriteDebugLog("Cash device type is: " + cashDevType);
                    }

                    else if (cashDevType == "H68V")
                    {
                        if (myIni.Read("CRMLogPath") != null)
                        {
                            List <FileInfo> crmLogs = crmLog.getLogFiles(Convert.ToBoolean(myIni.Read("CRMLog")), @"C:\GRGBanking\Log\Hardware\CRM9250NLog");
                            crmLogFilesDateFiltered = crmLog.selectCrmLogs(logDaysArray, crmLogs, "^CRM9250NLog_\\d{8}", "H68V");

                            applicationLog.WriteDebugLog("Cash device type is: " + cashDevType);
                        }


                        applicationLog.WriteDebugLog("Cash device type is: " + cashDevType);
                    }
                    if (crmLogFilesDateFiltered.Count() > 0)
                    {
                        crmLog.createSubFolder(Convert.ToBoolean(myIni.Read("CRMLog")), targetPath, "CRMLog");
                    }
                    crmLog.copyLogs(crmLogFilesDateFiltered, targetPath + "\\CRMLog", "CRMLog");
                }
                catch (Exception ex)
                {
                    copyLogsConsole.applicationLog.WriteDebugLog(ex.ToString());
                }
            }

            else if (myIni.Read("CRMLog") == "false")
            {
                applicationLog.WriteDebugLog("CRMLog criteria is false. No CRM/CDM Logs will be copied");
            }


            #endregion

            #region driverLogs
            applicationLog.WriteDebugLog("Entered driverLogs section.");

            try
            {
                if (myIni.Read("driverLog") == "true")
                {
                    log driverLog = new log();

                    string          driverLogPathh         = myIni.Read("driverLogPath");
                    List <FileInfo> driverLogs             = driverLog.getLogFiles(Convert.ToBoolean(myIni.Read("driverLog")), myIni.Read("driverLogPath"));
                    List <FileInfo> driverLogsDateFiltered = driverLog.selectDriverLogs(logDaysArray, driverLogs, ".*\\(\\d{4}-\\d{2}-\\d{2}\\)\\..");

                    if (driverLogsDateFiltered.Count() > 0)
                    {
                        driverLog.createSubFolder(Convert.ToBoolean(myIni.Read("driverLog")), targetPath, "driverLogs");
                    }
                    driverLog.copyLogs(driverLogsDateFiltered, targetPath + "\\driverLogs", "Driver Logs");
                }
                else if (myIni.Read("driverLog") == "false")
                {
                    { applicationLog.WriteDebugLog("driverLog criteria is false. No driverLogs will be copied"); }
                }
            }
            catch (Exception ex)
            {
                copyLogsConsole.applicationLog.WriteDebugLog(ex.ToString());
            }
            applicationLog.WriteDebugLog("Exited driverLogs section.");

            #endregion

            #region duniteLogs
            applicationLog.WriteDebugLog("Entered duniteLogs section.");

            try
            {
                if (myIni.Read("duniteLog") == "true")
                {
                    log             duniteLog              = new log();
                    List <FileInfo> duniteLogs             = duniteLog.getLogFiles(Convert.ToBoolean(myIni.Read("duniteLog")), myIni.Read("duniteLogPath"));
                    List <FileInfo> duniteLogsDateFiltered = duniteLog.selectDuniteLogs(logDaysArray, duniteLogs, ".*\\(\\d{4}-\\d{2}-\\d{2}\\).zip");

                    if (duniteLogsDateFiltered.Count() > 0)
                    {
                        duniteLog.createSubFolder(Convert.ToBoolean(myIni.Read("duniteLog")), targetPath, "duniteLogs");
                    }
                    duniteLog.copyLogs(duniteLogsDateFiltered, targetPath + "\\duniteLogs", "Dunite Logs");
                }

                else if (myIni.Read("duniteLog") == "false")
                {
                    { applicationLog.WriteDebugLog("duniteLog criteria is false. No duniteLogs will be copied"); }
                }
            }
            catch (Exception ex)
            {
                copyLogsConsole.applicationLog.WriteDebugLog(ex.ToString());
            }
            applicationLog.WriteDebugLog("Exited duniteLogs section.");

            #endregion

            #region xfsmanLogs
            applicationLog.WriteDebugLog("Entered XFS Manager Logs section.");

            try
            {
                if (myIni.Read("XFSManLog") == "true")
                {
                    log             xfsManLog              = new log();
                    List <FileInfo> xfsManLogs             = xfsManLog.getLogFiles(Convert.ToBoolean(myIni.Read("XFSManLog")), myIni.Read("XFSManLogPath"));
                    List <FileInfo> xfsManLogsDateFiltered = xfsManLog.selectxfsManLogs(logDaysArray, xfsManLogs, "\\d{8}.txt");

                    if (xfsManLogsDateFiltered.Count() > 0)
                    {
                        xfsManLog.createSubFolder(Convert.ToBoolean(myIni.Read("XFSManLog")), targetPath, "xfsManLogs");
                    }
                    xfsManLog.copyLogs(xfsManLogsDateFiltered, targetPath + "\\xfsManLogs", "xfsManLogs");
                }
                else if (myIni.Read("XFSManLog") == "false")
                {
                    { applicationLog.WriteDebugLog("XFSManLog criteria is false. No xfsManLog will be copied"); }
                }
            }
            catch (Exception ex)
            {
                copyLogsConsole.applicationLog.WriteDebugLog(ex.ToString());
            }
            applicationLog.WriteDebugLog("Exited XFS Manager Logs section.");

            #endregion

            #region YDCLogs
            applicationLog.WriteDebugLog("Entered YDCLogs section");
            try
            {
                if (myIni.Read("YDCLogs") == "true")
                {
                    RegistryKey rKey   = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\grgbanking\YDC");
                    log         YDCLog = new log();



                    if (rKey != null)
                    {
                        applicationLog.WriteDebugLog("YDC installation found.");
                        string          ydcLogPath = rKey.GetValue("PATH").ToString() + "\\ATMAPP\\log";
                        List <FileInfo> ydcLogs    = YDCLog.getLogFiles(Convert.ToBoolean(myIni.Read("YDCLogs")), ydcLogPath);
                        //List<string> ydcRegexPatterns = new List<string> { @"\d{4}\.\d{2}\.\d{2}.*\.dmp", @"(COM)\d{6}\.log", @"(EJ)\d{6}\.log", @"(EMVKernel)\d{4}-\d{2}-\d{2}\.log", @"(Icc)\d{6}\.log", @"(TRACE)\d{6}\.log" };

                        List <FileInfo> ydcLogsDateFiltered = ydcLogsDateFiltered = YDCLog.selectYdcLogs(logDaysArray, ydcLogs);

                        if (ydcLogsDateFiltered.Count() > 0)
                        {
                            YDCLog.createSubFolder(Convert.ToBoolean(myIni.Read("YDCLogs")), targetPath, "YDCLogs");
                        }
                        YDCLog.copyLogs(ydcLogsDateFiltered, targetPath + "\\YDCLogs", "YDCLogs");
                    }
                    else if (rKey == null)
                    {
                        applicationLog.WriteDebugLog("YDC installation not found.");
                    }
                }

                else if (myIni.Read("YDCLogs") == "false")
                {
                    { applicationLog.WriteDebugLog("YDCLog criteria is false. No YDCLogs will be copied"); }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            applicationLog.WriteDebugLog("Exited YDCLogs section");

            #endregion

            #region Windows system log

            applicationLog.WriteDebugLog("Entered Windows system log section");

            //copy system event log


            try
            {
                bool winSystemLog = Convert.ToBoolean(myIni.Read("winSystemLog"));
                if (winSystemLog)
                {
                    log winSystemLogs = new log();
                    winSystemLogs.createSubFolder(winSystemLog, targetPath, "windowsSystemLog");
                    System.Diagnostics.ProcessStartInfo procStartInfo =
                        new System.Diagnostics.ProcessStartInfo("cmd", "/c " + "wevtutil epl system " + targetPath + "\\WindowsSystemLog\\system.evtx");

                    System.Diagnostics.Process proc = new System.Diagnostics.Process();
                    //proc.StartInfo.UseShellExecute = false;
                    //proc.StartInfo.CreateNoWindow = true;
                    proc.StartInfo             = procStartInfo;
                    proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    proc.Start();
                    applicationLog.WriteDebugLog("Windows system log has been copied.");
                }
                else if (myIni.Read("winSystemLog") == "false")
                {
                    { applicationLog.WriteDebugLog("winSystemLog criteria is false. Windows System event log will be copied"); }
                }
            }
            catch (Exception ex)
            {
                copyLogsConsole.applicationLog.WriteDebugLog(ex.ToString());
            }
            applicationLog.WriteDebugLog("Exited Windows system log section");

            #endregion

            #region zip

            applicationLog.WriteDebugLog("Entered zip section");

            Thread.Sleep(10000);

            try
            {
                //DirectoryInfo dir = System.IO.Directory(");

                string nowDateTime = DateTime.Now.ToLongDateString();

                string nowYear   = DateTime.Now.Year.ToString();
                string nowMonth  = DateTime.Now.Month.ToString();
                string nowDay    = DateTime.Now.Day.ToString();
                string nowHour   = DateTime.Now.Hour.ToString();
                string nowMinute = DateTime.Now.Minute.ToString();
                string nowSecond = DateTime.Now.Second.ToString();



                string zipFileName = myIni.Read("zipFileLocation") + "\\grgLogs_" + nowYear + nowMonth + nowDay + "_" + nowHour + nowMinute + nowSecond + ".zip";

                using (Package package = ZipPackage.Open(zipFileName, FileMode.Create))
                {
                    string startFolder = targetPath;

                    foreach (string currentFile in Directory.GetFiles(startFolder, "*.*", SearchOption.AllDirectories))
                    {
                        applicationLog.WriteDebugLog("Packing " + currentFile);
                        Uri relUri = zipFile.GetRelativeUri(currentFile);

                        PackagePart packagePart =
                            package.CreatePart(relUri, System.Net.Mime.MediaTypeNames.Application.Octet, CompressionOption.Maximum);
                        using (FileStream fileStream = new FileStream(currentFile, FileMode.Open, FileAccess.Read))
                        {
                            zipFile.CopyStream(fileStream, packagePart.GetStream());
                        }
                    }
                    copyLogsConsole.applicationLog.WriteDebugLog("Zip file has been created with " + Directory.GetFiles(startFolder, "*.*", SearchOption.AllDirectories).Length.ToString() + " files.");
                }
            }
            catch (Exception ex)
            {
                applicationLog.WriteDebugLog(ex.ToString());
            }
            applicationLog.WriteDebugLog("Exited zip section");

            #endregion

            #region end of program
            //Console.WriteLine("Logs have been copied successfully" + "\n" + "Please press a key to continue");
            applicationLog.WriteDebugLog("Reached the end of the program section");
            watch.Stop();
            var elapsedMs = watch.Elapsed;
            applicationLog.WriteDebugLog(elapsedMs.ToString());
            //Console.WriteLine("Total time elapsed:" + elapsedMs.ToString());
            //Console.ReadKey();
            try
            {
                if (Convert.ToInt16(registry.readDevLogReturn) != 0)
                {
                    applicationLog.WriteDebugLog("Problem with CRMLogs, registry value is different from zero.");
                }
            }
            catch (Exception ex)
            {
                applicationLog.WriteDebugLog(ex.ToString());
            }
            #endregion

            copyLogsConsole.applicationLog.WriteDebugLog("<--------------------------End-of-log-file-------------------------->");

            return(0);
        }