Пример #1
0
 /**
  * <summary> This method will construct a SOAP message and send it to the web service. </summary>
  * <remarks> This web service does not seem to be enabled. It needs to be enabled before using otherwise,
  * this program will encounter an InvalidOperationException</remarks>
  * <param name="loginInfo">Web service LoginInfo class that contains the logon credentials necessary to file the web service.</param>
  * <param name="sql">The SQL query text to be interpreted by the Cache database.</param>
  * <param name="runtimeMode">This property will set the SQL runtime mode for the query to be executed. There are 3 modes to choose from 0,1,2.
  * 0 for LOGICAL mode also the DEFAULT. 1 for ODBC mode. 2 for DISPLAY mode.</param>
  * <returns>The web service response is returned by this method because this is the call that is made to the web service. This response will contain
  * the sql query results if no errors were encountered otherwise read the message part of the response to determine what error was detected.</returns>
  */
 private XMLService.XMLResponse submitSQL(XMLService.LoginInfo loginInfo, String sql, String runtimeMode)
 {
     try
     {
         var XMLServiceInstance = new XMLService.XMLService();
         return(XMLServiceInstance.XMLResultSet(loginInfo, sql, runtimeMode));
     }
     catch (InvalidOperationException e)
     {
         XMLService.XMLResponse err = new XMLService.XMLResponse();
         err.resultCode    = "-1";
         err.resultMessage = e.Message + newline + "A fatal exception was encountered, this is known to occur when the XMLService web service is not"
                             + " enabled in your system. Contact your Netsmart Representative for further information.";
         return(err);
     }
 }
Пример #2
0
        /**
         * <summary>When the submit button is clicked, this method is executed. This will get the wheels turning, construct the SOAP message and send it
         * to the referenced Avatar web service.</summary>
         */
        private void btSubmit_Click(object sender, EventArgs e)
        {
            /* Collect parameters for the Web Service. */
            runtimeMode = ascertainRuntimeMode(); // runtime mode
            sqlQuery    = SQLtextbox.Text;        // The SQL query

            /* builds and sends SOAP message. */
            XMLService.XMLResponse response = submitSQL(buildLoginInfo(), sqlQuery, runtimeMode);

            /* Display response - this will clear the previous response in the textbox. */
            ResponseBox.Text  = "Result Code: " + response.resultCode + newline + "Result Message: " + response.resultMessage + newline;
            ResponseBox.Text += response.XMLResponse1 + newline;
            XMLdata2export    = response.XMLResponse1 + newline;

            /* A resultCode of 1 indicates that there were no errors returned from the database. */
            if (response.resultCode == "1")
            {
                displayXMLTextFriendly(XMLdata2export);
            }
            else
            {
                MessageBox.Show(response.resultMessage);
            }
        }