Ejemplo n.º 1
0
        private void BindInstruction()
        {
            Entities.Instruction instruction = null;

            // Get the instruction to work with.
            using (Facade.IInstruction facInstruction = new Facade.Instruction())
            {
                if (m_instructionId == 0)
                {
                    // Get the job's next instruction.
                    instruction = facInstruction.GetNextInstruction(m_jobId);
                }
                else
                {
                    // Get the specific instruction.
                    instruction = facInstruction.GetInstruction(m_instructionId);
                }
            }

            if (instruction != null)
            {
                m_pointId = instruction.PointID;
                ViewState[C_POINT_ID_VS] = m_pointId;
            }
        }
Ejemplo n.º 2
0
        private void InitialisePage()
        {
            // Retrieve the instruction.
            Facade.IInstruction facInstruction = new Facade.Instruction();
            m_instruction = facInstruction.GetInstruction(m_instructionID);
            ViewState[C_Instruction_VS] = m_instruction;

            // Populate the control and traffic area dropdowns.
            Facade.IControlArea facControlArea = new Facade.Traffic();
            cboControlArea.DataSource = facControlArea.GetAll();
            cboControlArea.DataBind();
            cboTrafficArea.DataSource = ((Facade.ITrafficArea)facControlArea).GetAll();
            cboTrafficArea.DataBind();

            // Select the current control and traffic area assigned to the leg.
            cboControlArea.Items.FindByValue(m_instruction.ControlAreaId.ToString()).Selected = true;
            cboTrafficArea.Items.FindByValue(m_instruction.TrafficAreaId.ToString()).Selected = true;

            // Enable the checkbox if this is not the last leg in the job.
            Facade.IJob facJob = new Facade.Job();
            Entities.InstructionCollection instructions = facInstruction.GetForJobId(m_instruction.JobId);
            if (instructions.Count == m_instruction.InstructionOrder + 1)
            {
                chkApplyToAllFollowingInstructions.Enabled = false;
            }
            else
            {
                chkApplyToAllFollowingInstructions.Enabled = true;
            }
        }
Ejemplo n.º 3
0
        private void LoadJob()
        {
            Facade.IJob facJob = new Facade.Job();
            m_job = facJob.GetJob(m_jobId);

            if (m_job != null)
            {
                if (m_job.JobState == eJobState.Cancelled)
                {
                    Response.Redirect("../../Job/job.aspx?wiz=true&jobId=" + m_job.JobId.ToString() + "&csid=" + this.CookieSessionID);
                }

                Facade.IPCV facPCV = new Facade.PCV();
                m_job.PCVs = facPCV.GetForJobId(m_jobId);

                if (m_job.JobState == eJobState.Booked)
                {
                    Response.Redirect("../jobManagement.aspx?jobId=" + m_jobId + "&csid=" + this.CookieSessionID);
                }

                // Load the various parts of the job.
                Facade.IInstruction facInstruction = new Facade.Instruction();
                m_job.Instructions = facInstruction.GetForJobId(m_jobId);

                PopulateJobInformation();
            }

            ViewState[C_JOB_VS] = m_job;
        }
