예제 #1
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;
                }
            }
        }
예제 #2
0
        private void TrunkLeg()
        {
            Entities.CustomPrincipal user   = (Entities.CustomPrincipal)Page.User;
            Entities.FacadeResult    result = null;

            int pointId = ucPoint.PointID;// int.Parse(cboPoint.SelectedValue);

            if (!IsUpdate)
            {
                #region Create New Trunk
                Entities.Instruction instruction = null;
                using (Facade.IInstruction facInstruction = new Facade.Instruction())
                {
                    instruction = facInstruction.GetInstruction(m_instructionId);
                }

                // We've trunked the leg.
                DateTime arriveAtTrunkPoint;
                DateTime leaveTrunkPoint;

                // Get the arrival time.
                //arriveAtTrunkPoint = timeStartDate.xDateTime;
                arriveAtTrunkPoint = new DateTime(rdiStartDate.SelectedDate.Value.Year, rdiStartDate.SelectedDate.Value.Month, rdiStartDate.SelectedDate.Value.Day, rdiStartTime.SelectedDate.Value.Hour, rdiStartTime.SelectedDate.Value.Minute, 0);

                // Get the departure time.
                //leaveTrunkPoint = timeEndDate.xDateTime;
                leaveTrunkPoint = new DateTime(rdiEndDate.SelectedDate.Value.Year, rdiEndDate.SelectedDate.Value.Month, rdiEndDate.SelectedDate.Value.Day, rdiEndTime.SelectedDate.Value.Hour, rdiEndTime.SelectedDate.Value.Minute, 0);

                DateTime lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]);

                // Create the new trunk instruction
                Entities.Instruction trunkInstruction = new Orchestrator.Entities.Instruction();
                trunkInstruction.InstructionTypeId        = (int)eInstructionType.Trunk;
                trunkInstruction.JobId                    = instruction.JobId;
                trunkInstruction.PointID                  = pointId;
                trunkInstruction.PlannedDepartureDateTime = leaveTrunkPoint;
                trunkInstruction.PlannedArrivalDateTime   = arriveAtTrunkPoint;
                trunkInstruction.Trailer                  = instruction.Trailer;

                // Set the booked datetime of the trunk to the trunks planned arrival time. This could produce a situation
                // where the booked times do not flow, however, the trunks booked time is irrelevant so if this happens, it shouldn't matter.
                // Failing to set a booked time for the trunk here would cause an error when attempting to save the instruction.
                trunkInstruction.BookedDateTime = arriveAtTrunkPoint;

                // Note: Always get the driver and the vehicle.
                trunkInstruction.Driver  = instruction.Driver;
                trunkInstruction.Vehicle = instruction.Vehicle;

                // Add the trunk to the job.
                using (Facade.IJob facJob = new Facade.Job())
                {
                    Entities.Job job = facJob.GetJob(instruction.JobId);
                    result = facJob.Trunk(trunkInstruction, instruction, job.IdentityId, user.UserName, job.LastUpdateDate, chkDriver.Checked, chkVehicle.Checked);
                }

                #endregion
            }
            else
            {
                using (Facade.IInstruction facInstruction = new Facade.Instruction())
                {
                    facInstruction.UpdatePointID(m_instructionId, pointId, user.UserName);
                    result = new Orchestrator.Entities.FacadeResult(true);
                }
            }

            if (result.Success)
            {
                this.ReturnValue = "refresh";
                this.Close();
            }
            else
            {
                infringementDisplay.Infringements = result.Infringements;
                infringementDisplay.DisplayInfringments();
            }
        }