Exemple #1
0
        private reportingEngineResponse SendRequest(reportingEngineRequest req)
        {
            PayFlowProRequest pfpReq = new PayFlowProRequest();

            pfpReq.URL = URL;
            reportingEngineResponse resp = pfpReq.SendRequest(req);

            if (resp.Item == null)
            {
                throw new Exception(resp.baseResponse.responseCode + ": " + resp.baseResponse.responseMsg);
            }
            return(resp);
        }
Exemple #2
0
        public DataTable RunReport(DateTime startDate, DateTime endDate)
        {
            // Report variables
            string reportId   = "";
            int    totalPages = 0;
            int    statusCode = 0;

            // Build the report parameters
            reportParam[] ReportParams = new reportParam[2];
            ReportParams[0] = new Services.reportParam()
            {
                paramName  = "start_date",
                paramValue = String.Format("{0:yyyy-MM-dd HH:mm:ss}", startDate)
            };
            ReportParams[1] = new Services.reportParam()
            {
                paramName  = "end_date",
                paramValue = String.Format("{0:yyyy-MM-dd HH:mm:ss}", endDate)
            };

            // Setup the report and bind parameters to it.
            reportingEngineRequestRunReportRequest reportRequest = new Services.reportingEngineRequestRunReportRequest();

            reportRequest.ItemElementName   = reportType.templateName;
            reportRequest.Item              = Name;
            reportRequest.pageSize          = 50;
            reportRequest.pageSizeSpecified = true;
            reportRequest.reportParam       = ReportParams;


            // Setup the request, with authentication
            reportingEngineRequest req = new reportingEngineRequest();

            req.authRequest = GetAuthRequest();
            req.Item        = reportRequest;

            reportingEngineResponse resp = SendRequest(req);

            // Get the response from the report request
            reportingEngineResponseRunReportResponse reportResp = ( reportingEngineResponseRunReportResponse )resp.Item;

            if (reportResp == null)
            {
                throw new Exception(resp.baseResponse.responseCode + ": " + resp.baseResponse.responseMsg);
            }

            reportId   = reportResp.reportId;
            statusCode = reportResp.statusCode;

            // Now just wait until PayPal is done generating the report
            while (statusCode != REPORTSTATUS_CREATEDSUCCESSFULLY)
            {
                //wait before checking status...
                System.Threading.Thread.Sleep(PollingTimeout * 1000);

                Services.reportingEngineRequestGetResultsRequest resultsRequest = new Services.reportingEngineRequestGetResultsRequest();
                resultsRequest.ItemElementName = ItemChoiceType3.reportId;
                resultsRequest.Item            = reportId;

                resp = SendRequest(req);

                statusCode = (( reportingEngineResponseRunReportResponse )resp.Item).statusCode;
            }

            // Get the total number of pages (from the report metadata)
            Services.reportingEngineRequestGetMetaDataRequest metadataRequest = new Services.reportingEngineRequestGetMetaDataRequest();
            metadataRequest.reportId = reportId;

            req.Item = metadataRequest;
            resp     = SendRequest(req);
            reportingEngineResponseGetMetaDataResponse metaResp = ( reportingEngineResponseGetMetaDataResponse )resp.Item;

            totalPages = metaResp.numberOfPages;
            SetupDataTable(metaResp.columnMetaData);


            // Now loop and aggregate all the pages together
            for (int p = 0; p < totalPages; p++)
            {
                Services.reportingEngineRequestGetDataRequest dataRequest = new Services.reportingEngineRequestGetDataRequest();
                dataRequest.reportId         = reportId;
                dataRequest.pageNum          = p + 1;
                dataRequest.pageNumSpecified = true;

                req.Item = dataRequest;
                resp     = SendRequest(req);

                reportingEngineResponseGetDataResponse dataResp = ( reportingEngineResponseGetDataResponse )resp.Item;

                LoadDataRows(dataResp.reportDataRow);
            }

            return(Data);
        }