public void RunRunset(bool doContinueRun = false) { List <Task> runnersTasks = new List <Task>(); //reset run if (doContinueRun == false) { RunSetConfig.LastRunsetLoggerFolder = "-1"; Reporter.ToLog(eLogLevel.INFO, string.Format("Reseting {0} elements", GingerDicser.GetTermResValue(eTermResKey.RunSet))); mStopwatch.Reset(); ResetRunnersExecutionDetails(); } else { RunSetConfig.LastRunsetLoggerFolder = null; } mStopRun = false; //configure Runners for run Reporter.ToLog(eLogLevel.INFO, string.Format("Configurating {0} elements for execution", GingerDicser.GetTermResValue(eTermResKey.RunSet))); ConfigureAllRunnersForExecution(); //Process all pre execution Run Set Operations if (doContinueRun == false) { Reporter.ToLog(eLogLevel.INFO, string.Format("Running Pre-Execution {0} Operations", GingerDicser.GetTermResValue(eTermResKey.RunSet))); //Dispatcher.CurrentDispatcher.Invoke(() => //ToDO: Remove dependency on UI thread- it should run in backend //{ WorkSpace.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> { RunSetActionBase.eRunAt.ExecutionStart, RunSetActionBase.eRunAt.DuringExecution }); //}); } //Start Run if (doContinueRun == false) { Reporter.ToLog(eLogLevel.INFO, string.Format("########################## Starting {0} Execution", GingerDicser.GetTermResValue(eTermResKey.RunSet))); SetRunnersExecutionLoggerConfigs();//contains ExecutionLogger.RunSetStart() } else { Reporter.ToLog(eLogLevel.INFO, string.Format("########################## Continue {0} Execution", GingerDicser.GetTermResValue(eTermResKey.RunSet))); } mStopwatch.Start(); if (RunSetConfig.RunModeParallel) { //running parallel foreach (IGingerRunner GR in Runners) { if (mStopRun) { return; } Task t = new Task(() => { if (doContinueRun == false) { GR.RunRunner(); } else if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) //we continue only Stopped Runners { GR.ResetRunnerExecutionDetails(doNotResetBusFlows: true); //reset stopped runners only and not their BF's GR.ContinueRun(eContinueLevel.Runner, eContinueFrom.LastStoppedAction); } }, TaskCreationOptions.LongRunning); runnersTasks.Add(t); t.Start(); // Wait one second before starting another runner Thread.Sleep(1000); } } else { //running sequentially Task t = new Task(() => { foreach (IGingerRunner GR in Runners) { if (mStopRun) { return; } if (doContinueRun == false) { GR.RunRunner(); } else if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) //we continue only Stopped Runners { GR.ResetRunnerExecutionDetails(doNotResetBusFlows: true); //reset stopped runners only and not their BF's GR.ContinueRun(eContinueLevel.Runner, eContinueFrom.LastStoppedAction); } else if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending) //continue the runners flow { GR.RunRunner(); } // Wait one second before starting another runner Thread.Sleep(1000); } }, TaskCreationOptions.LongRunning); runnersTasks.Add(t); t.Start(); } //Wait till end of run when all tasks are completed int count = 0; while (count < runnersTasks.Count) //removing dependency on stop because all Runners needs to stop first before exit { Thread.Sleep(100); count = (from x in runnersTasks where x.IsCompleted select x).Count(); } mStopwatch.Stop(); //Do post execution items Reporter.ToLog(eLogLevel.INFO, string.Format("######## {0} Runners Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet))); ExecutionLogger.RunSetEnd(); if (mStopRun == false) { // Process all post execution RunSet Operations Reporter.ToLog(eLogLevel.INFO, string.Format("######## Running Post-Execution {0} Operations", GingerDicser.GetTermResValue(eTermResKey.RunSet))); //Dispatcher.CurrentDispatcher.Invoke(() => //ToDO: Remove dependency on UI thread- it should run in backend //{ WorkSpace.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> { RunSetActionBase.eRunAt.ExecutionEnd }); //}); } Reporter.ToLog(eLogLevel.INFO, string.Format("######## Doing {0} Execution Cleanup", GingerDicser.GetTermResValue(eTermResKey.RunSet))); CreateGingerExecutionReportAutomaticly(); CloseAllEnvironments(); Reporter.ToLog(eLogLevel.INFO, string.Format("########################## {0} Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet))); }
public void RunRunset(bool doContinueRun = false) { List <Task> runnersTasks = new List <Task>(); //reset run if (doContinueRun == false) { RunSetConfig.LastRunsetLoggerFolder = "-1"; // !!!!!!!!!!!!!!!!!! Reporter.ToLog(eLogLevel.DEBUG, string.Format("Reseting {0} elements", GingerDicser.GetTermResValue(eTermResKey.RunSet))); mStopwatch.Reset(); ResetRunnersExecutionDetails(); } else { RunSetConfig.LastRunsetLoggerFolder = null; } mStopRun = false; //configure Runners for run Reporter.ToLog(eLogLevel.DEBUG, string.Format("Configurating {0} elements for execution", GingerDicser.GetTermResValue(eTermResKey.RunSet))); ConfigureAllRunnersForExecution(); //Process all pre execution Run Set Operations if (doContinueRun == false) { Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running Pre-Execution {0} Operations", GingerDicser.GetTermResValue(eTermResKey.RunSet))); WorkSpace.Instance.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> { RunSetActionBase.eRunAt.ExecutionStart, RunSetActionBase.eRunAt.DuringExecution }); } //Start Run if (doContinueRun == false) { Reporter.ToLog(eLogLevel.DEBUG, string.Format("########################## {0} Execution Started: '{1}'", GingerDicser.GetTermResValue(eTermResKey.RunSet), RunSetConfig.Name)); SetRunnersExecutionLoggerConfigs();//contains ExecutionLogger.RunSetStart() } else { Reporter.ToLog(eLogLevel.DEBUG, string.Format("########################## {0} Execution Continuation: '{1}'", GingerDicser.GetTermResValue(eTermResKey.RunSet), RunSetConfig.Name)); } mStopwatch.Start(); Reporter.ToLog(eLogLevel.DEBUG, string.Format("######## {0} Runners Execution Started", GingerDicser.GetTermResValue(eTermResKey.RunSet))); if (RunSetConfig.RunModeParallel) { foreach (GingerRunner GR in Runners) { if (mStopRun) { return; } Task t = new Task(() => { if (doContinueRun == false) { GR.RunRunner(); } else if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) //we continue only Stopped Runners { GR.ResetRunnerExecutionDetails(doNotResetBusFlows: true); //reset stopped runners only and not their BF's GR.ContinueRun(eContinueLevel.Runner, eContinueFrom.LastStoppedAction); } }, TaskCreationOptions.LongRunning); runnersTasks.Add(t); t.Start(); // Wait one second before starting another runner Thread.Sleep(1000); } } else { //running sequentially Task t = new Task(() => { foreach (GingerRunner GR in Runners) { if (mStopRun) { return; } if (doContinueRun == false) { GR.RunRunner(); } else if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) //we continue only Stopped Runners { GR.ResetRunnerExecutionDetails(doNotResetBusFlows: true); //reset stopped runners only and not their BF's GR.ContinueRun(eContinueLevel.Runner, eContinueFrom.LastStoppedAction); } else if (GR.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending) //continue the runners flow { GR.RunRunner(); } // Wait one second before starting another runner Thread.Sleep(1000); } }, TaskCreationOptions.LongRunning); runnersTasks.Add(t); t.Start(); } Task.WaitAll(runnersTasks.ToArray()); mStopwatch.Stop(); //Do post execution items Reporter.ToLog(eLogLevel.DEBUG, string.Format("######## {0} Runners Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet))); ExecutionLogger.RunSetEnd(); if (mStopRun == false) { // Process all post execution RunSet Operations Reporter.ToLog(eLogLevel.DEBUG, string.Format("######## Running Post-Execution {0} Operations", GingerDicser.GetTermResValue(eTermResKey.RunSet))); WorkSpace.Instance.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> { RunSetActionBase.eRunAt.ExecutionEnd }); } Reporter.ToLog(eLogLevel.DEBUG, string.Format("######## Doing {0} Execution Cleanup", GingerDicser.GetTermResValue(eTermResKey.RunSet))); CreateGingerExecutionReportAutomaticly(); CloseAllEnvironments(); Reporter.ToLog(eLogLevel.DEBUG, string.Format("########################## {0} Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet))); }