public static string GetScanXML(long scanId)
        {
            string             path        = "";
            LoginResult        loginResult = getLoginResult();
            CxWebServiceClient client;

            try
            {
                client = new CxWebServiceClient(loginResult.AuthenticationData);
            }
            catch (Exception e)
            {
                Logger.Create().Error(e.ToString());
                return(null);
            }

            string savedFileName = string.Format("report{0}", Guid.NewGuid());
            // create status report
            CxWSReportRequest reportRequest = new CxWSReportRequest();

            reportRequest.ScanID = scanId;
            reportRequest.Type   = CxWSReportType.XML;
            CxWSCreateReportResponse cXWSCreateReportResponse = client.ServiceClient.CreateScanReport(loginResult.SessionId, reportRequest);
            long reportID        = cXWSCreateReportResponse.ID;
            int  numOfTrials     = 0;
            bool resultsObtained = false;

            while (!resultsObtained && numOfTrials < 100)
            {
                CxWSReportStatusResponse cxWSReportStatusResponse = client.ServiceClient.GetScanReportStatus(loginResult.SessionId, reportID);
                if (cxWSReportStatusResponse.IsReady)
                {
                    resultsObtained = true;
                }
                else
                {
                    Thread.Sleep(500);
                }
                numOfTrials++;
            }

            CxWSResponseScanResults cxWSResponseScanResults = client.ServiceClient.GetScanReport(loginResult.SessionId, reportID);

            if (!cxWSResponseScanResults.IsSuccesfull)
            {
                Logger.Create().Error(cxWSResponseScanResults.ErrorMessage);
                return(null);
            }

            StorageHelper.Save(cxWSResponseScanResults.ScanResults, savedFileName);
            path = savedFileName;



            return(path);
        }
Exemple #2
0
        /// <summary>
        /// Start creating a scan report.
        /// </summary>
        /// <param name="scanId">
        /// The scan ID to generate a report for.
        /// </param>
        /// <param name="reportType">
        /// The report type.
        /// </param>
        /// <returns>
        /// The report ID.
        /// </returns>
        /// <exception cref="CheckmarxErrorException">
        /// The Checkmarx API returned an unexpected error.
        /// </exception>
        /// <exception cref="CheckmarxCommunicationException">
        /// An error occurred communicating with the Checkmarx server.
        /// </exception>
        public long CreateScanReport(long scanId, CxWSReportType reportType)
        {
            CxWSReportRequest reportRequest;

            reportRequest = new CxWSReportRequest()
            {
                ScanID = scanId,
                Type   = reportType
            };

            return(CallCheckmarxApi(() => SoapClient.CreateScanReport(SessionId, reportRequest)).ID);
        }