コード例 #1
0
        private string GetContactValue(Entities.ContactCollection contacts, eContactType type)
        {
            string contactValue = String.Empty;

            if (contacts != null)
            {
                Entities.Contact tempContact = contacts.GetForContactType(type);

                if (tempContact != null)
                {
                    contactValue = tempContact.ContactDetail;
                }
            }

            return(contactValue);
        }
コード例 #2
0
        internal void SetDataSource(Entities.ContactCollection contacts)
        {
            if (this.datasource != null)
            {
                this.datasource.ListChanged -= new
                                               ListChangedEventHandler(datasource_ListChanged);
            }

            this.datasource = contacts;
            if (this.datasource != null)
            {
                this.datasource.ListChanged += new
                                               ListChangedEventHandler(datasource_ListChanged);
            }

            this.SetObjects(contacts);
        }
コード例 #3
0
        private void LoadCommunication()
        {
            Facade.IInstruction facInstrucion = new Facade.Instruction();
            var jobInstructions = facInstrucion.GetForJobId(_jobId);
            var instruction     = jobInstructions.Single(i => i.InstructionID == _instructionID);

            // Get the driver.
            Facade.IDriver  facDriver = new Facade.Resource();
            Entities.Driver driver    = facDriver.GetDriverForResourceId(_driverId);

            var communicationTypes = Utilities.GetEnumPairs <eDriverCommunicationType>();

            // We don't offer the option to communicate by Tough Touch if the driver doesn't have a passcode or the vehicle doesn't have a Tough Touch installed.
            if (string.IsNullOrWhiteSpace(driver.Passcode) || instruction.Vehicle == null || !instruction.Vehicle.IsTTInstalled)
            {
                communicationTypes.Remove((int)eDriverCommunicationType.ToughTouch);
            }

            cboCommunicationType.DataSource = communicationTypes;
            cboCommunicationType.DataBind();
            cboCommunicationType.Items.Insert(0, new ListItem("-- Select a communication type --", ""));
            cboCommunicationType.Attributes.Add("onchange", "cboCommunicationTypeIndex_Changed();");

            cboCommunicationStatus.DataSource = Utilities.UnCamelCase(Enum.GetNames(typeof(eDriverCommunicationStatus)));
            cboCommunicationStatus.DataBind();

            RadioButton rb = null;

            Entities.ContactCollection contacts = new Entities.ContactCollection();

            if (driver != null && driver.Individual.Contacts != null)
            {
                contacts = driver.Individual.Contacts;
            }

            // Get the vehicle the driver is currently assigned to.
            Facade.IJourney  facJourney     = new Facade.Journey();
            Entities.Vehicle currentVehicle = facJourney.GetCurrentVehicleForDriver(_driverId);

            if (currentVehicle != null)
            {
                contacts.Add(new Entities.Contact(eContactType.MobilePhone, currentVehicle.CabPhoneNumber));
            }

            Entities.ContactCollection cs = new Orchestrator.Entities.ContactCollection();
            rb = new RadioButton();

            bool numberSelected = false;

            foreach (Entities.Contact contact in contacts)
            {
                if (contact.ContactDetail.Length > 0)
                {
                    rb           = new RadioButton();
                    rb.GroupName = "rblNumbers";
                    rb.Text      = contact.ContactDetail;
                    rb.Attributes.Add("onclick", "setNumberUsed('" + contact.ContactDetail + "');");

                    if (contact.ContactType == eContactType.MobilePhone || contact.ContactType == eContactType.PersonalMobile ||
                        contact.ContactType == eContactType.Telephone)
                    {
                        if (!numberSelected)
                        {
                            rb.Checked     = true;
                            txtNumber.Text = contact.ContactDetail;
                            numberSelected = true;
                        }
                    }

                    plcNumbers.Controls.Add(rb);
                    plcNumbers.Controls.Add(new LiteralControl("<br/>"));
                }
            }

            rb           = new RadioButton();
            rb.Text      = "Other";
            rb.GroupName = "rblNumbers";
            rb.Attributes.Add("onclick", "enableOtherTextBox();");
            plcNumbers.Controls.Add(rb);

            bool isInvolvedInLoad = false;

            foreach (Entities.Instruction i in jobInstructions)
            {
                if (i.Driver != null && i.Driver.ResourceId == _driverId)
                {
                    if ((eInstructionType)i.InstructionTypeId == eInstructionType.Load)
                    {
                        isInvolvedInLoad = true;
                    }
                }
            }

            trLoadOrder.Visible = isInvolvedInLoad;

            if (isInvolvedInLoad)
            {
                var loadComments = BuildLoadComments(_driverId, jobInstructions);
                lblLoadOrder.Text   = loadComments;
                trLoadOrder.Visible = !string.IsNullOrWhiteSpace(loadComments);
            }

            var legPlan = new Facade.Instruction().GetLegPlan(jobInstructions, false);

            txtComments.Text = GetComments(legPlan, eDriverCommunicationType.Phone);
            txtSMSText.Text  = GetComments(legPlan, eDriverCommunicationType.Text);

            var defaultCommunicationTypeID = driver.DefaultCommunicationTypeID == 0 ? (int)eDriverCommunicationType.Phone : driver.DefaultCommunicationTypeID;

            //lookup the communication type in the drop down, dont select if it doesnt exist - this should only happen if the driver whos default method of communitication
            // is tough touch but has now moved into a vechicial without one being installed
            if (cboCommunicationType.Items.FindByValue(defaultCommunicationTypeID.ToString()) != null)
            {
                cboCommunicationType.Items.FindByValue(defaultCommunicationTypeID.ToString()).Selected = true;
            }

            Facade.IControlArea facControlArea = new Facade.Traffic();
            cboControlArea.DataSource = facControlArea.GetAll();
            cboControlArea.DataBind();

            for (int instructionIndex = jobInstructions.Count - 1; instructionIndex >= 0; instructionIndex--)
            {
                if (jobInstructions[instructionIndex].Driver != null && jobInstructions[instructionIndex].Driver.ResourceId == _driverId)
                {
                    hidLastInstructionInvolvedWith.Value = jobInstructions[instructionIndex].InstructionOrder.ToString();

                    cboControlArea.ClearSelection();
                    cboControlArea.Items.FindByValue(jobInstructions[instructionIndex].Point.Address.TrafficArea.ControlAreaId.ToString()).Selected = true;
                    BindTrafficAreas(Convert.ToInt32(cboControlArea.SelectedValue), jobInstructions[instructionIndex].Point.Address.TrafficArea.TrafficAreaId);
                    break;
                }
            }

            ShowPCVS();
        }