Esempio n. 1
0
        private void butSend_Click(object sender, EventArgs e)
        {
            if (!SmsPhones.IsIntegratedTextingEnabled())
            {
                MsgBox.Show(this, "Integrated Texting has not been enabled.");
                return;
            }
            if (textMessage.Text == "")
            {
                MsgBox.Show(this, "Please enter a message first.");
                return;
            }
            if (textMessage.Text.ToLower().Contains("[date]") || textMessage.Text.ToLower().Contains("[time]"))
            {
                MsgBox.Show(this, "Please replace or remove the [Date] and [Time] tags.");
                return;
            }
            if (PrefC.HasClinicsEnabled && !Clinics.IsTextingEnabled(_clinicNum))              //Checking for specific clinic.
            {
                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;
            }
            Cursor = Cursors.WaitCursor;
            int numTextsSent = 0;

            foreach (PatComm patComm in _listPatComms)
            {
                try {
                    string textMsgText = textMessage.Text.Replace("[NameF]", patComm.FName);
                    if (SendText(patComm, _clinicNum, textMsgText))
                    {
                        numTextsSent++;
                    }
                }
                catch (Exception ex) {
                    ex.DoNothing();
                    Cursor = Cursors.Default;
                    string errorMsg = Lan.g(this, "There was an error sending to") + " " + patComm.WirelessPhone + ". "
                                      + Lan.g(this, "Do you want to continue sending messages?");
                    if (MessageBox.Show(errorMsg, "", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        break;
                    }
                    Cursor = Cursors.WaitCursor;
                }
            }
            Cursor = Cursors.Default;
            MessageBox.Show(numTextsSent + " " + Lan.g(this, "texts sent successfully."));
            DialogResult = DialogResult.OK;
        }
Esempio n. 2
0
 /// <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.
     }
 }