public void RunReport(string report, string parameters, RunrepResultTypes resultType) { if (_soapService == null || String.IsNullOrEmpty(_sessionID)) throw new Exception("You must start the SOAP Service session before running a report."); try { if (resultType == RunrepResultTypes.Literal) { // Run the query, getting the results back into a generic object for iterating. object returnValue = _soapService.RunCallableRunrepRunReportLiteral(_sessionID, report, parameters); // Serialize the results to the screen. serializeToConsole(returnValue); XmlDocument docResults = serializeToXml(returnValue); } else if (resultType == RunrepResultTypes.String) { // Run the query, getting the results back into a generic object for iterating. string returnValue = _soapService.RunCallableRunrepRunReportString(_sessionID, report, parameters); // Write the results to the screen, and load into an XmlDocument Console.WriteLine(returnValue); XmlDocument docResults = new XmlDocument(); docResults.LoadXml(returnValue); } else if (resultType == RunrepResultTypes.FormattedCSV) { getFormattedResults(report, parameters, "csv"); } else if (resultType == RunrepResultTypes.FormattedPDF) { getFormattedResults(report, parameters, "pdf"); } else { throw new ApplicationException(String.Format("Invalid Report Result Type: {0}", resultType.ToString())); } } catch (Exception e) { // If we encounter an error, print it to the screen. Console.WriteLine(String.Format("Error running report: {0}", report)); Console.WriteLine(e); } }
/// <summary> /// Method to run a Geneva SELECT statement. /// </summary> /// <param name="query">String containing the SELECT statement to run.</param> /// <param name="sharedConnection">True if you want to use a shared connection, false if you want to use a persistent connection.</param> public void RunSQLSelect(string query, RunrepResultTypes resultType) { if (_soapService == null || String.IsNullOrEmpty(_sessionID)) throw new Exception("You must start the SOAP Service session before running a select statement."); try { // Run the basic result type. This returns an array of results, with field/value pairs. The structure of // these results does not change with the query or report, the results is always in the same format. if (resultType == RunrepResultTypes.DataStructure) { // Run the query, getting the results back into a structure for iterating. GenevaSOAPInterface.runrepResultsPortfolioStruct returnValue = _soapService.RunCallableRunrepRunSelect(_sessionID, query, String.Empty); int recordCount = 0; // Loop through the results, the records, and fields. foreach (GenevaSOAPInterface.runrepResultsStruct results in returnValue.results) { foreach (GenevaSOAPInterface.runrepResultsRecordStruct record in results.record) { // Print the row number along the way. recordCount++; Console.WriteLine(String.Format("Row {0}", recordCount)); foreach (GenevaSOAPInterface.runrepResultsVectorElement field in record.field) { // For each field, print the field name and value to the screen. Console.WriteLine(String.Format("\tField Name: {0}, Value: {1}", field.name, field.value)); } } } } else if (resultType == RunrepResultTypes.Literal) { // Run the query, getting the results back into a generic object for iterating. object returnValue = _soapService.RunCallableRunrepRunSelectLiteral(_sessionID, query, String.Empty); // Serialize the results to the screen. serializeToConsole(returnValue); XmlDocument docResults = serializeToXml(returnValue); } else if (resultType == RunrepResultTypes.String) { // Run the query, getting the results back into a generic object for iterating. string returnValue = _soapService.RunCallableRunrepRunSelectString(_sessionID, query, String.Empty); // Write the results to the screen, and load into an XmlDocument Console.WriteLine(returnValue); XmlDocument docResults = new XmlDocument(); docResults.LoadXml(returnValue); } else { throw new ApplicationException(String.Format("Invalid Report Result Type: {0}", resultType.ToString())); } } catch (Exception e) { // If we encounter an error, print it to the screen. Console.WriteLine(String.Format("Error running select statement: {0}", query)); Console.WriteLine(e); } }