Example #1
0
        private void btnRunResultData_Click(object sender, EventArgs e)
        {
            PCRunResults pcRunResults = pcRestProxy.GetRunResults(int.Parse(txtRunID.Text));



            string localFilePath         = @"c:\temp\GetRunResultData\";
            bool   RunResultDataReturned = true;

            foreach (PCRunResult pcRunResult in pcRunResults.ResultsList)
            {
                RunResultDataReturned = RunResultDataReturned?pcRestProxy.GetRunResultData(int.Parse(txtRunID.Text), pcRunResult.ID, localFilePath + pcRunResult.RunID + "\\" + pcRunResult.Name) :false;
            }

            if (RunResultDataReturned)
            {
                btnRunResultData.Text      = "RunResultData received in " + localFilePath;
                btnRunResultData.BackColor = Color.Green;
            }
            else
            {
                btnRunResultData.Text      = "TestData not received";
                btnRunResultData.BackColor = Color.Red;
            }
        }
Example #2
0
        public string PublishRunReport(int runId, string reportDirectory)
        {
            PCErrorResponse pcErrorResponse = new PCErrorResponse("", 0);

            try
            {
                PCRunResults runResultsList = _pcRestProxy.GetRunResults(runId, ref pcErrorResponse);
                if (runResultsList.ResultsList != null)
                {
                    foreach (PCRunResult result in runResultsList.ResultsList)
                    {
                        if (result.Name.Equals(PCBuilder.PC_REPORT_ARCHIVE_NAME))
                        {
                            string reportArchiveFullPath = Path.Combine(reportDirectory, PCBuilder.PC_REPORT_ARCHIVE_NAME);
                            _fileLog.Write(LogMessageType.Info, "Publishing analysis report:");
                            bool downloadSucceeded = _pcRestProxy.GetRunResultData(runId, result.ID, reportArchiveFullPath, ref pcErrorResponse);
                            if (downloadSucceeded && File.Exists(reportArchiveFullPath))
                            {
                                _fileLog.Write(LogMessageType.Info, "Result file downloaded successfully to: " + reportArchiveFullPath);
                                string extractedReportDirectory = reportDirectory;
                                if (!Directory.Exists(extractedReportDirectory))
                                {
                                    Directory.CreateDirectory(extractedReportDirectory);
                                }
                                if (Directory.Exists(reportDirectory))
                                {
                                    WaitForUnlockedFile(reportArchiveFullPath);
                                    ZipFile.ExtractToDirectory(reportArchiveFullPath, extractedReportDirectory);
                                }
                                else
                                {
                                    _fileLog.Write(LogMessageType.Info, "Failed to create directory for extracting the report");
                                }

                                string reportFile = Path.Combine(extractedReportDirectory, PCBuilder.PC_REPORT_FILENAME);
                                if (File.Exists(reportFile))
                                {
                                    _fileLog.Write(LogMessageType.Info, "Report file extracted and available from: " + reportFile + "\n");
                                    return(reportFile);
                                }
                                else
                                {
                                    _fileLog.Write(LogMessageType.Info, "Failed to extract report\n");
                                }
                            }
                            else
                            {
                                _fileLog.Write(LogMessageType.Info, "Failed to download\\create report\n");
                            }
                        }
                    }
                }
                _fileLog.Write(LogMessageType.Info, "Failed to get run report\n");
            }
            catch (Exception ex)
            {
                _fileLog.Write(LogMessageType.Error, "failed to get run report\n" + ex.Message);
                if (pcErrorResponse.ErrorCode > 0)
                {
                    _fileLog.Write(LogMessageType.Error, string.Format("PublishRunReport failed, ExceptionMessage: {0}, ErrorCode: {1}\n", pcErrorResponse.ExceptionMessage, pcErrorResponse.ErrorCode));
                }
            }
            return("");
        }