private void UpdateBusinessType() { // Populate the BusinessType PopulateBusinessType(); Facade.IBusinessType facBusinessType = new Facade.BusinessType(); Entities.FacadeResult retVal = new Orchestrator.Entities.FacadeResult(); bool AllowNominalCodeReUseForBusinessTypes = Orchestrator.Globals.Configuration.AllowNominalCodeReUseForBusinessTypes; if (this.BusinessTypeID > 0) { retVal = facBusinessType.Update(this.businessType, this.Page.User.Identity.Name, AllowNominalCodeReUseForBusinessTypes); } else { retVal = facBusinessType.Create(this.businessType, this.Page.User.Identity.Name, AllowNominalCodeReUseForBusinessTypes); } if (retVal.Success) { Response.Redirect("businesstypes.aspx"); } else { ucInfringements.Infringements = retVal.Infringements; ucInfringements.DisplayInfringments(); } }
Entities.FacadeResult GenerateValidationError(Dictionary <string, string> infringements) { Entities.FacadeResult result = new Orchestrator.Entities.FacadeResult(false); result.Infringements = new Entities.BusinessRuleInfringementCollection(); foreach (string key in infringements.Keys) { Entities.BusinessRuleInfringement infringement = new Orchestrator.Entities.BusinessRuleInfringement(key, infringements[key]); result.Infringements.Add(infringement); } return(result); }
void btnOK_Click(object sender, EventArgs e) { try { Orchestrator.Facade.INominalCode facNominalCode = new Orchestrator.Facade.NominalCode(); Orchestrator.Entities.FacadeResult facResult = null; int jobTypeID = 0; if (cboJobType.SelectedValue != "0") { jobTypeID = (int)Enum.Parse(typeof(eJobType), cboJobType.SelectedValue); } if (this.Code != null) // Update { facResult = facNominalCode.Update(this.Code.NominalCodeID, jobTypeID, txtNominalCode.Text, txtDescription.Text, this.Page.User.Identity.Name, chkIsActive.Checked); } else { facResult = facNominalCode.Create(jobTypeID, txtNominalCode.Text, txtDescription.Text, this.Page.User.Identity.Name, chkIsActive.Checked); } if (!facResult.Success) { string error = string.Empty; foreach (Orchestrator.Entities.BusinessRuleInfringement bri in facResult.Infringements) { error += "• " + bri.Description + "<br/>"; } lblError.Text = error; lblError.Visible = true; return; } if (facResult.Success) { InjectScript.Text = @"<script>RefreshParentPage()</script>"; } } catch { lblError.Text = "There was an error adding this Nominal Code."; lblError.Visible = true; } }
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); }
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(); } }
void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { Entities.FacadeResult success = new Orchestrator.Entities.FacadeResult(false); if (rdOrderAction_NotCollected.Checked) { #region Get Page details int rReasonId = 0; int.TryParse(cboRedeliveryReason.SelectedValue, out rReasonId); int nCPointId = 0, nDPointId = 0, dayDifference = 0; bool nCIsAnytime = false, nDIsAnyTime = false; DateTime nCDateTime = new DateTime(), nCByDateTime = new DateTime(), nDDateTime = new DateTime(), nDFromDateTime = new DateTime(), dateDiff = new DateTime(); nCDateTime = dteCollectionFromDate.SelectedDate.Value; nCDateTime = nCDateTime.Add(new TimeSpan(dteCollectionFromTime.SelectedDate.Value.Hour, dteCollectionFromTime.SelectedDate.Value.Minute, 0)); nCByDateTime = nCDateTime; if (rdCollectionBookingWindow.Checked) { nCByDateTime = dteCollectionByDate.SelectedDate.Value; nCByDateTime = nCByDateTime.Add(new TimeSpan(dteCollectionByTime.SelectedDate.Value.Hour, dteCollectionByTime.SelectedDate.Value.Minute, 0)); } nCIsAnytime = rdCollectionIsAnytime.Checked; if (chkChangeDeliveryDate.Checked) { nDFromDateTime = dteDeliveryFromDate.SelectedDate.Value; nDFromDateTime = nDFromDateTime.Add(new TimeSpan(dteDeliveryFromTime.SelectedDate.Value.Hour, dteDeliveryFromTime.SelectedDate.Value.Minute, 0)); nDDateTime = nDFromDateTime; if (rdDeliveryBookingWindow.Checked) { nDDateTime = dteDeliveryByDate.SelectedDate.Value; nDDateTime = nDDateTime.Add(new TimeSpan(dteDeliveryByTime.SelectedDate.Value.Hour, dteDeliveryByTime.SelectedDate.Value.Minute, 0)); } nDIsAnyTime = rdDeliveryIsAnytime.Checked; } if (chkCollectGoodsElsewhere.Checked && ucNewCollectionPoint.SelectedPoint != null) { nCPointId = ucNewCollectionPoint.SelectedPoint.PointId; } if (chkDeliverGoodsElsewhere.Checked && ucNewDeliveryPoint.SelectedPoint != null) { nDPointId = ucNewDeliveryPoint.SelectedPoint.PointId; } Entities.Extra extra = null; // If Updates processed sucessfully, log the extra against the highest value order. if (chkCharging.Checked) { // Build an extra to cover the redelivery. extra = new Entities.Extra(); extra.ExtraType = (eExtraType)int.Parse(cboExtraType.SelectedValue); extra.ForeignAmount = (decimal)txtExtraAmount.Value; extra.ExtraState = Utilities.SelectedEnumValue <eExtraState>(cboExtraState.SelectedValue);; extra.CustomDescription = txtExtraCustomReason.Text; if (!string.IsNullOrEmpty(txtClientContact.Text)) { extra.ClientContact = txtClientContact.Text; } } #endregion Facade.IAttemptedCollection facAC = new Facade.AttemptedCollection(); success = facAC.Create(JobId, InstructionId, rdResolutionMethod_AttemptLater.Checked, rReasonId, txtAttemptedCollectionReference.Text, txtAttemptedClientContact.Text, nCDateTime, nCByDateTime, nCIsAnytime, nCPointId, chkChangeDeliveryDate.Checked, nDFromDateTime, nDDateTime, nDIsAnyTime, nDPointId, chkCreateOnwardRun.Checked, extra, Page.User.Identity.Name); } #region Display Results if (success != null && success.Success) { if (success.ObjectId > 0) { Facade.IJob facJob = new Facade.Job(); Entities.Job eJob = facJob.GetJob(JobId); // If the existing run has been cancelled, then re-direct to the new run. if (eJob == null) { JobId = success.ObjectId; InstructionId = -1; } else { dlgOrder.Open(string.Format("jobId={0}", success.ObjectId)); } } btnCancel_Click(null, null); } else { if (success != null) { idErrors.Infringements = success.Infringements; } idErrors.DisplayInfringments(); idErrors.Visible = true; } #endregion } }
public bool ImportCustomers(DataSet ds) { DataTable dt = ds.Tables[0]; Orchestrator.Entities.Organisation organisation; Orchestrator.Entities.OrganisationLocation ol; Orchestrator.Entities.Individual i; Orchestrator.Entities.Point point; Orchestrator.Entities.Address address; Orchestrator.Facade.Organisation facOrganisation = new Orchestrator.Facade.Organisation(); foreach (DataRow row in dt.Rows) { organisation = new Orchestrator.Entities.Organisation(); organisation.OrganisationName = row["NAME"].ToString(); organisation.OrganisationDisplayName = row["NAME"].ToString(); organisation.OrganisationType = Orchestrator.eOrganisationType.Client; organisation.AccountCode = row["ACCOUNT_REF"].ToString(); address = new Orchestrator.Entities.Address(); address.AddressType = Orchestrator.eAddressType.Correspondence; address.AddressLine1 = row["ADDRESS_1"].ToString(); address.AddressLine2 = row["ADDRESS_2"].ToString(); address.PostTown = row["ADDRESS_3"].ToString(); address.County = row["ADDRESS_4"].ToString(); address.PostCode = row["ADDRESS_5"].ToString(); address.TrafficArea = new Orchestrator.Entities.TrafficArea(); address.TrafficArea.TrafficAreaId = 0; //Resolve The post Town if possible. string defaultPostTown = "Glasgow"; int defaultPostTownId = 9063; string postTown = (row["ADDRESS_4"].ToString() == "" ? null : row["ADDRESS_4"].ToString()) ?? (row["ADDRESS_3"].ToString() == "" ? null : row["ADDRESS_3"].ToString()) ?? (row["ADDRESS_2"].ToString() == "" ? null : row["ADDRESS_2"].ToString()) ?? defaultPostTown; if (address.PostTown == string.Empty) { address.PostTown = postTown; } int?postTownID = null; Orchestrator.Facade.ReferenceData facRef = new Orchestrator.Facade.ReferenceData(); DataSet dsTown = facRef.GetTownForTownName(postTown); if (dsTown.Tables[0].Rows.Count > 0) { postTownID = int.Parse(dsTown.Tables[0].Rows[0]["TownId"].ToString()); } ol = new Orchestrator.Entities.OrganisationLocation(); ol.OrganisationLocationName = "Head Office"; ol.OrganisationLocationType = Orchestrator.eOrganisationLocationType.HeadOffice; point = new Orchestrator.Entities.Point(); point.Description = "Head Office"; point.Collect = false; point.Deliver = false; point.Address = address; point.PostTown = new Orchestrator.Entities.PostTown(); point.PostTown.TownName = postTown; point.PostTown.TownId = postTownID ?? defaultPostTownId; ol.Point = point; if (organisation.Locations == null) { organisation.Locations = new Orchestrator.Entities.OrganisationLocationCollection(); } organisation.Locations.Add(ol); i = new Orchestrator.Entities.Individual(); i.Contacts = new Orchestrator.Entities.ContactCollection(); i.IndividualType = Orchestrator.eIndividualType.Contact; i.Title = Orchestrator.eTitle.Mr; if (row["CONTACT_NAME"] != string.Empty) { if (row["CONTACT_NAME"].ToString().IndexOf(' ') > 0) { i.FirstNames = row["CONTACT_NAME"].ToString().Split(' ')[0]; i.LastName = row["CONTACT_NAME"].ToString().Split(' ')[1]; } else { i.FirstNames = row["CONTACT_NAME"].ToString(); i.LastName = string.Empty; } } if (row["TELEPHONE"].ToString() != string.Empty) { i.Contacts.Add(new Orchestrator.Entities.Contact(Orchestrator.eContactType.Telephone, row["TELEPHONE"].ToString())); ol.TelephoneNumber = row["TELEPHONE"].ToString(); } if (row["FAX"].ToString() != string.Empty) { i.Contacts.Add(new Orchestrator.Entities.Contact(Orchestrator.eContactType.Fax, row["FAX"].ToString())); ol.FaxNumber = row["FAX"].ToString(); } if (row["E_MAIL"].ToString() != string.Empty) { i.Contacts.Add(new Orchestrator.Entities.Contact(Orchestrator.eContactType.Email, row["E_MAIL"].ToString())); } if (row["CONTACT_NAME"] != string.Empty) { organisation.IndividualContacts.Add(i); } Orchestrator.Entities.FacadeResult ret = facOrganisation.Create(organisation, "Orchestrator_Import"); if (!ret.Success) { return(false); } } return(true); }