Пример #1
0
        public void Perform()
        {
            IPCClient pcClient = new PCClient(_pcModel, _fileLog);

            try
            {
                bool authenticated = pcClient.Login();
                int  runID;
                if (authenticated)
                {
                    runID = pcClient.StartRun();
                    if (runID == 0)
                    {
                        pcClient.Logout();
                        return;
                    }
                }
                else
                {
                    return;
                }

                string        testName      = pcClient.GetTestName();
                PCRunResponse pcRunResponse = null;
                if (runID > 0)
                {
                    pcRunResponse = pcClient.WaitForRunCompletion(runID);
                }

                if (pcRunResponse != null)
                {
                    //analysis report
                    string pcReportFile = (pcRunResponse.RunState == EnumerationHelper.GetEnumDescription(PCConstants.RunStates.Finished)) ? pcClient.PublishRunReport(runID, _workDirectory) : "";

                    // Adding the trend report section if ID has been set
                    if (_pcModel.GetAddRunToTrendReport.Equals("UseTrendReportID") && !string.IsNullOrWhiteSpace(_pcModel.TrendReportId) && pcRunResponse.RunState != EnumerationHelper.GetEnumDescription(PCConstants.RunStates.RunFailure))
                    {
                        bool addRunToTrendReportSuccess = pcClient.AddRunToTrendReport(runID, _pcModel.TrendReportId);
                        if (addRunToTrendReportSuccess)
                        {
                            pcClient.WaitForRunToPublishOnTrendReport(runID, _pcModel.TrendReportId);
                            pcClient.DownloadTrendReportAsPdf(_pcModel.TrendReportId, _workDirectory);
                        }
                    }

                    // Adding the trend report if the Associated Trend report is selected.
                    if (_pcModel.GetAddRunToTrendReport.Equals("AssociatedTrend") && pcRunResponse.RunState != EnumerationHelper.GetEnumDescription(PCConstants.RunStates.RunFailure))
                    {
                        bool addRunToTrendReportSuccess = pcClient.AddRunToTrendReport(runID, _pcModel.TrendReportId);
                        if (addRunToTrendReportSuccess)
                        {
                            pcClient.WaitForRunToPublishOnTrendReport(runID, _pcModel.TrendReportId);
                            pcClient.DownloadTrendReportAsPdf(_pcModel.TrendReportId, _workDirectory);
                        }
                    }
                    if (_statusBySLA && pcRunResponse.RunState == EnumerationHelper.GetEnumDescription(PCConstants.RunStates.Finished))
                    {
                        pcClient.verifySlaStatus(pcRunResponse.RunSLAStatus);
                    }
                }
                pcClient.Logout();
            }
            catch { }
            finally
            {
                //important ending to mark the end of the task for log report parsing!!
                pcClient.PCClientEnd();
            }
        }
Пример #2
0
 private bool beforeRun(PCClient pcClient) => ValidatePcForm() && pcClient.Login();