Beispiel #1
0
        public IActionResult CancelExecution(Guid id)
        {
            var resource = ResourceDataService.Get(id);

            if (resource == null || resource.SubscriberId != User.Claims.First(claim => claim.Type == JwtClaimTypes.Subject).Value)
            {
                return(NotFound(ResourceNotFound(id.ToString())));
            }
            if (resource.Status == Status.Enqueued || resource.Status == Status.InProgress)
            {
                //if(resource.InnerJobId != null)
                //    BackgroundJob.Delete(resource.InnerJobId);

                //BackgroundJob.Delete(resource.JobId);

                ExecutionLogger.SetExecutionId(id);
                ExecutionLogger.Error("Execution canceled by the user.");

                resource.Status     = Status.Canceled;
                resource.FinishTime = DateTime.Now;
                resource.CancelJob  = true;
                ResourceDataService.Update(resource);
                ResourceDataService.SaveChanges();
            }
            return(NoContent());
        }
        private void ReportBtnClicked(object sender, RoutedEventArgs e)
        {
            HTMLReportsConfiguration currentConf = App.UserProfile.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();

            if (grdExecutionsHistory.CurrentItem == null)
            {
                Reporter.ToUser(eUserMsgKeys.NoItemWasSelected);
                return;
            }

            string runSetFolder = ExecutionLogger.GetLoggerDirectory(((RunSetReport)grdExecutionsHistory.CurrentItem).LogFolder);

            string reportsResultFolder = Ginger.Reports.GingerExecutionReport.ExtensionMethods.CreateGingerExecutionReport(new ReportInfo(runSetFolder), false, null, null, false, currentConf.HTMLReportConfigurationMaximalFolderSize);

            if (reportsResultFolder == string.Empty)
            {
                Reporter.ToUser(eUserMsgKeys.NoItemWasSelected);
                return;
            }
            else
            {
                Process.Start(reportsResultFolder);
                Process.Start(reportsResultFolder + "\\" + "GingerExecutionReport.html");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new Workflow Application instance and executes the Current Workflow
        /// </summary>
        private void CmdWorkflowRun(object sender, ExecutedRoutedEventArgs e)
        {
            _wfApp?.Abort();

            var name = Name;
            var m    = new ExecutionMessage()
            {
                ExecutionState = "WorkflowStart", Sender = Name, ParentNames = new string[0]
            };

            subject.OnNext(m);
            var s = string.Format("[{0}] [{1}] [{2}]",
                                  DateTime.Now.ToString("HH:mm:ss"),
                                  m.Sender,
                                  m.ExecutionState);

            LogExecution(s);

            var activityExecute = GetActivity();

            //configure workflow application
            executionLog.Text = string.Empty;
            //consoleOutput.Text = string.Empty;
            _executionLog         = new ExecutionLogger();
            disposable.Disposable = _executionLog.Messages.Subscribe(InjectExecutionLog);

            _wfApp = new WorkflowApplication(activityExecute);
            _wfApp.Extensions.Add(_executionLog);
            _wfApp.Completed = WfExecutionCompleted;
            _wfApp.Aborted   = WfAborted;

            //execute
            _wfApp.Run();
        }
Beispiel #4
0
        // Wraps our use of the proxy client library
        private async Task GetFileAsync(ContainerItem ticketedItem, string tmpDownloadPath, CancellationToken cancellationToken)
        {
            // Will get doubled on each attempt.
            TimeSpan timeBetweenRetries = ContainerFetchEngineOptions.RetryInterval;

            for (int triesRemaining = ContainerFetchEngineOptions.RetryLimit; ; triesRemaining--)
            {
                bool lastAttempt = (triesRemaining == 0);
                timeBetweenRetries += timeBetweenRetries;

                // Delete the tmp file inbetween attempts
                FileSystemManager.DeleteFile(tmpDownloadPath);

                try
                {
                    Task <Stream> getFileTask = Provider.GetFileTask(ticketedItem, cancellationToken);

                    ExecutionLogger.Debug(StringUtil.Format("Fetching contents of file {0}", tmpDownloadPath));

                    await getFileTask.ConfigureAwait(false);

                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }

                    ExecutionLogger.Debug(StringUtil.Format("Writing contents of file {0} to disk", tmpDownloadPath));

                    using (Stream stream = await getFileTask.ConfigureAwait(false))
                    {
                        await FileSystemManager.WriteStreamToFile(stream, tmpDownloadPath, ContainerFetchEngineOptions.DownloadBufferSize, cancellationToken);
                    }

                    ExecutionLogger.Debug(StringUtil.Format("Finished writing contents of file {0} to disk", tmpDownloadPath));

                    break;
                }
                catch (Exception exception)
                {
                    if (exception is AggregateException)
                    {
                        exception = ((AggregateException)exception).Flatten().InnerException;
                    }

                    if (lastAttempt)
                    {
                        throw new Exception(StringUtil.Loc("RMErrorDownloadingContainerItem", tmpDownloadPath, exception));
                    }

                    lock (_lock)
                    {
                        ExecutionLogger.Warning(StringUtil.Loc("RMReAttemptingDownloadOfContainerItem", tmpDownloadPath, exception));
                    }
                }

                // "Sleep" in between attempts. (Can't await inside a catch clause.)
                await Task.Delay(timeBetweenRetries);
            }
        }
Beispiel #5
0
        public void Dispose()
        {
            if (_downloadedFiles > 0)
            {
                ExecutionLogger.Output(StringUtil.Loc("RMDownloadComplete"));
            }

            LogStatistics();
        }
Beispiel #6
0
        //ExecutionLogger executionLogger;
        void RunFlow(BusinessFlow businessFlow)
        {
            GingerRunner    gingerRunner = new GingerRunner();
            ExecutionLogger ex           = (ExecutionLogger)gingerRunner.RunListeners[0]; // temp until we remove it from GR constructor and add manually

            ex.ExecutionLogfolder = jsonDumpFolder;
            ex.Configuration.ExecutionLoggerConfigurationIsEnabled = true;
            //ex.exec
            // ex.Configuration.exe
            // TODO: add dumper

            ProjEnvironment projEnvironment = new ProjEnvironment();

            //ExecutionDumperListener executionDumperListener = new ExecutionDumperListener(@"c:\temp\dumper");   // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! temp
            //gingerRunner.RunListeners.Add(executionDumperListener);


            // executionLogger = new ExecutionLogger(projEnvironment, eExecutedFrom.Automation);
            // executionLogger.Configuration.ExecutionLoggerConfigurationIsEnabled = true;
            // gingerRunner.RunListeners.Add(executionLogger);
            gingerRunner.BusinessFlows.Clear();
            gingerRunner.BusinessFlows.Add(businessFlow);
            gingerRunner.CurrentBusinessFlow = businessFlow;
            gingerRunner.RunRunner();

            Console.WriteLine("Execution Completed");
            Console.WriteLine("----------------------------");
            Console.WriteLine("Elapsed: " + businessFlow.Elapsed);
            Console.WriteLine("Business Flow: " + businessFlow.Name);
            Console.WriteLine("Business Flow Description: " + businessFlow.Description);
            Console.WriteLine("Business Flow Status: " + businessFlow.RunStatus);
            Console.WriteLine("Activities Count: " + businessFlow.Activities.Count);
            Console.WriteLine("----------------------------");

            foreach (Activity activity in businessFlow.Activities)
            {
                Console.WriteLine("Activity: " + activity.ActivityName + " Status: " + activity.Status);

                Console.WriteLine("Actions Found:" + activity.Acts.Count);
                foreach (Act act in activity.Acts)
                {
                    Console.WriteLine("--");
                    Console.WriteLine("Action:" + act.Description);
                    Console.WriteLine("Description:" + act.ActionDescription);
                    Console.WriteLine("Type:" + act.ActionType);
                    Console.WriteLine("Class:" + act.ActClass);
                    Console.WriteLine("Status:" + act.Status);
                    Console.WriteLine("Error:" + act.Error);
                    Console.WriteLine("ExInfo:" + act.ExInfo);
                }
                Console.WriteLine("----------");
            }

            GenerateReport(businessFlow);

            //TODO: create report
        }
Beispiel #7
0
        // Wraps our use of the proxy client library
        private async Task GetFileAsync(ContainerItem ticketedItem, string tmpDownloadPath, CancellationToken cancellationToken)
        {
            // Will get doubled on each attempt.
            TimeSpan timeBetweenRetries = ContainerFetchEngineOptions.RetryInterval;

            for (int triesRemaining = ContainerFetchEngineOptions.RetryLimit; ; triesRemaining--)
            {
                bool lastAttempt = (triesRemaining == 0);
                timeBetweenRetries += timeBetweenRetries;

                // Delete the tmp file inbetween attempts
                FileSystemManager.DeleteFile(tmpDownloadPath);

                try
                {
                    Task <Stream> getFileTask = Provider.GetFileTask(ticketedItem, cancellationToken);
                    Task          timeoutTask = Task.Delay(ContainerFetchEngineOptions.GetFileAsyncTimeout, cancellationToken);

                    // Wait for GetFileAsync or the timeout to elapse.
                    await Task.WhenAny(getFileTask, timeoutTask).ConfigureAwait(false);

                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }

                    if (!getFileTask.IsCompleted)
                    {
                        throw new TimeoutException(
                                  StringUtil.Loc("RMGetFileAsyncTimedOut", GetFileAsyncTimeoutMinutes));
                    }

                    using (Stream stream = await getFileTask.ConfigureAwait(false))
                    {
                        await FileSystemManager.WriteStreamToFile(stream, tmpDownloadPath, cancellationToken);
                    }

                    break;
                }
                catch (Exception exception)
                {
                    if (lastAttempt)
                    {
                        throw new Exception(StringUtil.Loc("RMErrorDownloadingContainerItem", tmpDownloadPath, exception));
                    }

                    lock (_lock)
                    {
                        ExecutionLogger.Warning(StringUtil.Loc("RMReAttemptingDownloadOfContainerItem", tmpDownloadPath, exception.Message));
                    }
                }

                // "Sleep" inbetween attempts. (Can't await inside a catch clause.)
                await Task.Delay(timeBetweenRetries);
            }
        }
        public override void Execute(ReportInfo RI)
        {
            string reportsResultFolder           = string.Empty;
            HTMLReportsConfiguration currentConf = App.UserProfile.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();

            if (App.RunsetExecutor.RunSetConfig.RunsetExecLoggerPopulated)
            {
                string runSetFolder = string.Empty;
                if (App.RunsetExecutor.RunSetConfig.LastRunsetLoggerFolder != null)
                {
                    runSetFolder = App.RunsetExecutor.RunSetConfig.LastRunsetLoggerFolder;
                    AutoLogProxy.UserOperationStart("Online Report");
                }
                else
                {
                    runSetFolder = ExecutionLogger.GetRunSetLastExecutionLogFolderOffline();
                    AutoLogProxy.UserOperationStart("Offline Report");
                }
                if (!string.IsNullOrEmpty(selectedHTMLReportTemplateID.ToString()))
                {
                    if ((isHTMLReportFolderNameUsed) && (HTMLReportFolderName != null) && (HTMLReportFolderName != string.Empty))
                    {
                        ObservableList <HTMLReportConfiguration> HTMLReportConfigurations = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <HTMLReportConfiguration>();
                        reportsResultFolder = Ginger.Reports.GingerExecutionReport.ExtensionMethods.CreateGingerExecutionReport(new ReportInfo(runSetFolder),
                                                                                                                                false,
                                                                                                                                HTMLReportConfigurations.Where(x => (x.ID == selectedHTMLReportTemplateID)).FirstOrDefault(),
                                                                                                                                HTMLReportFolderName + "\\" + System.IO.Path.GetFileName(runSetFolder),
                                                                                                                                isHTMLReportPermanentFolderNameUsed, currentConf.HTMLReportConfigurationMaximalFolderSize);
                    }
                    else
                    {
                        ObservableList <HTMLReportConfiguration> HTMLReportConfigurations = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <HTMLReportConfiguration>();
                        reportsResultFolder = Ginger.Reports.GingerExecutionReport.ExtensionMethods.CreateGingerExecutionReport(new ReportInfo(runSetFolder),
                                                                                                                                false,
                                                                                                                                HTMLReportConfigurations.Where(x => (x.ID == selectedHTMLReportTemplateID)).FirstOrDefault(),
                                                                                                                                null,
                                                                                                                                isHTMLReportPermanentFolderNameUsed);
                    }
                }
                else
                {
                    reportsResultFolder = Ginger.Reports.GingerExecutionReport.ExtensionMethods.CreateGingerExecutionReport(new ReportInfo(runSetFolder),
                                                                                                                            false,
                                                                                                                            null,
                                                                                                                            null,
                                                                                                                            isHTMLReportPermanentFolderNameUsed);
                }
            }
            else
            {
                Errors = "In order to get HTML report, please, perform executions before";
                Reporter.CloseGingerHelper();
                Status = Ginger.Run.RunSetActions.RunSetActionBase.eRunSetActionStatus.Failed;
                return;
            }
        }
