//--------------------------------------------------------------------------------------- protected void btnRefresh_Click(object sender, EventArgs e) { int resourceId = 0; bool driverOrVehicle = false; if (this.VehiclesRadioButton.Checked) { int.TryParse(this.cboVehicle.SelectedValue, out resourceId); driverOrVehicle = true; } else if (this.DriversRadioButton.Checked) { int.TryParse(this.cboDriver.SelectedValue, out resourceId); driverOrVehicle = false; } Facade.IInstruction facInstruction = new Orchestrator.Facade.Instruction(); DataSet dsRouteDeviation = facInstruction.GetRouteDeviationReport(resourceId, driverOrVehicle, dteStartDate.SelectedDate.Value, dteEndDate.SelectedDate.Value, Convert.ToInt32(this.txtDeviationPerc.Value.Value), Convert.ToInt32(this.txtEstimatedDistance.Value.Value)); NameValueCollection reportParams = new NameValueCollection(); reportParams.Add("StartDate", dteStartDate.SelectedDate.Value.ToString("dd/MM/yy")); reportParams.Add("EndDate", dteEndDate.SelectedDate.Value.ToString("dd/MM/yy")); // Configure the Session variables used to pass data to the report Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable] = eReportType.RouteDeviation; Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable] = dsRouteDeviation; Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable] = String.Empty; Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table"; Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable] = reportParams; // Show the user control reportViewer.Visible = true; }
//--------------------------------------------------------------------------------------- protected void btnExport_Click(object sender, EventArgs e) { int resourceId = 0; bool driverOrVehicle = false; if (this.VehiclesRadioButton.Checked) { int.TryParse(this.cboVehicle.SelectedValue, out resourceId); driverOrVehicle = true; } else if (this.DriversRadioButton.Checked) { int.TryParse(this.cboDriver.SelectedValue, out resourceId); driverOrVehicle = false; } Facade.IInstruction facInstruction = new Orchestrator.Facade.Instruction(); DataSet dsRouteDeviation = facInstruction.GetRouteDeviationReport(resourceId, driverOrVehicle, dteStartDate.SelectedDate.Value, dteEndDate.SelectedDate.Value, Convert.ToInt32(this.txtDeviationPerc.Value.Value), Convert.ToInt32(this.txtEstimatedDistance.Value.Value)); Session["__ExportDS"] = dsRouteDeviation.Tables[0]; Response.Redirect("../reports/csvexport.aspx?filename=RouteDeviationByDateRange" + resourceId.ToString() + ".CSV"); }
public List <RunLeg> GetLegsForRun(int runID, bool includeDataPoints) { List <RunLeg> runLegs = new List <RunLeg>(); try { Orchestrator.Facade.IJob facJob = new Orchestrator.Facade.Job(); Orchestrator.Facade.IInstruction facInstruction = new Orchestrator.Facade.Instruction(); Orchestrator.Facade.IGPS facGPS = new Orchestrator.Facade.GPS(); Orchestrator.Entities.InstructionCollection instructions = facInstruction.GetForJobId(runID); Orchestrator.Entities.LegPlan lp = new Orchestrator.Facade.Instruction().GetLegPlan(instructions, true); DataTable ds = facGPS.GetLegTable(lp); runLegs = (from v in ds.AsEnumerable() select new RunLeg() { JobID = v.Field <int>("JobID"), StartInstructionID = v.Field <int>("StartInstructionID"), EndInstructionID = v.Field <int>("EndInstructionID"), ActualDistance = (v.IsNull("ActualDistance")) ? 0 : v.Field <int>("ActualDistance"), ActualDuration = (v.IsNull("ActualDuration")) ? 0 : v.Field <int>("ActualDuration"), EstimatedDistance = (v.IsNull("EstimatedDistance")) ? 0 : v.Field <int>("EstimatedDistance"), EstimatedDuration = (v.IsNull("EstimatedDuration")) ? 0 : v.Field <int>("EstimatedDuration"), PlannedStartDate = v.Field <DateTime>("PlannedStartDateTime"), StartActualArrivalDate = v.IsNull("StartActualArrivalDateTime") ? new DateTime?() : v.Field <DateTime>("StartActualArrivalDateTime"), StartActualDepartureDate = v.IsNull("StartActualDepartureDateTime") ? new DateTime?() : v.Field <DateTime>("StartActualDepartureDateTime"), StartPointID = v.Field <int>("StartPointID"), StartPointDescription = v.Field <string>("StartPointDisplay"), StartPointLatitude = Convert.ToDouble(v.Field <decimal>("StartLatitude")), StartPointLongitude = Convert.ToDouble(v.Field <decimal>("StartLongitude")), PlannedEndDate = v.Field <DateTime>("PlannedEndDateTime"), EndActualArrivalDate = v.IsNull("EndActualArrivalDateTime") ? new DateTime?() : v.Field <DateTime>("EndActualArrivalDateTime"), EndActualDepartureDate = v.IsNull("EndActualDepartureDateTime") ? new DateTime?() : v.Field <DateTime>("EndActualDepartureDateTime"), EndPointID = v.Field <int>("EndPointID"), EndPointDescription = v.Field <string>("EndPointDisplay"), EndPointLatitude = Convert.ToDouble(v.Field <decimal>("EndLatitude")), EndPointLongitude = Convert.ToDouble(v.Field <decimal>("EndLongitude")), RegNo = v.Field <string>("RegNo"), VehicleResourceID = v.Field <int>("VehicleResourceID"), DriverName = v.Field <string>("FullName"), TrailerRef = v.Field <string>("TrailerRef"), JobSubContractID = v.Field <int>("JobSubContractID"), SubContractorIdentityID = v.Field <int>("SubContractor"), SubContractorName = v.Field <string>("DrivingDisplayName"), ETA = String.Empty, InstructionStateID = v.Field <int>("InstructionStateId"), }).ToList(); if (includeDataPoints) { foreach (RunLeg runLeg in runLegs) { runLeg.DataPoints = GetPositionHistoryForRunLeg(runLeg); } } } catch (Exception ex) { throw; } return(runLegs); }
void btnDriverManifests_Click(object sender, EventArgs e) { Session[Orchestrator.Globals.Constants.SubbyManifestListFromDate] = dteStartdate.SelectedDate; Session[Orchestrator.Globals.Constants.SubbyManifestListToDate] = dteEndDate.SelectedDate; Session[Orchestrator.Globals.Constants.SubbyManifestDate] = dteManifestDate.SelectedDate; CheckBox chkManifest = null; HiddenField hidResourceIds = null; int runningJobOrder = 0; Entities.ResourceManifest resourceManifest = new Orchestrator.Entities.ResourceManifest(); resourceManifest.ManifestDate = dteManifestDate.SelectedDate.Value; resourceManifest.Description = txtManifestName.Text; resourceManifest.ResourceManifestJobs = new List <Entities.ResourceManifestJob>(); Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest(); Facade.Instruction facInstruction = new Orchestrator.Facade.Instruction(); foreach (Telerik.Web.UI.GridDataItem gdi in grdManifests.Items) { chkManifest = gdi.FindControl("chkDriverManifest") as CheckBox; if (chkManifest != null && chkManifest.Checked) { if (gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["JobID"] != DBNull.Value) { hidResourceIds = gdi.FindControl("hidResourceId") as HiddenField; // Save ResourceManifestJob rows here int subContractorID = Convert.ToInt32(hidResourceIds.Value); int jobId = Convert.ToInt32(gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["JobID"]); if (resourceManifest.SubcontractorId == null || resourceManifest.SubcontractorId == 0) { resourceManifest.SubcontractorId = subContractorID; } //Get Instructions Resourced List <int> instructionIDs = facInstruction.GetInstructionIDsForSubContractor(jobId, subContractorID, true); foreach (int instructionID in instructionIDs) { // Create new resource manifest jobs rows Entities.ResourceManifestJob rmj = new Orchestrator.Entities.ResourceManifestJob(); rmj.JobId = jobId; rmj.InstructionId = instructionID; rmj.JobOrder = ++runningJobOrder; // Add the resource manifest job to the collection. resourceManifest.ResourceManifestJobs.Add(rmj); } } } } // Create the new resource manifest. this.ResourceManifestId = facResourceManifest.CreateResourceManifest(resourceManifest, this.Page.User.Identity.Name); // Redirect to the drivers ResourceManifestJob edit page. Response.Redirect("SubbyResourceManifest.aspx?rmID=" + this.ResourceManifestId.ToString()); }
protected void Page_Load(object sender, EventArgs e) { int startInstructionID = 0, endInstructionID = 0; bool sIsCollection = false, eIsCollection = false; int.TryParse(Request.QueryString["sID"].ToString(), out startInstructionID); int.TryParse(Request.QueryString["eID"].ToString(), out endInstructionID); StringBuilder siSB = new StringBuilder(); StringBuilder eiSB = new StringBuilder(); StringBuilder displayString = new StringBuilder(); Entities.Instruction foundSInstruction = null, foundEInstruction = null; if (startInstructionID > 0 && endInstructionID > 0) { Facade.IInstruction facIns = new Orchestrator.Facade.Instruction(); List <Entities.CollectDrop> sCollectionDrops = new List <Entities.CollectDrop>(); List <Entities.CollectDrop> eCollectionDrops = new List <Entities.CollectDrop>(); string cacheName = "_InstructionCollectionDeliveryNotes" + startInstructionID.ToString(); if (Cache[cacheName] == null) { foundSInstruction = facIns.GetInstruction(startInstructionID); if (foundSInstruction != null) { Cache.Add(cacheName, foundSInstruction, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), System.Web.Caching.CacheItemPriority.Normal, null); } } else { foundSInstruction = (Entities.Instruction)Cache[cacheName]; } cacheName = "_InstructionCollectionDeliveryNotes" + endInstructionID.ToString(); if (Cache[cacheName] == null) { foundEInstruction = facIns.GetInstruction(endInstructionID); if (foundEInstruction != null) { Cache.Add(cacheName, foundEInstruction, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), System.Web.Caching.CacheItemPriority.Normal, null); } } else { foundEInstruction = (Entities.Instruction)Cache[cacheName]; } sIsCollection = foundSInstruction.InstructionTypeId == (int)eInstructionType.Load ? true : false; eIsCollection = foundEInstruction.InstructionTypeId == (int)eInstructionType.Load ? true : false; if (foundSInstruction.CollectDrops.Exists(cd => cd.OrderAction == eOrderAction.Default && cd.Order.CollectionPointID == foundSInstruction.PointID)) { sCollectionDrops = foundSInstruction.CollectDrops.FindAll(cd => cd.OrderAction == eOrderAction.Default && cd.Order.CollectionPointID == foundSInstruction.PointID).ToList(); } if (foundEInstruction.CollectDrops.Exists(cd => cd.OrderAction == eOrderAction.Default && cd.Order.DeliveryPointID == foundEInstruction.PointID)) { eCollectionDrops = foundEInstruction.CollectDrops.FindAll(cd => cd.OrderAction == eOrderAction.Default && cd.Order.DeliveryPointID == foundEInstruction.PointID).ToList(); } foreach (Entities.CollectDrop cd in sCollectionDrops) { if ((sIsCollection && !string.IsNullOrEmpty(cd.Order.CollectionNotes)) || (!sIsCollection && !string.IsNullOrEmpty(cd.Order.DeliveryNotes))) { siSB.Append(string.Format(note, sIsCollection ? "Collection" : "Delivery", cd.Order.OrderID, sIsCollection ? cd.Order.CollectionNotes : cd.Order.DeliveryNotes)); } } foreach (Entities.CollectDrop cd in eCollectionDrops) { if ((eIsCollection && !string.IsNullOrEmpty(cd.Order.CollectionNotes)) || (!eIsCollection && !string.IsNullOrEmpty(cd.Order.DeliveryNotes))) { eiSB.Append(string.Format(note, eIsCollection ? "Collection" : "Delivery", cd.Order.OrderID, eIsCollection ? cd.Order.CollectionNotes : cd.Order.DeliveryNotes)); } } if (siSB.Length > 0) { displayString.Append(siSB.ToString()); } if (eiSB.Length > 0) { displayString.Append(eiSB.ToString()); } Response.Write(displayString.ToString()); Response.Flush(); Response.End(); } }