///<summary>This takes about 3-5 seconds to run, so we don't run it automatically when first opening the form.</summary> private string GetPatientPortalLink() { mb.Url = PrefC.GetString(PrefName.MobileSyncServerURL); if (!mb.ServiceExists()) { return(""); } try { long customerNum = mb.GetCustomerNum(PrefC.GetString(PrefName.RegistrationKey)); string patientPortalLink = mb.GetPatientPortalAddress(PrefC.GetString(PrefName.RegistrationKey)) + "?DentalOfficeID=" + customerNum; return(patientPortalLink); } catch { return(""); } }
///<summary>Returns false if validation failed. This also makes sure the web service exists, the customer is paid, and the registration key is correct.</summary> private bool SavePrefs() { //validation if (textSynchMinutes.errorProvider1.GetError(textSynchMinutes) != "" || textDateBefore.errorProvider1.GetError(textDateBefore) != "") { MsgBox.Show(this, "Please fix data entry errors first."); return(false); } //yes, workstation is allowed to be blank. That's one way for user to turn off auto synch. //if(textMobileSynchWorkStation.Text=="") { // MsgBox.Show(this,"WorkStation cannot be empty"); // return false; //} // the text field is read because the keyed in values have not been saved yet if (textMobileSyncServerURL.Text.Contains("192.168.0.196") || textMobileSyncServerURL.Text.Contains("localhost")) { IgnoreCertificateErrors(); // done so that TestWebServiceExists() does not thow an error. } // if this is not done then an old non-functional url prevents any new url from being saved. Prefs.UpdateString(PrefName.MobileSyncServerURL, textMobileSyncServerURL.Text); if (!TestWebServiceExists()) { MsgBox.Show(this, "Web service not found."); return(false); } if (mb.GetCustomerNum(PrefC.GetString(PrefName.RegistrationKey)) == 0) { MsgBox.Show(this, "Registration key is incorrect."); return(false); } if (!VerifyPaidCustomer()) { return(false); } //Minimum 10 char. Must contain uppercase, lowercase, numbers, and symbols. Valid symbols are: !@#$%^&+= //The set of symbols checked was far too small, not even including periods, commas, and parentheses. //So I rewrote it all. New error messages say exactly what's wrong with it. if (textMobileUserName.Text != "") //allowed to be blank { if (textMobileUserName.Text.Length < 10) { MsgBox.Show(this, "User Name must be at least 10 characters long."); return(false); } if (!Regex.IsMatch(textMobileUserName.Text, "[A-Z]+")) { MsgBox.Show(this, "User Name must contain an uppercase letter."); return(false); } if (!Regex.IsMatch(textMobileUserName.Text, "[a-z]+")) { MsgBox.Show(this, "User Name must contain an lowercase letter."); return(false); } if (!Regex.IsMatch(textMobileUserName.Text, "[0-9]+")) { MsgBox.Show(this, "User Name must contain a number."); return(false); } if (!Regex.IsMatch(textMobileUserName.Text, "[^0-9a-zA-Z]+")) //absolutely anything except number, lower or upper. { MsgBox.Show(this, "User Name must contain punctuation or symbols."); return(false); } } if (textDateBefore.Text == "") //default to one year if empty { textDateBefore.Text = DateTime.Today.AddYears(-1).ToShortDateString(); //not going to bother informing user. They can see it. } //save to db------------------------------------------------------------------------------------ if (Prefs.UpdateString(PrefName.MobileSyncServerURL, textMobileSyncServerURL.Text) | Prefs.UpdateInt(PrefName.MobileSyncIntervalMinutes, PIn.Int(textSynchMinutes.Text)) //blank entry allowed | Prefs.UpdateString(PrefName.MobileExcludeApptsBeforeDate, POut.Date(PIn.Date(textDateBefore.Text), false)) //blank | Prefs.UpdateString(PrefName.MobileSyncWorkstationName, textMobileSynchWorkStation.Text) | Prefs.UpdateString(PrefName.MobileUserName, textMobileUserName.Text) ) { changed = true; Prefs.RefreshCache(); } //Username and password----------------------------------------------------------------------------- mb.SetMobileWebUserPassword(PrefC.GetString(PrefName.RegistrationKey), textMobileUserName.Text.Trim(), textMobilePassword.Text.Trim()); return(true); }