Beispiel #9
0
        private void LogStatistics()
        {
            ExecutionLogger.Output(StringUtil.Loc("RMDownloadProgress", _totalFiles, _downloadedFiles, _newEmptyFiles));

            if (_downloadedFiles > 0)
            {
                string message = StringUtil.Loc("RMDownloadProgressDetails", Math.Ceiling(_bytesDownloaded / (1024.0 * 1024.0)), Math.Floor(_bytesDownloaded / (1024.0 * _elapsedDownloadTime.TotalSeconds)), _elapsedDownloadTime);
                ExecutionLogger.Output(message);
            }
        }
Beispiel #10
0
        public StorageTable(
            IOptionsMonitor <TOptions> storageTableOptionsMonitor,
            IOptionsMonitor <StorageAccountOptions> storageAccountOptionsMonitor,
            ILogger <StorageTable <TOptions> > logger)
        {
            _storageTableOptionsMonitor   = storageTableOptionsMonitor ?? throw new ArgumentNullException(nameof(storageTableOptionsMonitor));
            _storageAccountOptionsMonitor = storageAccountOptionsMonitor ?? throw new ArgumentNullException(nameof(storageAccountOptionsMonitor));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _executionLogger = new ExecutionLogger(_logger);
        }
        private async void LoadExecutionsHistoryData()
        {
            grdExecutionsHistory.Visibility = Visibility.Collapsed;
            Loading.Visibility = Visibility.Visible;
            mExecutionsHistoryList.Clear();
            await Task.Run(() => {
                if (App.UserProfile.Solution != null && App.UserProfile.Solution.ExecutionLoggerConfigurationSetList != null && App.UserProfile.Solution.ExecutionLoggerConfigurationSetList.Count > 0)
                {
                    mRunSetExecsRootFolder = ExecutionLogger.GetLoggerDirectory(App.UserProfile.Solution.ExecutionLoggerConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault().ExecutionLoggerConfigurationExecResultsFolder);

                    //pull all RunSets JSON files from it
                    string[] runSetsfiles = Directory.GetFiles(mRunSetExecsRootFolder, "RunSet.txt", SearchOption.AllDirectories);
                    foreach (string runSetFile in runSetsfiles)
                    {
                        try
                        {
                            RunSetReport runSetReport = (RunSetReport)ExecutionLogger.LoadObjFromJSonFile(runSetFile, typeof(RunSetReport));
                            runSetReport.LogFolder    = System.IO.Path.GetDirectoryName(runSetFile);
                            if (mExecutionHistoryLevel == eExecutionHistoryLevel.SpecificRunSet)
                            {
                                //filer the run sets by GUID
                                if (RunsetConfig != null && string.IsNullOrEmpty(runSetReport.GUID) == false)
                                {
                                    Guid runSetReportGuid = Guid.Empty;
                                    Guid.TryParse(runSetReport.GUID, out runSetReportGuid);
                                    if (RunsetConfig.Guid.Equals(runSetReportGuid))
                                    {
                                        mExecutionsHistoryList.Add(runSetReport);
                                    }
                                }
                            }
                            else
                            {
                                mExecutionsHistoryList.Add(runSetReport);
                            }
                        }
                        catch { }
                    }
                }
            });

            ObservableList <RunSetReport> executionsHistoryListSortedByDate = new ObservableList <RunSetReport>();

            foreach (RunSetReport runSetReport in mExecutionsHistoryList.OrderByDescending(item => item.StartTimeStamp))
            {
                runSetReport.StartTimeStamp = runSetReport.StartTimeStamp.ToLocalTime();
                runSetReport.EndTimeStamp   = runSetReport.EndTimeStamp.ToLocalTime();
                executionsHistoryListSortedByDate.Add(runSetReport);
            }

            grdExecutionsHistory.DataSourceList = executionsHistoryListSortedByDate;
            grdExecutionsHistory.Visibility     = Visibility.Visible;
            Loading.Visibility = Visibility.Collapsed;
        }
