Beispiel #1
0
        private static bool CommunicateInstructionsForSubContractor(int jobID, int subContractorId, string userId)
        {
            if (!Globals.Configuration.SubContractorCommunicationsRequired)
            {
                return(false);
            }

            Entities.DriverCommunication communication = new Entities.DriverCommunication();
            communication.Comments = "Communicated via Deliveries ScreSubcontractorCommunicationsRequireden";
            communication.DriverCommunicationStatus = eDriverCommunicationStatus.Accepted;
            string mobileNumber = "unknown";

            communication.DriverCommunicationType = eDriverCommunicationType.Manifest;
            communication.NumberUsed = mobileNumber;

            Facade.IInstruction facInstruction = new Facade.Instruction();
            List <int>          instructionIds = facInstruction.GetInstructionIDsForSubContractor(jobID, subContractorId, false);

            Facade.IJobSubContractor facJob = new Facade.Job();
            foreach (int instructionId in instructionIds)
            {
                communication.DriverCommunicationId = facJob.CreateCommunication(jobID, subContractorId, communication, userId);
            }

            return(true);
        }
        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.";
                }
            }
        }