/// <summary>Inserts RegistrationKey with blank PracticeTitle into bugs database so next time cusotmer hits the update service it will reset their PracticeTitle.</summary> private void butPracticeTitleReset_Click(object sender, EventArgs e) { if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Are you sure you want to reset the Practice Title associated with this Registration Key? This should only be done if they are getting a message saying, \"Practice title given does not match the practice title on record,\" when connecting to the Patient Portal. It will be cleared out of the database and filled in with the appropriate Practice Title next time they connect using this Registration Key.")) { return; } //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("PracticeTitleReset"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(RegKey.RegKey); 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 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; updateService.Proxy = proxy; } updateService.PracticeTitleReset(strbuild.ToString()); //may throw error }
private static string SendAndReceiveDownloadXml(string codeSystemName) { //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)) { //TODO: include more user information writer.WriteStartElement("UpdateRequest"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteStartElement("PracticeTitle"); writer.WriteString(PrefC.GetString(PrefName.PracticeTitle)); writer.WriteEndElement(); writer.WriteStartElement("PracticeAddress"); writer.WriteString(PrefC.GetString(PrefName.PracticeAddress)); writer.WriteEndElement(); writer.WriteStartElement("PracticePhone"); writer.WriteString(PrefC.GetString(PrefName.PracticePhone)); writer.WriteEndElement(); writer.WriteStartElement("ProgramVersion"); writer.WriteString(PrefC.GetString(PrefName.ProgramVersion)); writer.WriteEndElement(); writer.WriteStartElement("CodeSystemRequested"); writer.WriteString(codeSystemName); 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 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; updateService.Proxy = proxy; } string result = ""; try { result = updateService.RequestCodeSystemDownload(strbuild.ToString()); //may throw error } catch (Exception ex) { //Cursor=Cursors.Default; MessageBox.Show("Error: " + ex.Message); return(""); } return(result); }
private void butSendCode_Click(object sender, EventArgs e) { if (textEmailAddress.Text.Trim() == "") { MsgBox.Show(this, "Email Address is blank."); return; } Cursor = Cursors.WaitCursor; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = (" "); StringBuilder strbuild = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(strbuild, settings)) { writer.WriteStartElement("RequestEmailVeritificationCode"); writer.WriteElementString("RegistrationKey", PrefC.GetString(PrefName.RegistrationKey)); writer.WriteElementString("EmailAddress", textEmailAddress.Text); 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 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; updateService.Proxy = proxy; } string xmlResponse = ""; try { xmlResponse = updateService.RequestEmailVerificationCode(strbuild.ToString()); } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show(Lan.g(this, "Error.") + " " + ex.Message); return; } XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlResponse); string strError = WebServiceRequest.CheckForErrors(doc); if (!string.IsNullOrEmpty(strError)) { Cursor = Cursors.Default; MessageBox.Show(Lan.g(this, "Error.") + " " + Lan.g(this, "Verification code was not sent.") + " " + strError); return; } Cursor = Cursors.Default; textVerificationCode.Text = ""; //Clear the old verification code if there was one. MessageBox.Show(Lan.g(this, "Done.") + " " + Lan.g(this, "The verification code has been sent to") + " " + textEmailAddress.Text); }
private void butSendCode_Click(object sender,EventArgs e) { if(textEmailAddress.Text.Trim()=="") { MsgBox.Show(this,"Email Address is blank."); return; } Cursor=Cursors.WaitCursor; XmlWriterSettings settings=new XmlWriterSettings(); settings.Indent=true; settings.IndentChars=(" "); StringBuilder strbuild=new StringBuilder(); using(XmlWriter writer=XmlWriter.Create(strbuild,settings)) { writer.WriteStartElement("RequestEmailVeritificationCode"); writer.WriteElementString("RegistrationKey",PrefC.GetString(PrefName.RegistrationKey)); writer.WriteElementString("EmailAddress",textEmailAddress.Text); 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 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; updateService.Proxy=proxy; } string xmlResponse=""; try { xmlResponse=updateService.RequestEmailVerificationCode(strbuild.ToString()); } catch(Exception ex) { Cursor=Cursors.Default; MessageBox.Show(Lan.g(this,"Error.")+" "+ex.Message); return; } XmlDocument doc=new XmlDocument(); doc.LoadXml(xmlResponse); XmlNode node=doc.SelectSingleNode("//Error"); if(node!=null) { Cursor=Cursors.Default; MessageBox.Show(Lan.g(this,"Error.")+" "+Lan.g(this,"Verification code was not sent.")+" "+node.InnerText); return; } Cursor=Cursors.Default; textVerificationCode.Text="";//Clear the old verification code if there was one. MessageBox.Show(Lan.g(this,"Done.")+" "+Lan.g(this,"The verification code has been sent to")+" "+textEmailAddress.Text); }
private void buttonGetURL_Click(object sender, EventArgs e) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = (" "); StringBuilder strbuild = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(strbuild, settings)) { writer.WriteStartElement("CustomerIdRequest"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteEndElement(); } #if DEBUG OpenDental.localhost.Service1 portalService = new OpenDental.localhost.Service1(); #else OpenDental.customerUpdates.Service1 portalService = new OpenDental.customerUpdates.Service1(); portalService.Url = PrefC.GetString(PrefName.UpdateServerAddress); #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; portalService.Proxy = proxy; } string patNum = ""; string result = portalService.RequestCustomerID(strbuild.ToString()); //may throw error XmlDocument doc = new XmlDocument(); doc.LoadXml(result); XmlNode node = doc.SelectSingleNode("//CustomerIdResponse"); if (node != null) { patNum = node.InnerText; textOpenDentalURl.Text = "https://www.opendentalsoft.com/PatientPortal/PatientPortal.html?ID=" + patNum; if (textPatientPortalURL.Text == "") { textPatientPortalURL.Text = "https://www.opendentalsoft.com/PatientPortal/PatientPortal.html?ID=" + patNum; } } if (patNum == "") { MsgBox.Show(sender, "You are not currently registered for support with Open Dental Software."); } }
private void buttonGetURL_Click(object sender,EventArgs e) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = (" "); StringBuilder strbuild=new StringBuilder(); using(XmlWriter writer=XmlWriter.Create(strbuild,settings)) { writer.WriteStartElement("CustomerIdRequest"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteEndElement(); } #if DEBUG OpenDental.localhost.Service1 portalService=new OpenDental.localhost.Service1(); #else OpenDental.customerUpdates.Service1 portalService=new OpenDental.customerUpdates.Service1(); portalService.Url=PrefC.GetString(PrefName.UpdateServerAddress); #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; portalService.Proxy=proxy; } string patNum=""; string result=portalService.RequestCustomerID(strbuild.ToString());//may throw error XmlDocument doc=new XmlDocument(); doc.LoadXml(result); XmlNode node=doc.SelectSingleNode("//CustomerIdResponse"); if(node!=null) { patNum=node.InnerText; textOpenDentalURl.Text="https://www.opendentalsoft.com/PatientPortal/PatientPortal.html?ID="+patNum; if(textPatientPortalURL.Text=="") { textPatientPortalURL.Text="https://www.opendentalsoft.com/PatientPortal/PatientPortal.html?ID="+patNum; } } if(patNum=="") { MsgBox.Show(sender,"You are not currently registered for support with Open Dental Software."); } }
private void FillGrid() { //if(textSearch.Text.Length<3){ // MsgBox.Show(this,"Please enter a search term with at least three letters in it."); // return; //} Cursor = Cursors.WaitCursor; //Yes, this would be slicker if it were asynchronous, but no time right now. //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 //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; } //textConnectionMessage.Text=Lan.g(this,"Connection successful."); //Application.DoEvents(); Cursor = Cursors.Default; //MessageBox.Show(result); XmlDocument doc = new XmlDocument(); doc.LoadXml(result); //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; } //Process a valid return value------------------------------------------------------------------------------------------------ node = doc.SelectSingleNode("//ResultTable"); table = new ODDataTable(node.InnerXml); //Admin mode---------------------------------------------------------------------------------------------------------------- node = doc.SelectSingleNode("//IsAdminMode"); if (node.InnerText == "true") { isAdminMode = true; } else { isAdminMode = false; } //FillGrid used to start here------------------------------------------------ long selectedRequestId = 0; int selectedIndex = gridMain.GetSelectedIndex(); if (selectedIndex != -1) { if (table.Rows.Count > selectedIndex) { selectedRequestId = PIn.Long(table.Rows[gridMain.GetSelectedIndex()]["RequestId"]); } } gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableRequest", "Req#"), 40); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRequest", "Mine"), 40); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRequest", "My Votes"), 60); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRequest", "Total Votes"), 70); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRequest", "Diff"), 40); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRequest", "Weight"), 45); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRequest", "Approval"), 90); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRequest", "Description"), 500); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; for (int i = 0; i < table.Rows.Count; i++) { row = new ODGridRow(); row.Cells.Add(table.Rows[i]["RequestId"]); row.Cells.Add(table.Rows[i]["isMine"]); row.Cells.Add(table.Rows[i]["myVotes"]); row.Cells.Add(table.Rows[i]["totalVotes"]); row.Cells.Add(table.Rows[i]["Difficulty"]); row.Cells.Add(table.Rows[i]["Weight"]); row.Cells.Add(table.Rows[i]["approval"]); row.Cells.Add(table.Rows[i]["Description"]); gridMain.Rows.Add(row); } gridMain.EndUpdate(); for (int i = 0; i < table.Rows.Count; i++) { if (selectedRequestId.ToString() == table.Rows[i]["RequestId"]) { gridMain.SetSelected(i, true); } } }
private void GetOneFromServer() { //get a table with data Cursor = Cursors.WaitCursor; //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("FeatureRequestGetOne"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteStartElement("RequestId"); writer.WriteString(RequestId.ToString()); 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 //Send the message and get the result------------------------------------------------------------------------------------- string result = ""; try { result = updateService.FeatureRequestGetOne(strbuild.ToString()); } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show("Error: " + ex.Message); return; } //textConnectionMessage.Text=Lan.g(this,"Connection successful."); //Application.DoEvents(); Cursor = Cursors.Default; //MessageBox.Show(result); XmlDocument doc = new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node = doc.SelectSingleNode("//Error"); if (node != null) { //textConnectionMessage.Text=node.InnerText; MessageBox.Show(node.InnerText, "Error"); DialogResult = DialogResult.Cancel; return; } //Process a valid return value------------------------------------------------------------------------------------------------ node = doc.SelectSingleNode("//ResultTable"); tableObj = new ODDataTable(node.InnerXml); ODDataRow row = tableObj.Rows[0]; textDescription.Text = row["Description"]; string detail = row["Detail"]; detail = detail.Replace("\n", "\r\n"); textDetail.Text = detail; checkIsMine.Checked = PIn.Bool(row["isMine"]); textDifficulty.Text = row["Difficulty"]; int approval = PIn.Int(row["Approval"]); if (IsAdminMode) { textSubmitter.Text = row["submitter"]; } comboApproval.SelectedIndex = approval; //textApproval gets set automatically due to comboApproval_SelectedIndexChanged. if (!IsAdminMode && PIn.Bool(row["isMine"])) //user editing their own request { if ((ApprovalEnum)approval == ApprovalEnum.New || (ApprovalEnum)approval == ApprovalEnum.NeedsClarification || (ApprovalEnum)approval == ApprovalEnum.NotARequest || (ApprovalEnum)approval == ApprovalEnum.Redundant || (ApprovalEnum)approval == ApprovalEnum.TooBroad) //so user not allowed to edit if Approved,AlreadyDone,Obsolete, or InProgress. { textDescription.BackColor = Color.White; textDescription.ReadOnly = false; textDetail.BackColor = Color.White; textDetail.ReadOnly = false; if ((ApprovalEnum)approval != ApprovalEnum.New) { butResubmit.Visible = true; } butDelete.Visible = true; } } if ((ApprovalEnum)approval != ApprovalEnum.Approved) { //only allowed to vote on Approved features. //All others should always have zero votes, except InProgress and Complete groupMyVotes.Visible = false; } if ((ApprovalEnum)approval == ApprovalEnum.Approved || (ApprovalEnum)approval == ApprovalEnum.InProgress || (ApprovalEnum)approval == ApprovalEnum.Complete) { //even administrators should not be able to change things at this point textDescription.BackColor = colorDisabled; textDescription.ReadOnly = true; textDetail.BackColor = colorDisabled; textDetail.ReadOnly = true; } myPointsUsed = PIn.Int(row["myPointsUsed"]); try { myPointsAllotted = PIn.Int(row["myPointsAllotted"]); } catch { myPointsAllotted = 100; } //textMyPointsRemain.Text=;this will be filled automatically when myPoints changes textMyPoints.Text = row["myPoints"]; RecalcMyPoints(); checkIsCritical.Checked = PIn.Bool(row["IsCritical"]); textMyPledge.Text = row["myPledge"]; textTotalPoints.Text = row["totalPoints"]; textTotalCritical.Text = row["totalCritical"]; textTotalPledged.Text = row["totalPledged"]; textWeight.Text = row["Weight"]; try { textBounty.Text = row["Bounty"]; } catch { } }
private void butWebSchedEnable_Click(object sender,EventArgs e) { labelWebSchedEnable.Text=""; Application.DoEvents(); //The enable button is not enabled for offices that already have the service enabled. Therefore go straight to making the web call to our service. Cursor.Current=Cursors.WaitCursor; #region Web Service Settings #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 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; updateService.Proxy=proxy; } XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = (" "); StringBuilder strbuild=new StringBuilder(); using(XmlWriter writer=XmlWriter.Create(strbuild,settings)) { writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); } #endregion string result=""; try { result=updateService.ValidateWebSched(strbuild.ToString()); } catch { //Our service might be down or the client might not be connected to the internet or the transmission got cut off somehow. } Cursor.Current=Cursors.Default; string error=""; int errorCode=0; if(Recalls.IsWebSchedResponseValid(result,out error,out errorCode)) { //Everything went good, the office is actively on support and has an active WebSched repeating charge. butWebSchedEnable.Enabled=false; labelWebSchedEnable.Text=Lan.g(this,"The Web Sched service has been enabled."); //This if statement will only save database calls in the off chance that this window was originally loaded with the pref turned off and got turned on by another computer while open. if(Prefs.UpdateBool(PrefName.WebSchedService,true)) { _changed=true; SecurityLogs.MakeLogEntry(Permissions.EServicesSetup,0,"The Web Sched service was enabled."); } return; } #region Error Handling //At this point we know something went wrong. So we need to give the user a hint as to why they can't enable the Web Sched service. if(errorCode==110) {//Customer not registered for WebSched monthly service //We want to launch our Web Sched page if the user is not signed up: try { Process.Start(Recalls.GetWebSchedPromoURL()); } catch(Exception) { //The promotional web site can't be shown, most likely due to the computer not having a default browser. Simply don't do anything. } //Just in case no browser was opened for them, make the message next to the button say something now so that they can visually see that something should have happened. labelWebSchedEnable.Text=error; return; } else if(errorCode==120) { labelWebSchedEnable.Text=error; return; } //For every other error message returned, we'll simply show a generic error in the label and display the detailed error in a pop up. labelWebSchedEnable.Text=Lan.g(this,"There was a problem enabling the Web Sched. Please give us a call or try again."); MessageBox.Show(error); #endregion }
private void butRetrieveOIDs_Click(object sender,EventArgs e) { Cursor=Cursors.WaitCursor; //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("CustomerIdRequest"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteStartElement("RegKeyDisabledOverride"); writer.WriteString("true"); writer.WriteEndElement(); writer.WriteEndElement(); } #if DEBUG OpenDental.localhost.Service1 OIDService=new OpenDental.localhost.Service1(); #else OpenDental.customerUpdates.Service1 OIDService=new OpenDental.customerUpdates.Service1(); OIDService.Url=PrefC.GetString(PrefName.UpdateServerAddress); #endif //Send the message and get the result------------------------------------------------------------------------------------- string result=""; try { result=OIDService.RequestCustomerID(strbuild.ToString()); } catch(Exception ex) { Cursor=Cursors.Default; MessageBox.Show("Error: "+ex.Message); return; } Cursor=Cursors.Default; XmlDocument doc=new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node=doc.SelectSingleNode("//Error"); if(node!=null) { MessageBox.Show(node.InnerText,"Error"); return; } //Process a valid return value------------------------------------------------------------------------------------------------ node=doc.SelectSingleNode("//CustomerIdResponse"); if(node==null) { MsgBox.Show(this,"There was an error requesting your OID or processing the result of the request. Please try again."); return; } if(node.InnerText=="") { labelRetrieveStatus.Text=""; MsgBox.Show(this,"Invalid registration key. Your OIDs will have to be set manually."); return; } //CustomerIdResponse has been returned and is not blank, use it for the root displayed as the recommended value _rootOIDString="2.16.840.1.113883.3.4337.1486."+node.InnerText; labelRetrieveStatus.Text="Connection successful. Root OID has been retrieved."; labelRetrieveStatus.ForeColor=System.Drawing.Color.Black; //we will overwrite their root value with the returned value, but we will ask if they want to overwrite all of their other values in case they have manually set them _listOIDInternal[0].IDRoot=_rootOIDString; bool customOIDsExist=false; for(int i=1;i<_listOIDInternal.Count;i++) {//start with 1, root is 0 and is updated above if(_listOIDInternal[i].IDRoot!="" && _listOIDInternal[i].IDRoot!=_rootOIDString+"."+i.ToString()) {//if any of the OIDs other than root are filled and not what we are going to fill it with using the root with CustomerID, we will be overwriting their manually entered data, ask first customOIDsExist=true; break; } } //ask if they want to overwrite the current actual values with the recommended values if(customOIDsExist && !MsgBox.Show(this,MsgBoxButtons.YesNo,"Would you like to update all OIDs using the root provided by Open Dental?")) { FillGrid(); return; } for(int i=1;i<_listOIDInternal.Count;i++) {//start with 1, root is 0 and is updated above _listOIDInternal[i].IDRoot=_rootOIDString+"."+i.ToString();//adds the .1, .2, .3, and .4 to the root //database updated on OK click } FillGrid(); }
private void panelWebSched_MouseClick(object sender,MouseEventArgs e) { if(!PrefC.GetBool(PrefName.WebSchedService)) { //Office has yet to enable the Web Sched service. //Send them to a promotional web site so that they can learn about how great it is. try { Process.Start(Recalls.GetWebSchedPromoURL()); } catch(Exception) { //The promotional web site can't be shown, most likely due to the computer not having a default browser. Simply do nothing. } //Automatically open the eService Setup window so that they can easily click the Enable button if they call us to sign up or are already signed up and just need to enable it. FormEServicesSetup FormESS=new FormEServicesSetup(FormEServicesSetup.EService.WebSched); FormESS.ShowDialog(); if(!PrefC.GetBool(PrefName.WebSchedService)) { //User might not have enabled the Web Sched. //No need to waste the time calling our web service if they didn't enable it. return; } } //Either the Web Sched service was enabled or they just enabled it. //Send off a web request to WebServiceCustomersUpdates to verify that the office is still valid and is currently paying for the eService. Cursor.Current=Cursors.WaitCursor; StringBuilder strbuild=new StringBuilder(); #region Web Service Call #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 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; updateService.Proxy=proxy; } XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = (" "); using(XmlWriter writer=XmlWriter.Create(strbuild,settings)) { writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); } #endregion string result=""; try { result=updateService.ValidateWebSched(strbuild.ToString()); } catch { //Do nothing. Leaving result empty will display correct error messages later on. } Cursor.Current=Cursors.Default; string error=""; int errorCode=0; if(Recalls.IsWebSchedResponseValid(result,out error,out errorCode)) { //Everything went good, the office is active on support and has an active Web Sched repeating charge. //Send recall notifications to the selected patients. SendWebSchedNotifications(); return; } #region Error Handling //At this point we know something went wrong. So we need to give the user a hint as to why they can't enable if(errorCode==110) {//Customer not registered for Web Sched monthly service //We want to launch our Web Sched page if the user is not signed up: try { Process.Start(Recalls.GetWebSchedPromoURL()); } catch(Exception) { //The promotional web site can't be shown, most likely due to the computer not having a default browser. Simply do nothing. } } //For every error message returned, we'll show it to the user in a pop up. MessageBox.Show(error); #endregion }
///<summary>Sends a payload to the web service to get obfuscated URLs for the selected patients. Once the obfuscated URLs are returned it emails each patient their recall reminder.</summary> private void SendWebSchedNotifications() { #region Recall List Validation if(gridMain.Rows.Count < 1){ MessageBox.Show(Lan.g(this,"There are no Patients in the Recall table. Must have at least one.")); return; } if(!EmailAddresses.ExistsValidEmail()) { MsgBox.Show(this,"You need to enter an SMTP server name in e-mail setup before you can send e-mail."); return; } if(PrefC.GetLong(PrefName.RecallStatusEmailed)==0){ MsgBox.Show(this,"You need to set an email status first in the Recall Setup window."); return; } if(gridMain.SelectedIndices.Length==0) { ContactMethod cmeth; for(int i=0;i<table.Rows.Count;i++) { cmeth=(ContactMethod)PIn.Long(table.Rows[i]["PreferRecallMethod"].ToString()); if(cmeth!=ContactMethod.Email) { continue; } if(table.Rows[i]["Email"].ToString()=="") { continue; } gridMain.SetSelected(i,true); } if(gridMain.SelectedIndices.Length==0) { MsgBox.Show(this,"No patients of email type."); return; } } else {//deselect the ones that do not have email addresses specified int skipped=0; for(int i=gridMain.SelectedIndices.Length-1;i>=0;i--) { if(table.Rows[gridMain.SelectedIndices[i]]["Email"].ToString()=="") { skipped++; gridMain.SetSelected(gridMain.SelectedIndices[i],false); } } if(gridMain.SelectedIndices.Length==0) { MsgBox.Show(this,"None of the selected patients had email addresses entered."); return; } if(skipped>0) { MessageBox.Show(Lan.g(this,"Selected patients skipped due to missing email addresses: ")+skipped.ToString()); } } #endregion if(!MsgBox.Show(this,MsgBoxButtons.YesNo,"Send Web Sched emails to all of the selected patients?")) { return; } Cursor.Current=Cursors.WaitCursor; string response=""; Dictionary<long,string> dictWebSchedParameters=new Dictionary<long,string>(); List<long> recallNums=new List<long>(); //Loop through all selected patients and grab their corresponding RecallNum. for(int i=0;i<gridMain.SelectedIndices.Length;i++) { recallNums.Add(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["RecallNum"].ToString())); } //Send off a web request to WebServiceCustomersUpdates to get the obfuscated URLs for the selected patients. #region Send Web Service Request For URLs #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 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; updateService.Proxy=proxy; } XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = (" "); StringBuilder strbuild=new StringBuilder(); using(XmlWriter writer=XmlWriter.Create(strbuild,settings)) { writer.WriteStartElement("RSData"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteStartElement("RecallNums"); writer.WriteString(String.Join("|",recallNums));//A pipe delimited list of recall nums. E.g. 3|2|1|4 writer.WriteEndElement(); writer.WriteEndElement(); } try { response=updateService.GetWebSchedURLs(strbuild.ToString()); } catch { //Do nothing. Leaving result empty will display correct error messages later on. } #endregion #region Parse Response XmlDocument doc=new XmlDocument(); XmlNode nodeError=null; XmlNode nodeResponse=null; XmlNodeList nodeURLs=null; try { doc.LoadXml(response); nodeError=doc.SelectSingleNode("//Error"); nodeResponse=doc.SelectSingleNode("//GetWebSchedURLsResponse"); } catch { //Invalid web service response passed in. Node will be null and will return false correctly. } #region Error Handling if(nodeError!=null || nodeResponse==null) { string error=Lans.g(this,"There was an error with the web request. Please try again or give us a call."); //Either something went wrong or someone tried to get cute and use our Web Sched service when they weren't supposed to. if(nodeError!=null) { error+="\r\n"+Lan.g(this,"Error Details")+":\r\n" +nodeError.InnerText; } Cursor.Current=Cursors.Default; MessageBox.Show(error); return; } #endregion //At this point we know we got a valid response from our web service. dictWebSchedParameters.Clear(); nodeURLs=doc.GetElementsByTagName("URL"); if(nodeURLs!=null) { //Loop through all the URL nodes that were returned. //Each URL node will contain an RN attribute which will be the corresponding recall num. for(int i=0;i<nodeURLs.Count;i++) { long recallNum=0; XmlAttribute attributeRecallNum=nodeURLs[i].Attributes["RN"]; if(attributeRecallNum!=null) { recallNum=PIn.Long(attributeRecallNum.Value); } dictWebSchedParameters.Add(recallNum,nodeURLs[i].InnerText); } } #endregion //Now that the web service response has been validated, parsed, and our dictionary filled, we now can loop through the selected patients and send off the emails. RecallListSort sortBy=(RecallListSort)comboSort.SelectedIndex; addrTable=Recalls.GetAddrTableForWebSched(recallNums,checkGroupFamilies.Checked,sortBy); EmailMessage emailMessage; EmailAddress emailAddress; for(int i=0;i<addrTable.Rows.Count;i++) { #region Send Email Notification string emailBody=""; string emailSubject=""; emailMessage=new EmailMessage(); emailMessage.PatNum=PIn.Long(addrTable.Rows[i]["emailPatNum"].ToString()); emailMessage.ToAddress=PIn.String(addrTable.Rows[i]["email"].ToString());//might be guarantor email emailAddress=EmailAddresses.GetByClinic(PIn.Long(addrTable.Rows[i]["ClinicNum"].ToString())); emailMessage.FromAddress=emailAddress.SenderAddress; if(addrTable.Rows[i]["numberOfReminders"].ToString()=="0") { emailSubject=PrefC.GetString(PrefName.WebSchedSubject); emailBody=PrefC.GetString(PrefName.WebSchedMessage); } else if(addrTable.Rows[i]["numberOfReminders"].ToString()=="1") { emailSubject=PrefC.GetString(PrefName.WebSchedSubject2); emailBody=PrefC.GetString(PrefName.WebSchedMessage2); } else { emailSubject=PrefC.GetString(PrefName.WebSchedSubject3); emailBody=PrefC.GetString(PrefName.WebSchedMessage3); } emailSubject=emailSubject.Replace("[NameF]",addrTable.Rows[i]["patientNameF"].ToString()); //It is common for offices to have paitents with a blank recall date (they've never had a recall performed at the office). //Instead of showing 01/01/0001 in the email, we will simply show today's date because that is what the Web Sched time slots will start showing. DateTime dateDue=PIn.Date(addrTable.Rows[i]["dateDue"].ToString()); if(dateDue.Year < 1880) { dateDue=DateTime.Today; } emailBody=emailBody.Replace("[DueDate]",dateDue.ToShortDateString()); emailBody=emailBody.Replace("[NameF]",addrTable.Rows[i]["patientNameF"].ToString()); string URL=""; try { dictWebSchedParameters.TryGetValue(PIn.Long(addrTable.Rows[i]["RecallNum"].ToString()),out URL); } catch(Exception ex) { Cursor=Cursors.Default; string error=ex.Message+"\r\n"; MessageBox.Show(error+Lan.g(this,"Problem getting Web Sched URL for patient")+": "+addrTable.Rows[i]["patientNameFL"].ToString()); break; } emailBody=emailBody.Replace("[URL]",URL); string officePhone=PrefC.GetString(PrefName.PracticePhone); Clinic clinic=Clinics.GetClinic(PIn.Long(addrTable.Rows[i]["clinicNum"].ToString())); if(clinic!=null && !String.IsNullOrEmpty(clinic.Phone)) { officePhone=clinic.Phone; } if(CultureInfo.CurrentCulture.Name=="en-US" && officePhone.Length==10) { officePhone="("+officePhone.Substring(0,3)+")"+officePhone.Substring(3,3)+"-"+officePhone.Substring(6); } emailBody=emailBody.Replace("[OfficePhone]",officePhone); emailMessage.Subject=emailSubject; emailMessage.BodyText=emailBody; try { EmailMessages.SendEmailUnsecure(emailMessage,emailAddress); } catch(Exception ex) { Cursor=Cursors.Default; string error=ex.Message+"\r\n"; if(ex.GetType()==typeof(System.ArgumentException)) { error+=Lan.g(this,"Go to Setup | Appointments | Recall. The subject for WebSched notifications must not span multiple lines.")+"\r\n"; } MessageBox.Show(error+Lan.g(this,"Patient")+": "+addrTable.Rows[i]["patientNameFL"].ToString()); break; } emailMessage.MsgDateTime=DateTime.Now; emailMessage.SentOrReceived=EmailSentOrReceived.Sent; EmailMessages.Insert(emailMessage); #endregion #region Insert Commlog Commlogs.InsertForRecall(PIn.Long(addrTable.Rows[i]["PatNum"].ToString()),CommItemMode.Email,PIn.Int(addrTable.Rows[i]["numberOfReminders"].ToString()), PrefC.GetLong(PrefName.RecallStatusEmailed),true,Security.CurUser.UserNum); Recalls.UpdateStatus(PIn.Long(addrTable.Rows[i]["RecallNum"].ToString()),PrefC.GetLong(PrefName.RecallStatusEmailed)); #endregion } FillMain(null); Cursor=Cursors.Default; }
private void GetOneFromServer(){ //get a table with data Cursor=Cursors.WaitCursor; //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("FeatureRequestGetOne"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteStartElement("RequestId"); writer.WriteString(RequestId.ToString()); 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 //Send the message and get the result------------------------------------------------------------------------------------- string result=""; try { result=updateService.FeatureRequestGetOne(strbuild.ToString()); } catch(Exception ex) { Cursor=Cursors.Default; MessageBox.Show("Error: "+ex.Message); return; } //textConnectionMessage.Text=Lan.g(this,"Connection successful."); //Application.DoEvents(); Cursor=Cursors.Default; //MessageBox.Show(result); XmlDocument doc=new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node=doc.SelectSingleNode("//Error"); if(node!=null) { //textConnectionMessage.Text=node.InnerText; MessageBox.Show(node.InnerText,"Error"); DialogResult=DialogResult.Cancel; return; } //Process a valid return value------------------------------------------------------------------------------------------------ node=doc.SelectSingleNode("//ResultTable"); tableObj=new ODDataTable(node.InnerXml); ODDataRow row=tableObj.Rows[0]; textDescription.Text=row["Description"]; string detail=row["Detail"]; detail=detail.Replace("\n","\r\n"); textDetail.Text=detail; checkIsMine.Checked=PIn.Bool(row["isMine"]); textDifficulty.Text=row["Difficulty"]; int approval=PIn.Int(row["Approval"]); if(IsAdminMode){ textSubmitter.Text=row["submitter"]; } comboApproval.SelectedIndex=approval; //textApproval gets set automatically due to comboApproval_SelectedIndexChanged. if(!IsAdminMode && PIn.Bool(row["isMine"])){//user editing their own request if((ApprovalEnum)approval==ApprovalEnum.New || (ApprovalEnum)approval==ApprovalEnum.NeedsClarification || (ApprovalEnum)approval==ApprovalEnum.NotARequest || (ApprovalEnum)approval==ApprovalEnum.Redundant || (ApprovalEnum)approval==ApprovalEnum.TooBroad) //so user not allowed to edit if Approved,AlreadyDone,Obsolete, or InProgress. { textDescription.BackColor=Color.White; textDescription.ReadOnly=false; textDetail.BackColor=Color.White; textDetail.ReadOnly=false; if((ApprovalEnum)approval!=ApprovalEnum.New){ butResubmit.Visible=true; } butDelete.Visible=true; } } if((ApprovalEnum)approval!=ApprovalEnum.Approved){ //only allowed to vote on Approved features. //All others should always have zero votes, except InProgress and Complete groupMyVotes.Visible=false; } if((ApprovalEnum)approval==ApprovalEnum.Approved || (ApprovalEnum)approval==ApprovalEnum.InProgress || (ApprovalEnum)approval==ApprovalEnum.Complete) {//even administrators should not be able to change things at this point textDescription.BackColor=colorDisabled; textDescription.ReadOnly=true; textDetail.BackColor=colorDisabled; textDetail.ReadOnly=true; } myPointsUsed=PIn.Int(row["myPointsUsed"]); try { myPointsAllotted=PIn.Int(row["myPointsAllotted"]); } catch { myPointsAllotted=100; } //textMyPointsRemain.Text=;this will be filled automatically when myPoints changes textMyPoints.Text=row["myPoints"]; RecalcMyPoints(); checkIsCritical.Checked=PIn.Bool(row["IsCritical"]); textMyPledge.Text=row["myPledge"]; textTotalPoints.Text=row["totalPoints"]; textTotalCritical.Text=row["totalCritical"]; textTotalPledged.Text=row["totalPledged"]; textWeight.Text=row["Weight"]; try { textBounty.Text=row["Bounty"]; } catch { } }
///<summary></summary> private bool SaveDiscuss(){//bool doDelete) { //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("FeatureRequestDiscussSubmit"); //regkey writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); //DiscussId //writer.WriteStartElement("DiscussId"); //writer.WriteString(DiscussIdCur.ToString());//this will be zero for a new entry. We currently only support new entries //writer.WriteEndElement(); //RequestId writer.WriteStartElement("RequestId"); writer.WriteString(RequestId.ToString()); writer.WriteEndElement(); //can't pass patnum. Determined on the server side. //date will also be figured on the server side. //Note writer.WriteStartElement("Note"); writer.WriteString(textNote.Text); writer.WriteEndElement(); /*if(doDelete){ //delete writer.WriteStartElement("Delete"); writer.WriteString("true"); writer.WriteEndElement(); }*/ } Cursor=Cursors.WaitCursor; #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 //Send the message and get the result------------------------------------------------------------------------------------- string result=""; try { result=updateService.FeatureRequestDiscussSubmit(strbuild.ToString()); } catch(Exception ex) { Cursor=Cursors.Default; MessageBox.Show("Error: "+ex.Message); return false; } //textConnectionMessage.Text=Lan.g(this,"Connection successful."); //Application.DoEvents(); Cursor=Cursors.Default; //MessageBox.Show(result); XmlDocument doc=new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node=doc.SelectSingleNode("//Error"); if(node!=null) { //textConnectionMessage.Text=node.InnerText; MessageBox.Show(node.InnerText,"Error"); return false; } return true; }
///<summary>Only called when user clicks Delete or OK. Not called repeatedly when adding discussions.</summary> private bool SaveChangesToDb(bool doDelete) { #region validation //validate--------------------------------------------------------------------------------------------------------- int difficulty = 0; int myPoints = 0; double myPledge = 0; double bounty = 0; if (!doDelete) { if (textDescription.Text == "") { MsgBox.Show(this, "Description cannot be blank."); return(false); } try{ difficulty = int.Parse(textDifficulty.Text); } catch { MsgBox.Show(this, "Difficulty is invalid."); return(false); } if (difficulty < 0 || difficulty > 10) { MsgBox.Show(this, "Difficulty is invalid."); return(false); } if (IsAdminMode) { try { bounty = PIn.Int(textBounty.Text); } catch { MsgBox.Show(this, "Bounty is invalid."); return(false); } } if (!IsAdminMode) { try{ myPoints = PIn.Int(textMyPoints.Text); //handles "" gracefully } catch { MsgBox.Show(this, "Points is invalid."); return(false); } if (difficulty < 0 || difficulty > 100) { MsgBox.Show(this, "Points is invalid."); return(false); } //still need to validate that they have enough points. if (textMyPledge.Text == "") { myPledge = 0; } else { try{ myPledge = double.Parse(textMyPledge.Text); } catch { MsgBox.Show(this, "Pledge is invalid."); return(false); } } if (myPledge < 0) { MsgBox.Show(this, "Pledge is invalid."); return(false); } } double myPointsRemain = PIn.Double(textMyPointsRemain.Text); if (myPointsRemain < 0) { MsgBox.Show(this, "You have gone over your allotted points."); return(false); } } //end of validation------------------------------------------------------------------------------------------------ #endregion validation //if user has made no changes, then exit out------------------------------------------------------------------------- bool changesMade = false; if (doDelete) { changesMade = true; } if (tableObj == null || tableObj.Rows.Count == 0) //new { changesMade = true; } else { ODDataRow row = tableObj.Rows[0]; if (textDescription.Text != row["Description"]) { changesMade = true; } if (textDetail.Text != row["Detail"]) { changesMade = true; } if (textDifficulty.Text != row["Difficulty"]) { changesMade = true; } int approval = PIn.Int(row["Approval"]); if (comboApproval.SelectedIndex != approval) { changesMade = true; } if (groupMyVotes.Visible) { if (textMyPoints.Text != row["myPoints"] || checkIsCritical.Checked != PIn.Bool(row["IsCritical"]) || textMyPledge.Text != row["myPledge"]) { changesMade = true; } } try { if (textBounty.Text != row["Bounty"]) { changesMade = true; } } catch { } } if (!changesMade) { //temporarily show me which ones shortcutted out //MessageBox.Show("no changes made"); return(true); } Cursor = Cursors.WaitCursor; //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("FeatureRequestSubmitChanges"); //regkey writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); //requestId writer.WriteStartElement("RequestId"); writer.WriteString(RequestId.ToString()); //this will be zero for a new request. writer.WriteEndElement(); if (doDelete) { //delete writer.WriteStartElement("Delete"); writer.WriteString("true"); //all the other elements will be ignored. writer.WriteEndElement(); } else { if (!textDescription.ReadOnly) { //description writer.WriteStartElement("Description"); writer.WriteString(textDescription.Text); writer.WriteEndElement(); } if (!textDetail.ReadOnly) { //detail writer.WriteStartElement("Detail"); writer.WriteString(textDetail.Text); writer.WriteEndElement(); } if (IsAdminMode || RequestId == 0) //This allows the initial difficulty of 5 to get saved. { //difficulty writer.WriteStartElement("Difficulty"); writer.WriteString(difficulty.ToString()); writer.WriteEndElement(); } if (IsAdminMode) { //Bounty writer.WriteStartElement("Bounty"); writer.WriteString(bounty.ToString()); writer.WriteEndElement(); } //approval writer.WriteStartElement("Approval"); writer.WriteString(comboApproval.SelectedIndex.ToString()); writer.WriteEndElement(); if (!IsAdminMode) { //mypoints writer.WriteStartElement("MyPoints"); writer.WriteString(myPoints.ToString()); writer.WriteEndElement(); //iscritical writer.WriteStartElement("IsCritical"); if (checkIsCritical.Checked) { writer.WriteString("1"); } else { writer.WriteString("0"); } writer.WriteEndElement(); //mypledge writer.WriteStartElement("MyPledge"); writer.WriteString(myPledge.ToString("f2")); 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 //Send the message and get the result------------------------------------------------------------------------------------- string result = ""; try { result = updateService.FeatureRequestSubmitChanges(strbuild.ToString()); } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show("Error: " + ex.Message); return(false); } //textConnectionMessage.Text=Lan.g(this,"Connection successful."); //Application.DoEvents(); Cursor = Cursors.Default; //MessageBox.Show(result); XmlDocument doc = new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node = doc.SelectSingleNode("//Error"); if (node != null) { //textConnectionMessage.Text=node.InnerText; MessageBox.Show(node.InnerText, "Error"); return(false); } return(true); }
///<summary>Returns a list of available code systems. Throws exceptions, put in try catch block.</summary> private static string RequestCodeSystemsXml() { #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 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; updateService.Proxy=proxy; } return updateService.RequestCodeSystems("");//may throw error. No security on this webmethod. }
///<summary>Never happens with a new request.</summary> private void FillGrid() { Cursor = Cursors.WaitCursor; //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("FeatureRequestDiscussGetList"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteStartElement("RequestId"); writer.WriteString(RequestId.ToString()); 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 //Send the message and get the result------------------------------------------------------------------------------------- string result = ""; try { result = updateService.FeatureRequestDiscussGetList(strbuild.ToString()); } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show("Error: " + ex.Message); return; } //textConnectionMessage.Text=Lan.g(this,"Connection successful."); //Application.DoEvents(); Cursor = Cursors.Default; //MessageBox.Show(result); XmlDocument doc = new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node = doc.SelectSingleNode("//Error"); if (node != null) { //textConnectionMessage.Text=node.InnerText; MessageBox.Show(node.InnerText, "Error"); return; } //Process a valid return value------------------------------------------------------------------------------------------------ node = doc.SelectSingleNode("//ResultTable"); ODDataTable table = new ODDataTable(node.InnerXml); gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableRequestDiscuss", "Date"), 70); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRequestDiscuss", "Note"), 200); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; for (int i = 0; i < table.Rows.Count; i++) { row = new ODGridRow(); row.Cells.Add(table.Rows[i]["dateTime"]); row.Cells.Add(table.Rows[i]["Note"]); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
private void FillGrid(){ //if(textSearch.Text.Length<3){ // MsgBox.Show(this,"Please enter a search term with at least three letters in it."); // return; //} Cursor=Cursors.WaitCursor; //Yes, this would be slicker if it were asynchronous, but no time right now. //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 //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; } //textConnectionMessage.Text=Lan.g(this,"Connection successful."); //Application.DoEvents(); Cursor=Cursors.Default; //MessageBox.Show(result); XmlDocument doc=new XmlDocument(); doc.LoadXml(result); //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; } //Process a valid return value------------------------------------------------------------------------------------------------ node=doc.SelectSingleNode("//ResultTable"); table=new ODDataTable(node.InnerXml); //Admin mode---------------------------------------------------------------------------------------------------------------- node=doc.SelectSingleNode("//IsAdminMode"); if(node.InnerText=="true"){ isAdminMode=true; } else{ isAdminMode=false; } //FillGrid used to start here------------------------------------------------ long selectedRequestId=0; int selectedIndex=gridMain.GetSelectedIndex(); if(selectedIndex!=-1){ if(table.Rows.Count>selectedIndex){ selectedRequestId=PIn.Long(table.Rows[gridMain.GetSelectedIndex()]["RequestId"]); } } gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col=new ODGridColumn(Lan.g("TableRequest","Req#"),40); gridMain.Columns.Add(col); col=new ODGridColumn(Lan.g("TableRequest","Mine"),40); gridMain.Columns.Add(col); col=new ODGridColumn(Lan.g("TableRequest","My Votes"),60); gridMain.Columns.Add(col); col=new ODGridColumn(Lan.g("TableRequest","Total Votes"),70); gridMain.Columns.Add(col); col=new ODGridColumn(Lan.g("TableRequest","Diff"),40); gridMain.Columns.Add(col); col=new ODGridColumn(Lan.g("TableRequest","Weight"),45); gridMain.Columns.Add(col); col=new ODGridColumn(Lan.g("TableRequest","Approval"),90); gridMain.Columns.Add(col); col=new ODGridColumn(Lan.g("TableRequest","Description"),500); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; for(int i=0;i<table.Rows.Count;i++){ row=new ODGridRow(); row.Cells.Add(table.Rows[i]["RequestId"]); row.Cells.Add(table.Rows[i]["isMine"]); row.Cells.Add(table.Rows[i]["myVotes"]); row.Cells.Add(table.Rows[i]["totalVotes"]); row.Cells.Add(table.Rows[i]["Difficulty"]); row.Cells.Add(table.Rows[i]["Weight"]); row.Cells.Add(table.Rows[i]["approval"]); row.Cells.Add(table.Rows[i]["Description"]); gridMain.Rows.Add(row); } gridMain.EndUpdate(); for(int i=0;i<table.Rows.Count;i++){ if(selectedRequestId.ToString()==table.Rows[i]["RequestId"]){ gridMain.SetSelected(i,true); } } }
private void butDownload_Click(object sender,EventArgs e) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {//Do not let users download code systems when using the middle tier. MsgBox.Show("CodeSystemImporter","Cannot download code systems when using the middle tier."); return; } if(gridMain.GetSelectedIndex()==-1) { MsgBox.Show("CodeSystemImporter","No code systems selected."); return; } _mapCodeSystemStatus.Clear(); for(int i=0;i<gridMain.SelectedIndices.Length;i++) { CodeSystem codeSystem=_listCodeSystems[gridMain.SelectedIndices[i]]; try { //Show warnings and prompts if(!PreDownloadHelper(codeSystem.CodeSystemName)) { _mapCodeSystemStatus[codeSystem.CodeSystemName]=Lan.g("CodeSystemImporter","Import cancelled"); continue; } //CPT codes require user to choose a local file so we will not do this on a thread. //We will handle the CPT import right here on the main thread before we start all other imports in parallel below. if(codeSystem.CodeSystemName=="CPT") { #region Import CPT codes //Default status for CPT codes. We will clear this below if the file is selected and unzipped succesfully. _mapCodeSystemStatus[codeSystem.CodeSystemName]=Lan.g("CodeSystemImporter","To purchase CPT codes go to https://commerce.ama-assn.org/store/"); if(!MsgBox.Show("CodeSystemImporter",MsgBoxButtons.OKCancel,"CPT codes must be purchased from the American Medical Association separately in the data file format. " +"Please consult the online manual to help determine if you should purchase these codes and how to purchase them. Most offices are not required to purchase these codes. " +"If you have already purchased the code file click OK to browse to the downloaded file.")) { continue; } OpenFileDialog fdlg=new OpenFileDialog(); fdlg.Title=Lan.g("CodeSystemImporter","Choose CPT .zip file"); fdlg.InitialDirectory=Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); fdlg.Filter="zip|*.zip"; fdlg.RestoreDirectory=true; fdlg.Multiselect=false; if(fdlg.ShowDialog()!=DialogResult.OK) { continue; } if(!fdlg.FileName.ToLower().Contains("cpt-2014-data-files-download.zip") && !fdlg.FileName.ToLower().Contains("cpt-2015-data-files.zip")) { //This check will need to be changed every year once we know what the new file is called. _mapCodeSystemStatus[codeSystem.CodeSystemName]=Lan.g("CodeSystemImporter","Could not locate .zip file in specified folder."); continue; } string[] filename=fdlg.FileName.ToLower().Split('\\'); string versionID=filename[filename.Length-1].Split('-')[1]; //Unzip the compressed file----------------------------------------------------------------------------------------------------- bool foundFile=false; string meduFileExtention=".txt"; //Assume the the extention is going be .txt and not .txt.txt until it is found MemoryStream ms=new MemoryStream(); using(ZipFile unzipped=ZipFile.Read(fdlg.FileName)) { for(int unzipIndex=0;unzipIndex<unzipped.Count;unzipIndex++) {//unzip/write all files to the temp directory ZipEntry ze=unzipped[unzipIndex]; if(!ze.FileName.ToLower().Contains("medu.txt")) { //This file used to be called "medu.txt.txt" and is now called "medu.txt". Uses .Contains() to catch both cases. continue; } if(ze.FileName.ToLower().EndsWith(".txt.txt")) { meduFileExtention=".txt.txt"; //The file we're looking for is .txt.txt, used to build file name for import later. } ze.Extract(PrefL.GetTempFolderPath(),ExtractExistingFileAction.OverwriteSilently); foundFile=true; } } if(!foundFile) { _mapCodeSystemStatus[codeSystem.CodeSystemName]=Lan.g("CodeSystemImporter","MEDU.txt file not found in zip archive."); //Used to be MEDU.txt.txt, For error purposes we'll just show .txt continue; } //Add a new thread. We will run these all in parallel once we have them all queued. //MEDU.txt.txt is not a typo. That is litterally how the resource file is realeased to the public! UpdateCodeSystemThread.Add(ODFileUtils.CombinePaths(PrefL.GetTempFolderPath(),"MEDU"+meduFileExtention),_listCodeSystems[gridMain.SelectedIndices[i]],new UpdateCodeSystemThread.UpdateCodeSystemArgs(UpdateCodeSystemThread_UpdateSafe),versionID); //We got this far so the local file was retreived successfully. No initial status to report. _mapCodeSystemStatus[codeSystem.CodeSystemName]=""; #endregion } else { #region Import all other codes //Add a new thread. We will run these all in parallel once we have them all queued. //This code system file does not exist on the system so it will be downloaded before being imported. if(codeSystem.CodeSystemName=="SNOMEDCT") {//SNOMEDCT codes cannot be given out to non-member nations. We treat non-USA reg keys as non-member nations. //Ensure customer has a valid USA registration key #if DEBUG OpenDental.localhost.Service1 regService=new OpenDental.localhost.Service1(); #else OpenDental.customerUpdates.Service1 regService=new OpenDental.customerUpdates.Service1(); regService.Url=PrefC.GetString(PrefName.UpdateServerAddress); #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; regService.Proxy=proxy; } XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = (" "); StringBuilder strbuild=new StringBuilder(); using(XmlWriter writer=XmlWriter.Create(strbuild,settings)) { writer.WriteStartElement("IsForeignRegKeyRequest"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteEndElement(); } string result=regService.IsForeignRegKey(strbuild.ToString()); XmlDocument doc=new XmlDocument(); doc.LoadXml(result); XmlNode node=doc.SelectSingleNode("//IsForeign"); bool isForeignKey=true; if(node!=null) { if(node.InnerText=="false") { isForeignKey=false; } } if(isForeignKey) { string errorMessage=Lan.g(this,"SNOMEDCT has been skipped")+":\r\n"; node=doc.SelectSingleNode("//ErrorMessage"); if(node!=null) { errorMessage+=node.InnerText; } //The user will have to click OK on this message in order to continue downloading any additional code systems. //In the future we might turn this into calling a delegate in order to update the affected SNOMED row's text instead of stopping the main thread. MessageBox.Show(errorMessage); continue; } } UpdateCodeSystemThread.Add(_listCodeSystems[gridMain.SelectedIndices[i]],new UpdateCodeSystemThread.UpdateCodeSystemArgs(UpdateCodeSystemThread_UpdateSafe)); #endregion } } catch(Exception ex) { //Set status for this code system. _mapCodeSystemStatus[codeSystem.CodeSystemName]=Lan.g("CodeSystemImporter",ex.Message); } } //Threads are all ready to go start them all in parallel. We will re-enable these buttons when we handle the UpdateCodeSystemThread.Finished event. if(UpdateCodeSystemThread.StartAll()) { butDownload.Enabled=false; butCheckUpdates.Enabled=false; } _hasDownloaded=true; FillGrid(); }
/// <summary>Inserts RegistrationKey with blank PracticeTitle into bugs database so next time cusotmer hits the update service it will reset their PracticeTitle.</summary> private void butPracticeTitleReset_Click(object sender,EventArgs e) { if(!MsgBox.Show(this,MsgBoxButtons.OKCancel,"Are you sure you want to reset the Practice Title associated with this Registration Key? This should only be done if they are getting a message saying, \"Practice title given does not match the practice title on record,\" when connecting to the Patient Portal. It will be cleared out of the database and filled in with the appropriate Practice Title next time they connect using this Registration Key.")) { return; } //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("PracticeTitleReset"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(RegKey.RegKey); 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 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; updateService.Proxy=proxy; } updateService.PracticeTitleReset(strbuild.ToString());//may throw error }
private void butOK_Click(object sender, EventArgs e) { if (textVerificationCode.Text.Trim() == "") { MsgBox.Show(this, "Verification Code is blank."); return; } if (!File.Exists(textCertFilePath.Text)) { MsgBox.Show(this, "Certificate file path is invalid."); return; } string ext = Path.GetExtension(textCertFilePath.Text).ToLower(); if (ext != ".der" && ext != ".cer") { MsgBox.Show(this, "Certificate file path extension must be .der or .cer."); return; } byte[] arrayCertificateBytes = null; try { arrayCertificateBytes = File.ReadAllBytes(textCertFilePath.Text); } catch (Exception ex) { MessageBox.Show(Lan.g(this, "Failed to read the certificate file.") + " " + ex.Message); return; } X509Certificate2 cert = null; try { cert = new X509Certificate2(arrayCertificateBytes); } catch (Exception ex) { MessageBox.Show(Lan.g(this, "Invalid certificate file.") + " " + ex.Message); return; } if (EmailNameResolver.GetCertSubjectName(cert).ToLower() != textEmailAddress.Text.ToLower()) { MessageBox.Show(Lan.g(this, "Email certificates are tied to specific addresses or domains.") + " " + Lan.g(this, "The email address on the certificate is") + " " + EmailNameResolver.GetCertSubjectName(cert) + ", " + Lan.g(this, "but the email address you specified is") + " " + textEmailAddress.Text); return; } if (cert.HasPrivateKey) { MsgBox.Show(this, "The specified certificate contains a private key. For your security, please export your public key and upload that instead."); return; } Cursor = Cursors.WaitCursor; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = (" "); StringBuilder strbuild = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(strbuild, settings)) { writer.WriteStartElement("PostEmailCertificate"); writer.WriteElementString("RegistrationKey", PrefC.GetString(PrefName.RegistrationKey)); writer.WriteElementString("EmailAddress", textEmailAddress.Text); writer.WriteElementString("VerificationCode", textVerificationCode.Text); writer.WriteElementString("CertificateData", Convert.ToBase64String(arrayCertificateBytes)); 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 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; updateService.Proxy = proxy; } string xmlResponse = ""; try { xmlResponse = updateService.PostEmailCertificate(strbuild.ToString()); } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show("Error: " + ex.Message); return; } XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlResponse); XmlNode node = doc.SelectSingleNode("//Error"); if (node != null) { Cursor = Cursors.Default; MessageBox.Show(Lan.g(this, "Error.") + " " + Lan.g(this, "Email certificate was not registered.") + " " + node.InnerText); return; } Cursor = Cursors.Default; if (doc.InnerText == "Insert") { MessageBox.Show(Lan.g(this, "Done.") + " " + Lan.g(this, "The email certificate has been registered for address") + " " + textEmailAddress.Text); } else //Updated { MessageBox.Show(Lan.g(this, "Done.") + " " + Lan.g(this, "The email certificate has been updated for address") + " " + textEmailAddress.Text); } DialogResult = DialogResult.OK; }
///<summary></summary> private bool SaveDiscuss() //bool doDelete) { //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("FeatureRequestDiscussSubmit"); //regkey writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); //DiscussId //writer.WriteStartElement("DiscussId"); //writer.WriteString(DiscussIdCur.ToString());//this will be zero for a new entry. We currently only support new entries //writer.WriteEndElement(); //RequestId writer.WriteStartElement("RequestId"); writer.WriteString(RequestId.ToString()); writer.WriteEndElement(); //can't pass patnum. Determined on the server side. //date will also be figured on the server side. //Note writer.WriteStartElement("Note"); writer.WriteString(textNote.Text); writer.WriteEndElement(); /*if(doDelete){ * //delete * writer.WriteStartElement("Delete"); * writer.WriteString("true"); * writer.WriteEndElement(); * }*/ } Cursor = Cursors.WaitCursor; #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 //Send the message and get the result------------------------------------------------------------------------------------- string result = ""; try { result = updateService.FeatureRequestDiscussSubmit(strbuild.ToString()); } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show("Error: " + ex.Message); return(false); } //textConnectionMessage.Text=Lan.g(this,"Connection successful."); //Application.DoEvents(); Cursor = Cursors.Default; //MessageBox.Show(result); XmlDocument doc = new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node = doc.SelectSingleNode("//Error"); if (node != null) { //textConnectionMessage.Text=node.InnerText; MessageBox.Show(node.InnerText, "Error"); return(false); } return(true); }
private void butOK_Click(object sender,EventArgs e) { if(textVerificationCode.Text.Trim()=="") { MsgBox.Show(this,"Verification Code is blank."); return; } if(!File.Exists(textCertFilePath.Text)) { MsgBox.Show(this,"Certificate file path is invalid."); return; } string ext=Path.GetExtension(textCertFilePath.Text).ToLower(); if(ext!=".der" && ext!=".cer") { MsgBox.Show(this,"Certificate file path extension must be .der or .cer."); return; } byte[] arrayCertificateBytes=null; try { arrayCertificateBytes=File.ReadAllBytes(textCertFilePath.Text); } catch(Exception ex) { MessageBox.Show(Lan.g(this,"Failed to read the certificate file.")+" "+ex.Message); return; } X509Certificate2 cert=null; try { cert=new X509Certificate2(arrayCertificateBytes); } catch(Exception ex) { MessageBox.Show(Lan.g(this,"Invalid certificate file.")+" "+ex.Message); return; } if(EmailMessages.GetSubjectEmailNameFromSignature(cert).ToLower()!=textEmailAddress.Text.ToLower()) { MessageBox.Show(Lan.g(this,"Email certificates are tied to specific addresses or domains.")+" " +Lan.g(this,"The email address on the certificate is")+" "+EmailMessages.GetSubjectEmailNameFromSignature(cert)+", " +Lan.g(this,"but the email address you specified is")+" "+textEmailAddress.Text); return; } if(cert.HasPrivateKey) { MsgBox.Show(this,"The specified certificate contains a private key. For your security, please export your public key and upload that instead."); return; } Cursor=Cursors.WaitCursor; XmlWriterSettings settings=new XmlWriterSettings(); settings.Indent=true; settings.IndentChars=(" "); StringBuilder strbuild=new StringBuilder(); using(XmlWriter writer=XmlWriter.Create(strbuild,settings)) { writer.WriteStartElement("PostEmailCertificate"); writer.WriteElementString("RegistrationKey",PrefC.GetString(PrefName.RegistrationKey)); writer.WriteElementString("EmailAddress",textEmailAddress.Text); writer.WriteElementString("VerificationCode",textVerificationCode.Text); writer.WriteElementString("CertificateData",Convert.ToBase64String(arrayCertificateBytes)); 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 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; updateService.Proxy=proxy; } string xmlResponse=""; try { xmlResponse=updateService.PostEmailCertificate(strbuild.ToString()); } catch(Exception ex) { Cursor=Cursors.Default; MessageBox.Show("Error: "+ex.Message); return; } XmlDocument doc=new XmlDocument(); doc.LoadXml(xmlResponse); XmlNode node=doc.SelectSingleNode("//Error"); if(node!=null) { Cursor=Cursors.Default; MessageBox.Show(Lan.g(this,"Error.")+" "+Lan.g(this,"Email certificate was not registered.")+" "+node.InnerText); return; } Cursor=Cursors.Default; if(doc.InnerText=="Insert") { MessageBox.Show(Lan.g(this,"Done.")+" "+Lan.g(this,"The email certificate has been registered for address")+" "+textEmailAddress.Text); } else {//Updated MessageBox.Show(Lan.g(this,"Done.")+" "+Lan.g(this,"The email certificate has been updated for address")+" "+textEmailAddress.Text); } DialogResult=DialogResult.OK; }
private static string SendAndReceiveXml() { //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("UpdateRequest"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteStartElement("PracticeTitle"); writer.WriteString(PrefC.GetString(PrefName.PracticeTitle)); writer.WriteEndElement(); writer.WriteStartElement("PracticePhone"); writer.WriteString(PrefC.GetString(PrefName.PracticePhone)); writer.WriteEndElement(); writer.WriteStartElement("ProgramVersion"); writer.WriteString(PrefC.GetString(PrefName.ProgramVersion)); 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 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; updateService.Proxy=proxy; } string result=""; //try { result=updateService.RequestUpdate(strbuild.ToString());//may throw error //} //catch(Exception ex) { // Cursor=Cursors.Default; // MessageBox.Show("Error: "+ex.Message); // return; //} return result; }
private void butRetrieveOIDs_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; //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("CustomerIdRequest"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteStartElement("RegKeyDisabledOverride"); writer.WriteString("true"); writer.WriteEndElement(); writer.WriteEndElement(); } #if DEBUG OpenDental.localhost.Service1 OIDService = new OpenDental.localhost.Service1(); #else OpenDental.customerUpdates.Service1 OIDService = new OpenDental.customerUpdates.Service1(); OIDService.Url = PrefC.GetString(PrefName.UpdateServerAddress); #endif //Send the message and get the result------------------------------------------------------------------------------------- string result = ""; try { result = OIDService.RequestCustomerID(strbuild.ToString()); } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show("Error: " + ex.Message); return; } Cursor = Cursors.Default; XmlDocument doc = new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node = doc.SelectSingleNode("//Error"); if (node != null) { MessageBox.Show(node.InnerText, "Error"); return; } //Process a valid return value------------------------------------------------------------------------------------------------ node = doc.SelectSingleNode("//CustomerIdResponse"); if (node == null) { MsgBox.Show(this, "There was an error requesting your OID or processing the result of the request. Please try again."); return; } if (node.InnerText == "") { labelRetrieveStatus.Text = ""; MsgBox.Show(this, "Invalid registration key. Your OIDs will have to be set manually."); return; } //CustomerIdResponse has been returned and is not blank, use it for the root displayed as the recommended value _rootOIDString = "2.16.840.1.113883.3.4337.1486." + node.InnerText; labelRetrieveStatus.Text = "Connection successful. Root OID has been retrieved."; labelRetrieveStatus.ForeColor = System.Drawing.Color.Black; //we will overwrite their root value with the returned value, but we will ask if they want to overwrite all of their other values in case they have manually set them _listOIDInternal[0].IDRoot = _rootOIDString; bool customOIDsExist = false; for (int i = 1; i < _listOIDInternal.Count; i++) //start with 1, root is 0 and is updated above { if (_listOIDInternal[i].IDRoot != "" && _listOIDInternal[i].IDRoot != _rootOIDString + "." + i.ToString()) //if any of the OIDs other than root are filled and not what we are going to fill it with using the root with CustomerID, we will be overwriting their manually entered data, ask first { customOIDsExist = true; break; } } //ask if they want to overwrite the current actual values with the recommended values if (customOIDsExist && !MsgBox.Show(this, MsgBoxButtons.YesNo, "Would you like to update all OIDs using the root provided by Open Dental?")) { FillGrid(); return; } for (int i = 1; i < _listOIDInternal.Count; i++) //start with 1, root is 0 and is updated above { _listOIDInternal[i].IDRoot = _rootOIDString + "." + i.ToString(); //adds the .1, .2, .3, and .4 to the root //database updated on OK click } FillGrid(); }
///<summary>Can throw exception.</summary> private static string SendAndReceiveDownloadXml(string codeSystemName) { //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)) { //TODO: include more user information writer.WriteStartElement("UpdateRequest"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteStartElement("PracticeTitle"); writer.WriteString(PrefC.GetString(PrefName.PracticeTitle)); writer.WriteEndElement(); writer.WriteStartElement("PracticeAddress"); writer.WriteString(PrefC.GetString(PrefName.PracticeAddress)); writer.WriteEndElement(); writer.WriteStartElement("PracticePhone"); writer.WriteString(PrefC.GetString(PrefName.PracticePhone)); writer.WriteEndElement(); writer.WriteStartElement("ProgramVersion"); writer.WriteString(PrefC.GetString(PrefName.ProgramVersion)); writer.WriteEndElement(); writer.WriteStartElement("CodeSystemRequested"); writer.WriteString(codeSystemName); 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 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; updateService.Proxy=proxy; } //may throw error return updateService.RequestCodeSystemDownload(strbuild.ToString()); }
private void butImportCanada_Click(object sender,EventArgs e) { if(!MsgBox.Show(this,true,"If you want a clean slate, the current fee schedule should be cleared first. When imported, any fees that are found in the text file will overwrite values of the current fee schedule showing in the main window. Are you sure you want to continue?")) { return; } Cursor=Cursors.WaitCursor; FormFeeSchedPickRemote formPick=new FormFeeSchedPickRemote(); formPick.Url=@"http://www.opendental.com/feescanada/";//points to index.php file if(formPick.ShowDialog()!=DialogResult.OK) { Cursor=Cursors.Default; return; } Cursor=Cursors.WaitCursor;//original wait cursor seems to go away for some reason. Application.DoEvents(); string feeData=""; if(formPick.IsFileChosenProtected) { string memberNumberODA=""; string memberPasswordODA=""; if(formPick.FileChosenName.StartsWith("ON_")) {//Any and all Ontario fee schedules FormFeeSchedPickAuthOntario formAuth=new FormFeeSchedPickAuthOntario(); if(formAuth.ShowDialog()!=DialogResult.OK) { Cursor=Cursors.Default; return; } memberNumberODA=formAuth.ODAMemberNumber; memberPasswordODA=formAuth.ODAMemberPassword; } //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("RequestFeeSched"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement();//RegistrationKey writer.WriteStartElement("FeeSchedFileName"); writer.WriteString(formPick.FileChosenName); writer.WriteEndElement();//FeeSchedFileName if(memberNumberODA!="") { writer.WriteStartElement("ODAMemberNumber"); writer.WriteString(memberNumberODA); writer.WriteEndElement();//ODAMemberNumber writer.WriteStartElement("ODAMemberPassword"); writer.WriteString(memberPasswordODA); writer.WriteEndElement();//ODAMemberPassword } writer.WriteEndElement();//RequestFeeSched } #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 //Send the message and get the result------------------------------------------------------------------------------------- string result=""; try { result=updateService.RequestFeeSched(strbuild.ToString()); } catch(Exception ex) { Cursor=Cursors.Default; MessageBox.Show("Error: "+ex.Message); return; } Cursor=Cursors.Default; XmlDocument doc=new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node=doc.SelectSingleNode("//Error"); if(node!=null) { 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 three places in the program where this happens. DataValid.SetInvalid(InvalidType.Prefs); } } else { MessageBox.Show(node.InnerText); if(Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled,true)) {//this is one of three places in the program where this happens. DataValid.SetInvalid(InvalidType.Prefs); } return; } //Process a valid return value------------------------------------------------------------------------------------------------ node=doc.SelectSingleNode("//ResultCSV64"); string feeData64=node.InnerXml; byte[] feeDataBytes=Convert.FromBase64String(feeData64); feeData=Encoding.UTF8.GetString(feeDataBytes); } else { string tempFile=Path.GetTempFileName(); WebClient myWebClient=new WebClient(); try { myWebClient.DownloadFile(formPick.FileChosenUrl,tempFile); } catch(Exception ex) { MessageBox.Show(Lan.g(this,"Failed to download fee schedule file")+": "+ex.Message); Cursor=Cursors.Default; return; } feeData=File.ReadAllText(tempFile); File.Delete(tempFile); } string[] feeLines=feeData.Split('\n'); double feeAmt; long numImported=0; long numSkipped=0; for(int i=0;i<feeLines.Length;i++) { string[] fields=feeLines[i].Split('\t'); if(fields.Length>1) {// && fields[1]!=""){//we no longer skip blank fees string procCode=fields[0]; if(ProcedureCodes.IsValidCode(procCode)) { //The Fees.Import() function will not import fees for codes that do not exist. if(fields[1]=="") { feeAmt=-1;//triggers deletion of existing fee, but no insert. } else { feeAmt=PIn.Double(fields[1]); } Fees.Import(procCode,feeAmt,SchedNum); numImported++; } else { numSkipped++; } } } DataValid.SetInvalid(InvalidType.Fees); Cursor=Cursors.Default; DialogResult=DialogResult.OK; string outputMessage=Lan.g(this,"Done. Number imported")+": "+numImported; if(numSkipped>0) { outputMessage+=" "+Lan.g(this,"Number skipped")+": "+numSkipped; } MessageBox.Show(outputMessage); }
///<summary>Never happens with a new request.</summary> private void FillGrid(){ Cursor=Cursors.WaitCursor; //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("FeatureRequestDiscussGetList"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); writer.WriteStartElement("RequestId"); writer.WriteString(RequestId.ToString()); 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 //Send the message and get the result------------------------------------------------------------------------------------- string result=""; try { result=updateService.FeatureRequestDiscussGetList(strbuild.ToString()); } catch(Exception ex) { Cursor=Cursors.Default; MessageBox.Show("Error: "+ex.Message); return; } //textConnectionMessage.Text=Lan.g(this,"Connection successful."); //Application.DoEvents(); Cursor=Cursors.Default; //MessageBox.Show(result); XmlDocument doc=new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node=doc.SelectSingleNode("//Error"); if(node!=null) { //textConnectionMessage.Text=node.InnerText; MessageBox.Show(node.InnerText,"Error"); return; } //Process a valid return value------------------------------------------------------------------------------------------------ node=doc.SelectSingleNode("//ResultTable"); ODDataTable table=new ODDataTable(node.InnerXml); gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col=new ODGridColumn(Lan.g("TableRequestDiscuss","Date"),70); gridMain.Columns.Add(col); col=new ODGridColumn(Lan.g("TableRequestDiscuss","Note"),200); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; for(int i=0;i<table.Rows.Count;i++){ row=new ODGridRow(); row.Cells.Add(table.Rows[i]["dateTime"]); row.Cells.Add(table.Rows[i]["Note"]); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
private void Tool_eRx_Click() { if(!Security.IsAuthorized(Permissions.RxCreate)) { return; } Program programNewCrop=Programs.GetCur(ProgramName.NewCrop); string newCropAccountId=PrefC.GetString(PrefName.NewCropAccountId); if(newCropAccountId==""){//NewCrop has not been enabled yet. if(!MsgBox.Show(this,MsgBoxButtons.YesNo,"Are you sure you want to enable NewCrop electronic prescriptions? The cost is $15/month for each prescribing provider. NewCrop only works for the United States and its territories, including Puerto Rico.")) { return; } //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("CustomerIdRequest"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); 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 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; updateService.Proxy=proxy; } string patNum=""; try { string result=updateService.RequestCustomerID(strbuild.ToString());//may throw error XmlDocument doc=new XmlDocument(); doc.LoadXml(result); XmlNode node=doc.SelectSingleNode("//CustomerIdResponse"); if(node!=null) { patNum=node.InnerText; } if(patNum=="") { throw new ApplicationException("Failed to validate registration key."); } newCropAccountId=patNum; newCropAccountId+="-"+CodeBase.MiscUtils.CreateRandomAlphaNumericString(3); long checkSum=PIn.Long(patNum); checkSum+=Convert.ToByte(newCropAccountId[newCropAccountId.IndexOf('-')+1])*3; checkSum+=Convert.ToByte(newCropAccountId[newCropAccountId.IndexOf('-')+2])*5; checkSum+=Convert.ToByte(newCropAccountId[newCropAccountId.IndexOf('-')+3])*7; newCropAccountId+=(checkSum%100).ToString().PadLeft(2,'0'); Prefs.UpdateString(PrefName.NewCropAccountId,newCropAccountId); programNewCrop.Enabled=true; Programs.Update(programNewCrop); } catch(Exception ex) { MessageBox.Show(ex.Message); return; } } else { //newCropAccountId!="" if(!programNewCrop.Enabled) { MessageBox.Show(Lan.g(this,"Electronic prescriptions are currently disabled.")+"\r\n"+Lan.g(this,"To enable, go to Setup | Program Links | NewCrop.")); return; } if(!NewCropIsAccountIdValid()) { string newCropName=PrefC.GetString(PrefName.NewCropName); string newCropPassword=PrefC.GetString(PrefName.NewCropPassword); if(newCropName=="" || newCropPassword=="") { //NewCrop does not allow blank passwords. MsgBox.Show(this,"NewCropName preference and NewCropPassword preference must not be blank when using a NewCrop AccountID provided by a reseller."); return; } } } //Validation------------------------------------------------------------------------------------------------------------------------------------------------------ if(Security.CurUser.EmployeeNum==0 && Security.CurUser.ProvNum==0) { MsgBox.Show(this,"This user must be associated with either a provider or an employee. The security admin must make this change before this user can submit prescriptions."); return; } if(PatCur==null) { MsgBox.Show(this,"No patient selected."); return; } string practicePhone=PrefC.GetString(PrefName.PracticePhone); if(!Regex.IsMatch(practicePhone,"^[0-9]{10}$")) {//"^[0-9]{10}(x[0-9]+)?$")) { MsgBox.Show(this,"Practice phone must be exactly 10 digits."); return; } if(practicePhone.StartsWith("555")) { MsgBox.Show(this,"Practice phone cannot start with 555."); return; } if(Regex.IsMatch(practicePhone,"^[0-9]{3}555[0-9]{4}$")) { MsgBox.Show(this,"Practice phone cannot contain 555 in the middle 3 digits."); return; } string practiceFax=PrefC.GetString(PrefName.PracticeFax); if(!Regex.IsMatch(practiceFax,"^[0-9]{10}(x[0-9]+)?$")) { MsgBox.Show(this,"Practice fax must be exactly 10 digits."); return; } if(practiceFax.StartsWith("555")) { MsgBox.Show(this,"Practice fax cannot start with 555."); return; } if(Regex.IsMatch(practiceFax,"^[0-9]{3}555[0-9]{4}$")) { MsgBox.Show(this,"Practice fax cannot contain 555 in the middle 3 digits."); return; } if(PrefC.GetString(PrefName.PracticeAddress)=="") { MsgBox.Show(this,"Practice address blank."); return; } if(Regex.IsMatch(PrefC.GetString(PrefName.PracticeAddress),".*P\\.?O\\.? .*",RegexOptions.IgnoreCase)) { MsgBox.Show(this,"Practice address cannot be a PO BOX."); return; } if(PrefC.GetString(PrefName.PracticeCity)=="") { MsgBox.Show(this,"Practice city blank."); return; } List<string> stateCodes=new List<string>(new string[] { //50 States. "AK","AL","AR","AZ","CA","CO","CT","DE","FL","GA", "HI","IA","ID","IL","IN","KS","KY","LA","MA","MD", "ME","MI","MN","MO","MS","MT","NC","ND","NE","NH", "NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC", "SD","TN","TX","UT","VA","VT","WA","WI","WV","WY", //US Districts "DC", //US territories. Reference http://www.itl.nist.gov/fipspubs/fip5-2.htm "AS","FM","GU","MH","MP","PW","PR","UM","VI", }); if(stateCodes.IndexOf(PrefC.GetString(PrefName.PracticeST))<0) { MsgBox.Show(this,"Practice state abbreviation invalid."); return; } string practiceZip=Regex.Replace(PrefC.GetString(PrefName.PracticeZip),"[^0-9]*","");//Zip with all non-numeric characters removed. if(practiceZip.Length!=9) { MsgBox.Show(this,"Practice zip must be 9 digits."); return; } if(!PrefC.GetBool(PrefName.EasyNoClinics) && PatCur.ClinicNum!=0) { //Using clinics and the patient is assigned to a clinic. Clinic clinic=Clinics.GetClinic(PatCur.ClinicNum); if(!Regex.IsMatch(clinic.Phone,"^[0-9]{10}?$")) { MessageBox.Show(Lan.g(this,"Clinic phone must be exactly 10 digits")+": "+clinic.Description); return; } if(clinic.Phone.StartsWith("555")) { MessageBox.Show(Lan.g(this,"Clinic phone cannot start with 555")+": "+clinic.Description); return; } if(Regex.IsMatch(clinic.Phone,"^[0-9]{3}555[0-9]{4}$")) { MessageBox.Show(Lan.g(this,"Clinic phone cannot contain 555 in the middle 3 digits")+": "+clinic.Description); return; } if(!Regex.IsMatch(clinic.Fax,"^[0-9]{10}?$")) { MessageBox.Show(Lan.g(this,"Clinic fax must be exactly 10 digits")+": "+clinic.Description); return; } if(clinic.Fax.StartsWith("555")) { MessageBox.Show(Lan.g(this,"Clinic fax cannot start with 555")+": "+clinic.Description); return; } if(Regex.IsMatch(clinic.Fax,"^[0-9]{3}555[0-9]{4}$")) { MessageBox.Show(Lan.g(this,"Clinic fax cannot contain 555 in the middle 3 digits")+": "+clinic.Description); return; } if(clinic.Address=="") { MessageBox.Show(Lan.g(this,"Clinic address blank")+": "+clinic.Description); return; } if(Regex.IsMatch(clinic.Address,".*P\\.?O\\.? .*",RegexOptions.IgnoreCase)) { MessageBox.Show(Lan.g(this,"Clinic address cannot be a PO BOX")+": "+clinic.Description); return; } if(clinic.City=="") { MessageBox.Show(Lan.g(this,"Clinic city blank")+": "+clinic.Description); return; } if(stateCodes.IndexOf(clinic.State)<0) { MessageBox.Show(Lan.g(this,"Clinic state abbreviation invalid")+": "+clinic.Description); return; } string clinicZip=Regex.Replace(clinic.Zip,"[^0-9]*","");//Zip with all non-numeric characters removed. if(clinicZip.Length!=9) { MessageBox.Show(Lan.g(this,"Clinic zip must be 9 digits")+": "+clinic.Description); return; } } Provider prov=null; if(Security.CurUser.ProvNum!=0) { prov=Providers.GetProv(Security.CurUser.ProvNum); } else { prov=Providers.GetProv(PatCur.PriProv); } if(prov.IsNotPerson) { MessageBox.Show(Lan.g(this,"Provider must be a person")+": "+prov.Abbr); return; } string fname=prov.FName.Trim(); if(fname=="") { MessageBox.Show(Lan.g(this,"Provider first name missing")+": "+prov.Abbr); return; } if(Regex.Replace(fname,"[^A-Za-z\\-]*","")!=fname) { MessageBox.Show(Lan.g(this,"Provider first name can only contain letters and dashes.")+": "+prov.Abbr); return; } string lname=prov.LName.Trim(); if(lname=="") { MessageBox.Show(Lan.g(this,"Provider last name missing")+": "+prov.Abbr); return; } if(Regex.Replace(lname,"[^A-Za-z\\-]*","")!=lname) { //Will catch situations such as "Dale Jr. III" and "Ross DMD". MessageBox.Show(Lan.g(this,"Provider last name can only contain letters and dashes. Use the suffix box for I, II, III, Jr, or Sr")+": "+prov.Abbr); return; } //prov.Suffix is not validated here. In ErxXml.cs, the suffix is converted to the appropriate suffix enumeration value, or defaults to DDS if the suffix does not make sense. if(prov.DEANum.ToLower()!="none" && !Regex.IsMatch(prov.DEANum,"^[A-Za-z]{2}[0-9]{7}$")) { MessageBox.Show(Lan.g(this,"Provider DEA Number must be 2 letters followed by 7 digits. If no DEA Number, enter NONE.")+": "+prov.Abbr); return; } string npi=Regex.Replace(prov.NationalProvID,"[^0-9]*","");//NPI with all non-numeric characters removed. if(npi.Length!=10) { MessageBox.Show(Lan.g(this,"Provider NPI must be exactly 10 digits")+": "+prov.Abbr); return; } if(prov.StateLicense=="") { MessageBox.Show(Lan.g(this,"Provider state license missing")+": "+prov.Abbr); return; } if(stateCodes.IndexOf(prov.StateWhereLicensed)<0) { MessageBox.Show(Lan.g(this,"Provider state where licensed invalid")+": "+prov.Abbr); return; } Employee emp=null; if(Security.CurUser.EmployeeNum!=0) { emp=Employees.GetEmp(Security.CurUser.EmployeeNum); if(emp.LName=="") {//Checked in UI, but check here just in case this database was converted from another software. MessageBox.Show(Lan.g(this,"Employee last name missing for user")+": "+Security.CurUser.UserName); return; } if(emp.FName=="") {//Not validated in UI. MessageBox.Show(Lan.g(this,"Employee first name missing for user")+": "+Security.CurUser.UserName); return; } } if(PatCur.Birthdate.Year<1880) { MsgBox.Show(this,"Patient birthdate missing."); return; } if(PatCur.State!="" && stateCodes.IndexOf(PatCur.State)<0) { MsgBox.Show(this,"Patient state abbreviation invalid"); return; } //FormErx formErx=new FormErx(); //formErx.prov=prov; //formErx.emp=emp; //formErx.pat=PatCur; //formErx.ShowDialog(); string clickThroughXml=ErxXml.BuildClickThroughXml(prov,emp,PatCur); string xmlBase64=System.Web.HttpUtility.HtmlEncode(Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(clickThroughXml))); xmlBase64=xmlBase64.Replace("+","%2B");//A common base 64 character which needs to be escaped within URLs. xmlBase64=xmlBase64.Replace("/","%2F");//A common base 64 character which needs to be escaped within URLs. xmlBase64=xmlBase64.Replace("=","%3D");//Base 64 strings usually end in '=', which could mean a new parameter definition within the URL so we escape. String postdata="RxInput=base64:"+xmlBase64; byte[] PostDataBytes=System.Text.Encoding.UTF8.GetBytes(postdata); string additionalHeaders="Content-Type: application/x-www-form-urlencoded\r\n"; InternetExplorer IEControl=new InternetExplorer(); IWebBrowserApp IE=(IWebBrowserApp)IEControl; IE.Visible=true; #if DEBUG string newCropUrl="http://preproduction.newcropaccounts.com/interfaceV7/rxentry.aspx"; #else //Debug string newCropUrl="https://secure.newcropaccounts.com/interfacev7/rxentry.aspx"; #endif IE.Navigate(newCropUrl,null,null,PostDataBytes,additionalHeaders); ErxLog erxLog=new ErxLog(); erxLog.PatNum=PatCur.PatNum; erxLog.MsgText=clickThroughXml; erxLog.ProvNum=prov.ProvNum; ErxLogs.Insert(erxLog); }
///<summary>Only called when user clicks Delete or OK. Not called repeatedly when adding discussions.</summary> private bool SaveChangesToDb(bool doDelete) { #region validation //validate--------------------------------------------------------------------------------------------------------- int difficulty=0; int myPoints=0; double myPledge=0; double bounty=0; if(!doDelete){ if(textDescription.Text==""){ MsgBox.Show(this,"Description cannot be blank."); return false; } try{ difficulty=int.Parse(textDifficulty.Text); } catch{ MsgBox.Show(this,"Difficulty is invalid."); return false; } if(difficulty<0 || difficulty>10){ MsgBox.Show(this,"Difficulty is invalid."); return false; } if(IsAdminMode) { try { bounty=PIn.Int(textBounty.Text); } catch { MsgBox.Show(this,"Bounty is invalid."); return false; } } if(!IsAdminMode){ try{ myPoints=PIn.Int(textMyPoints.Text);//handles "" gracefully } catch{ MsgBox.Show(this,"Points is invalid."); return false; } if(difficulty<0 || difficulty>100){ MsgBox.Show(this,"Points is invalid."); return false; } //still need to validate that they have enough points. if(textMyPledge.Text==""){ myPledge=0; } else{ try{ myPledge=double.Parse(textMyPledge.Text); } catch{ MsgBox.Show(this,"Pledge is invalid."); return false; } } if(myPledge<0){ MsgBox.Show(this,"Pledge is invalid."); return false; } } double myPointsRemain=PIn.Double(textMyPointsRemain.Text); if(myPointsRemain<0){ MsgBox.Show(this,"You have gone over your allotted points."); return false; } } //end of validation------------------------------------------------------------------------------------------------ #endregion validation //if user has made no changes, then exit out------------------------------------------------------------------------- bool changesMade=false; if(doDelete){ changesMade=true; } if(tableObj==null || tableObj.Rows.Count==0){//new changesMade=true; } else{ ODDataRow row=tableObj.Rows[0]; if(textDescription.Text!=row["Description"]){ changesMade=true; } if(textDetail.Text!=row["Detail"]){ changesMade=true; } if(textDifficulty.Text!=row["Difficulty"]){ changesMade=true; } int approval=PIn.Int(row["Approval"]); if(comboApproval.SelectedIndex!=approval){ changesMade=true; } if(groupMyVotes.Visible){ if(textMyPoints.Text!=row["myPoints"] || checkIsCritical.Checked!=PIn.Bool(row["IsCritical"]) || textMyPledge.Text!=row["myPledge"]) { changesMade=true; } } try { if(textBounty.Text!=row["Bounty"]) { changesMade=true; } } catch { } } if(!changesMade){ //temporarily show me which ones shortcutted out //MessageBox.Show("no changes made"); return true; } Cursor=Cursors.WaitCursor; //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("FeatureRequestSubmitChanges"); //regkey writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); //requestId writer.WriteStartElement("RequestId"); writer.WriteString(RequestId.ToString());//this will be zero for a new request. writer.WriteEndElement(); if(doDelete){ //delete writer.WriteStartElement("Delete"); writer.WriteString("true");//all the other elements will be ignored. writer.WriteEndElement(); } else{ if(!textDescription.ReadOnly){ //description writer.WriteStartElement("Description"); writer.WriteString(textDescription.Text); writer.WriteEndElement(); } if(!textDetail.ReadOnly){ //detail writer.WriteStartElement("Detail"); writer.WriteString(textDetail.Text); writer.WriteEndElement(); } if(IsAdminMode || RequestId==0)//This allows the initial difficulty of 5 to get saved. { //difficulty writer.WriteStartElement("Difficulty"); writer.WriteString(difficulty.ToString()); writer.WriteEndElement(); } if(IsAdminMode) { //Bounty writer.WriteStartElement("Bounty"); writer.WriteString(bounty.ToString()); writer.WriteEndElement(); } //approval writer.WriteStartElement("Approval"); writer.WriteString(comboApproval.SelectedIndex.ToString()); writer.WriteEndElement(); if(!IsAdminMode){ //mypoints writer.WriteStartElement("MyPoints"); writer.WriteString(myPoints.ToString()); writer.WriteEndElement(); //iscritical writer.WriteStartElement("IsCritical"); if(checkIsCritical.Checked){ writer.WriteString("1"); } else{ writer.WriteString("0"); } writer.WriteEndElement(); //mypledge writer.WriteStartElement("MyPledge"); writer.WriteString(myPledge.ToString("f2")); 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 //Send the message and get the result------------------------------------------------------------------------------------- string result=""; try { result=updateService.FeatureRequestSubmitChanges(strbuild.ToString()); } catch(Exception ex) { Cursor=Cursors.Default; MessageBox.Show("Error: "+ex.Message); return false; } //textConnectionMessage.Text=Lan.g(this,"Connection successful."); //Application.DoEvents(); Cursor=Cursors.Default; //MessageBox.Show(result); XmlDocument doc=new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node=doc.SelectSingleNode("//Error"); if(node!=null) { //textConnectionMessage.Text=node.InnerText; MessageBox.Show(node.InnerText,"Error"); return false; } return true; }
private void butImportCanada_Click(object sender, EventArgs e) { if (!MsgBox.Show(this, true, "If you want a clean slate, the current fee schedule should be cleared first. When imported, any fees that are found in the text file will overwrite values of the current fee schedule showing in the main window. Are you sure you want to continue?")) { return; } Cursor = Cursors.WaitCursor; FormFeeSchedPickRemote formPick = new FormFeeSchedPickRemote(); formPick.Url = @"http://www.opendental.com/feescanada/"; //points to index.php file if (formPick.ShowDialog() != DialogResult.OK) { Cursor = Cursors.Default; return; } Cursor = Cursors.WaitCursor; //original wait cursor seems to go away for some reason. Application.DoEvents(); string feeData = ""; if (formPick.IsFileChosenProtected) { string memberNumberODA = ""; string memberPasswordODA = ""; if (formPick.FileChosenName.StartsWith("ON_")) //Any and all Ontario fee schedules { FormFeeSchedPickAuthOntario formAuth = new FormFeeSchedPickAuthOntario(); if (formAuth.ShowDialog() != DialogResult.OK) { Cursor = Cursors.Default; return; } memberNumberODA = formAuth.ODAMemberNumber; memberPasswordODA = formAuth.ODAMemberPassword; } //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("RequestFeeSched"); writer.WriteStartElement("RegistrationKey"); writer.WriteString(PrefC.GetString(PrefName.RegistrationKey)); writer.WriteEndElement(); //RegistrationKey writer.WriteStartElement("FeeSchedFileName"); writer.WriteString(formPick.FileChosenName); writer.WriteEndElement(); //FeeSchedFileName if (memberNumberODA != "") { writer.WriteStartElement("ODAMemberNumber"); writer.WriteString(memberNumberODA); writer.WriteEndElement(); //ODAMemberNumber writer.WriteStartElement("ODAMemberPassword"); writer.WriteString(memberPasswordODA); writer.WriteEndElement(); //ODAMemberPassword } writer.WriteEndElement(); //RequestFeeSched } #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 //Send the message and get the result------------------------------------------------------------------------------------- string result = ""; try { result = updateService.RequestFeeSched(strbuild.ToString()); } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show("Error: " + ex.Message); return; } Cursor = Cursors.Default; XmlDocument doc = new XmlDocument(); doc.LoadXml(result); //Process errors------------------------------------------------------------------------------------------------------------ XmlNode node = doc.SelectSingleNode("//Error"); if (node != null) { 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 three places in the program where this happens. { DataValid.SetInvalid(InvalidType.Prefs); } } else { MessageBox.Show(node.InnerText); if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, true)) //this is one of three places in the program where this happens. { DataValid.SetInvalid(InvalidType.Prefs); } return; } //Process a valid return value------------------------------------------------------------------------------------------------ node = doc.SelectSingleNode("//ResultCSV64"); string feeData64 = node.InnerXml; byte[] feeDataBytes = Convert.FromBase64String(feeData64); feeData = Encoding.UTF8.GetString(feeDataBytes); } else { string tempFile = Path.GetTempFileName(); WebClient myWebClient = new WebClient(); try { myWebClient.DownloadFile(formPick.FileChosenUrl, tempFile); } catch (Exception ex) { MessageBox.Show(Lan.g(this, "Failed to download fee schedule file") + ": " + ex.Message); Cursor = Cursors.Default; return; } feeData = File.ReadAllText(tempFile); File.Delete(tempFile); } string[] feeLines = feeData.Split('\n'); double feeAmt; long numImported = 0; long numSkipped = 0; for (int i = 0; i < feeLines.Length; i++) { string[] fields = feeLines[i].Split('\t'); if (fields.Length > 1) // && fields[1]!=""){//we no longer skip blank fees { string procCode = fields[0]; if (ProcedureCodes.IsValidCode(procCode)) //The Fees.Import() function will not import fees for codes that do not exist. { if (fields[1] == "") { feeAmt = -1; //triggers deletion of existing fee, but no insert. } else { feeAmt = PIn.Double(fields[1]); } Fees.Import(procCode, feeAmt, SchedNum); numImported++; } else { numSkipped++; } } } DataValid.SetInvalid(InvalidType.Fees); Cursor = Cursors.Default; DialogResult = DialogResult.OK; string outputMessage = Lan.g(this, "Done. Number imported") + ": " + numImported; if (numSkipped > 0) { outputMessage += " " + Lan.g(this, "Number skipped") + ": " + numSkipped; } MessageBox.Show(outputMessage); }