Esempio n. 1
0
        public override bool execute( )
        {
            Registry("execute schedule_batch ");

            /// USER [ execute ]

            // #####################
            // ## Watch directory:
            // #####################

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

            Registry(dir_watch);

            string [] my_files = Directory.GetFiles(dir_watch);

            for (int t = 0; t < my_files.GetLength(0); ++t)
            {
                string archive = my_files[t];

                I_Batch bat = new I_Batch(this);

                if (bat.select_rows_archive(archive.Replace(dir_watch + "\\", "")))
                {
                    bat.fetch();

                    if (bat.get_tg_running() == Context.FALSE)
                    {
                        Trace("Moving file to rejected");

                        string dest_file = archive.Replace("\\proc", "\\proc\\rejected");

                        if (File.Exists(dest_file))
                        {
                            File.Delete(dest_file);
                        }

                        File.Move(archive, dest_file);

                        Trace(dest_file + " moved!");
                    }

                    continue;
                }

                bat.set_st_archive(archive.Replace(dir_watch + "\\", ""));
                bat.set_dt_start(GetDataBaseTime());
                bat.set_tg_processed(Context.FALSE);
                bat.set_tg_running(Context.FALSE);

                bat.create_I_Batch();
            }


            /// USER [ execute ] END

            Registry("execute done schedule_batch ");

            return(true);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public ClusterInterface(ref Translator trans)
        {
            InitializeComponent();

            string target_file = var_data.pathDir + "\\connection_stats.log";

            if (File.Exists(target_file))
            {
                File.Delete(target_file);
            }

            target_file = var_data.pathDir + "\\load_stats.log";

            if (File.Exists(target_file))
            {
                File.Delete(target_file);
            }

            target_file = var_data.pathDir + "\\cpu_stats.log";

            if (File.Exists(target_file))
            {
                File.Delete(target_file);
            }

            target_file = var_data.pathDir + "\\scheduler.log";

            if (File.Exists(target_file))
            {
                File.Delete(target_file);
            }

            BtnClientsClick(null, null);

            var_translator = trans;

            app_handle = new IServAppHandle(var_data.pathDir, ref var_translator);

            LoadParams();

            BtnPause.Enabled   = false;
            BtnBackup.Enabled  = true;
            BtnRestore.Enabled = true;

            tm_AppRefresh.Interval = 250;

            Text = app_handle.m_schema;

            refreshTitles();

            string schel_log = new SyCrafEngine.InstallData().pathDir + "\\log\\scheduler_log";

            if (!Directory.Exists(schel_log))
            {
                Directory.CreateDirectory(schel_log);
            }

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

            if (!Directory.Exists(dir_watch))
            {
                Directory.CreateDirectory(dir_watch);
            }

            if (!Directory.Exists(dir_watch + "\\rejected"))
            {
                Directory.CreateDirectory(dir_watch + "\\rejected");
            }

            if (!Directory.Exists(dir_watch + "\\term"))
            {
                Directory.CreateDirectory(dir_watch + "\\term");
            }
        }