Ejemplo n.º 4
0
        private void BindLegs()
        {
            Facade.IJob  facJob = new Facade.Job();
            Entities.Job job    = facJob.GetJob(m_jobId, true, true);

            Entities.LegPlan lp = new Facade.Instruction().GetLegPlan(job.Instructions, false);
            repLegs.DataSource = lp.Legs();
            repLegs.DataBind();

            if (job.Instructions.Count > 0)
            {
                if (job.Instructions[0].Driver != null)
                {
                    chkLinkDriver.Text = "Link " + job.Instructions[0].Driver.Individual.FullName;
                }
                if (job.Instructions[0].Vehicle != null)
                {
                    chkLinkVehicle.Text = "Link " + job.Instructions[0].Vehicle.RegNo;
                }
                if (job.Instructions[0].Trailer != null)
                {
                    chkLinkTrailer.Text = "Link " + job.Instructions[0].Trailer.TrailerRef;
                }
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        //-----------------------------------------------------------------------------------------------------------

        private void ChangeExistingInstruction(Entities.Instruction instruction, Entities.Job run, List <int> orderIds)
        {
            Facade.IInstruction facInstruction = new Facade.Instruction();
            // no need to create a new instruction.
            Entities.FacadeResult      retVal   = new Entities.FacadeResult();
            Orchestrator.Facade.IOrder facOrder = new Orchestrator.Facade.Order();
            Facade.Job facJob = new Facade.Job();
            Entities.CollectDropCollection collectDrops = new Orchestrator.Entities.CollectDropCollection();
            // Update the Order and the relevant instructions
            foreach (int ordId in orderIds)
            {
                DataSet dsOrders = facOrder.GetLegsForOrder(ordId);
                // Get the last job id from the dataset
                int jobId = -1;
                if (dsOrders.Tables[0].Rows.Count > 0)
                {
                    jobId = Convert.ToInt32(dsOrders.Tables[0].Rows[dsOrders.Tables[0].Rows.Count - 1]["JobID"].ToString());
                }

                Entities.Order currentOrder = facOrder.GetForOrderID(ordId);
                if (instruction.CollectDrops.GetForOrderID(currentOrder.OrderID) != null)
                {
                    facInstruction.UpdatePointID(instruction.InstructionID, this.cboNewDeliveryPoint.PointID, this.Page.User.Identity.Name);
                    instruction.PointID = this.cboNewDeliveryPoint.PointID;

                    this.UpdateOrder(currentOrder);

                    instruction.BookedDateTime           = currentOrder.DeliveryDateTime;
                    instruction.PlannedArrivalDateTime   = currentOrder.DeliveryDateTime;
                    instruction.PlannedDepartureDateTime = currentOrder.DeliveryDateTime;
                }
            }
        }
        private void LoadJob()
        {
            Facade.IJob         facJob         = new Facade.Job();
            Facade.IInstruction facInstruction = new Facade.Instruction();

            m_job = facJob.GetJob(m_jobId, true, true);
            ViewState[C_JOB_VS] = m_job;
        }
Ejemplo n.º 8
0
        public void OrderPlanChange(int orderID, int instructionTypeID, int?instructionID, int vehicleResourceID, DateTime arrivalDateTime)
        {
            using (var uow = DIContainer.CreateUnitOfWork())
            {
                if (instructionID.HasValue)
                {
                    Facade.IInstruction facInstruction = new Facade.Instruction();
                    Facade.IJob         facJob         = new Facade.Job();

                    var instructionRepo = DIContainer.CreateRepository <IInstructionRepository>(uow);
                    var jobID           = instructionRepo.Find(instructionID.Value).JobID;

                    var job         = facJob.GetJob(jobID, true, true);
                    var instruction = job.Instructions.Find(i => i.InstructionID == instructionID.Value);

                    var changeTimes   = instruction.PlannedArrivalDateTime != arrivalDateTime;
                    var changeVehicle = instruction.Vehicle.ResourceId != vehicleResourceID;

                    var userName = HttpContext.Current.User.Identity.Name;

                    if (changeVehicle)
                    {
                        var result = facInstruction.PlanInstruction(new[] { instructionID.Value }, jobID, -1, vehicleResourceID, -1, job.LastUpdateDate, userName);

                        if (!result.Success)
                        {
                            throw new ApplicationException(
                                      string.Format(
                                          "Could not update vehicle on run {0} due to the following infringements: {1}",
                                          jobID,
                                          string.Join("\n", result.Infringements.Select(i => i.Description))));
                        }
                    }

                    if (changeTimes)
                    {
                        instruction.PlannedArrivalDateTime   = arrivalDateTime;
                        instruction.PlannedDepartureDateTime = arrivalDateTime.AddMinutes(15);
                        var result = facJob.UpdatePlannedTimes(jobID, job.Instructions, job.LastUpdateDate, userName);

                        if (!result.Success)
                        {
                            throw new ApplicationException(
                                      string.Format(
                                          "Could not update planned times on run {0} due to the following infringements: {1}",
                                          jobID,
                                          string.Join("\n", result.Infringements.Select(i => i.Description))));
                        }
                    }
                }
                else
                {
                    var repo = DIContainer.CreateRepository <IOrderRepository>(uow);
                    repo.AddUpdateOrderPrePlan(orderID, (eInstructionType)instructionTypeID, vehicleResourceID, arrivalDateTime);
                    uow.SaveChanges();
                }
            }
        }
Ejemplo n.º 9
0
        private void CountChargeableLegs()
        {
            ReadOnlyCollection <Entities.LegView> legs = new Facade.Instruction().GetLegPlan(m_job.Instructions, false).Legs();

            m_chargeableLegs = 0;

            Entities.LegView leg           = null;
            bool             legChargeable = false;

            for (int i = 0; i < legs.Count; i++)
            {
                legChargeable = false;
                leg           = legs[i];

                // Does the Leg Have a trailer
                if (leg.Trailer != null || m_job.HasBeenSubContracted || leg.Vehicle.IsFixedUnit)
                {
                    //if there is a delivery on this leg then it is chargeable
                    if ((leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.Drop) ||
                        (leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.LeaveGoods) ||
                        ((m_job.JobType == eJobType.PalletReturn) && (leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.DeHirePallets))
                        )
                    {
                        legChargeable = true;
                        //J.Steele 05/06/08
                        //Shouldn't break here - this was causing a Divide by zero error
                        //break;
                    }

                    // Is there a delivery on any future leg
                    if (!legChargeable)
                    {
                        for (int x = i + 1; x < legs.Count; x++)
                        {
                            leg = legs[i];

                            if (
                                (leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.Drop) ||
                                (leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.LeaveGoods) ||
                                ((m_job.JobType == eJobType.PalletReturn) && (leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.DeHirePallets))
                                )
                            {
                                legChargeable = true;
                                break;
                            }
                        }
                    }

                    if (legChargeable)
                    {
                        m_chargeableLegs++;
                    }
                }
            }
        }
        private void ConfigureDisplay()
        {
            int jobId, instructionId = 0;

            if (JobId == -1 && !string.IsNullOrEmpty(Request.QueryString["jId"]))
            {
                if (int.TryParse(Request.QueryString["jId"], out jobId))
                {
                    JobId = jobId;
                }
            }

            if (InstructionId == -1 && !string.IsNullOrEmpty(Request.QueryString["iId"]))
            {
                if (int.TryParse(Request.QueryString["iId"], out instructionId))
                {
                    InstructionId = instructionId;
                }
            }

            // Bind the options for redelivery reasons, collection options only.
            cboRedeliveryReason.DataSource = EF.DataContext.Current.RedeliveryReasonSet.Where(rr => rr.IsEnabled == true && rr.IsCollection == true).OrderBy(rr => rr.Description);
            cboRedeliveryReason.DataBind();

            // Bind the extra types (remove any invalid options).
            Facade.ExtraType facExtraType        = new Facade.ExtraType();
            bool?            getActiveExtraTypes = true;

            List <Entities.ExtraType> extraTypes = facExtraType.GetForIsEnabled(getActiveExtraTypes);

            extraTypes.RemoveAll(o => (eExtraType)(o.ExtraTypeId) == eExtraType.Custom ||
                                 (eExtraType)(o.ExtraTypeId) == eExtraType.Demurrage ||
                                 (eExtraType)(o.ExtraTypeId) == eExtraType.DemurrageExtra);

            cboExtraType.DataSource     = extraTypes;
            cboExtraType.DataValueField = "ExtraTypeId";
            cboExtraType.DataTextField  = "Description";
            cboExtraType.DataBind();

            // Bind the extra states (remove any invalid options).
            List <string> extraStates = new List <string>(Utilities.UnCamelCase(Enum.GetNames(typeof(eExtraState))));

            extraStates.Remove(Utilities.UnCamelCase(Enum.GetName(typeof(eExtraState), eExtraState.Invoiced)));
            cboExtraState.DataSource = extraStates;
            cboExtraState.DataBind();

            // Get Instruction Details
            Facade.IInstruction facIns   = new Facade.Instruction();
            Facade.IPoint       facPoint = new Facade.Point();

            Entities.Instruction currentIns = facIns.GetInstruction(InstructionId);
            Entities.Point       loadPoint  = facPoint.GetPointForPointId(currentIns.PointID);

            txtExtraCustomReason.Text = string.Format("Attempted Collection from {0}", loadPoint.Description);
        }
Ejemplo n.º 11
0
        private void InitialisePage()
        {
            // Populate the control and traffic area dropdowns.
            Facade.IControlArea facControlArea = new Facade.Traffic();
            cboControlArea.DataSource = facControlArea.GetAll();
            cboControlArea.DataBind();
            cboTrafficArea.DataSource = ((Facade.ITrafficArea)facControlArea).GetAll();
            cboTrafficArea.DataBind();

            if (m_instructionId != 0)
            {
                Facade.IInstruction  facInstruction = new Facade.Instruction();
                Entities.Instruction instruction    = facInstruction.GetInstruction(m_instructionId);

                if (instruction.Driver != null)
                {
                    tdDriver.InnerText = instruction.Driver.Individual.FullName;
                }
                if (instruction.Vehicle != null)
                {
                    tdVehicle.InnerText = instruction.Vehicle.RegNo;
                }
                if (instruction.Trailer != null)
                {
                    tdTrailer.InnerText = instruction.Trailer.TrailerRef;
                }

                // Select the current control and traffic area assigned to the leg.
                cboControlArea.Items.FindByValue(instruction.ControlAreaId.ToString()).Selected = true;
                cboTrafficArea.Items.FindByValue(instruction.TrafficAreaId.ToString()).Selected = true;
            }

            if (m_driverResourceId != 0)
            {
                tdDriver.InnerText = m_fullName;
                // Select the current control and traffic area assigned to the leg.
                if (m_controlAreaId > 0)
                {
                    cboControlArea.Items.FindByValue(m_controlAreaId.ToString()).Selected = true;
                }
                if (m_trafficAreaId > 0)
                {
                    cboTrafficArea.Items.FindByValue(m_trafficAreaId.ToString()).Selected = true;
                }
            }
            if (m_vehicleResourceId != 0)
            {
                tdVehicle.InnerText = m_regNo;
            }
            if (m_trailerResourceId != 0)
            {
                tdTrailer.InnerText = m_trailerRef;
            }
        }
Ejemplo n.º 12
0
        void btnChangeTrailerType_Click(object sender, EventArgs e)
        {
            List <int> instructionIDs = new List <int>();

            foreach (Entities.Instruction instruction in this.Instrutions)
            {
                instructionIDs.Add(instruction.InstructionID);
            }
            Facade.IInstruction facInstruction = new Facade.Instruction();
            facInstruction.AssignPlanningCategory(instructionIDs, this.JobID, int.Parse(cboType.SelectedValue), DateTime.Now, Page.User.Identity.Name);
            this.ReturnValue = "changetrailertype";
            this.Close();
        }
Ejemplo n.º 13
0
        void btnConfirm_Click(object sender, EventArgs e)
        {
            int newControlAreaId = Convert.ToInt32(cboControlArea.SelectedValue);
            int newTrafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue);

            bool success = true;

            if (newControlAreaId != m_instruction.ControlAreaId || newTrafficAreaId != m_instruction.TrafficAreaId)
            {
                // Update the control area and traffic area for the leg, and it's following legs if the checkbox is checked.
                // If the checkbox is checked, the resources on the leg are moved onto the receiving planner's resource list.
                Facade.IJob facJob = new Facade.Job();

                // The end instruction of the leg should always be passed when calling SetControlArea. This is different from
                // m_instruction, which is the start instruction of the leg. The Start instruction of the leg detertmines the
                // traffic area responsible for planning the leg.
                int instructionOrder = m_instruction.InstructionOrder + 1;

                if (m_instruction.InstructionOrder == 0)
                {
                    // The instruction is the 1st on the job
                    // Edge case: ensure it is not the only one (ie. collection only job)
                    // If it is then we shouldn't increment the instruction order when calling SetControlArea.
                    Facade.IInstruction            facInstruction = new Facade.Instruction();
                    Entities.InstructionCollection instructions   = facInstruction.GetForJobId(m_instruction.JobId);

                    if (instructions.Count == 1)
                    {
                        instructionOrder--;
                    }
                }

                Entities.FacadeResult result = facJob.SetControlArea(m_instruction.JobId, newControlAreaId, newTrafficAreaId, instructionOrder, chkApplyToAllFollowingInstructions.Checked, m_lastUpdateDate, ((Entities.CustomPrincipal)Page.User).UserName);
                success = result.Success;

                if (!success)
                {
                    // Display the infringements.
                    idErrors.Infringements = result.Infringements;
                    idErrors.DisplayInfringments();
                    idErrors.Visible = true;
                    trErrors.Visible = true;
                }
            }

            if (success)
            {
                this.ReturnValue = "refresh";
                this.Close();
            }
        }
Ejemplo n.º 14
0
        private void PopulateLegTimes()
        {
            var instructions = this.Instructions;

            if (instructions != null)
            {
                var facInstruction = new Facade.Instruction();
                var legs           = facInstruction.GetLegPlan(instructions, false).Legs();

                repLegs.DataSource = legs;
                repLegs.DataBind();

                if (Globals.Configuration.CollectionTimeDeliveryWindow)
                {
                    var collects = instructions.Where(i => i.InstructionTypeId == (int)eInstructionType.Load);

                    // Only set up collection time recalculation if the last collection point on the run has a delivery matrix
                    if (collects.Any() && collects.Last().Point != null && collects.Last().Point.DeliveryMatrix > 0)
                    {
                        var firstDropFound = false;

                        for (var i = 0; i < legs.Count; i++)
                        {
                            var leg      = legs[i];
                            var legRow   = (HtmlTableRow)repLegs.Items[i].FindControl("legRow");
                            var cssClass = legRow.Attributes["class"];

                            cssClass += string.Format(" legRow_{0}", leg.InstructionID);

                            if (leg.StartLegPoint.Instruction != null)
                            {
                                cssClass += string.Format(" legStart_{0}", leg.StartLegPoint.Instruction.InstructionID);
                            }

                            if (!firstDropFound && leg.EndLegPoint.InstructionTypeId == (int)eInstructionType.Drop)
                            {
                                firstDropFound = true;
                                cssClass      += " firstDrop";
                            }

                            legRow.Attributes["class"] += cssClass.TrimStart();
                        }
                    }
                }
            }
            else
            {
                repLegs.DataSource = null;
                repLegs.DataBind();
            }
        }
Ejemplo n.º 15
0
        public void Populate()
        {
            GetSessionIDFromQueryString();

            rtsCallIn.Tabs.Clear();

            m_jobId         = Convert.ToInt32(Request.QueryString["jobId"]);
            m_instructionId = Convert.ToInt32(Request.QueryString["instructionId"]);

            // Get the instruction to work with.
            if (m_instructionId == 0)
            {
                using (Facade.IInstruction facInstruction = new Facade.Instruction())
                {
                    Entities.Instruction instruction = facInstruction.GetNextInstruction(m_jobId);
                    if (instruction != null)
                    {
                        m_instructionId = instruction.InstructionID;
                    }
                }
            }

            rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[0], "CallIn", 0));

            var instructionType = (from i in EF.DataContext.Current.InstructionSet
                                   where i.InstructionId == m_instructionId
                                   select i.InstructionType.InstructionTypeId).FirstOrDefault();

            if (instructionType == 2)
            {
                rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[1], "Refusal", 1));
                rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[2], "Shortage", 2));
            }

            rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[3], "tabReturns", 3));

            if (!((Entities.CustomPrincipal) this.Page.User).IsInRole(((int)eUserRole.SubConPortal).ToString()))
            {
                rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[4], "tabPCVS", 4));
                rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[5], "tabProgress", 5));
            }

            int selectedTabID = 0;

            int.TryParse(Request.QueryString["t"], out selectedTabID);
            if (selectedTabID > -1 && rtsCallIn.Tabs.FindTabByText(m_tabTexts[selectedTabID]) != null)
            {
                rtsCallIn.Tabs.FindTabByText(m_tabTexts[selectedTabID]).Selected = true;
            }
        }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                m_jobId = Convert.ToInt32(Request.QueryString["JobId"]);
            }
            catch {}

            if (!IsPostBack)
            {
                cboCallIns.Attributes.Add("onChange", "javascript:SelectCallIn()");

                if (m_jobId > 0)
                {
                    // Retrieve and populate the call in selector.
                    using (Facade.IInstruction facInstruction = new Facade.Instruction())
                    {
                        DataSet instructions = facInstruction.GetInstructionsForCallInSelection(m_jobId);
                        if (instructions.Tables[0].Rows.Count == 0)
                        {
                            cboCallIns.Visible = false;
                        }
                        else
                        {
                            DataView data = new DataView(instructions.Tables[0]);
                            if (m_hidePendingCallIns)
                            {
                                data.RowFilter = "InstructionActualId IS NOT NULL";
                            }

                            cboCallIns.DataValueField = "InstructionId";
                            cboCallIns.DataTextField  = "Description";
                            cboCallIns.DataSource     = data;
                            cboCallIns.DataBind();

                            cboCallIns.Items.Insert(0, new ListItem("-- Please select --", "0"));
                            if (cboCallIns.Items.Count == 1)
                            {
                                cboCallIns.Visible = false;
                            }
                        }
                    }
                }
                else
                {
                    cboCallIns.Visible = false;
                }
            }
        }
