public FormTxtMsgMany(List <PatComm> listPatComms, string textMessageText, long clinicNum, SmsMessageSource messageSource) { InitializeComponent(); Lan.F(this); _listPatComms = listPatComms; textMessage.Text = textMessageText; _clinicNum = clinicNum; _messageSource = messageSource; }
public static SmsToMobile CreateSmsToMobile(Patient pat, string guidMessage, SmsMessageSource source) { string guidBatch = Guid.NewGuid().ToString(); SmsToMobile smsToMobile = new SmsToMobile() { GuidBatch = guidBatch, GuidMessage = guidMessage, MsgType = source, PatNum = pat.PatNum, MobilePhoneNumber = pat.WirelessPhone }; smsToMobile.SmsToMobileNum = SmsToMobiles.Insert(smsToMobile); return(smsToMobile); }
///<summary>Surround with Try/Catch. Sent as time sensitive message.</summary> public static bool SendSmsSingle(long patNum, string wirelessPhone, string message, long clinicNum, SmsMessageSource smsMessageSource, bool makeCommLog = true, Userod user = null, bool canCheckBal = true) { //No need to check RemotingRole; no call to db. if (Plugins.HookMethod(null, "SmsToMobiles.SendSmsSingle_start", patNum, wirelessPhone, message, clinicNum)) { return(true); } double balance = SmsPhones.GetClinicBalance(clinicNum); if (balance - CHARGE_PER_MSG < 0 && canCheckBal) //ODException.ErrorCode 1 will be processed specially by caller. { throw new ODException("To send this message first increase spending limit for integrated texting from eServices Setup.", 1); } string countryCodeLocal = CultureInfo.CurrentCulture.Name.Substring(CultureInfo.CurrentCulture.Name.Length - 2); //Example "en-US"="US" string countryCodePhone = SmsPhones.GetForClinics(new List <long> { clinicNum }).FirstOrDefault()?.CountryCode ?? ""; SmsToMobile smsToMobile = new SmsToMobile(); smsToMobile.ClinicNum = clinicNum; smsToMobile.GuidMessage = Guid.NewGuid().ToString(); smsToMobile.GuidBatch = smsToMobile.GuidMessage; smsToMobile.IsTimeSensitive = true; smsToMobile.MobilePhoneNumber = ConvertPhoneToInternational(wirelessPhone, countryCodeLocal, countryCodePhone); smsToMobile.PatNum = patNum; smsToMobile.MsgText = message; smsToMobile.MsgType = smsMessageSource; SmsToMobiles.SendSms(new List <SmsToMobile>() { smsToMobile }); //Will throw if failed. HandleSentSms(new List <SmsToMobile>() { smsToMobile }, makeCommLog, user); return(true); }
///<summary>Gets the first Enum T with a ShortCodeAttribute such that SmsMessageSouce matches the given value.</summary> public static T GetFirstOrDefault <T>(SmsMessageSource smsMessageSource) where T : Enum { return(Enum.GetValues(typeof(T)).AsEnumerable <T>() .FirstOrDefault(x => x.GetAttributeOrDefault <ShortCodeAttribute>().SmsMessageSource.Contains(smsMessageSource))); }
/// <summary>May be called from other parts of the program without showing this form. You must still create an instance of this form though. /// Checks CallFire bridge, if it is OK to send a text, etc. (Buttons to load this form are usually disabled if it is not OK, /// but this is needed for Confirmations, Recalls, etc.). CanIncreaseLimit will prompt the user to increase the spending limit if sending the /// text would exceed that limit. Should only be true when this method is called from this form. </summary> public bool SendText(long patNum, string wirelessPhone, string message, YN txtMsgOk, long clinicNum, SmsMessageSource smsMessageSource, bool canIncreaseLimit = false) { if (Plugins.HookMethod(this, "FormTxtMsgEdit.SendText_Start", patNum, wirelessPhone, message, txtMsgOk)) { return(false); } if (Plugins.HookMethod(this, "FormTxtMsgEdit.SendText_Start2", patNum, wirelessPhone, message, txtMsgOk)) { return(true); } if (wirelessPhone == "") { MsgBox.Show(this, "Please enter a phone number."); return(false); } if (SmsPhones.IsIntegratedTextingEnabled()) { if (!PrefC.HasClinicsEnabled && PrefC.GetDateT(PrefName.SmsContractDate).Year < 1880) //Checking for practice (clinics turned off). { MsgBox.Show(this, "Integrated Texting has not been enabled."); return(false); } else if (PrefC.HasClinicsEnabled && !Clinics.IsTextingEnabled(clinicNum)) //Checking for specific clinic. //This is likely to happen a few times per office until they setup texting properly. { if (clinicNum != 0) { MessageBox.Show(Lans.g(this, "Integrated Texting has not been enabled for the following clinic") + ":\r\n" + Clinics.GetClinic(clinicNum).Description + "."); } else { //Should never happen. This message is precautionary. MsgBox.Show(this, "The default texting clinic has not been set."); } return(false); } } else if (!Programs.IsEnabled(ProgramName.CallFire)) { MsgBox.Show(this, "CallFire Program Link must be enabled."); return(false); } if (patNum != 0 && txtMsgOk == YN.Unknown && PrefC.GetBool(PrefName.TextMsgOkStatusTreatAsNo)) { MsgBox.Show(this, "It is not OK to text this patient."); return(false); } if (patNum != 0 && txtMsgOk == YN.No) { MsgBox.Show(this, "It is not OK to text this patient."); return(false); } if (SmsPhones.IsIntegratedTextingEnabled()) { try { SmsToMobiles.SendSmsSingle(patNum, wirelessPhone, message, clinicNum, smsMessageSource, user: Security.CurUser); //Can pass in 0 as PatNum if no patient selected. return(true); } catch (Exception ex) { //ProcessSendSmsException handles the spending limit has been reached error, or returns false if the exception is different. if (!canIncreaseLimit || !FormEServicesSetup.ProcessSendSmsException(ex)) { MsgBox.Show(this, ex.Message); } return(false); } } else { if (message.Length > 160) //only a limitation for CallFire { MsgBox.Show(this, "Text length must be less than 160 characters."); return(false); } return(SendCallFire(patNum, wirelessPhone, message)); //Can pass in 0 as PatNum if no patient selected. } }