static void Main(string[] args) { LogInitializer.InitializeLogger("BLW.WindowServiceInvokation"); try { // Invoke class instance Factory getInstance = new Factory(); SingletonLogger.Instance.Error(ConfigurationManager.AppSettings["DbFile"]); try { // Class Trigger based var tiggerBased = getInstance.GetInstance("TRIGGERBASE"); tiggerBased.Processing(); } catch (Exception ex) { SingletonLogger.Instance.Error(ex.GetBaseException().ToString()); } // Call Time based try { var timeBased = getInstance.GetInstance("TIMEBASE"); timeBased.Processing(); } catch (Exception ex) { SingletonLogger.Instance.Error(ex.GetBaseException().ToString()); } } catch (Exception ex) { SingletonLogger.Instance.Error(ex.Message, ex.GetBaseException()); } }
public bool Initialize(string[] args) { #if DEBUG Console.WriteLine("Starting Debugging Mode.."); #else Console.WriteLine("Starting Production Mode.."); #endif //Initializing variables LogInitializer.InitializeLogger(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name); //show current assembly version SingletonLogger.Instance.Info("Assembly Version Infomration : " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); #if !DEBUG //Validate command line arguments #region Validate Arguments SingletonLogger.Instance.Debug("Validating command arguments.."); if (args.Length == 0) { SingletonLogger.Instance.Debug("System generated GUID not passed to."); return(false); } var systemGuid = args[0]; SingletonLogger.Instance.Debug(" System generated GUID = " + systemGuid); #endregion #endif return(true); }
/// <summary> /// Initialise Manage Licences form /// </summary> public frmManageLicences() { InitializeComponent(); LogInitializer.InitializeLogger("LicenceApp"); lblMessage.Visible = true; SingletonLogger.Instance.Attach(new ObserverLogToWindows(lblMessage)); // Send log messages to debugger form lbl message (output window). }
public void Start() { LogInitializer.InitializeLogger(); Global.Logger.Info("Initializing database."); var databaseInitializer = new DatabaseInitializer(); databaseInitializer.Initialize(); Global.Logger.Info("Initializing snapshot update scheduler."); var damSnapshotUpdateService = new DamSnapshotUpdateService( new DamExcelDownloader(new DownloadService()), new ExcelReader(), new DataSetToDamSnapshotTranslator(new DamRepository(() => new DataContext())), new DamSnapshotRepository(() => new DataContext())); _updateDamSnapshotsScheduler = new UpdateDamSnapshotsScheduler( damSnapshotUpdateService); Global.Logger.Info("Strating scheduler database."); var task = _updateDamSnapshotsScheduler.Start(); task.Wait(TimeSpan.FromSeconds(30)); if (task.Status != TaskStatus.RanToCompletion) { throw new Exception("Failed to start scheduler."); } }
static void Main(string[] args) { var logInitializer = new LogInitializer(); var logger = logInitializer.InitializeLogger(); var engine = new Engine(logger); engine.Run(); }
static void Main(string[] args) { LogInitializer.InitializeLogger("ZipExtractor"); SingletonLogger.Instance.Debug("Extractor component has been started."); var systemGuid = string.Empty; var triggerFile = string.Empty; #region Validate Command Arguments // Start Processing if (args.Length != 2) { SingletonLogger.Instance.Debug("Number of passed arguments are Invalid."); return; } else { triggerFile = args[0]; systemGuid = args[1]; } if (!File.Exists(triggerFile)) { SingletonLogger.Instance.Error("Trigger file does not exist at = " + triggerFile); return; } else { SingletonLogger.Instance.Debug("Trigger file = " + triggerFile); } if (String.IsNullOrEmpty(systemGuid)) { SingletonLogger.Instance.Error("Trigger file does not exist at = " + triggerFile); return; } else { SingletonLogger.Instance.Debug("System generated GUID = " + systemGuid); } #endregion #region Move trigger file from Invoker trigger location to Component trigger location // We are moving trigger file from invoker location to avoid reprocessing of same file TriggerFileLocation = AppConfig.GetValueByKey("TriggerFileDirectory"); if (!Directory.Exists(TriggerFileLocation)) { Directory.CreateDirectory(TriggerFileLocation); } TriggerFileLocation = Path.Combine(TriggerFileLocation, Path.GetFileName(triggerFile)); //Move to intermediate directory File.Move(triggerFile, TriggerFileLocation); SingletonLogger.Instance.Debug("Trigger has been moved at " + TriggerFileLocation); #endregion XmlHelper objXmlHelper = new XmlHelper(); var componentStartDate = DateTime.Now.ToString(); SingletonLogger.Instance.Debug("Process start reading Trigger XML file " + TriggerFileLocation); TriggerFileReader objTriggerFileReader = new TriggerFileReader(); objTriggerFileReader.TriggerFileLocaton = TriggerFileLocation; var triggerFileDetail = objTriggerFileReader.GetTriggerFileDetail(); SingletonLogger.Instance.Debug("Process successfully read trigger XML file."); try { mapper = new PatternMatchingMapper(); mapper.SetCurrentDateFormat(); mapper.SetClientAndAppDetails(triggerFileDetail.RunNumber); var inputLocation = triggerFileDetail.InputDetails.FirstOrDefault(); var outputLocation = triggerFileDetail.OutputDetails.FirstOrDefault(); if (inputLocation == null) { throw new Exception(""); } string inputLoc = mapper.EvaluateString(inputLocation.DirectoryLocation); string outputLoc = mapper.EvaluateString(outputLocation.DirectoryLocation); if (String.IsNullOrEmpty(inputLoc)) { throw new Exception("Input loction is never be null or empty"); } if (!Directory.Exists(inputLoc)) { throw new Exception("Input loction not exists" + inputLoc); } var availableFiles = Directory.GetFiles(inputLoc, inputLocation.FileMask); if (String.IsNullOrEmpty(outputLoc)) { throw new Exception("Output loction is never be null or empty"); } if (!Directory.Exists(outputLoc)) { Directory.CreateDirectory(outputLoc); } foreach (var zipfile in availableFiles) { // Start Extracting SingletonLogger.Instance.Debug("Start processing " + Path.GetFileName(TriggerFileLocation) + " file."); ExtractOperations.ExtractFile(zipfile, outputLoc); if (AppConfig.FileOperation) { File.Delete(zipfile); } } objXmlHelper.WriteComponentStatusInTriggerFile(TriggerFileLocation, componentStartDate, DateTime.Now.ToString()); File.Move(TriggerFileLocation, triggerFileDetail.ComponentStatusDirectory + "\\status_" + Path.GetFileName(TriggerFileLocation)); } catch (Exception ex) { objXmlHelper.WriteComponentStatusInTriggerFile(TriggerFileLocation, componentStartDate, DateTime.Now.ToString(), "Error", ex.GetBaseException().ToString()); File.Move(TriggerFileLocation, triggerFileDetail.ComponentStatusDirectory + "\\status_" + Path.GetFileName(TriggerFileLocation)); SingletonLogger.Instance.Error("Error in ZipExtractor. Error message : " + ex.Message + ". Error Detail : " + ex.StackTrace); } finally { #region Deleting Entry from Transaction Table try { // SQLITE Database Initialization Transaction trans = Transaction.Get(systemGuid); if (Transaction.Delete(systemGuid)) { if (trans != null) { Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now); } SingletonLogger.Instance.Debug("Successfully removed column. GUID = " + systemGuid); } else { SingletonLogger.Instance.Debug("Error while removing column. GUID = " + systemGuid); } } catch (Exception ex2) { SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString()); } #endregion } }
/// <summary> /// Entry point of application /// </summary> /// <param name="args">Command line arguments({Session Key} and {AppId})</param> static void Main(string[] args) { //Declare global variables String sessionKey = String.Empty; int appId = -1; //start application try { Console.WriteLine("======Job initialization Process started======"); #region Validate Command Arguments //Validating arguments if (args.Count() == 0) { throw new ArgumentOutOfRangeException("No argument supplied for run Job initialization"); } if (String.IsNullOrEmpty(args[0])) { throw new ArgumentOutOfRangeException("Session key not supplied"); } else { sessionKey = Convert.ToString(args[0]); } if (String.IsNullOrEmpty(args[1])) { throw new ArgumentOutOfRangeException("Application ID not supplied"); } else { appId = Convert.ToInt32(args[1]); } #endregion LogInitializer.InitializeLogger("JobInitialization_" + appId); SingletonLogger.Instance.Info("Assembly Version Infomration : " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); SingletonLogger.Instance.Debug("Connecting to WCF."); JobInitHelper helper = new JobInitHelper(); SingletonLogger.Instance.Debug("Connected."); var runNos = helper.Processing(sessionKey, appId); if (runNos.Count() != 0) { foreach (var runNo in runNos) { SingletonLogger.Instance.Debug("Start preprocessing for run number " + runNo.RunNumber + " and outputPath" + runNo.Output); Main processRunNo = new Main(); int status = processRunNo.Run(runNo.RunNumber, runNo.Output); if (status == 0) { SingletonLogger.Instance.Debug("Completed preprocessing for run number " + runNo.RunNumber + " and outputPath" + runNo.Output); } } } } catch (Exception e) { Console.WriteLine("Error " + e.ToString()); //If errors, then do nothing (just exit) try { if (!string.IsNullOrEmpty(sessionKey)) { using (IProcSessionsRepository repository = new ProcSessionsRepository()) { repository.UpdateBySessionKey(sessionKey, Convert.ToByte(JobStatusType.Error)); } } } catch (Exception ex) { /*Error in update session key*/ SingletonLogger.Instance.Error("Error in update session key" + ex.ToString()); } SingletonLogger.Instance.Error("Error in Job Initializer" + e.ToString()); // SingletonLogger.Instance.Error(e.ToString()); } }
static void Main(string[] args) { var systemGuid = string.Empty; try { #region Validate Command Arguments if (args.Length == 0) { throw new ArgumentOutOfRangeException("No argument supplied for run Trigger manager"); } if (String.IsNullOrEmpty(args[0])) { throw new ArgumentOutOfRangeException("System Guid not supplied"); } else { systemGuid = Convert.ToString(args[0]); } #endregion LogInitializer.InitializeLogger("Email Sender"); SingletonLogger.Instance.Debug("Email Sender Component starts."); SingletonLogger.Instance.Info("Assembly Version Infomration : " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); Processing obj = new Processing(); obj.SendEmails(); } catch (Exception ex) { SingletonLogger.Instance.Error(ex.GetBaseException().ToString()); } finally { #region Deleting Entry from Transaction Table try { // SQLITE Database Initialization Transaction trans = Transaction.Get(systemGuid); if (Transaction.Delete(systemGuid)) { if (trans != null) { Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now); } SingletonLogger.Instance.Debug("Successfully removed column. GUID = " + systemGuid); } else { SingletonLogger.Instance.Debug("Error while removing column. GUID = " + systemGuid); } } catch (Exception ex2) { SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString()); } #endregion } }
/// <summary> /// Entry point of the application /// </summary> /// <param name="args">Command Line arguments</param> static void Main(string[] args) { var systemGuid = string.Empty; try { #region Validate Command Arguments if (args.Length == 0) { throw new ArgumentOutOfRangeException("No argument supplied for run ProcSession manager"); } if (String.IsNullOrEmpty(args[0])) { throw new ArgumentOutOfRangeException("System Guid not supplied"); } else { systemGuid = args[0]; } #endregion try { LogInitializer.InitializeLogger("ProcSessionManager"); SingletonLogger.Instance.Debug(" Application ProcSession Manager Component starts."); SingletonLogger.Instance.Debug(" System generated GUID = " + systemGuid); IProcSessionsRepository sessionRepository = new ProcSessionsRepository(); SingletonLogger.Instance.Debug("Getting the list of the Unused process"); // get list of Unused process from ProcSessions table whose killrequired= true or status=3 or status=2 etc. var unUsedProcessList = sessionRepository.GetAllUnusedProcess(); if (unUsedProcessList != null) { foreach (var unusedProcSession in unUsedProcessList) { // validating unusedProcSession if (unusedProcSession != null) { // kill the Process if killrequired = true or expected datetime is < current datetime if (unusedProcSession.KillRequired) { //Check that no component is running for it int processId = 0; // parsing the processId if (!int.TryParse(unusedProcSession.ProcessID, out processId)) { throw new Exception("ProcessId is not valid" + processId); } Process process = Process.GetProcessById(processId); if (process == null) { SingletonLogger.Instance.Error("No process is running with id{0}" + processId); } else { try { SingletonLogger.Instance.Debug("Start killing the ProcessId = " + processId); //Killing the process for particular ProcessId process.Kill(); } catch (Exception ex) { throw new Exception("Error while killing the process for processId" + processId, ex); } } } } //update the status of the RunningJob table byte jobstatus = 0; if (unusedProcSession.KillRequired) { jobstatus = (byte)JobStatusType.Status_Killed; } if (unusedProcSession.ExpectedDateTime < DateTime.Now) { jobstatus = (byte)JobStatusType.Status_TimeExp; } if (unusedProcSession.ProcStatus == (Int32)SessionStatusType.Status_Error) { jobstatus = (byte)JobStatusType.Error; } if (unusedProcSession.ProcStatus == (Int32)SessionStatusType.Status_Complete) { jobstatus = (byte)JobStatusType.Complete; } SingletonLogger.Instance.Debug("Deleting the entry from procsession table for ProcsessionId =" + unusedProcSession.ProcSessionId); //Delete ProcSession entry from ProcSessions table sessionRepository.Delete(unusedProcSession.ProcSessionId); SingletonLogger.Instance.Debug("Proc session has been deleted due to status = " + jobstatus); } SingletonLogger.Instance.Debug("ProcSessionManager Component has been Completed"); } } catch (Exception ex) { SingletonLogger.Instance.Error("Error occur in ProcSession component Error detail : " + ex.Message); } finally { #region Deleting Entry from Transaction Table try { // SQLITE Database Initialization Transaction trans = Transaction.Get(systemGuid); if (Transaction.Delete(systemGuid)) { if (trans != null) { Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now); } Console.WriteLine("Successfully removed column. GUID = " + systemGuid); } else { Console.WriteLine("Error while removing column. GUID = " + systemGuid); } } catch (Exception ex2) { SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString()); } #endregion } } catch (Exception ex) { //If errors, then do nothing (just exit) SingletonLogger.Instance.Fatal(ex.ToString()); } }
static void Main(string[] args) { #region Variable Declarations var systemGuid = string.Empty; var triggerFile = string.Empty; #endregion try { LogInitializer.InitializeLogger("ArchiveManager"); SingletonLogger.Instance.Debug("Archive Manager component has been started."); #region Validate Command Arguments // Start Processing if (args.Length != 2) { SingletonLogger.Instance.Debug("Number of passed arguments are Invalid."); return; } else { triggerFile = args[0]; systemGuid = args[1]; } if (!File.Exists(triggerFile)) { SingletonLogger.Instance.Error("Trigger file does not exist at = " + triggerFile); return; } else { SingletonLogger.Instance.Debug("Trigger file = " + triggerFile); } if (String.IsNullOrEmpty(systemGuid)) { SingletonLogger.Instance.Error("Trigger file does not exist at = " + triggerFile); return; } else { SingletonLogger.Instance.Debug("System generated GUID = " + systemGuid); } #endregion #region Move trigger file from Invoker trigger location to Component trigger location // We are moving trigger file from invoker location to avoid reprocessing of same file var intermediateTriggerDirectory = AppConfig.GetValueByKey("TriggerFileDirectory"); if (!Directory.Exists(intermediateTriggerDirectory)) { Directory.CreateDirectory(intermediateTriggerDirectory); } var intermediateTriggerFile = Path.Combine(intermediateTriggerDirectory, Path.GetFileName(triggerFile)); //Move to intermediate directory File.Move(triggerFile, intermediateTriggerFile); SingletonLogger.Instance.Debug("Trigger has been moved at " + intermediateTriggerFile); #endregion #region Start processing Processing objProcessing = new Processing(intermediateTriggerFile); objProcessing.Run(); SingletonLogger.Instance.Debug("Process of Archive Manager has been completed sucesfully."); #endregion } catch (Exception ex) { throw ex; } finally { #region Deleting Entry from Transaction Table try { // SQLITE Database Initialization Transaction trans = Transaction.Get(systemGuid); if (Transaction.Delete(systemGuid)) { if (trans != null) { Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now); } SingletonLogger.Instance.Debug("Successfully removed column. GUID = " + systemGuid); } else { SingletonLogger.Instance.Debug("Error while removing column. GUID = " + systemGuid); } } catch (Exception ex2) { SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString()); } #endregion } }
static void Main(string[] args) { var systemGuid = string.Empty; try { LogInitializer.InitializeLogger("Status Manager"); SingletonLogger.Instance.Debug("Application Status Manager Component started."); #region Validate Command Arguments if (args.Length == 0) { throw new ArgumentOutOfRangeException("No argument supplied for run Status Manager"); } if (String.IsNullOrEmpty(args[0])) { throw new ArgumentOutOfRangeException("System Guid not supplied"); } else { systemGuid = Convert.ToString(args[0]); } #endregion StatusUpdater objStatusUpdater = new StatusUpdater(); // Get all status location to check status file. List <string> statusFileList = objStatusUpdater.GetAllActiveComponentTriggerAndStatusFileLocation().Select(x => x.StepStatusLocation).Distinct().ToList(); SingletonLogger.Instance.Debug("Total Component status location " + statusFileList.Count()); if (statusFileList.Count() > 0) { SingletonLogger.Instance.Debug("Total " + statusFileList.Count() + " Status locations found for status file update."); //Process for each location for status file update. foreach (var item in statusFileList) { try { SingletonLogger.Instance.Debug("Status File location = " + item); objStatusUpdater.UpdateStatus(item); } catch (Exception ex) { SingletonLogger.Instance.Info(ex.ToString()); continue; } } } else { SingletonLogger.Instance.Debug("No Status location found for status file update."); } } catch (Exception ex) { SingletonLogger.Instance.Error(ex.ToString()); } finally { #region Deleting Entry from Transaction Table try { // SQLITE Database Initialization Transaction trans = Transaction.Get(systemGuid); if (Transaction.Delete(systemGuid)) { if (trans != null) { Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now); } SingletonLogger.Instance.Debug("Successfully removed column. GUID = " + systemGuid); } else { SingletonLogger.Instance.Debug("Error while removing column. GUID = " + systemGuid); } } catch (Exception ex2) { SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString()); } #endregion } SingletonLogger.Instance.Debug(" Application Status Manager Component ended."); }
static void Main(string[] args) { var systemGuid = string.Empty; try { LogInitializer.InitializeLogger("Trigger Manager"); SingletonLogger.Instance.Debug("Trigger Manager Component starts."); #region Validate Command Arguments if (args.Length == 0) { throw new ArgumentOutOfRangeException("No argument supplied for run Trigger manager"); } if (String.IsNullOrEmpty(args[0])) { throw new ArgumentOutOfRangeException("System Guid not supplied"); } else { systemGuid = Convert.ToString(args[0]); } #endregion try { SingletonLogger.Instance.Debug("System generated GUID = " + systemGuid); IRunDetailsRepository _runRepository = new RunDetailsRepository(); // Getting Active RunNumber From RunDetails Table. Get only those RunNumber those have "RunStatus=1" var runNumberDetailList = _runRepository.GetRunDetailByStatus((int)RunNumberStatusType.Ready); if (runNumberDetailList.Count() == 0) { SingletonLogger.Instance.Debug("No run number found for trigger generation."); return; } SingletonLogger.Instance.Debug("Total " + runNumberDetailList.Count() + " run number found for trigger generation."); TriggerFileGenerator objTriggerFileGenerator = new TriggerFileGenerator(); foreach (var runNumber in runNumberDetailList) { // If any component for this run number is already running or error out // then no need to created the trigger file and continue for other run number trigger file creation. bool status = objTriggerFileGenerator.CheckForTriggerFileCreation(runNumber); if (!status) { continue; } // Get total trigger file to be generated for run number SingletonLogger.Instance.Debug("Process has been started for creating trigger file for RunNumber = " + runNumber.RunNumber); List <TriggerFileGenerator> TriggerFileGeneratorList = objTriggerFileGenerator.GetTriggerFileGeneratorList(runNumber); if (TriggerFileGeneratorList.Count() > 0) { try { objTriggerFileGenerator.CreateTriggerFile(TriggerFileGeneratorList); } catch (IOBLWException iEx) { SingletonLogger.Instance.Warning(iEx.ToString()); continue; } catch (Exception) { throw; } } else { SingletonLogger.Instance.Debug("No Component Found For Trigger file Generation for RunNumber = " + runNumber.RunNumber); } SingletonLogger.Instance.Debug("All trigger file for RunNumber = " + runNumber.RunNumber + " has been created."); //Update RunStatus of RunNumber to 2 using (IRunDetailsRepository repository = new RunDetailsRepository()) { repository.UpdateRunStatusByRunNumberId(runNumber.RunDetailId, (int)RunNumberStatusType.Running); } SingletonLogger.Instance.Debug("RunStatus of RunNumber in table RunDetails has been Updated to 2."); } } catch (Exception ex) { SingletonLogger.Instance.Error("Error occur while generating trigger for RunNumber. Error detail : " + ex.GetBaseException().StackTrace); } finally { #region Deleting Entry from Transaction Table try { // SQLITE Database Initialization Transaction trans = Transaction.Get(systemGuid); if (Transaction.Delete(systemGuid)) { if (trans != null) { Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now); } SingletonLogger.Instance.Debug("Successfully removed column. GUID = " + systemGuid); } else { SingletonLogger.Instance.Debug("Error while removing column. GUID = " + systemGuid); } } catch (Exception ex2) { SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString()); } #endregion } SingletonLogger.Instance.Debug("Trigger Generation process has been Completed."); } catch (Exception ex) { //If errors, then do nothing (just exit) SingletonLogger.Instance.Fatal(ex.ToString()); } }