Ejemplo n.º 17
0
        private void btnCancelJob_Click(object sender, EventArgs e)
        {
            if (this.btnCancelJob.Text == "Close")
            {
                this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CloseWindow", "window.close();", true);
            }
            else
            if (Page.IsValid)
            {
                bool result = false;
                using (Facade.IJob facJob = new Facade.Job())
                {
                    Facade.IInstruction            facInstruction = new Facade.Instruction();
                    Entities.InstructionCollection insCol         = facInstruction.GetForJobId(m_jobId);

                    if (insCol.Count == 0 || insCol[0].InstructionActuals == null || insCol[0].InstructionActuals.Count == 0)
                    {
                        result =
                            facJob.UpdateState(m_jobId, eJobState.Cancelled,
                                               ((Entities.CustomPrincipal)Page.User).UserName);

                        if (result)
                        {
                            lblConfirmation.Text    = "The Job " + m_jobId + " has been cancelled successfully.";
                            lblConfirmation.Visible = true;
                            //LoadJob();
                            //PopulatePage();

                            this.ButtonBar.Visible          = false;
                            this.cancellationTable.Visible  = false;
                            this.jobDetailsFieldset.Visible = false;
                            this.btnCancelJob.Text          = "Close";
                            this.jobDetailsTD.Width         = "0%";
                            this.cancellationReasnTD.Width  = "100%";
                        }
                        else
                        {
                            lblConfirmation.Text    = "The job could not be cancelled.";
                            lblConfirmation.Visible = true;
                        }
                    }
                    else
                    {
                        lblConfirmation.Visible = true;
                        lblConfirmation.Text    = "This job can not be cancelled at this time as it has at least one call-in.";
                    }
                }
            }
        }
