Beispiel #1
0
        public void skynetWork()
        {
            ActuallyPerformStep.performStepTxtBox(txtConsole, "Skynet started", true);

            while (true)
            {
                if (!checkDatabaseStatus())
                {
                    return;
                }
                if (!checkServerStatus())
                {
                    return;
                }

                if (DateTime.Now.ToString("HH").Equals("00"))
                {
                    generatedToday = false;
                }
                else if (DateTime.Now.ToString("HH").Equals(Properties.Settings.Default.INTERVAL_DOWNLOAD_TIME) && generatedToday == false)
                {
                    doYourShit();
                    generatedToday = true;
                }

                ActuallyPerformStep.performStepTxtBox(txtConsole, "Skynet spava: " + Properties.Settings.Default.INTERVAL_INTERVAL + " minuta. Do: " + Properties.Settings.Default.INTERVAL_DOWNLOAD_TIME + "h.", true);
                Thread.Sleep(new TimeSpan(0, int.Parse(Properties.Settings.Default.INTERVAL_INTERVAL), 0));
            }
        }
Beispiel #2
0
        private void slanjeMaila(List <FileAndMails> listFam)
        {
            bool nekiNijePoslat = false;
            int  pauza          = 60000;
            int  i = 1;

            ActuallyPerformStep.performStepTxtBox(txtConsole, "Pocinje slanje mailova...", true);

            int j = 1;

            while (i <= 3)
            {
                foreach (FileAndMails fam in listFam)
                {
                    if (fam.poslato == false)
                    {
                        fam.poslato = UcitavanjeGenerisanje.email_send(fam.klijentNaziv, fam.filePath, fam.mails, fam.potencijalnoNeaktivna, fam.maticniNePostoji);
                        if (fam.poslato == false)
                        {
                            nekiNijePoslat = true;
                        }
                        else
                        {
                            ActuallyPerformStep.performStepTxtBox(txtConsole2, "Poslat mail: " + j++ + "/" + listFam.Count, false);
                        }
                    }
                }
                j = 0;
                if (nekiNijePoslat)
                {
                    ActuallyPerformStep.performStepTxtBox(txtConsole, "Neki mail nije poslat, spava: " + (i * pauza), true);
                    Thread.Sleep(i * pauza);
                    i++;
                    nekiNijePoslat = false;
                }
                else
                {
                    i = 5;
                }
            }

            if (nekiNijePoslat)
            {
                ActuallyPerformStep.performStepTxtBox(txtConsole, "Neki mail nije poslat", true);
            }

            ActuallyPerformStep.performStepTxtBox(txtConsole, "Zavrseno slanje mailova.", true);
        }
Beispiel #3
0
        private bool preuzimanjeFajlaSaServera()
        {
            ActuallyPerformStep.performStepTxtBox(txtConsole, "Pocinje preuzimanje fajla...", true);
            bool uspehFajl = WinScp.GetFile.getFile();

            if (uspehFajl)
            {
                ActuallyPerformStep.performStepTxtBox(txtConsole, "Uspesno preuzet fajl.", true);
                return(true);
            }
            else
            {
                ActuallyPerformStep.performStepTxtBox(txtConsole, "GRESKA: Neuspesno preuzet fajl!", true);
                return(false);
            }
        }
Beispiel #4
0
        private bool checkServerStatus()
        {
            ActuallyPerformStep.performStepTxtBox(txtConsole, "Provera statusa servera...", true);
            bool serverStatus = WinScp.GetFile.checkServerStatus();

            if (serverStatus)
            {
                ActuallyPerformStep.performStepTxtBox(txtConsole, "Server status: OK.", true);
                return(true);
            }
            else
            {
                ActuallyPerformStep.performStepTxtBox(txtConsole, "Server status: ERROR", true);
                Thread.Sleep(2 * 60 * 1000);
                return(checkDatabaseStatus());
            }
        }
Beispiel #5
0
        private void slanjeTamariMaila()
        {
            ActuallyPerformStep.performStepTxtBox(txtConsole, "Pocinje slanje potencijalno neaktivnih...", true);

            // slanje tamari informaciju o potencijalno neaktivnim firmama
            string text = DBZaGenerisanje.getPotencijalnoNeaktivne();

            if (!UcitavanjeGenerisanje.email_sendTamara(text))
            {
                Thread.Sleep(2 * 60 * 1000);
                if (!UcitavanjeGenerisanje.email_sendTamara(text))
                {
                    ActuallyPerformStep.performStepTxtBox(txtConsole, "Tamari nije poslat mail", true);
                }
            }
            ActuallyPerformStep.performStepTxtBox(txtConsole, "Zavrseno slanje potencijalno neaktivnih.", true);
        }
Beispiel #6
0
 private bool checkDatabaseStatus()
 {
     ActuallyPerformStep.performStepTxtBox(txtConsole, "Provera statusa baze...", true);
     DBCommOsnovnePostavke.connection = new SqlConnection(DBBlokadeData.connectionString);
     try
     {
         DBCommOsnovnePostavke.connection.Open();
         DBCommOsnovnePostavke.connection.Close();
     }
     catch (SqlException ex)
     {
         ActuallyPerformStep.performStepTxtBox(txtConsole, "Database error! " + ex.ToString(), true);
         Thread.Sleep(2 * 60 * 1000);
         return(checkDatabaseStatus());
     }
     ActuallyPerformStep.performStepTxtBox(txtConsole, "Database OK!", true);
     return(true);
 }
Beispiel #7
0
 private void frmSkynet_FormClosing(object sender, FormClosingEventArgs e)
 {
     ActuallyPerformStep.performStepTxtBox(txtConsole, "Stopiranje servisa", true);
     skynetThread.Abort();
 }