Пример #1
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            if (System.IO.File.Exists(TimingFileFolder + AlertusDbFileName))
            {
                clsCsvReader fileReader = new clsCsvReader(TimingFileFolder + AlertusDbFileName);
                string[]     thisLine   = fileReader.GetCsvLine();
                thisConnection = thisLine[0];
                fileReader.Dispose();

                clsImportData thisImportData = new clsImportData();
                thisImportData.Connect((int)thisImportData.DatabaseType_MySql(),
                                       thisConnection);

                thisImportData.thisSetting.Ensure("thisRootPath", @"v:\chc.dev2.welman.co.nz\");
                thisImportData.thisSetting.Ensure("thisReportPath", @"v:\Resources\ReportTemplates\");
            }

            timer1.Enabled  = true;
            timer1.Interval = MaxAgeBeforeActionMinutes * 60 * 1000;             //A bit of grace to start
            timer1.Start();
            for (int counter = 0; counter < CampFolders.GetUpperBound(0) + 1; counter++)
            {
                Process.Start(executableFolder + projectToRunFileSuffix + CampFolders[counter] + ".exe");
            }
        }
Пример #2
0
 private void Form1_Load(object sender, System.EventArgs e)
 {
     //See if there is a file which dictates our Connection
     if (System.IO.File.Exists(TimingFileFolder + AlertusDbFileName))
     {
         clsCsvReader fileReader = new clsCsvReader(TimingFileFolder + AlertusDbFileName);
         string[]     thisLine   = fileReader.GetCsvLine();
         thisConnection = thisLine[0];
         fileReader.Dispose();
     }
 }
Пример #3
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            clsImportData thisImportData = new clsImportData();

            thisImportData.Connect((int)thisImportData.DatabaseType_MySql(),
                                   thisConnection);

            if (System.IO.File.Exists(TimingFileFolder + AlertusDbFileName))
            {
                clsCsvReader fileReader = new clsCsvReader(TimingFileFolder + AlertusDbFileName);
                string[]     thisLine   = fileReader.GetCsvLine();
                thisConnection = thisLine[0];
                fileReader.Dispose();

//				thisImportData.thisSetting.Ensure("thisRootPath", @"v:\chc.dev2.welman.co.nz\");
//				thisImportData.thisSetting.Ensure("thisReportPath", @"v:\Resources\ReportTemplates\");
            }

            thisImportData.PreImport();

            if (System.IO.File.Exists(TimingFileFolder + AlertusDbFileName))
            {
                clsCsvReader fileReader = new clsCsvReader(TimingFileFolder + AlertusDbFileName);
                string[]     thisLine   = fileReader.GetCsvLine();
                thisConnection = thisLine[0];
                fileReader.Dispose();

//				thisImportData.thisSetting.Ensure("thisRootPath", @"C:\www\chc.dev2.welman.co.nz\");
//				thisImportData.thisSetting.Ensure("thisReportPath", @"C:\www\Resources\ReportTemplates\");
            }
            else
            {
//				thisImportData.thisSetting.Ensure("thisRootPath", @"D:\FREEDOM\Web\Chc\");
//				thisImportData.thisSetting.Ensure("thisReportPath", @"D:\FREEDOM\Resources\ReportTemplates\");
            }

            MessageBox.Show("Complete");
        }
