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; } }
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(); } }
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."; } } } }
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); } } } }
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."); } } }
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; }
private string BuildLoadComments(int driverId, Entities.InstructionCollection instructionCollection) { StringBuilder loadComments = new StringBuilder(); ArrayList collectedDockets = new ArrayList(); // Build the list of dockets being collected. foreach (Entities.Instruction instruction in instructionCollection) { if (instruction.InstructionTypeId == (int)eInstructionType.Load) { foreach (Entities.CollectDrop collection in instruction.CollectDrops) { collectedDockets.Add(collection.Docket); } } } Entities.Instruction instruc = null; // Display the dockets in the reverse order they are being delivered. for (int instructionIndex = instructionCollection.Count - 1; instructionIndex >= 0; instructionIndex--) { instruc = instructionCollection[instructionIndex]; if (instruc.InstructionTypeId == (int)eInstructionType.Drop) { foreach (Entities.CollectDrop delivery in instruc.CollectDrops) { if (collectedDockets.Contains(delivery.Docket)) { loadComments.Append(string.Format("{0} ({1})", delivery.Docket, instruc.Point.PostTown.TownName)); loadComments.Append("<br>"); } } } } return(loadComments.ToString()); }
void btnConfirm_Click(object sender, EventArgs e) { if (Page.IsValid) { Facade.IJob facJob = new Facade.Job(); Entities.InstructionCollection instructionCollection = PopulateInstructions(); DateTime lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]); Entities.FacadeResult result = facJob.UpdatePlannedTimes(this.JobID, instructionCollection, lastUpdateDate, ((Entities.CustomPrincipal)Page.User).Name); if (result.Success) { // Successful update return and refresh the grid. this.ReturnValue = "refresh"; this.Close(); } else { // Display infringements to user. infrigementDisplay.Infringements = result.Infringements; infrigementDisplay.DisplayInfringments(); } } }
private void PopulateDockets() { cboDockets.Items.Clear(); Facade.IReferenceData facReferenceData = new Facade.ReferenceData(); string docketNumberText = facReferenceData.GetDocketNumberTextForIdentityId(m_job.IdentityId); if (docketNumberText != String.Empty) { cboDockets.Items.Add(new ListItem("-- Please select a " + docketNumberText + " --")); } else { cboDockets.Items.Add(new ListItem("-- Please select a Docket Number --")); } if (m_isUpdate) { #region Display the dockets that have not been been assigned to a drop foreach (Entities.Instruction instruction in m_job.Instructions) { if (instruction.InstructionTypeId == (int)eInstructionType.Load) { foreach (Entities.CollectDrop collectDrop in instruction.CollectDrops) { bool collectDropHasBeenDropped = false; foreach (Entities.Instruction dropInstruction in m_job.Instructions) { if (dropInstruction.InstructionTypeId == (int)eInstructionType.Drop) { foreach (Entities.CollectDrop dropCollectDrop in dropInstruction.CollectDrops) { if (dropCollectDrop.Docket == collectDrop.Docket) { collectDropHasBeenDropped = true; } } } } if (m_instruction.InstructionTypeId == (int)eInstructionType.Drop) { foreach (Entities.CollectDrop dropCollectDrop in m_instruction.CollectDrops) { if (dropCollectDrop.Docket == collectDrop.Docket) { collectDropHasBeenDropped = true; } } } if (!collectDropHasBeenDropped) { cboDockets.Items.Add(DocketItem(collectDrop)); } } } } #endregion if (m_isAmendment) { cboDockets.ClearSelection(); cboDockets.Items.Insert(1, DocketItem(m_collectdrop)); cboDockets.Items[1].Selected = true; } } else { #region Display a list of dockets that have not been assigned to a drop // Check both within the m_job.Instructions collection, but also the new collection being built-up. Entities.InstructionCollection insCollection = new Entities.InstructionCollection(); foreach (Entities.Instruction instruction in m_job.Instructions) { insCollection.Add(instruction); } insCollection.Add(m_instruction); foreach (Entities.Instruction instruction in insCollection) { if (instruction.InstructionTypeId == (int)eInstructionType.Load) { foreach (Entities.CollectDrop collectDrop in instruction.CollectDrops) { bool collectDropHasBeenDropped = false; foreach (Entities.Instruction dropInstruction in insCollection) { if (dropInstruction.InstructionTypeId == (int)eInstructionType.Drop) { foreach (Entities.CollectDrop dropCollectDrop in dropInstruction.CollectDrops) { if (collectDrop.Docket == dropCollectDrop.Docket) { collectDropHasBeenDropped = true; } } } } if (!collectDropHasBeenDropped) { cboDockets.Items.Add(DocketItem(collectDrop)); } } } } #endregion if (m_isAmendment) { cboDockets.ClearSelection(); // Add and select the docket cboDockets.Items.Insert(1, DocketItem(m_collectdrop)); cboDockets.Items[1].Selected = true; } } if (m_instruction.InstructionTypeId == (int)eInstructionType.Drop && cboDockets.Items.Count == 2) { chkAddAnotherDocket.Enabled = false; } }
void btnConfirmSubContract_Click(object sender, EventArgs e) { if (Page.IsValid && ValidateSubContractLeg()) { // Check whether the user is trying to subcontract instructions that have resources assigned. // Only applies to driver and vehicle resources. Entities.InstructionCollection instructions = Job.Instructions; // Extract the collections. Entities.Instruction selected = instructions.Find( delegate(Entities.Instruction instruction) { return(instruction.InstructionOrder == 0); }); // No resources exist for selected instructions, so continue with save oepration. SubContractingMethod method = (SubContractingMethod)int.Parse(rdoSubContractMethod.SelectedValue); string userID = ((Entities.CustomPrincipal)Page.User).UserName; Entities.JobSubContractor jobSubContractor = GetJobSubContract(selected); DateTime lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]); // Set the job to be sub-contracted Entities.FacadeResult result = null; switch (method) { case SubContractingMethod.WholeJob: //add something that finds if any of the other legs have been subbed out already. result = SubContractWholeJob(jobSubContractor, lastUpdateDate, userID); break; case SubContractingMethod.SpecificLegs: result = SubContractSpecificLegs(jobSubContractor, lastUpdateDate, userID); break; case SubContractingMethod.PerOrder: result = SubContractPerOrder(jobSubContractor, lastUpdateDate, userID); break; } if (Globals.Configuration.SubContractorCommunicationsRequired && chkShowAsCommunicated.Checked) { CommunicateInstructionsForSubContractor(Job.JobId, jobSubContractor.ContractorIdentityId, userID); } if (result.Success) { Cache.Remove("JobEntityForJobId" + m_jobId.ToString()); //InjectScript.Text = "<script>RefreshParentPage();</script>"; this.ReturnValue = "refresh"; this.Close(); } else { infrigementDisplay.Infringements = result.Infringements; infrigementDisplay.DisplayInfringments(); infrigementDisplay.Visible = true; pnlConfirmation.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { int instructionId = Convert.ToInt32(Request.QueryString["iID"]); if (!Page.IsPostBack) { using (Facade.Instruction facInstruction = new Facade.Instruction()) { Entities.Instruction affectedInstruction = null; Entities.Job job = null; int jobId = 0; Entities.InstructionCollection instructions = null; if (int.TryParse(Request.QueryString["jobId"], out jobId)) { if (instructionId != 0) { affectedInstruction = facInstruction.GetInstruction(instructionId); // Get the job. job = (Entities.Job)Cache.Get("JobEntityForJobId" + jobId.ToString()); // Try and get the job from the cache if (job == null) { Facade.IJob facJob = new Facade.Job(); job = facJob.GetJob(jobId); } } else { // We have no instruction id - this means that ascx is being used for adding // multiple destinations. We should use the last instruction on the job. // Get the job. job = (Entities.Job)Cache.Get("JobEntityForJobId" + jobId.ToString()); // Try and get the job from the cache 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 end instruction Entities.Instruction endInstruction = null; endInstruction = instructions.Find(instruc => instruc.InstructionOrder == instructions.Count - 1); if (endInstruction == null) { throw new ApplicationException("Cannot find last instruction."); } affectedInstruction = endInstruction; } 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 Entities.Instruction endInstruction = null; endInstruction = instructions.Find(instruc => instruc.InstructionOrder == instructions.Count - 1); if (endInstruction == null) { throw new ApplicationException("Cannot find last instruction."); } affectedInstruction = endInstruction; } } } if (job.JobState != eJobState.Invoiced && job.JobState != eJobState.Cancelled) { if (affectedInstruction.Driver != null) { chkDriver.Text = affectedInstruction.Driver.Individual.FullName; } else { chkDriver.Enabled = false; } if (affectedInstruction.Vehicle != null) { chkVehicle.Text = affectedInstruction.Vehicle.RegNo; } else { chkVehicle.Enabled = false; } } } } }
void dgJobs_ItemCommand(object sender, ComponentArt.Web.UI.GridItemCommandEventArgs e) { Facade.Job facJob = new Orchestrator.Facade.Job(); string userId = ((Entities.CustomPrincipal)Page.User).UserName; int jobId; bool success = false; switch (((Button)e.Control).CommandName.ToLower()) { case "reinstate": jobId = Convert.ToInt32(e.Item["JobId"]); success = facJob.UpdateForCancellation(jobId, false, "", userId); if (success == true) { pnlConfirmation.Visible = true; imgIcon.ImageUrl = "~/images/ico_info.gif"; lblNote.Text = "The Job " + jobId + " has been reinstated successfully."; } else { pnlConfirmation.Visible = true; imgIcon.ImageUrl = "~/images/ico_critical.gif"; lblNote.Text = "The application failed while reinstating the job, please try again."; } break; case "cancel": jobId = Convert.ToInt32(e.Item["JobId"]); Facade.IInstruction facInstruction = new Facade.Instruction(); Entities.InstructionCollection insCol = facInstruction.GetForJobId(jobId); if (insCol.Count == 0 || insCol[0].InstructionActuals == null || insCol[0].InstructionActuals.Count == 0) { success = facJob.UpdateState(jobId, eJobState.Cancelled, ((Entities.CustomPrincipal)Page.User).UserName); if (success) { pnlConfirmation.Visible = true; imgIcon.ImageUrl = "../images/ico_info.gif"; lblNote.Text = "The Job " + jobId + " has been cancelled successfully."; } else { pnlConfirmation.Visible = true; imgIcon.ImageUrl = "../images/ico_critical.gif"; lblNote.Text = "The application failed while cancelling the job, please try again."; } } else { pnlConfirmation.Visible = true; imgIcon.ImageUrl = "../images/ico_critical.gif"; lblNote.Text = "This job can not be cancelled at this time as it has at least one call-in."; } break; } ApplyFilter(); }