Beispiel #12
0
        public static void ClassInitialize(TestContext TestContext)
        {
            mGingerRunner = new GingerRunner();

            // Add listener
            //ProjEnvironment projEnvironment = new ProjEnvironment();   // !!!!!!!!!!!!!!!!!!!!!!!remove the need for proj env
            //mExecutionLogger = new ExecutionLogger(projEnvironment, eExecutedFrom.Automation);
            //mExecutionLogger.ExecutionLogfolder = @"c:\temp\koko1";
            //mExecutionLogger.Configuration.ExecutionLoggerConfigurationIsEnabled = true; // !!!!!!!!!!!!!!!!!!!!! remove this flag
            //mGingerRunner.RunListeners.Add(mExecutionLogger);
            mExecutionLogger = (ExecutionLogger)mGingerRunner.RunListeners.Where(x => x.GetType() == typeof(ExecutionLogger)).FirstOrDefault();   // !!!!!!!!!!!!!!!!
        }
Beispiel #13
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_downloadedFiles > 0)
                {
                    ExecutionLogger.Output(StringUtil.Loc("RMDownloadComplete"));
                }

                LogStatistics();
            }
        }
        public StorageTable(
            IOptionsMonitor <TOptions> storageTableOptions,
            IOptionsMonitor <StorageAccountOptions> storageAccountOptions,
            ILogger <StorageTable <TOptions> > logger)
        {
            var options        = storageTableOptions.CurrentValue;
            var accountOptions = storageAccountOptions.Get(options.AzureStorageConfiguration);

            _table  = new Lazy <Task <CloudTable> >(() => CreateOrGetBlobTable(options, accountOptions));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _executionLogger = new ExecutionLogger(_logger);
        }
