static void Process(Uri endpoint, string customerId, string sharedSecret) { //Create the OLSA Web Services Client using code OlsaPortTypeClient client = Helpers.Olsa.GetOLSAClient(endpoint, customerId, sharedSecret); Console.WriteLine("Issuing the UD_SubmitReport Request"); Console.WriteLine("------------------------------------"); HandleResponse handleResponse = new HandleResponse(); //-------------------------------------------------------------------------------------------- //Define report settings here to ease changes string scopingUserId = "admin"; reportFormat reportFormat = reportFormat.CSV; string reportFilename = "report." + reportFormat.ToString(); string reportLanguage = "en_US"; //en_US only supported value int reportRetainperiod = 3; //1 - 1 hour, 2 - 8 hours, 3 - 24 hours. //For details of report names and parameters see https://documentation.skillsoft.com/en_us/skillport/8_0/ah/35465.htm string reportName = "summary_catalog"; //Define report parameters List <MapItem> paramList = new List <MapItem>(); paramList.Add(new MapItem() { key = "asset_category", value = "1,2,3,4,5,21" }); paramList.Add(new MapItem() { key = "display_options", value = "all" }); //-------------------------------------------------------------------------------------------- //Submit Report request try { handleResponse = Helpers.Olsa.SubmitReport(scopingUserId, reportFormat, reportName, paramList.ToArray(), reportLanguage, reportRetainperiod, client, false); //Minutes between polls int sleepInterval = 2; Console.WriteLine("Handle: {0}", handleResponse.handle); UrlResponse url = null; for (int i = 0; i < 10; i++) { Console.WriteLine("{0}: Sleeping {1} minutes", DateTime.UtcNow.ToLongTimeString(), sleepInterval); //ms - so here we sleep for 10 minutes System.Threading.Thread.Sleep(sleepInterval * 60 * 1000); try { url = Helpers.Olsa.PollforReport(handleResponse.handle, client, false); break; } catch (FaultException <Olsa.DataNotReadyYetFault> ) { //The report has not completed generation, we are checking for a Specific OLSA Exception Console.WriteLine("{0}: The specified report is not yet ready", DateTime.UtcNow.ToLongTimeString()); } catch (Exception ex) { Console.WriteLine("{0}: Issue while Polling for Report.", DateTime.UtcNow.ToLongTimeString()); Console.WriteLine("{0}: Exception: {1}", DateTime.UtcNow.ToLongTimeString(), ex.ToString()); throw; } } if (url != null) { WebClient myWebClient = new WebClient(); Console.WriteLine("{0}: Downloading Report: {1}", DateTime.UtcNow.ToLongTimeString(), url.olsaURL); myWebClient.DownloadFile(url.olsaURL, reportFilename); Console.WriteLine("{0}: Successfully Downloaded: {1}", DateTime.UtcNow.ToLongTimeString(), reportFilename); } } catch (Exception ex) { Console.WriteLine("{0}: Issue while Submitting Report.", DateTime.UtcNow.ToLongTimeString()); Console.WriteLine("{0}: Exception: {1}", DateTime.UtcNow.ToLongTimeString(), ex.ToString()); } //Now we can close the client if (client != null) { if (client.State == CommunicationState.Faulted) { client.Abort(); } client.Close(); } }
private Exception RunSSRSReport(ReportParameters Report, ActivityRun activityRun, reportFormat format) { rsExec = new ReportExecutionService(); rsExec.Url = Properties.Settings.Default.RE2005_ReportExecutionService; rsExec.UseDefaultCredentials = true; string historyID = null; string deviceInfo = null; Byte[] results; string encoding = String.Empty; string mimeType = String.Empty; string extension = String.Empty; Warning[] warnings = null; string[] streamIDs = null; var p = ""; for (int i = 0; i < Report.Parameters.Count; i++) { p = "Param[" + i.ToString() + "]" + Report.Parameters[i].Name + "|" + Report.Parameters[i].Value.ToString() + Environment.NewLine + p; } // Path of the Report - XLS, PDF etc. Report.OutputFilePath = GetOutputFileName(Report); string FilePath = outputFolder + Report.OutputFilePath + "." + format.ToString().ToLower(); // Name of the report - Please note this is not the RDL file. string _reportName = @"/GenevaReports/" + Report.Name; try { ExecutionInfo ei = rsExec.LoadReport(_reportName, historyID); ParameterValue[] parameters = new ParameterValue[Report.Parameters.Count]; for (int i = 0; i < Report.Parameters.Count; i++) { parameters[i] = new ParameterValue(); parameters[i].Name = Report.Parameters[i].Name; parameters[i].Value = (string)Report.Parameters[i].Value; } rsExec.SetExecutionParameters(parameters, "en-IE"); DataSourceCredentials dataSourceCredentials2 = new DataSourceCredentials(); dataSourceCredentials2.DataSourceName = Properties.Settings.Default.DataSourceName; dataSourceCredentials2.UserName = Properties.Settings.Default.GenevaUser; dataSourceCredentials2.Password = Properties.Settings.Default.GenevaPass; DataSourceCredentials[] _credentials2 = new DataSourceCredentials[] { dataSourceCredentials2 }; var c = ""; for (int i = 0; i < _credentials2.Length; i++) { c = "_credentials2[" + i.ToString() + "]:" + _credentials2[i].DataSourceName + "|" + _credentials2[i].UserName + "|" + _credentials2[i].Password + "|" + Environment.NewLine + c; } rsExec.SetExecutionCredentials(_credentials2); //rsExec.UseDefaultCredentials = true; results = rsExec.Render(format.ToString(), deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); using (FileStream stream = File.OpenWrite(FilePath)) { stream.Write(results, 0, results.Length); } } catch (Exception ex) { status = "--- ERROR ---" + Environment.NewLine + "Running PDF Report: " + Report.Name + Environment.NewLine + ex.Message + Environment.NewLine + "--------------" + Environment.NewLine + status + Environment.NewLine; return(new Exception(status)); } return(null); }