Beispiel #1
0
        public async Task RunRunset(bool doContinueRun = false)
        {
            try
            {
                mRunSetConfig.IsRunning = true;

                //reset run
                if (doContinueRun == false)
                {
                    if (WorkSpace.Instance.RunningInExecutionMode == false || RunSetConfig.ExecutionID == null)
                    {
                        RunSetConfig.ExecutionID = Guid.NewGuid();
                    }
                    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("Configuring {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)));
                    WorkSpace.Instance.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> {
                        RunSetActionBase.eRunAt.ExecutionStart, RunSetActionBase.eRunAt.DuringExecution
                    });
                }

                //Start Run
                if (doContinueRun == false)
                {
                    Reporter.ToLog(eLogLevel.INFO, string.Format("########################## {0} Execution Started: '{1}'", GingerDicser.GetTermResValue(eTermResKey.RunSet), RunSetConfig.Name));
                    SetRunnersExecutionLoggerConfigs();//contains ExecutionLogger.RunSetStart()
                }
                else
                {
                    Reporter.ToLog(eLogLevel.INFO, string.Format("########################## {0} Execution Continuation: '{1}'", GingerDicser.GetTermResValue(eTermResKey.RunSet), RunSetConfig.Name));
                }

                mStopwatch.Start();
                Reporter.ToLog(eLogLevel.INFO, string.Format("######## {0} Runners Execution Started", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                List <Task> runnersTasks = new List <Task>();
                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
                            {
                                //continue
                                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();
                                }
                            }

                            if (GR.Status == eRunStatus.Failed && mRunSetConfig.StopRunnersOnFailure)
                            {
                                //marking next Runners as blocked and stopping execution
                                for (int indx = Runners.IndexOf(GR) + 1; indx < Runners.Count; indx++)
                                {
                                    Runners[indx].SetNextBusinessFlowsBlockedStatus();
                                    Runners[indx].Status = eRunStatus.Blocked;
                                    Runners[indx].GiveUserFeedback();//for getting update for runner stats on runset page
                                }

                                break;
                            }

                            // 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.INFO, string.Format("######## {0} Runners Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                //ExecutionLoggerManager.RunSetEnd();
                Runners[0].ExecutionLoggerManager.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)));
                    WorkSpace.Instance.RunsetExecutor.ProcessRunSetActions(new List <RunSetActionBase.eRunAt> {
                        RunSetActionBase.eRunAt.ExecutionEnd
                    });
                }
                Reporter.ToLog(eLogLevel.INFO, string.Format("######## Creating {0} Execution Report", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                CreateGingerExecutionReportAutomaticly();
                Reporter.ToLog(eLogLevel.INFO, string.Format("######## Doing {0} Execution Cleanup", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                CloseAllEnvironments();
                Reporter.ToLog(eLogLevel.INFO, string.Format("########################## {0} Execution Ended", GingerDicser.GetTermResValue(eTermResKey.RunSet)));

                await Runners[0].ExecutionLoggerManager.PublishToCentralDBAsync(RunSetConfig.LiteDbId, RunSetConfig.ExecutionID ?? Guid.Empty);
            }
            finally
            {
                mRunSetConfig.IsRunning = false;
            }
        }
Beispiel #2
0
 private void CalculateMargin()
 {
     Margin = Runners.Sum(x => x.DecimalPrice);
 }
 public virtual T AddRunner(Action <IContainer> runner)
 {
     Runners.Add(runner);
     return(this as T);
 }
Beispiel #4
0
 /// <summary>
 /// Calculates the race margin for the <see cref="Runners"/>.
 /// </summary>
 private void ReCalculateRaceMargin()
 {
     _raceMargin = Math.Round(Runners.Sum(r => r.GetMargin()), 2);
     OnPropertyChanged(nameof(RaceMargin));
     EvaluateCanRunRace();
 }
 public void AddRunner(Runner runner)
 {
     Runners.Add(runner);
 }