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

            if (pcRunResults != null)
            {
                dgvForAll.DataSource   = pcRunResults.ResultsList;
                btnRunResult.Text      = "pcRunResults received";
                btnRunResult.BackColor = Color.Green;
            }
            else
            {
                btnRunResult.Text      = "TestData not received";
                btnRunResult.BackColor = Color.Red;
            }
        }
예제 #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("");
        }