Ejemplo n.º 18
0
        private void LoadJob()
        {
            using (Facade.IJob facJob = new Facade.Job())
            {
                m_job = facJob.GetJob(m_jobId);

                if (m_job.JobState == eJobState.Cancelled)
                {
                    Response.Redirect("../../Job/job.aspx?wiz=true&jobId=" + m_job.JobId + "&csid=" + this.CookieSessionID);
                }

                Facade.IInstruction facInstruction = new Facade.Instruction();
                m_job.Instructions = facInstruction.GetForJobId(m_job.JobId);
            }

            ViewState[C_JOB_VS] = m_job;
        }
Ejemplo n.º 19
0
        private void GetJobAndInstructions()
        {
            // Get the job.
            using (Facade.IInstruction facInstruction = new Facade.Instruction())
            {
                _endInstruction = facInstruction.GetInstruction(_instructionId);

                // Try and get the job from the cache
                _job = (Entities.Job)Cache.Get("JobEntityForJobId" + _jobId.ToString());

                if (_job == null)
                {
                    Facade.IJob facJob = new Facade.Job();
                    _job = facJob.GetJob(_jobId);

                    // Job was not in the cache thus get the instruction collection from the db
                    _instructions = new Facade.Instruction().GetForJobId(_jobId);

                    // Get the previous instruction
                    _startInstruction = _instructions.GetPreviousInstruction(_instructionId);
                }
                else
                {
                    // Job is in the cache, check for instructions

                    if (_job.Instructions != null)
                    {
                        // We have instructions
                        _instructions = _job.Instructions;

                        // use the instruction collection from the cached job
                        _startInstruction = _instructions.GetPreviousInstruction(_instructionId);
                    }
                    else
                    {
                        // otherwise get a fresh instruction collection
                        _instructions = new Facade.Instruction().GetForJobId(_jobId);

                        // Get the previous instruction
                        _startInstruction = _instructions.GetPreviousInstruction(_instructionId);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        void btnConfirm_Click(object sender, EventArgs e)
        {
            Facade.IResource facResource = new Facade.Resource();
            int controlAreaId            = int.Parse(cboControlArea.SelectedValue);
            int trafficAreaId            = int.Parse(cboTrafficArea.SelectedValue);

            if (m_instructionId != 0)
            {
                Facade.IInstruction  facInstruction = new Facade.Instruction();
                Entities.Instruction instruction    = facInstruction.GetInstruction(m_instructionId);

                if (instruction.Driver != null)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, instruction.Driver.ResourceId, "Driver was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
                if (instruction.Vehicle != null)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, instruction.Vehicle.ResourceId, "Vehicle was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
                if (instruction.Trailer != null)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, instruction.Trailer.ResourceId, "Trailer was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
            }
            else
            {
                if (m_driverResourceId != 0)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, m_driverResourceId, "Driver was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
                if (m_vehicleResourceId != 0)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, m_vehicleResourceId, "Vehicle was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
                if (m_trailerResourceId != 0)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, m_trailerResourceId, "Trailer was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
            }

            mwhelper.CausePostBack = false;
            mwhelper.CloseForm     = true;
        }
        private void ConfigurePage()
        {
            int instructionId = Convert.ToInt32(Request.QueryString["instructionId"]);

            Entities.Instruction instruction = null;
            using (Facade.IInstruction facInstruction = new Facade.Instruction())
            {
                instruction = facInstruction.GetInstruction(instructionId);
            }

            // Display the resource information
            if (instruction.Driver != null)
            {
                tdDriver.InnerText = instruction.Driver.Individual.FullName;
            }
            if (instruction.Vehicle != null)
            {
                tdVehicle.InnerText = instruction.Vehicle.RegNo;
            }
            if (instruction.Trailer != null)
            {
                tdTrailer.InnerText = instruction.Trailer.TrailerRef;
            }

            // Display the point information
            XslCompiledTransform transformer = new XslCompiledTransform();

            transformer.Load(Server.MapPath(@"..\xsl\instructions.xsl"));

            XsltArgumentList args = new XsltArgumentList();

            args.AddParam("webserver", "", Orchestrator.Globals.Configuration.WebServer);
            args.AddParam("showShortAddress", "", "false");

            XmlUrlResolver resolver  = new XmlUrlResolver();
            XPathNavigator navigator = instruction.Point.ToXml().CreateNavigator();

            // Populate the Point.
            StringWriter sw = new StringWriter();

            transformer.Transform(navigator, args, sw);
            tdPoint.InnerHtml = sw.GetStringBuilder().ToString();
        }
Ejemplo n.º 22
0
        private Entities.FacadeResult CreateInstructionActual(Entities.InstructionActual instructionActual, string userId)
        {
            Entities.FacadeResult result = new Orchestrator.Entities.FacadeResult(false);

            Entities.PCV m_PCV = null;

            try
            {
                using (Facade.IInstructionActual facInstructionActual = new Facade.Instruction())
                {
                    DateTime startedAt = DateTime.UtcNow;
                    result = facInstructionActual.Create(m_job, instructionActual, m_PCV, userId);
                    DateTime endedAt = DateTime.UtcNow;
                    instructionActual.InstructionActualId = result.ObjectId;
                }
            }
            catch { }

            return(result);
        }
Ejemplo n.º 23
0
        private void GetJobAndInstructions()
        {
            // Get the job.
            using (Facade.IInstruction facInstruction = new Facade.Instruction())
            {
                // Try and get the job from the cache
                _job = (Entities.Job)Cache.Get("JobEntityForJobId" + _jobId.ToString());

                if (_job == null)
                {
                    Facade.IJob facJob = new Facade.Job();
                    _job = facJob.GetJob(_jobId);

                    // Job was not in the cache thus get the instruction collection from the db
                    _instructions = new Facade.Instruction().GetForJobId(_jobId);
                }
                else
                {
                    // Job is in the cache, check for instructions

                    if (_job.Instructions != null)
                    {
                        // We have instructions
                        _instructions = _job.Instructions;
                    }
                    else
                    {
                        // otherwise get a fresh instruction collection
                        _instructions = new Facade.Instruction().GetForJobId(_jobId);
                    }
                }

                // Get the end instruction
                _endInstruction = _instructions.Find(instruc => instruc.InstructionOrder == _instructions.Count - 1);

                if (_endInstruction == null)
                {
                    throw new ApplicationException("Cannot find last instruction.");
                }
            }
        }
Ejemplo n.º 24
0
        private void PopulateForm()
        {
            Facade.IInstruction facInstruction = new Facade.Instruction();
            m_instruction = facInstruction.GetInstruction(m_instructionID);

            bool canRemoveTrunkPoint = false;

            if (m_instruction != null)
            {
                if (m_instruction.InstructionTypeId == (int)eInstructionType.Trunk && (m_instruction.CollectDrops.Count == 0 || m_instruction.CollectDrops[0].OrderID == 0))
                {
                    canRemoveTrunkPoint = true; // This instruction is either a trunk or a trunk that has zero orders.
                }
                // Get the previous instruction.
                Entities.InstructionCollection instructions = facInstruction.GetForJobId(m_instruction.JobId);
                m_previousInstruction = instructions.GetPreviousInstruction(m_instruction.InstructionID);
            }

            pnlConfirmation.Visible      = canRemoveTrunkPoint;
            pnlCannotRemoveTrunk.Visible = !canRemoveTrunkPoint;
            btnRemoveTrunk.Visible       = canRemoveTrunkPoint;
        }
Ejemplo n.º 25
0
        private void GetDocketNumbers(int instructionId)
        {
            using (Facade.IInstruction facInstruction = new Facade.Instruction())
            {
                Entities.Instruction selected = facInstruction.GetInstruction(instructionId);

                string docketCollection = string.Empty;

                if (selected != null)
                {
                    foreach (Entities.CollectDrop cd in selected.CollectDrops)
                    {
                        if (docketCollection.Length > 0)
                        {
                            docketCollection += "/";
                        }
                        docketCollection += cd.Docket;
                    }
                }

                txtRef.Text = docketCollection;
            }
        }
Ejemplo n.º 26
0
        private bool AddGoodsRefused()
        {
            Facade.IGoodsRefusal facGoods = new Facade.GoodsRefusal();
            bool   retVal   = false;
            string userName = ((Entities.CustomPrincipal)Page.User).UserName;

            eJobType jobType = eJobType.Normal;

            using (Facade.IInstruction facInstruction = new Facade.Instruction())
            {
                Entities.Instruction instruction = facInstruction.GetInstruction(_instructionId);

                using (Facade.IJob facJob = new Facade.Job())
                {
                    Entities.Job job = facJob.GetJob(instruction.JobId);
                    jobType = job.JobType;
                }
            }

            retVal = facGoods.Create(_goodsRefused, jobType, _instructionId, userName);

            if (!retVal)
            {
                lblConfirmation.Text      = "There was an error adding the Goods Refused, please try again.";
                lblConfirmation.Visible   = true;
                lblConfirmation.ForeColor = Color.Red;
                retVal = false;
            }
            else
            {
                btnAdd.Text      = "Update Goods Refused";
                this.ReturnValue = "Refresh_Redeliveries_And_Refusals";
                this.Close();
            }

            return(retVal);
        }
Ejemplo n.º 27
0
        private void btnBack_Click(object sender, EventArgs e)
        {
            if (m_isUpdate)
            {
                // Reload the job.

                Facade.IJob facJob = new Facade.Job();
                m_job = facJob.GetJob(m_jobId);

                Facade.IInstruction facInstruction = new Facade.Instruction();

                if (m_job.JobType == eJobType.Normal)
                {
                    m_job.Charge       = ((Facade.IJobCharge)facJob).GetForJobId(m_jobId);
                    m_job.Instructions = facInstruction.GetForJobId(m_job.JobId);
                    m_job.References   = ((Facade.IJobReference)facJob).GetJobReferences(m_jobId);

                    Session[wizard.C_JOB] = m_job;
                }
                else
                {
                    switch (m_job.JobType)
                    {
                    case eJobType.PalletReturn:
                        GoToStep("PR");
                        break;

                    case eJobType.Return:
                        GoToStep("GR");
                        break;
                    }
                }
            }

            GoToStep("JD");
        }
Ejemplo n.º 28
0
        void btnAddSelectedJob_Click(object sender, EventArgs e)
        {
            Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest();

            int highestJobOrder = 0;

            // Find the highest job order and simply add it to the end
            foreach (Entities.ResourceManifestJob rmj in this.SavedResourceManifest.ResourceManifestJobs)
            {
                if (rmj.JobOrder > highestJobOrder)
                {
                    highestJobOrder = rmj.JobOrder;
                }
            }

            foreach (GridItem row in grdResourceManifestAddJobs.Items)
            {
                if (row.ItemType == GridItemType.AlternatingItem || row.ItemType == GridItemType.Item)
                {
                    HtmlInputHidden hidJobId          = row.FindControl("hidJobId") as HtmlInputHidden;
                    HtmlInputHidden hidJobOrder       = row.FindControl("hidJobOrder") as HtmlInputHidden;
                    CheckBox        chkDriverManifest = row.FindControl("chkDriverManifest") as CheckBox;
                    if (chkDriverManifest.Checked)
                    {
                        int jobId = int.Parse(hidJobId.Value);

                        // Double check to make sure the rmj isn't already on the manifest.
                        Entities.ResourceManifestJob rmj = this.SavedResourceManifest.ResourceManifestJobs.Find(o => o.JobId == Convert.ToInt32(hidJobId.Value));
                        if (rmj != null)
                        {
                            // The rmj is already on the manifest, simply change its removed flag
                            if (rmj.Removed == true)
                            {
                                rmj.Removed = false;
                            }
                        }
                        else
                        {
                            //Get Instructions Resourced
                            Facade.Instruction facInstruction = new Facade.Instruction();
                            List <int>         instructionIDs = facInstruction.GetInstructionIDsForDriverResource(jobId, this.SavedResourceManifest.ResourceId, true);

                            foreach (int instructionID in instructionIDs)
                            {
                                // create a new rmj to add to the manifest
                                Entities.ResourceManifestJob newRmj = new Orchestrator.Entities.ResourceManifestJob();
                                newRmj.JobOrder           = ++highestJobOrder;
                                newRmj.ResourceManifestId = this.SavedResourceManifest.ResourceManifestId;
                                newRmj.JobId         = Convert.ToInt32(hidJobId.Value);
                                newRmj.InstructionId = instructionID;
                                this.SavedResourceManifest.ResourceManifestJobs.Add(newRmj);
                            }
                        }
                    }
                }
            }

            facResourceManifest.UpdateResourceManifest(this.SavedResourceManifest, this.Page.User.Identity.Name);
            this.SavedResourceManifest = facResourceManifest.GetResourceManifest(this.ResourceManifestId);

            grdResourceManifestJobs.Rebind();

            // Clear the add jobs grid.
            grdResourceManifestAddJobs.DataSource = null;
            grdResourceManifestAddJobs.DataBind();
            pnlAddJobs.Visible          = false;
            pnlExistingManifest.Visible = true;
        }
Ejemplo n.º 29
0
        private Entities.InstructionActual PopulateInstructionActual()
        {
            Facade.IInstruction        facInstruction    = new Facade.Instruction();
            Entities.InstructionActual instructionActual = ((Facade.IInstructionActual)facInstruction).GetEntityForInstructionId(m_instructionId);
            if (instructionActual == null)
            {
                instructionActual = new Entities.InstructionActual();
                instructionActual.InstructionId      = m_instructionId;
                instructionActual.CollectDropActuals = new Entities.CollectDropActualCollection();
            }
            Entities.Instruction i = facInstruction.GetInstruction(m_instructionId);

            // Populate the main data about a call-in.
            instructionActual.Discrepancies = "";
            instructionActual.DriversNotes  = "";

            instructionActual.ArrivalDateTime     = i.BookedDateTime;
            instructionActual.CollectDropDateTime = i.BookedDateTime;
            instructionActual.LeaveDateTime       = i.BookedDateTime;

            // Populate the collect drop information.
            eInstructionType instructionType = (eInstructionType)i.InstructionTypeId;

            #region Instruction Type Specific Loadings

            switch (instructionType)
            {
            case eInstructionType.Load:
                // The collect drop dockets are specified by the drop recording process - we just need to create dummy actuals (we only do this for the initial create).
                if (instructionActual.InstructionActualId == 0)
                {
                    Entities.Instruction instruction = facInstruction.GetInstruction(m_instructionId);

                    foreach (Entities.CollectDrop loadDocket in instruction.CollectDrops)
                    {
                        Entities.CollectDropActual loadDocketDummyActual = new Entities.CollectDropActual();

                        loadDocketDummyActual.CollectDropId   = loadDocket.CollectDropId;
                        loadDocketDummyActual.NumberOfCases   = 0;
                        loadDocketDummyActual.NumberOfPallets = 0;
                        loadDocketDummyActual.Weight          = 0;

                        instructionActual.CollectDropActuals.Add(loadDocketDummyActual);
                    }
                }
                break;

            case eInstructionType.Trunk:
                // The collect drop dockets are specified by the drop recording process - we just need to create dummy actuals (we only do this for the initial create).
                if (instructionActual.InstructionActualId == 0)
                {
                    Entities.Instruction instruction = i;

                    foreach (Entities.CollectDrop loadDocket in instruction.CollectDrops)
                    {
                        Entities.CollectDropActual loadDocketDummyActual = new Entities.CollectDropActual();

                        loadDocketDummyActual.CollectDropId   = loadDocket.CollectDropId;
                        loadDocketDummyActual.NumberOfCases   = 0;
                        loadDocketDummyActual.NumberOfPallets = 0;
                        loadDocketDummyActual.Weight          = 0;

                        instructionActual.CollectDropActuals.Add(loadDocketDummyActual);
                    }
                }
                break;

            case eInstructionType.Drop:
                if (m_job.JobType == eJobType.Normal || m_job.JobType == eJobType.Groupage)
                {
                    //create a collectdropactual for each collectdrop
                    Entities.CollectDropActual cda = new Orchestrator.Entities.CollectDropActual();
                    foreach (Entities.CollectDrop cd in i.CollectDrops)
                    {
                        cda = new Orchestrator.Entities.CollectDropActual();
                        cda.NumberOfCases           = cd.NoCases;
                        cda.NumberOfPallets         = cd.NoPallets;
                        cda.NumberOfPalletsReturned = cd.NoPallets;
                        cda.CollectDropId           = cd.CollectDropId;
                        cda.Weight = cd.Weight;
                    }
                    instructionActual.CollectDropActuals.Add(cda);
                }
                break;
            }

            #endregion

            return(instructionActual);
        }
Ejemplo n.º 30
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            int pointId       = Convert.ToInt32(Request.QueryString["pointId"]);
            int instructionId = Convert.ToInt32(Request.QueryString["iID"]);

            Entities.Instruction instruction = null;
            Entities.Point       point       = null;

            if (instructionId > 0)
            {
                string cacheName = "_pointAddressWithNotes" + instructionId.ToString();

                if (Cache[cacheName] == null)
                {
                    Facade.IInstruction facInstruction = new Facade.Instruction();
                    instruction = facInstruction.GetInstruction(instructionId);

                    if (instruction != null)
                    {
                        Cache.Add(cacheName, instruction, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), System.Web.Caching.CacheItemPriority.Normal, null);
                    }
                }
                else
                {
                    instruction = (Entities.Instruction)Cache[cacheName];
                }

                if (instruction != null)
                {
                    point = instruction.Point;
                }
            }

            if (pointId > 0)
            {
                string cacheName = "_pointAddress" + pointId.ToString();
                if (Cache[cacheName] == null)
                {
                    Facade.IPoint facPoint = new Facade.Point();
                    point = facPoint.GetPointForPointId(pointId);
                    if (point != null)
                    {
                        Cache.Add(cacheName, point, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), System.Web.Caching.CacheItemPriority.Normal, null);
                    }
                }
                else
                {
                    point = (Entities.Point)Cache["_pointAddress" + pointId.ToString()];
                }
            }

            if (point != null)
            {
                // A leg has been selected for viewing so display it.
                XslCompiledTransform transformer = new XslCompiledTransform();
                transformer.Load(Server.MapPath(@"..\xsl\instructions.xsl"));

                XmlUrlResolver resolver  = new XmlUrlResolver();
                XPathNavigator navigator = point.ToXml().CreateNavigator();

                // Populate the Point.
                StringWriter sw = new StringWriter();
                transformer.Transform(navigator, null, sw);
                Response.Write(sw.GetStringBuilder().ToString());

                // If instruction notes are present, attach them to the response.
                if (instruction != null && instruction.Note.Length > 0)
                {
                    Response.Write("<br>" + instruction.Note);
                }

                Response.Write(string.Format("<br>tel: {0}", point.PhoneNumber));

                if (point.PointNotes != string.Empty)
                {
                    Response.Write("<br>" + point.PointNotes.Replace("\r\n", "</br>"));
                }

                if (Response.IsClientConnected)
                {
                    Response.Flush();
                    Response.End();
                }

                return;
            }
        }