Exemplo n.º 1
0
 public DataServer(ref StreamWriter log, ref LoadMonitor ldl, ref DB_Access dba)
 {
     this.i_Comm        = new Communication();
     this.logStream     = log;
     this.i_monDataLoad = ldl;
     this.dbAccess      = dba;
 }
Exemplo n.º 2
0
 public void ExecuteTransaction(ref Dispatcher disp, string TransactionLabel, int iPid, ref StreamWriter m_Log, ref Communication m_Comm, ref DB_Access m_my_access, string session)
 {
     this.var_m_disp           = disp;
     this.var_TransactionLabel = TransactionLabel;
     this.var_iPid             = iPid;
     this.var_m_Log            = m_Log;
     this.var_m_Comm           = m_Comm;
     this.var_m_my_access      = m_my_access;
     this.var_session          = session;
     this.workThread           = new Thread(new ThreadStart(this.Exec));
     this.workThread.Start();
 }
Exemplo n.º 3
0
        public tst_ins_agenda(ref StreamWriter p_m_Log,
                              ref Communication p_m_Comm,
                              ref DB_Access p_m_my_access,
                              string p_session,
                              string current_demand)
        {
            m_Comm         = p_m_Comm;
            m_Log          = p_m_Log;
            m_my_access    = p_m_my_access;
            demand         = current_demand;
            my_transaction = (Transaction)transaction;

            session          = p_session;
            tst_unit.session = session;

            transaction.SetSessionKey(session);
            transaction.SetCommunication(ref m_Comm);
            transaction.SetLogAccess(ref m_Log);
            transaction.SetAccess(ref m_my_access);

            transaction.var_Translator = new Translator();
            transaction.ut_enabled     = true;
        }
Exemplo n.º 4
0
 public DB_Access(ref DB_Access ac)
 {
     this.i_monCpu         = ac.i_monCpu;
     this.MyconnString     = ac.MyconnString;
     this.i_ctrl           = ac.i_ctrl;
     this.failSafe_archive = ac.failSafe_archive;
     if (this.i_ctrl.StandByAlive)
     {
         this.tcpClientStandBy = new TcpClient(this.i_ctrl.standby_server, this.i_ctrl.standby_server_port);
         this.netStreamStandBy = this.tcpClientStandBy.GetStream();
     }
     this.MyConnection = new OdbcConnection(this.MyconnString);
     try
     {
         this.MyConnection.Open();
         this.setDateFormat();
     }
     catch (OdbcException ex)
     {
         throw new Exception(ex.Message);
     }
     this.m_lockArea = ac.m_lockArea;
 }