Beispiel #15
0
        private void Businessflow_ClickGenerateReport(object sender, RoutedEventArgs e)
        {
            if (CheckCurrentRunnerIsNotRuning())
            {
                return;
            }

            BusinessFlow bf = (BusinessFlow)((RunnerItemPage)sender).ItemObject;
            ExecutionLoggerConfiguration _selectedExecutionLoggerConfiguration = WorkSpace.UserProfile.Solution.ExecutionLoggerConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();
            HTMLReportsConfiguration     currentConf = WorkSpace.UserProfile.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();

            if (App.RunsetExecutor.RunSetConfig.LastRunsetLoggerFolder != null)
            {
                string reportpath          = ((BusinessFlow)((RunnerItemPage)sender).ItemObject).ExecutionFullLogFolder;
                string reportsResultFolder = string.Empty;
                if (!string.IsNullOrEmpty(reportpath))
                {
                    reportsResultFolder = Ginger.Reports.GingerExecutionReport.ExtensionMethods.CreateGingerExecutionReport(new ReportInfo(reportpath), false, null, currentConf.HTMLReportsFolder + Ginger.Run.ExecutionLogger.defaultRunTabBFName + Ginger.Reports.GingerExecutionReport.ExtensionMethods.folderNameNormalazing(bf.Name));
                }

                if (!_selectedExecutionLoggerConfiguration.ExecutionLoggerConfigurationIsEnabled)
                {
                    Reporter.ToUser(eUserMsgKey.ExecutionsResultsProdIsNotOn);
                    return;
                }
                else if (reportsResultFolder == string.Empty)
                {
                    Reporter.ToUser(eUserMsgKey.ExecutionsResultsNotExists);
                    return;
                }
                else
                {
                    foreach (string txt_file in System.IO.Directory.GetFiles(reportsResultFolder))
                    {
                        string fileName = System.IO.Path.GetFileName(txt_file);
                        if (fileName.Contains(".html"))
                        {
                            Process.Start(reportsResultFolder);
                            Process.Start(reportsResultFolder + "\\" + fileName);
                        }
                    }
                }
            }
            else
            {
                ExecutionLogger.GenerateBusinessFlowOfflineReport(mRunner.ProjEnvironment, currentConf.HTMLReportsFolder + bf.Name, bf, App.RunsetExecutor.RunSetConfig.Name);
            }
        }
 // TODO: remove the need for env - get it from notify event !!!!!!
 public ExecutionLoggerManager(Context context, eExecutedFrom executedFrom = eExecutedFrom.Run)
 {
     mContext        = context;
     mJsonSerializer = new Newtonsoft.Json.JsonSerializer();
     mJsonSerializer.NullValueHandling = NullValueHandling.Ignore;
     ExecutedFrom = executedFrom;
     if (WorkSpace.Instance != null && WorkSpace.Instance.Solution != null && WorkSpace.Instance.Solution.LoggerConfigurations.SelectedDataRepositoryMethod == ExecutionLoggerConfiguration.DataRepositoryMethod.LiteDB)
     {
         mExecutionLogger = new LiteDBRepository();
     }
     else
     {
         mExecutionLogger = new TextFileRepository();
     }
     executionLoggerHelper = new ExecutionLoggerHelper();
 }