Пример #4
0
        static void Main(string[] args)
        {
            string Dev64Connection = "DRIVER={mySql ODBC 5.3 Unicode Driver};SERVER=Dev64;port=3306;UID=graham;PASSWORD=1fuckyou;DATABASE=kdl_mod3";

            string thisConnection    = Dev64Connection;
            string AlertusDbFileName = "AlertusDB";

            string thisFolder = Directory.GetCurrentDirectory() + @"\";

            if (System.IO.File.Exists(thisFolder + AlertusDbFileName))
            {
                clsCsvReader fileReader = new clsCsvReader(thisFolder + AlertusDbFileName);
                string[]     thisLine   = fileReader.GetCsvLine();
                thisConnection = thisLine[0];
                fileReader.Dispose();
            }

            clsImportData thisImportData = new clsImportData();

            thisImportData.Connect((int)thisImportData.DatabaseType_MySql(),
                                   thisConnection);
            try
            {
                thisImportData.PreImport();
                thisImportData.RestartImportFromLastRecord(@"C:\", @"C:\KDL0504.CSV", 0);
                thisImportData.AddOrdersAndItems();
                thisImportData.AddUsersForPeople();
                thisImportData.ExportContactsForMailMerge();

                int currentYear  = DateTime.Now.Year;
                int currentMonth = DateTime.Now.Month;


                for (int counter = 0; counter < 13; counter++)
                {
                    int    SeedInvoiceNumber = 1;
                    string LogFolder         = @"W:\logs\";
                    string fileToExportTo    = @"export.csv";

                    thisImportData.DoCorrespondence(new DateTime(currentYear, currentMonth, 1), SeedInvoiceNumber, LogFolder, fileToExportTo);
                    currentMonth++;
                    if (currentMonth > 12)
                    {
                        currentYear++;
                        currentMonth = currentMonth % 12;
                    }
                }
            }
            catch (System.Exception e)
            {
                clsCsvWriter fileWriter = new clsCsvWriter(thisFolder + "Importererr.txt", true);

                fileWriter.WriteFields(new
                                       object[] {
                    e.ToString(),
                    e.Message,
                    DateTime.Now.ToString()
                });

                fileWriter.Close();
            }
        }
Пример #5
0
        private void timer1_Tick(object sender, System.EventArgs e)
        {
            timer1.Stop();
            timer1.Interval = TimerIntervalMs;

            bool alldone = true;

            //Check if the file has been recently updated
            for (int counter = 0; counter < CampFolders.GetUpperBound(0) + 1; counter++)
            {
                int totReferrals      = 0;
                int totReferralsAdded = 0;
                int totIncidents      = 0;
                int totIncidentsAdded = 0;

                if (!Completed[counter])
                {
                    //Check to see if we have completed
                    string thisLastGoodRecordPathFile = TimingFileFolder + CampFolders[counter] + lastGoodRecordFileSuffix;
                    int    lastGoodRecord             = 0;
                    int    lastCsvFileEntryIndexAdded = 0;
                    int    lastReferralToAdd          = 0;
                    int    numIncidents         = 0;
                    int    lastIncident_IdAdded = 0;

                    if (System.IO.File.Exists(thisLastGoodRecordPathFile))
                    {
                        clsCsvReader fileReader = new clsCsvReader(thisLastGoodRecordPathFile);

                        string[] thisLine = fileReader.GetCsvLine();
                        lastGoodRecord             = Convert.ToInt32(thisLine[0]);
                        lastCsvFileEntryIndexAdded = Convert.ToInt32(thisLine[1]) + 1;
                        lastReferralToAdd          = Convert.ToInt32(thisLine[2]);

                        if (thisLine.GetUpperBound(0) > 4)
                        {
                            lastIncident_IdAdded = Convert.ToInt32(thisLine[4]) + 1;
                            numIncidents         = Convert.ToInt32(thisLine[5]);
                        }

                        if (numIncidents == 0)
                        {
                            numIncidents = 1;
                        }

                        if (lastReferralToAdd == 0)
                        {
                            lastReferralToAdd = 1;
                        }

                        fileReader.Dispose();

                        totReferrals      += lastReferralToAdd;
                        totReferralsAdded += lastCsvFileEntryIndexAdded;
                        totIncidents      += numIncidents;
                        totIncidentsAdded += lastIncident_IdAdded;

                        if (lastCsvFileEntryIndexAdded == lastReferralToAdd && lastIncident_IdAdded == numIncidents && numIncidents > 1)
                        {
                            Completed[counter] = true;
                        }

                        string thisDisaplyLine = CampFolders[counter] + ": " + ((lastCsvFileEntryIndexAdded) * 100 / lastReferralToAdd).ToString().Trim()
                                                 + "% Done. " + lastCsvFileEntryIndexAdded.ToString().Trim() + " out of " + lastReferralToAdd.ToString().Trim()
                                                 + " Incidents: " + ((lastIncident_IdAdded) * 100 / numIncidents).ToString().Trim()
                                                 + "% Done. " + lastIncident_IdAdded.ToString().Trim() + " out of " + numIncidents.ToString().Trim();

                        switch (counter)
                        {
                        case 0:
                        default:
                            lblKdl.Text = thisDisaplyLine;
                            break;
                        }
                    }

                    if (!Completed[counter])
                    {
                        alldone = false;

                        bool thisProcFound = false;

                        DateTime thisLastAccess = DateTime.Now.AddMinutes(-2 * MaxAgeBeforeActionMinutes);

                        if (System.IO.File.Exists(TimingFileFolder + CampFolders[counter] + lastGoodRecordFileSuffix))
                        {
                            thisLastAccess = System.IO.File.GetLastWriteTime(TimingFileFolder + CampFolders[counter] + lastGoodRecordFileSuffix);
                        }

                        ArrayList al = new ArrayList();
                        al.AddRange(Process.GetProcesses());
                        foreach (object thisObj in al)
                        {
                            Process thisProc = (Process)thisObj;
                            if (thisProc.ProcessName.IndexOf(projectToRunFileSuffix + CampFolders[counter]) > -1)
                            {
                                thisProcFound = true;
                                if (thisLastAccess.AddMinutes(MaxAgeBeforeActionMinutes) < DateTime.Now)
                                {
                                    thisProc.Kill();
                                    Process.Start(executableFolder + projectToRunFileSuffix + CampFolders[counter] + ".exe");
                                }
                            }
                        }
                        if (!thisProcFound)
                        {
                            Process.Start(executableFolder + projectToRunFileSuffix + CampFolders[counter] + ".exe");
                        }
                    }
                }
            }
            if (!alldone)
            {
                timer1.Start();
            }
            else
            {
                clsImportData thisImportData = new clsImportData();
                thisImportData.Connect((int)thisImportData.DatabaseType_MySql(),
                                       thisConnection);

                if (System.IO.File.Exists(TimingFileFolder + AlertusDbFileName))
                {
                    clsCsvReader fileReader = new clsCsvReader(TimingFileFolder + AlertusDbFileName);
                    string[]     thisLine   = fileReader.GetCsvLine();
                    thisConnection = thisLine[0];
                    fileReader.Dispose();

                    thisImportData.thisSetting.Ensure("thisRootPath", @"C:\www\chc.dev2.welman.co.nz\");
                    thisImportData.thisSetting.Ensure("thisReportPath", @"C:\www\Resources\ReportTemplates\");
                }
                else
                {
                    thisImportData.thisSetting.Ensure("thisRootPath", @"D:\FREEDOM\Web\Chc\");
                    thisImportData.thisSetting.Ensure("thisReportPath", @"D:\FREEDOM\Resources\ReportTemplates\");
                }
                MessageBox.Show("Complete!");
            }
        }