Exemplo n.º 5
0
        public LoadAutomated(string connString, ref ListViewItem lstResults, int pos, string transact)
        {
            LockArea    m_lockArea = new LockArea();
            CPU_Monitor m_cpu      = new CPU_Monitor();
            DB_Access   m_access   = new DB_Access(connString, ref m_lockArea, ref m_cpu);

            string path = "Log" + pos.ToString() + ".txt";

            FileStream m_log_file;

            if (File.Exists(path))
            {
                m_log_file = new FileStream(path, FileMode.Truncate, FileAccess.Write);
            }
            else
            {
                m_log_file = new FileStream(path, FileMode.Create, FileAccess.Write);
            }

            StreamWriter  m_Log  = new StreamWriter(m_log_file);
            Communication m_Comm = new Communication();

            string session = "session";

            DateTime work_time    = new DateTime();
            double   lowest       = 0;
            double   percent      = (double)100 / 42;
            double   percent_done = 0;
            double   tim_result   = 0;

            {
                Thread.Sleep(1);
                tst_type_base type_base = new tst_type_base(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                type_base.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_cadastros fetch_cadastros = new tst_fetch_cadastros(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_cadastros.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_ins_cartaoProprietario ins_cartaoProprietario = new tst_ins_cartaoProprietario(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                ins_cartaoProprietario.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_proprietario fetch_proprietario = new tst_fetch_proprietario(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_proprietario.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_exec_login exec_login = new tst_exec_login(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                exec_login.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_exec_logoff exec_logoff = new tst_exec_logoff(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                exec_logoff.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_exec_trocaSenha exec_trocaSenha = new tst_exec_trocaSenha(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                exec_trocaSenha.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_ins_usuario ins_usuario = new tst_ins_usuario(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                ins_usuario.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_listaUsuarios fetch_listaUsuarios = new tst_fetch_listaUsuarios(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_listaUsuarios.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_usuarios fetch_usuarios = new tst_fetch_usuarios(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_usuarios.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_exec_alteraUsuario exec_alteraUsuario = new tst_exec_alteraUsuario(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                exec_alteraUsuario.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_ins_empresa ins_empresa = new tst_ins_empresa(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                ins_empresa.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_ins_loja ins_loja = new tst_ins_loja(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                ins_loja.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_dadosEmpresa fetch_dadosEmpresa = new tst_fetch_dadosEmpresa(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_dadosEmpresa.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_dadosLoja fetch_dadosLoja = new tst_fetch_dadosLoja(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_dadosLoja.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_exec_loginWeb exec_loginWeb = new tst_exec_loginWeb(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                exec_loginWeb.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_codEmpresa fetch_codEmpresa = new tst_fetch_codEmpresa(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_codEmpresa.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_exec_alteraEmpresa exec_alteraEmpresa = new tst_exec_alteraEmpresa(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                exec_alteraEmpresa.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_exec_alteraLoja exec_alteraLoja = new tst_exec_alteraLoja(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                exec_alteraLoja.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_codTerminal fetch_codTerminal = new tst_fetch_codTerminal(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_codTerminal.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_nomeEmpresa fetch_nomeEmpresa = new tst_fetch_nomeEmpresa(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_nomeEmpresa.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_validaEmpresa fetch_validaEmpresa = new tst_fetch_validaEmpresa(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_validaEmpresa.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_ins_terminal ins_terminal = new tst_ins_terminal(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                ins_terminal.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_terminais fetch_terminais = new tst_fetch_terminais(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_terminais.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_listaTerminais fetch_listaTerminais = new tst_fetch_listaTerminais(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_listaTerminais.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_codLoja fetch_codLoja = new tst_fetch_codLoja(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_codLoja.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_listaEmpresas fetch_listaEmpresas = new tst_fetch_listaEmpresas(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_listaEmpresas.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_terminalLoja fetch_terminalLoja = new tst_fetch_terminalLoja(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_terminalLoja.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_del_Terminal del_Terminal = new tst_del_Terminal(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                del_Terminal.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_consultaLoja fetch_consultaLoja = new tst_fetch_consultaLoja(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_consultaLoja.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_listaLoja fetch_listaLoja = new tst_fetch_listaLoja(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_listaLoja.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_consultaEmpresa fetch_consultaEmpresa = new tst_fetch_consultaEmpresa(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_consultaEmpresa.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_consultaAuditoria fetch_consultaAuditoria = new tst_fetch_consultaAuditoria(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_consultaAuditoria.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_listaAuditoria fetch_listaAuditoria = new tst_fetch_listaAuditoria(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_listaAuditoria.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_exec_alteraTerminal exec_alteraTerminal = new tst_exec_alteraTerminal(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                exec_alteraTerminal.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_limitesCartao fetch_limitesCartao = new tst_fetch_limitesCartao(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_limitesCartao.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_listaCartoes fetch_listaCartoes = new tst_fetch_listaCartoes(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_listaCartoes.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_exec_alteraCartao exec_alteraCartao = new tst_exec_alteraCartao(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                exec_alteraCartao.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_fetch_consultaCartao fetch_consultaCartao = new tst_fetch_consultaCartao(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                fetch_consultaCartao.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_infra_SchedulerDispatcher infra_SchedulerDispatcher = new tst_infra_SchedulerDispatcher(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                infra_SchedulerDispatcher.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_schedule_tst schedule_tst = new tst_schedule_tst(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                schedule_tst.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }

            {
                Thread.Sleep(1);
                tst_schedule_base schedule_base = new tst_schedule_base(ref m_Log, ref m_Comm, ref m_access, session, transact);
                work_time = DateTime.Now;
                schedule_base.Test();
                tim_result = -work_time.Subtract(DateTime.Now).TotalMilliseconds;
                if (tim_result > lowest)
                {
                    lowest = tim_result;
                }
                percent_done  += percent;
                lstResults.Tag = lowest;
                lstResults.SubItems[1].Text = String.Format("{0:n}", percent_done) + " %";
                lstResults.SubItems[2].Text = String.Format("{0:n}", lowest);
                Application.DoEvents();
            }


            m_Log.Flush();
            m_Log.Close();
            m_log_file.Close();
            m_cpu.StopMonit();
        }
Exemplo n.º 6
0
        public override bool execute( )
        {
            Registry("execute schedule_proc_batch ");

            /// USER [ execute ]

            string dir_watch = new SyCrafEngine.InstallData().pathDir + "\\proc\\";

            I_Batch bat = new I_Batch(this);

            Thread.Sleep(3000);                //  Wait to build valid filelist

            if (bat.select_rows_free(Context.FALSE, Context.FALSE))
            {
                while (bat.fetch())
                {
                    string archive = bat.get_st_archive();

                    #region - SETUP -

                    string path = new InstallData().pathDir + "\\Log_" +
                                  DateTime.Now.Year.ToString() +
                                  DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Day.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Hour.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Minute.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Second.ToString().PadLeft(2, '0') +
                                  "_batch_" + archive + ".txt.wrk";

                    FileStream   logFile;
                    StreamWriter logStream;

                    if (File.Exists(path))
                    {
                        logFile = new FileStream(path, FileMode.Append, FileAccess.Write);
                    }
                    else
                    {
                        logFile = new FileStream(path, FileMode.Create, FileAccess.Write);
                    }

                    logStream           = new StreamWriter(logFile);
                    logStream.AutoFlush = true;

                    var_Comm.Clear();
                    DB_Access new_access = new DB_Access(ref m_gen_my_access);

                    var_disp.var_Translator = var_Translator;

                    DataPortable port = new DataPortable();

                    port.setValue("archive", archive);

                    new_access.MemorySave("input", ref port);

                    #endregion

                    if (archive.StartsWith("CARGA_EDU_"))
                    {
                        // Runnig in a new thread
                        var_disp.ExecuteThreadTransaction("load_edu",
                                                          Convert.ToInt32(bat.get_identity()),
                                                          ref logStream,
                                                          ref var_Comm,
                                                          ref new_access,
                                                          path);
                    }
                    else if (archive.StartsWith("CARGA_EDUEMPRESASVIRTUAIS"))
                    {
                        // Runnig in a new thread
                        var_disp.ExecuteThreadTransaction("load_edu_emp_virtual",
                                                          Convert.ToInt32(bat.get_identity()),
                                                          ref logStream,
                                                          ref var_Comm,
                                                          ref new_access,
                                                          path);
                    }
                    else if (archive.StartsWith("LEGADO"))
                    {
                        // Runnig in a new thread
                        var_disp.ExecuteThreadTransaction("load_legado",
                                                          Convert.ToInt32(bat.get_identity()),
                                                          ref logStream,
                                                          ref var_Comm,
                                                          ref new_access,
                                                          path);
                    }
                }
            }

            /// USER [ execute ] END

            Registry("execute done schedule_proc_batch ");

            return(true);
        }
        public override bool execute( )
        {
            Registry("execute infra_SchedulerDispatcher ");

            /// USER [ execute ]

            I_Scheduler sch      = new I_Scheduler(this);
            DateTime    time_now = DateTime.Now;

            if (sch.selectAll())
            {
                while (sch.fetch())
                {
                    bool Exec = false;

                    if (sch.get_tg_status() == Context.CLOSED)
                    {
                        continue;
                    }

                    switch (sch.get_tg_type())
                    {
                    case Scheduler.Specific:
                    {
                        DateTime time = Convert.ToDateTime(sch.get_dt_specific());

                        if (time_now.Year == time.Year)
                        {
                            if (time_now.Month == time.Month)
                            {
                                if (time_now.Day == time.Day)
                                {
                                    if (time_now.Hour == time.Hour)
                                    {
                                        if (time_now.Minute == time.Minute)
                                        {
                                            Exec = true;
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    }

                    case Scheduler.Daily:
                    {
                        int daily_hh = Convert.ToInt32(sch.get_st_daily_hhmm().Substring(0, 2));
                        int daily_mm = Convert.ToInt32(sch.get_st_daily_hhmm().Substring(2, 2));

                        if (time_now.Hour == daily_hh)
                        {
                            if (time_now.Minute == daily_mm)
                            {
                                Exec = true;
                            }
                        }

                        break;
                    }

                    case Scheduler.Weekly:
                    {
                        long weekly_dow = sch.get_int_st_weekly_dow();
                        long weekly_hh  = Convert.ToInt64(sch.get_st_daily_hhmm().Substring(0, 2));
                        long weekly_mm  = Convert.ToInt64(sch.get_st_daily_hhmm().Substring(2, 2));

                        switch (weekly_dow)
                        {
                        case 0: if (time_now.DayOfWeek != DayOfWeek.Sunday)
                            {
                                continue;
                            }
                            break;

                        case 1: if (time_now.DayOfWeek != DayOfWeek.Monday)
                            {
                                continue;
                            }
                            break;

                        case 2: if (time_now.DayOfWeek != DayOfWeek.Tuesday)
                            {
                                continue;
                            }
                            break;

                        case 3: if (time_now.DayOfWeek != DayOfWeek.Wednesday)
                            {
                                continue;
                            }
                            break;

                        case 4: if (time_now.DayOfWeek != DayOfWeek.Thursday)
                            {
                                continue;
                            }
                            break;

                        case 5: if (time_now.DayOfWeek != DayOfWeek.Friday)
                            {
                                continue;
                            }
                            break;

                        case 6: if (time_now.DayOfWeek != DayOfWeek.Saturday)
                            {
                                continue;
                            }
                            break;

                        default: break;                                         // 7 is everyday
                        }

                        if (time_now.Hour == weekly_hh)
                        {
                            if (time_now.Minute == weekly_mm)
                            {
                                Exec = true;
                            }
                        }

                        break;
                    }

                    case Scheduler.Monthly:
                    {
                        long monthly_dd = sch.get_int_nu_monthly_day();
                        long monthly_hh = Convert.ToInt64(sch.get_st_monthly_hhmm().Substring(0, 2));
                        long monthly_mm = Convert.ToInt64(sch.get_st_monthly_hhmm().Substring(2, 2));

                        if (time_now.Day == monthly_dd)
                        {
                            if (time_now.Hour == monthly_hh)
                            {
                                if (time_now.Minute == monthly_mm)
                                {
                                    Exec = true;
                                }
                            }
                        }

                        break;
                    }

                    case Scheduler.Minute:
                    {
                        Exec = true;
                        break;
                    }

                    default:
                    {
                        Registry("Unrecognized code! " + sch.get_tg_type());
                        break;
                    }
                    }

                    if (Exec)
                    {
                        Registry(sch.get_st_job() + " >> MATCH!");
                    }

                    Registry(sch.get_st_job());

                    if (!Exec)
                    {
                        Registry(sch.get_st_job() + " >> Checking backlog....");

                        DateTime tim = Convert.ToDateTime(sch.get_dt_prev());

                        Registry(tim.ToString());
                        Registry(time_now.ToString());

                        if (time_now >= tim)
                        {
                            Registry("Back log for: " + sch.get_st_job());
                            Exec = true;
                        }
                    }

                    if (!Exec)
                    {
                        continue;
                    }

                    Registry("Running: " + sch.get_st_job());

                    ApplicationUtil var_util = new ApplicationUtil();

                    int    max_params = var_util.indexCSV(sch.get_st_job(), ';');
                    string job        = var_util.getCSV(0);

                    string path = var_SessionKey +
                                  "\\Log_" +
                                  DateTime.Now.Year.ToString() +
                                  DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Day.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Hour.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Minute.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Second.ToString().PadLeft(2, '0') +
                                  "_" +
                                  job +
                                  "_" +
                                  sch.get_identity() +
                                  ".txt.wrk";

                    FileStream   logFile;
                    StreamWriter logStream;

                    if (File.Exists(path))
                    {
                        logFile = new FileStream(path, FileMode.Append, FileAccess.Write);
                    }
                    else
                    {
                        logFile = new FileStream(path, FileMode.Create, FileAccess.Write);
                    }

                    logStream           = new StreamWriter(logFile);
                    logStream.AutoFlush = true;

                    var_Comm.Clear();

                    DB_Access new_access = new DB_Access(ref m_gen_my_access);

                    var_disp.var_Translator = var_Translator;

                    if (max_params >= 3)
                    {
                        DataPortable port = new DataPortable();

                        for (int t = 1; t < max_params;)
                        {
                            string ident     = var_util.getCSV(t); ++t;
                            string ident_val = var_util.getCSV(t); ++t;

                            port.setValue(ident, ident_val);
                        }

                        string buffer = "";

                        port.ExportBuffer(ref buffer);

                        Registry(buffer);

                        new_access.MemorySave("input", ref port);
                    }

                    // Runnig in a new thread
                    var_disp.ExecuteThreadTransaction(job,
                                                      Convert.ToInt32(sch.get_identity()),
                                                      ref logStream,
                                                      ref var_Comm,
                                                      ref new_access,
                                                      path);
                }
            }

            /// USER [ execute ] END

            Registry("execute done infra_SchedulerDispatcher ");

            return(true);
        }
Exemplo n.º 8
0
 public void SetAccess(ref DB_Access access)
 {
     this.m_gen_my_access = access;
 }
Exemplo n.º 9
0
 public virtual void ExecuteTransaction(string TransactionLabel, int iPid, ref StreamWriter m_Log, ref Communication m_Comm, ref DB_Access m_my_access, string session)
 {
 }
Exemplo n.º 10
0
        public void ExecuteThreadTransaction(string TransactionLabel, int iPid, ref StreamWriter m_Log, ref Communication m_Comm, ref DB_Access m_my_access, string session)
        {
            thread_Dispatcher threadDispatcher = new thread_Dispatcher();

            this.my_threads.Add((object)this);
            Dispatcher disp = this;

            threadDispatcher.ExecuteTransaction(ref disp, TransactionLabel, iPid, ref m_Log, ref m_Comm, ref m_my_access, session);
        }