Beispiel #17
0
        private async Task DownloadItemImplAsync(
            SemaphoreSlim downloadThrottle,
            ContainerItem ticketedItem,
            string downloadPath,
            CancellationToken cancellationToken)
        {
            try
            {
                lock (_lock)
                {
                    ExecutionLogger.Debug(StringUtil.Format("Acquiring semaphore to download file {0}", downloadPath));
                }

                await downloadThrottle.WaitAsync().ConfigureAwait(false);

                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }

                // Download the file content to a temp file on the same drive.
                // Assumption: the build won't produce files ending in .download.
                string tmpDownloadPath = downloadPath + ".download";

                FileSystemManager.EnsureParentDirectory(tmpDownloadPath);
                FileSystemManager.DeleteFile(downloadPath);

                lock (_lock)
                {
                    ExecutionLogger.Output(StringUtil.Loc("RMDownloadStartDownloadOfFile", downloadPath));
                }

                await GetFileAsync(ticketedItem, tmpDownloadPath, cancellationToken).ConfigureAwait(false);

                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }

                // With the content successfully downloaded, move the tmp file to its permanent location.
                FileSystemManager.MoveFile(tmpDownloadPath, downloadPath);
            }
            finally
            {
                downloadThrottle.Release();
            }
        }
        private void DeleteAllSelectedExecutionResults(object sender, System.Windows.RoutedEventArgs e)
        {
            if ((Reporter.ToUser(eUserMsgKeys.AllExecutionsResultsToDelete)) == Amdocs.Ginger.Common.MessageBoxResult.Yes)
            {
                foreach (RunSetReport runSetReport in grdExecutionsHistory.Grid.Items)
                {
                    string runSetFolder = ExecutionLogger.GetLoggerDirectory(runSetReport.LogFolder);

                    var fi = new DirectoryInfo(runSetFolder);
                    CleanDirectory(fi.FullName);
                    fi.Delete();
                }

                if (grdExecutionsHistory.Grid.SelectedItems.Count > 0)
                {
                    LoadExecutionsHistoryData();
                }
            }
        }
Beispiel #19
0
        public void CreateGingerExecutionReportAutomaticly()
        {
            HTMLReportsConfiguration currentConf = WorkSpace.Instance.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();

            mSelectedExecutionLoggerConfiguration = WorkSpace.Instance.Solution.ExecutionLoggerConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();
            if ((mSelectedExecutionLoggerConfiguration.ExecutionLoggerConfigurationIsEnabled) && (Runners != null) && (Runners.Count > 0))
            {
                if (mSelectedExecutionLoggerConfiguration.ExecutionLoggerHTMLReportsAutomaticProdIsEnabled)
                {
                    string runSetReportName;
                    if ((RunSetConfig.Name != null) && (RunSetConfig.Name != string.Empty))
                    {
                        runSetReportName = RunSetConfig.Name;
                    }
                    else
                    {
                        runSetReportName = ExecutionLogger.defaultRunTabLogName;
                    }
                    string exec_folder = ExecutionLogger.GetLoggerDirectory(mSelectedExecutionLoggerConfiguration.ExecutionLoggerConfigurationExecResultsFolder + "\\" + runSetReportName + "_" + Runners[0].ExecutionLogger.CurrentExecutionDateTime.ToString("MMddyyyy_HHmmss"));
                }
            }
        }
Beispiel #20
0
        public void CreateGingerExecutionReportAutomaticly()
        {
            HTMLReportsConfiguration currentConf = App.UserProfile.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();

            _selectedExecutionLoggerConfiguration = App.UserProfile.Solution.ExecutionLoggerConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();
            if ((_selectedExecutionLoggerConfiguration.ExecutionLoggerConfigurationIsEnabled) && (Runners != null) && (Runners.Count > 0))
            {
                if (_selectedExecutionLoggerConfiguration.ExecutionLoggerHTMLReportsAutomaticProdIsEnabled)
                {
                    string runSetReportName;
                    if ((RunSetConfig.Name != null) && (RunSetConfig.Name != string.Empty))
                    {
                        runSetReportName = RunSetConfig.Name;
                    }
                    else
                    {
                        runSetReportName = ExecutionLogger.defaultRunTabLogName;
                    }
                    string exec_folder         = ExecutionLogger.GetLoggerDirectory(_selectedExecutionLoggerConfiguration.ExecutionLoggerConfigurationExecResultsFolder + "\\" + runSetReportName + "_" + Runners[0].ExecutionLogger.CurrentExecutionDateTime.ToString("MMddyyyy_HHmmss"));
                    string reportsResultFolder = Ginger.Reports.GingerExecutionReport.ExtensionMethods.CreateGingerExecutionReport(new ReportInfo(exec_folder), false, null, null, false, currentConf.HTMLReportConfigurationMaximalFolderSize);
                }
            }
        }
