public string[] getReportResult(int reportId, List <AnalyticsReportFilter> filterList) { //Use RightNow SOAP API to run report and get RNow Contact search results //Set up Analytics Report //Create new AnalyticsReport Object AnalyticsReport analyticsReport = new AnalyticsReport(); //create limit and start parameters. Specifies the max number of rows to return (10,000 is the overall maximum) //start specifies the starting row int limit = 10; int start = 0; //Specify a report ID ID reportID = new ID(); //contact search report reportID.id = reportId; reportID.idSpecified = true; analyticsReport.ID = reportID; analyticsReport.Filters = filterList.ToArray(); CSVTableSet thisset = new CSVTableSet(); byte[] fd; // Run AnalyticsReport via SOAP API thisset = _rnowClient.RunAnalyticsReport(_rnowClientInfoHeader, analyticsReport, limit, start, ",", false, true, out fd); // Get Report Search Result CSVTable[] tableResults = thisset.CSVTables; String[] searchResults = tableResults[0].Rows; return(searchResults); }
/// <summary> /// Funtion to Run the report /// </summary> /// <param name="report">AnalyticsReport info like report ID and Filter detail</param> /// <returns>CSVTableSet</returns> public CSVTableSet RunReport(AnalyticsReport report) { CSVTableSet reportdata = null; byte[] bytearray = null; try { ClientInfoHeader hdr = new ClientInfoHeader() { AppID = "Get Report Data" }; reportdata = _rightNowClient.RunAnalyticsReport(hdr, report, 10000, 0, "~", false, true, out bytearray); if (reportdata != null && reportdata.CSVTables.Length > 0) { return(reportdata); } } catch (Exception ex) { WorkspaceAddIn.InfoLog("Exception in RunReport: " + ex.Message); } return(null); }
internal RunAnalyticsResponse GetAnalyticsReportResults(long reportId, AnalyticsReportFilter[] filters, int limit = 100, int start = 0, string delimiter = ",") { //Create new AnalyticsReport Object AnalyticsReport analyticsReport = new AnalyticsReport(); //Specify a report ID of Public Reports>Common>Data integration>Opportunities ID reportID = new ID(); reportID.id = reportId; reportID.idSpecified = true; analyticsReport.ID = reportID; analyticsReport.Filters = filters; GetProcessingOptions processingOptions = new GetProcessingOptions(); processingOptions.FetchAllNames = true; RNObject[] getAnalyticsObjects = new RNObject[] { analyticsReport }; CSVTableSet thisSet = new CSVTableSet(); byte[] ignore; bool mustRetry = false; // used to determine if we should retry a failed job int retryTimes = 0; // we don't want to endlessly retry, so we only will retry 3 times do { try { thisSet = _client.RunAnalyticsReport(_clientInfoHeader, analyticsReport, limit, start, delimiter, false, true, out ignore); return(new RunAnalyticsResponse { RunAnalyticsTableSet = thisSet, Successful = true, SuccessfulSet = true }); } catch (Exception ex) { GlobalContext.Log(string.Format("Failed RunAnalyticsReport: Retry {0}: {1}", retryTimes, ex.Message), true); GlobalContext.Log(string.Format("Failed RunAnalyticsReport: Retry {0}: {1}{2}{3}", retryTimes, ex.Message, Environment.NewLine, ex.StackTrace), false); if (retryTimes < 3) { // if we haven't retried 3 times then we retry the load again mustRetry = true; retryTimes++; } else { // don't retry for 3rd retry return(new RunAnalyticsResponse { Successful = false, SuccessfulSet = false, Details = ex.Message }); } } GlobalContext.Log(string.Format("RunAnalyticsReport Must Retry {0}", mustRetry), false); } while (mustRetry); GlobalContext.Log("RunAnalyticsReport End: This code should never be hit.", false); return(null); // this code should never be hit }