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); }
public void copy(ref I_Batch cpy) { st_archive = cpy.st_archive; dt_start = cpy.dt_start; dt_proc_start = cpy.dt_proc_start; dt_proc_end = cpy.dt_proc_end; tg_processed = cpy.tg_processed; tg_running = cpy.tg_running; }
public override bool authenticate( ) { Registry("authenticate type_load "); /// USER [ authenticate ] DataPortable dp = MemoryGet("input"); db_archive = dp.getValue("archive"); dir_watch = new SyCrafEngine.InstallData().pathDir + "\\proc\\"; archive = dir_watch + db_archive; Trace(archive); bat = new I_Batch(this); bat.ExclusiveAccess(); if (bat.select_rows_archive(db_archive)) { bat.fetch(); bat.set_dt_proc_start(GetDataBaseTime()); bat.set_tg_running(Context.TRUE); bat.synchronize_I_Batch(); bat.ReleaseExclusive(); } /// USER [ authenticate ] END Registry("authenticate done type_load "); return(true); }
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); }