Beispiel #21
0
        public IActionResult CreateResource([FromBody] DiscreteLogarithmCreateDto createDto)
        {
            var result = base.CreateResource <DiscreteLogarithmCreateDto, DiscreteLogarithmGetDto>(createDto);

            if (CreatedResource == null)
            {
                return(result);
            }

            if (User.Identity.IsAuthenticated)
            {
                CreatedResource.SubscriberId = User.Claims.First(claim => claim.Type == JwtClaimTypes.Subject).Value;
            }

            CreatedResource.JobId = CreatedResource.StartJobService();
            ResourceDataService.Update(CreatedResource);
            ResourceDataService.SaveChanges();

            ExecutionLogger.SetExecutionId(CreatedResource.Id);
            ExecutionLogger.Info("Enqueued for execution.");

            return(result);
        }
Beispiel #22
0
        public void SetRunnersExecutionLoggerConfigs()
        {
            _selectedExecutionLoggerConfiguration = WorkSpace.Instance.Solution.ExecutionLoggerConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();

            if (_selectedExecutionLoggerConfiguration.ExecutionLoggerConfigurationIsEnabled)
            {
                DateTime currentExecutionDateTime = DateTime.Now;

                ExecutionLogger.RunSetStart(_selectedExecutionLoggerConfiguration.ExecutionLoggerConfigurationExecResultsFolder, _selectedExecutionLoggerConfiguration.ExecutionLoggerConfigurationMaximalFolderSize, currentExecutionDateTime);

                int ginger_index = 0;
                while (Runners.Count > ginger_index)
                {
                    Runners[ginger_index].ExecutionLogger.GingerData.Seq                 = ginger_index + 1;
                    Runners[ginger_index].ExecutionLogger.GingerData.GingerName          = Runners[ginger_index].Name;
                    Runners[ginger_index].ExecutionLogger.GingerData.Ginger_GUID         = Runners[ginger_index].Guid;
                    Runners[ginger_index].ExecutionLogger.GingerData.GingerAggentMapping = Runners[ginger_index].ApplicationAgents.Select(a => a.AgentName + "_:_" + a.AppName).ToList();
                    Runners[ginger_index].ExecutionLogger.GingerData.GingerEnv           = Runners[ginger_index].ProjEnvironment.Name.ToString();
                    Runners[ginger_index].ExecutionLogger.CurrentExecutionDateTime       = currentExecutionDateTime;
                    Runners[ginger_index].ExecutionLogger.Configuration = _selectedExecutionLoggerConfiguration;
                    ginger_index++;
                }
            }
        }
Beispiel #23
0
        public void ExecutionLogger_LogExecutionCompleted_ExecutionSucceeded()
        {
            var mockExecutionHistory = new Mock <IExecutionHistory>();

            var mockSerializer = new Mock <ISerializer>();

            mockSerializer.Setup(o => o.Serialize(It.IsAny <AuditCommand>())).Verifiable();

            var mockWebSocketPool    = new Mock <IWebSocketPool>();
            var mockWebSocketWrapper = new Mock <IWebSocketWrapper>();

            mockWebSocketWrapper.Setup(o => o.SendMessage(It.IsAny <byte[]>())).Verifiable();
            mockWebSocketPool.Setup(o => o.Acquire(Dev2.Common.Config.Auditing.Endpoint)).Returns(mockWebSocketWrapper.Object).Verifiable();
            mockWebSocketPool.Setup(o => o.Release(It.IsAny <IWebSocketWrapper>())).Verifiable();

            var executionLogger = new ExecutionLogger(mockSerializer.Object, mockWebSocketPool.Object);

            executionLogger.ExecutionSucceeded(mockExecutionHistory.Object);

            mockSerializer.Verify(o => o.Serialize(It.IsAny <AuditCommand>()), Times.Once);
            mockWebSocketWrapper.Verify(o => o.SendMessage(It.IsAny <byte[]>()), Times.Once);
            mockWebSocketPool.Verify(o => o.Acquire(Dev2.Common.Config.Auditing.Endpoint), Times.Once);
            mockWebSocketPool.Verify(o => o.Release(It.IsAny <IWebSocketWrapper>()), Times.Once);
        }
