public static eTextAnywhereSendSMS SendSMS(string clientReference, string billingReference, eTextAnywhereOriginatorType originatorType, string recipientsNumber, string messageText, string user) { TextAnywhere_SMS myTextAnywhere_SMS = new TextAnywhere_SMS(); string formattedNumber = myTextAnywhere_SMS.FormatNumber(recipientsNumber); eTextAnywhereSendSMS wsResult = (eTextAnywhereSendSMS)myTextAnywhere_SMS.SendSMS( Orchestrator.Globals.Configuration.TextAnywhereUsername, Orchestrator.Globals.Configuration.TextAnywherePassword, clientReference, Orchestrator.Globals.Configuration.TextAnywhereOriginator, Int32.Parse(Orchestrator.Globals.Configuration.TextAnywhereConnection), Configuration.TextAnywhereOriginator, (int)originatorType, formattedNumber, messageText, 0, 0); if (wsResult == eTextAnywhereSendSMS.SMSSent) { // Log the message data for audit trail Facade.IDriverCommunication facDriverCommunication = new Facade.Resource(); facDriverCommunication.RecordSMS(clientReference, billingReference, recipientsNumber, messageText, user); } return(wsResult); }
protected void Communicate() { if (Page.IsValid) { string userId = ((Entities.CustomPrincipal)Page.User).UserName; Entities.DriverCommunication communication = new Entities.DriverCommunication(); communication.NumberUsed = txtNumber.Text; communication.Comments = txtComments.Text; communication.DriverCommunicationStatus = (eDriverCommunicationStatus)Enum.Parse(typeof(eDriverCommunicationStatus), cboCommunicationStatus.SelectedValue.Replace(" ", "")); communication.DriverCommunicationType = (eDriverCommunicationType)int.Parse(cboCommunicationType.SelectedValue); if (communication.DriverCommunicationType == eDriverCommunicationType.Text) { communication.Text = txtSMSText.Text; } if (_subContractorId > 0) { Facade.IJobSubContractor facSubContractor = new Facade.Job(); communication.DriverCommunicationId = facSubContractor.CreateCommunication(_jobId, _instructionID, _subContractorId, communication, userId); } else { Facade.IDriverCommunication facDriverCommunication = new Facade.Resource(); if (chkGiveResources.Checked) { communication.DriverCommunicationId = facDriverCommunication.Create(_jobId, _driverId, communication, userId, _instructionID, Convert.ToInt32(hidLastInstructionInvolvedWith.Value), Convert.ToInt32(cboControlArea.SelectedValue), Convert.ToInt32(cboTrafficArea.SelectedValue)); } else { communication.DriverCommunicationId = facDriverCommunication.Create(_jobId, _driverId, communication, userId, _instructionID); } } if (communication.DriverCommunicationId > 0) { // The communication was succesfully stored. lblConfirmation.Visible = true; lblConfirmation.Text = "The communication has been stored."; if (communication.DriverCommunicationType == eDriverCommunicationType.Text) { // Send the text message. eTextAnywhereSendSMS sendSMSStatus = Utilities.SendSMS("dc" + communication.DriverCommunicationId.ToString(), "dc" + communication.DriverCommunicationId.ToString(), eTextAnywhereOriginatorType.SendDescriptiveText, communication.NumberUsed, communication.Text, userId); if (sendSMSStatus != eTextAnywhereSendSMS.SMSSent) { // Display an error to the user lblConfirmation.Text += " But the Text message was not sent, the error code was " + Enum.GetName(typeof(eTextAnywhereSendSMS), sendSMSStatus); lblConfirmation.Visible = true; } } } else { // It was not possible to create the communication. lblConfirmation.Visible = true; lblConfirmation.Text = "The communication has not been stored."; } } }