public override bool Execute(ProgramOptions programOptions, JobConfiguration jobConfiguration) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); StepTiming stepTimingFunction = new StepTiming(); stepTimingFunction.JobFileName = programOptions.OutputJobFilePath; stepTimingFunction.StepName = jobConfiguration.Status.ToString(); stepTimingFunction.StepID = (int)jobConfiguration.Status; stepTimingFunction.StartTime = DateTime.Now; stepTimingFunction.NumEntities = jobConfiguration.Target.Count; this.DisplayJobStepStartingStatus(jobConfiguration); FilePathMap = new FilePathMap(programOptions, jobConfiguration); try { if (this.ShouldExecute(programOptions, jobConfiguration) == false) { return(true); } // Process each Controller once int i = 0; var controllers = jobConfiguration.Target.GroupBy(t => t.Controller); foreach (var controllerGroup in controllers) { Stopwatch stopWatchTarget = new Stopwatch(); stopWatchTarget.Start(); JobTarget jobTarget = controllerGroup.ToList()[0]; StepTiming stepTimingTarget = new StepTiming(); stepTimingTarget.Controller = jobTarget.Controller; stepTimingTarget.ApplicationName = jobTarget.Application; stepTimingTarget.ApplicationID = jobTarget.ApplicationID; stepTimingTarget.JobFileName = programOptions.OutputJobFilePath; stepTimingTarget.StepName = jobConfiguration.Status.ToString(); stepTimingTarget.StepID = (int)jobConfiguration.Status; stepTimingTarget.StartTime = DateTime.Now; stepTimingTarget.NumEntities = 1; try { this.DisplayJobTargetStartingStatus(jobConfiguration, jobTarget, i + 1); // Set up controller access using (ControllerApi controllerApi = new ControllerApi(jobTarget.Controller, jobTarget.UserName, AESEncryptionHelper.Decrypt(jobTarget.UserPassword))) { controllerApi.PrivateApiLogin(); #region Settings loggerConsole.Info("Controller Settings"); string controllerSettingsJSON = controllerApi.GetControllerSettings(); if (controllerSettingsJSON != String.Empty) { FileIOHelper.SaveFileToPath(controllerSettingsJSON, FilePathMap.ControllerSettingsDataFilePath(jobTarget)); } #endregion #region HTTP Templates loggerConsole.Info("HTTP Templates"); string httpTemplatesJSON = controllerApi.GetControllerHTTPTemplates(); if (httpTemplatesJSON != String.Empty) { FileIOHelper.SaveFileToPath(httpTemplatesJSON, FilePathMap.HTTPTemplatesDataFilePath(jobTarget)); } string httpTemplatesDetailJSON = controllerApi.GetControllerHTTPTemplatesDetail(); if (httpTemplatesDetailJSON != String.Empty) { FileIOHelper.SaveFileToPath(httpTemplatesDetailJSON, FilePathMap.HTTPTemplatesDetailDataFilePath(jobTarget)); } #endregion #region Email Templates loggerConsole.Info("Email Templates"); string emailTemplatesJSON = controllerApi.GetControllerEmailTemplates(); if (emailTemplatesJSON != String.Empty) { FileIOHelper.SaveFileToPath(emailTemplatesJSON, FilePathMap.EmailTemplatesDataFilePath(jobTarget)); } string emailTemplatesDetailJSON = controllerApi.GetControllerEmailTemplatesDetail(); if (emailTemplatesDetailJSON != String.Empty) { FileIOHelper.SaveFileToPath(emailTemplatesDetailJSON, FilePathMap.EmailTemplatesDetailDataFilePath(jobTarget)); } #endregion } } catch (Exception ex) { logger.Warn(ex); loggerConsole.Warn(ex); return(false); } finally { stopWatchTarget.Stop(); this.DisplayJobTargetEndedStatus(jobConfiguration, jobTarget, i + 1, stopWatchTarget); stepTimingTarget.EndTime = DateTime.Now; stepTimingTarget.Duration = stopWatchTarget.Elapsed; stepTimingTarget.DurationMS = stopWatchTarget.ElapsedMilliseconds; List <StepTiming> stepTimings = new List <StepTiming>(1); stepTimings.Add(stepTimingTarget); FileIOHelper.WriteListToCSVFile(stepTimings, new StepTimingReportMap(), FilePathMap.StepTimingReportFilePath(), true); } i++; } return(true); } catch (Exception ex) { logger.Error(ex); loggerConsole.Error(ex); return(false); } finally { stopWatch.Stop(); this.DisplayJobStepEndedStatus(jobConfiguration, stopWatch); stepTimingFunction.EndTime = DateTime.Now; stepTimingFunction.Duration = stopWatch.Elapsed; stepTimingFunction.DurationMS = stopWatch.ElapsedMilliseconds; List <StepTiming> stepTimings = new List <StepTiming>(1); stepTimings.Add(stepTimingFunction); FileIOHelper.WriteListToCSVFile(stepTimings, new StepTimingReportMap(), FilePathMap.StepTimingReportFilePath(), true); } }