Beispiel #24
0
        public void ExecutionLogger_LogResumedExecution()
        {
            var mockAudit = new Mock <IAudit>();

            var mockSerializer = new Mock <ISerializer>();

            mockSerializer.Setup(o => o.Serialize(It.IsAny <AuditCommand>())).Verifiable();

            var mockWebSocketPool    = new Mock <IWebSocketPool>();
            var mockWebSocketWrapper = new Mock <IWebSocketWrapper>();

            mockWebSocketWrapper.Setup(o => o.SendMessage(It.IsAny <byte[]>())).Verifiable();
            mockWebSocketPool.Setup(o => o.Acquire(Dev2.Common.Config.Auditing.Endpoint)).Returns(mockWebSocketWrapper.Object).Verifiable();
            mockWebSocketPool.Setup(o => o.Release(It.IsAny <IWebSocketWrapper>())).Verifiable();

            var executionLogger = new ExecutionLogger(mockSerializer.Object, mockWebSocketPool.Object);

            executionLogger.LogResumedExecution(mockAudit.Object);

            mockSerializer.Verify(o => o.Serialize(It.IsAny <AuditCommand>()), Times.Once);
            mockWebSocketWrapper.Verify(o => o.SendMessage(It.IsAny <byte[]>()), Times.Once);
            mockWebSocketPool.Verify(o => o.Acquire(Dev2.Common.Config.Auditing.Endpoint), Times.Once);
            mockWebSocketPool.Verify(o => o.Release(It.IsAny <IWebSocketWrapper>()), Times.Once);
        }
Beispiel #25
0
 public void RemoveLogger(ExecutionLogger logger)
 {
     _loggers.Remove(logger);
 }
Beispiel #26
0
 public void AddLogger(ExecutionLogger logger)
 {
     _loggers.Add(logger);
 }
Beispiel #27
0
        protected async Task FetchItemsAsync(IEnumerable <ContainerItem> containerItems, CancellationToken token)
        {
            ArgUtil.NotNull(containerItems, nameof(containerItems));

            var itemsToDownload = new List <ContainerItem>();

            foreach (ContainerItem item in containerItems)
            {
                if (item.ItemType == ItemType.Folder)
                {
                    string localDirectory = ConvertToLocalPath(item);
                    FileSystemManager.EnsureDirectoryExists(localDirectory);
                }
                else if (item.ItemType == ItemType.File)
                {
                    string localPath = ConvertToLocalPath(item);

                    ExecutionLogger.Debug(StringUtil.Format("[File] {0} => {1}", item.Path, localPath));

                    _totalFiles++;

                    if (item.FileLength == 0)
                    {
                        CreateEmptyFile(localPath);
                        _newEmptyFiles++;
                    }
                    else
                    {
                        itemsToDownload.Add(item);
                    }
                }
                else
                {
                    throw new NotSupportedException(StringUtil.Loc("RMContainerItemNotSupported", item.ItemType));
                }
            }

            if (_totalFiles == 0)
            {
                ExecutionLogger.Warning(StringUtil.Loc("RMArtifactEmpty"));
            }

            if (itemsToDownload.Count > 0)
            {
                using (var cancellationTokenSource = new CancellationTokenSource())
                    using (var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token, cancellationTokenSource.Token))
                        using (var downloadThrottle = new SemaphoreSlim(ContainerFetchEngineOptions.ParallelDownloadLimit))
                        {
                            CancellationToken cancellationToken = linkedTokenSource.Token;

                            // Used to limit the number of concurrent downloads.
                            Stopwatch         watch = Stopwatch.StartNew();
                            LinkedList <Task> remainingDownloads = new LinkedList <Task>();

                            foreach (ContainerItem ticketedItem in itemsToDownload)
                            {
                                _bytesDownloaded += ticketedItem.FileLength;
                                Task downloadTask = DownloadItemAsync(downloadThrottle, ticketedItem, cancellationToken);

                                if (downloadTask.IsCompleted)
                                {
                                    // don't wait to throw for faulted tasks.
                                    await downloadTask.ConfigureAwait(false);
                                }
                                else
                                {
                                    remainingDownloads.AddLast(downloadTask);
                                }
                            }

                            try
                            {
                                // Monitor and log the progress of the download tasks if they take over a few seconds.
                                await LogProgressAsync(remainingDownloads).ConfigureAwait(false);
                            }
                            catch (Exception)
                            {
                                cancellationTokenSource.Cancel();
                                await Task.WhenAll(remainingDownloads);

                                throw;
                            }

                            _elapsedDownloadTime += watch.Elapsed;
                        }

                _downloadedFiles += itemsToDownload.Count;
            }
        }
Beispiel #28
0
 public void RemoveLogger(ExecutionLogger logger)
 {
     _loggers.Remove(logger);
 }
Beispiel #29
0
 public void AddLogger(ExecutionLogger logger)
 {
     _loggers.Add(logger);
 }
