/// <summary>Get an instance of OpenDental.customerUpdates.Service1 (referred to as 'Customer Updates Web Service'. Also sets IWebProxy and ICredentials if specified for this customer. Service1 is ready to use on return.</summary> public static Service1 GetWebServiceInstance() { Service1 ws=new Service1(); ws.Url=PrefC.GetString(PrefName.UpdateServerAddress); //Uncomment this block if you want to test new web service funcionality on localhost. //Use .\Development\Shared Projects Subversion\WebServiceCustomerUpdates solution to attach debugger to process 'ASP .NET Development Server - Port 3824'. //#if DEBUG // ws.Url=@"http://localhost:3824/Service1.asmx"; // ws.Timeout=(int)TimeSpan.FromMinutes(20).TotalMilliseconds; //#endif if(PrefC.GetString(PrefName.UpdateWebProxyAddress) !="") { IWebProxy proxy = new WebProxy(PrefC.GetString(PrefName.UpdateWebProxyAddress)); ICredentials cred=new NetworkCredential(PrefC.GetString(PrefName.UpdateWebProxyUserName),PrefC.GetString(PrefName.UpdateWebProxyPassword)); proxy.Credentials=cred; ws.Proxy=proxy; } return ws; }
///<summary>Makes a web call to WebServiceCustomersUpdate in order to get an updated list of feature requests.</summary> private void RefreshRequestTable() { //Always clear the table first. _tableRequests = new ODDataTable(); Cursor = Cursors.WaitCursor; //Yes, this would be slicker if it were asynchronous, but no time right now. #region prepare the xml document to send-------------------------------------------------------------------------------------- XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = (" "); StringBuilder strbuild = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(strbuild, settings)) { writer.WriteStartElement("FeatureRequestGetList"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteStartElement("SearchString"); writer.WriteString(textSearch.Text); writer.WriteEndElement(); writer.WriteEndElement(); } #if DEBUG OpenDental.localhost.Service1 updateService = new OpenDental.localhost.Service1(); #else OpenDental.customerUpdates.Service1 updateService = new OpenDental.customerUpdates.Service1(); updateService.Url = PrefC.GetString(PrefName.UpdateServerAddress); #endif #endregion #region Send the message and get the result------------------------------------------------------------------------------------- string result = ""; try { result = updateService.FeatureRequestGetList(strbuild.ToString()); } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show("Error: " + ex.Message); return; } #endregion Cursor = Cursors.Default; XmlDocument doc = new XmlDocument(); doc.LoadXml(result); #region Process errors------------------------------------------------------------------------------------------------------------ XmlNode node = doc.SelectSingleNode("//Error"); if (node != null) { //textConnectionMessage.Text=node.InnerText; MessageBox.Show(node.InnerText, "Error"); return; } node = doc.SelectSingleNode("//KeyDisabled"); if (node == null) { //no error, and no disabled message if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, false)) //this is one of two places in the program where this happens. { DataValid.SetInvalid(InvalidType.Prefs); } } else { //textConnectionMessage.Text=node.InnerText; MessageBox.Show(node.InnerText); if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, true)) //this is one of two places in the program where this happens. { DataValid.SetInvalid(InvalidType.Prefs); } return; } #endregion #region Process a valid return value------------------------------------------------------------------------------------------------ node = doc.SelectSingleNode("//IsAdminMode"); if (node.InnerText == "true") { isAdminMode = true; } else { isAdminMode = false; } node = doc.SelectSingleNode("//ResultTable"); #endregion _tableRequests = new ODDataTable(node.InnerXml); }