Beispiel #30
0
        private async Task LogProgressAsync(LinkedList <Task> remainingTasks)
        {
            Stopwatch watch = Stopwatch.StartNew();

            // Log progress until all downloads complete
            while (remainingTasks.Any())
            {
                Task delayTask = Task.Delay(ProgressInterval);

                if (remainingTasks.Count < 20)
                {
                    // temporarily add the delay task.
                    remainingTasks.AddLast(delayTask);

                    // wait for the delay task or a download to complete.
                    // Task.WhenAny is probably an O(n) operation, so we only do this if there's not many downloads remaining.
                    await Task.WhenAny(remainingTasks).ConfigureAwait(false);

                    // remove the delay task.
                    remainingTasks.RemoveLast();
                }
                else
                {
                    // go do something else for 5 seconds.
                    await delayTask.ConfigureAwait(false);
                }

                // remove any download tasks that completed.
                LinkedListNode <Task> task = remainingTasks.First;
                while (task != null)
                {
                    LinkedListNode <Task> nextTask = task.Next;

                    if (task.Value.IsCompleted)
                    {
                        // don't wait to throw for faulted tasks.
                        await task.Value.ConfigureAwait(false);

                        remainingTasks.Remove(task);
                    }

                    task = nextTask;
                }

                // check how many downloads remain.
                if (remainingTasks.Count > 0)
                {
                    if (watch.Elapsed > ProgressInterval)
                    {
                        ExecutionLogger.Output(StringUtil.Loc("RMRemainingDownloads", remainingTasks.Count));
                        watch.Restart();
                    }

                    if (remainingTasks.Count != _previousRemainingTaskCount)
                    {
                        _lastTaskCompletionTime     = DateTime.UtcNow;
                        _previousRemainingTaskCount = remainingTasks.Count;
                    }

                    TimeSpan timeSinceLastTaskCompletion = DateTime.UtcNow - _lastTaskCompletionTime;
                    TimeSpan timeSinceLastDiag           = DateTime.UtcNow - _lastTaskDiagTime;

                    if (timeSinceLastTaskCompletion > TaskDiagThreshold &&
                        timeSinceLastDiag > TaskDiagThreshold)
                    {
                        var taskStates = remainingTasks.GroupBy(dt => dt.Status);

                        lock (_lock)
                        {
                            ExecutionLogger.Warning(StringUtil.Loc("RMDownloadTaskCompletedStatus", (int)timeSinceLastTaskCompletion.TotalMinutes));
                            foreach (IGrouping <TaskStatus, Task> group in taskStates)
                            {
                                ExecutionLogger.Warning(StringUtil.Loc("RMDownloadTaskStates", group.Key, group.Count()));
                            }
                        }

                        _lastTaskDiagTime = DateTime.UtcNow;
                    }
                }
            }
        }
Beispiel #31
0
        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)));
        }
Beispiel #32
0
        // Use it when we have data from disk which ws saved by ExecutionLogger
        public ReportInfo(string folder)    // this is only that should stayed after discussion !!!
        {
            // in received folder looking for json file with specific name (file should be single txt file in folder - if no - not proceed with deserialization)
            int    txtFilesInDirectoryCount = 0;
            string txtFileName = string.Empty;
            string fileName    = string.Empty;

            foreach (string txt_file in System.IO.Directory.GetFiles(folder))
            {
                fileName = Path.GetFileName(txt_file);
                if (fileName.Contains(".txt") && (fileName != "ActivityGroups.txt"))
                {
                    txtFilesInDirectoryCount++;
                    txtFileName = fileName;
                }
            }
            if ((txtFilesInDirectoryCount == 0) || (txtFilesInDirectoryCount > 1))
            {
                return;
            }

            // setting ReportInfoRootObject and ReportInfoLevel according to jason that folder pointing on
            string curFileWithPath = String.Empty;

            try
            {
                switch (txtFileName)
                {
                case "RunSet.txt":
                    curFileWithPath      = folder + @"\RunSet.txt";
                    ReportInfoRootObject = (RunSetReport)ExecutionLogger.LoadObjFromJSonFile(curFileWithPath, typeof(RunSetReport));
                    ((RunSetReport)ReportInfoRootObject).LogFolder = folder;
                    reportInfoLevel = ReportInfo.ReportInfoLevel.RunSetLevel;
                    break;

                case "Ginger.txt":
                    curFileWithPath      = folder + @"\Ginger.txt";
                    ReportInfoRootObject = (GingerReport)ExecutionLogger.LoadObjFromJSonFile(curFileWithPath, typeof(GingerReport));
                    ((GingerReport)ReportInfoRootObject).LogFolder = folder;
                    reportInfoLevel = ReportInfo.ReportInfoLevel.GingerLevel;
                    break;

                case "BusinessFlow.txt":
                    curFileWithPath      = folder + @"\BusinessFlow.txt";
                    ReportInfoRootObject = (BusinessFlowReport)ExecutionLogger.LoadObjFromJSonFile(curFileWithPath, typeof(BusinessFlowReport));
                    ((BusinessFlowReport)ReportInfoRootObject).LogFolder = folder;
                    reportInfoLevel = ReportInfo.ReportInfoLevel.BussinesFlowLevel;
                    break;

                case "Activity.txt":
                    curFileWithPath      = folder + @"\Activity.txt";
                    ReportInfoRootObject = (ActivityReport)ExecutionLogger.LoadObjFromJSonFile(curFileWithPath, typeof(ActivityReport));
                    ((ActivityReport)ReportInfoRootObject).LogFolder = folder;
                    reportInfoLevel = ReportInfo.ReportInfoLevel.ActivityLevel;
                    break;

                case "Action.txt":
                    curFileWithPath      = folder + @"\Action.txt";
                    ReportInfoRootObject = (ActionReport)ExecutionLogger.LoadObjFromJSonFile(curFileWithPath, typeof(ActionReport));
                    ((ActionReport)ReportInfoRootObject).LogFolder = folder;
                    reportInfoLevel = ReportInfo.ReportInfoLevel.ActionLevel;
                    break;

                default:
                    ReportInfoRootObject = null;
                    return;
                }
            }
            catch { }
        }