internal void AddRouteDetails(List <RouteStationViewModel> routeDetails) { RouteDetails.RemoveAll(item => item.RouteId == routeDetails[0].RouteId && item.RouteVariantId == routeDetails[0].RouteVariantId); RouteDetails.AddRange(routeDetails); RouteDetailsForRoute = routeDetails; OnPropertyChanged(nameof(RouteDetailsForRoute)); }
public async Task <List <Route> > createRoutes(List <RouteDelivery> allRoutes, Company company) { List <Route> routesCreatedInThisSession = new List <Route>(); for (int i = 0; i < allRoutes.Count(); i++) { RouteDelivery routeDelivery = allRoutes.ElementAt(i); var deliveriesInARoute = company.Deliveries.Where(d => routeDelivery.ids.Contains(d.ID)).ToList(); if (deliveriesInARoute.Count() != 0) { Route route = new Route(); route.Deliveries = deliveriesInARoute; route.DeliverBy = DateFilter.getEarliestDeliverByDate(deliveriesInARoute); var depot = await LocationService.FindClosestDepotLocationForRoute(company.PickUpLocations, routeDelivery.center); route.PickUpAddress = depot; route.Status = RouteStatus.New; route.PickUpAddressID = depot.ID; RouteDetails details = await LocationService.getRouteDurationAndOverallDistance(depot, deliveriesInARoute); route.OverallDistance = details.OverallDistance; //adding a time that a driver might need for stopping at the client's location, 10 min per stop double timeForStops = Math.Round((double)10 * deliveriesInARoute.Count() / 60, 2); route.OverallTimeRequired = details.OverallTimeRequired + timeForStops; routesCreatedInThisSession.Add(route); } // await context.SaveChangesAsync(); } return(routesCreatedInThisSession); }
internal void OnRouteChanged(BusRoute selectedRoute, RouteBeginTime.ScheduleDays scheduleDays, int routeVariant) { RouteDetailsForRoute = RouteDetails.Where(route => route.RouteId == selectedRoute.Id && route.RouteVariantId == routeVariant).ToList(); BeginTimesForRoute = RouteBeginTimes.Where(beginTime => beginTime.RouteId == selectedRoute.Id && beginTime.Days == scheduleDays && beginTime.RouteVariant == routeVariant).OrderBy(beginTime => beginTime.Time).ToList(); RouteVariants = Enumerable.Range(0, selectedRoute.VariantsNum).ToList(); OnPropertyChanged(nameof(RouteDetailsForRoute)); OnPropertyChanged(nameof(BeginTimesForRoute)); OnPropertyChanged(nameof(RouteVariants)); }
private TwilioDial ConstructDial(RouteDetails route) { var dial = new TwilioDial { TimeLimit = "60" }; dial.Text = route.terminationNumber; dial.Action = $"{_postCallUrl}/api/postcall?cd={route.callServiceUrlParameter}"; return(dial); }
public async Task updateRouteDetails(Route route) { List <Route> routesCreatedInThisSession = new List <Route>(); var deliveriesInARoute = route.Deliveries; if (deliveriesInARoute.Count() != 0) { RouteDetails details = await LocationService.getRouteDurationAndOverallDistance(route.PickUpAddress, deliveriesInARoute.ToList()); route.OverallDistance = details.OverallDistance; //adding a time that a driver might need for stopping at the client's location, 10 min per stop double timeForStops = Math.Round((double)10 * deliveriesInARoute.Count() / 60, 2); route.OverallTimeRequired = details.OverallTimeRequired + timeForStops; } }
public JsonResult GetPickDropRouteList(string RouteID) { RouteDetails model = new RouteDetails(); List <PickDropPoint> Obj = null; try { model.FinancialYearID = _Financialyearid; model.SchoolID = _OrgnisationID; model.RouteID = Convert.ToInt32(RouteID); Obj = BALObj.GetPickDropPointList(model); } catch { Obj = new List <PickDropPoint>(); } return(Json(Obj, JsonRequestBehavior.AllowGet)); }
public async Task testGetRouteDurationAndOverallDistance() { var responseMessageOne = new HttpResponseMessage(); string jsonResult = "{\"geocoded_waypoints\":[],\"routes\":[{\"legs\":[{\"distance\":{\"text\":\"141 mi\",\"value\":200},\"duration\":{\"text\":\"1 h. 54 min.\",\"value\":3600}},{\"distance\":{\"text\":\"70 m\",\"value\":200},\"duration\":{\"text\":\"1 min.\",\"value\":3600}}]}]}"; responseMessageOne.Content = new StringContent(jsonResult); List <HttpResponseMessage> responses = new List <HttpResponseMessage>(); responses.Add(responseMessageOne); TestGoogleMapsUtil googleMaps = new TestGoogleMapsUtil(responses); LocationService service = new LocationService(googleMaps); List <Delivery> deliveries = new List <Delivery>(); PickUpAddress depot = new PickUpAddress(); RouteDetails result = await service.getRouteDurationAndOverallDistance(depot, deliveries); Assert.Equal(0.4, result.OverallDistance); Assert.Equal(2, result.OverallTimeRequired); }
private Response HandleBasicRoute(RouteDetails numInfo) { _logger.LogInformation($"HandleBasicRoute"); var ret = new Response(); var dial = ConstructDial(numInfo); if (numInfo.callRecordEnabled) { TwilioSay saying = null; TwilioPlay play = null; bool callRecordKeyPressRequired = (numInfo.callRecordConfirmationRequired ?? false) && (!string.IsNullOrEmpty(numInfo.callRecordNotificationText) || !string.IsNullOrEmpty(numInfo.callRecordNotificationFileId)); if (!string.IsNullOrEmpty(numInfo.callRecordNotificationText)) { var lang = numInfo.terminationNumber.StartsWith("61") ? "en-AU" : "en-US"; saying = new TwilioSay { Loop = 1, Text = numInfo.callRecordNotificationText, Voice = "alice", Language = lang }; } else if (!string.IsNullOrEmpty(numInfo.callRecordNotificationFileId)) { var fileLink = $"{numInfo.callRecordNotificationFileId}-{numInfo.callRecordNotificationFileName}"; var mediaFileType = numInfo.callRecordNotificationFileType == 6 ? "CallRecordStudyFiles" : "CallRecordNotificationFiles"; play = new TwilioPlay { Loop = 1, Text = $"{_mediaFileUrl}/api/mediafile?mediaFile={Base64UrlTextEncoder.Encode(Encoding.UTF8.GetBytes(fileLink))}&mediaType={mediaFileType}&tenantId=1234" }; } ret.Saying = saying; ret.Play = play; } ret.Dialing = dial; return(ret); }
private RouteCost RequestRouteCost(RouteType routeType) { _routeDetails = new RouteDetails(); _routeDetails.descriptionType = Config.DesciptionType; _routeDetails.optimizeRoute = true; _routeDetails.routeType = Convert.ToInt32(routeType); _routeOptions.routeDetails = _routeDetails; using (var routeSoapClient = new RouteSoapClient()) { _routeInfo = routeSoapClient.getRoute(GenerateRouteStop(), _routeOptions, _token); } return(new RouteCost { TotalDistance = _routeInfo.routeTotals.totalDistance, TotalFuelCost = _routeInfo.routeTotals.totalfuelCost, TotalCostWithToll = _routeInfo.routeTotals.totalCost, TotalTimeRote = _routeInfo.routeTotals.totalTime }); }
private RouteCost RequestRouteCost(RouteType routeType) { _routeDetails = new RouteDetails(); _routeDetails.descriptionType = Config.DesciptionType; _routeDetails.optimizeRoute = true; _routeDetails.routeType = Convert.ToInt32(routeType); _routeOptions.routeDetails = _routeDetails; using (var routeSoapClient = new RouteSoapClient()) { _routeInfo = routeSoapClient.getRoute(GenerateRouteStop(), _routeOptions, _token); } return new RouteCost { TotalDistance = _routeInfo.routeTotals.totalDistance, TotalFuelCost = _routeInfo.routeTotals.totalfuelCost, TotalCostWithToll = _routeInfo.routeTotals.totalCost, TotalTimeRote = _routeInfo.routeTotals.totalTime }; }
public JsonResult AddRoute(string routeDetailsString) { bool isResult = false; RouteDetails routeDetails = new RouteDetails(); try { JavaScriptSerializer js = new JavaScriptSerializer(); routeDetails = js.Deserialize <RouteDetails>(routeDetailsString); routeDetails.CenterId = Convert.ToInt64(EncryptDecrypt.Decrypt64(routeDetails.Enc_CenterId)); Guid agencyId = new Guid(Session["AgencyId"].ToString()); string agency = Session["AgencyId"].ToString(); routeDetails.AgencyId = agencyId; routeDetails.UserId = new Guid(Session["UserID"].ToString()); isResult = new TransportationData().InsertRouteData(routeDetails); } catch (Exception ex) { clsError.WriteException(ex); } return(Json(isResult, JsonRequestBehavior.AllowGet)); }
internal void Setup(string jsonData) { try { BusServices.Clear(); _theSchedule = JsonConvert.DeserializeObject <ScheduleData>(jsonData); foreach (var service in _theSchedule.BusServices) { BusServices.Add(service); } BusStations.Clear(); foreach (var station in _theSchedule.BusStations) { BusStations.Add(station); } Routes.Clear(); Routes.AddRange(_theSchedule.Routes); RouteDetails.Clear(); RouteDetails.AddRange(_theSchedule.RoutesDetails.Select(rd => new RouteStationViewModel { RouteId = rd.BusRouteId, BusStation = BusStations.FirstOrDefault(BusStopSchedule => BusStopSchedule.Id == rd.BusStopId), OrderNum = rd.OrderNum, TimeDiff = rd.TimeDiff, RouteVariantId = rd.RouteVariant })); RouteBeginTimes.Clear(); RouteBeginTimes.AddRange(_theSchedule.RoutesBeginTimes); TimeAdjustments.Clear(); TimeAdjustments.AddRange(_theSchedule.TimeAdjustments.Select(adj => new TimeAdjustmentViewModel(RouteBeginTimes.First(rbt => rbt.RouteId == adj.RouteId && rbt.RouteVariant == adj.RouteVariantId && rbt.Id == adj.BeginTimeId && rbt.Days == adj.Days), TimeSpan.FromMinutes(adj.TimeAdjustmentMin), adj.StationId))); OnPropertyChanged(nameof(BusServices)); OnPropertyChanged(nameof(BusStations)); } catch (Exception exc) { var msg = exc.Message; } }
public ActionResult AddRoute(RouteDetails RouteDetail, FormCollection collection) { int res = 0; try { RouteDetail.SchoolID = _OrgnisationID; RouteDetail.FinancialYearID = _Financialyearid; RouteDetail.CreatedBy = WebSecurity.CurrentUserName; RouteDetail.IsActive = "1"; if (collection["btntype"].ToUpper() == "Save".ToUpper()) { RouteDetail.Action = "INS"; res = BALObj.InsertUpdateRouteDetails(RouteDetail); if (res > 0) { RouteDetail.PickDropPointLst.ToList().ForEach(p => { p.RouteID = res; p.IsActive = "1"; p.SchoolID = _OrgnisationID; p.FinancialYearID = _Financialyearid; p.Action = "INS"; p.CreatedBy = WebSecurity.CurrentUserName; }); BALObj.InsertUpdatePickDropPointDetails(RouteDetail.PickDropPointLst); } } else if (collection["btntype"].ToUpper() == "Update".ToUpper()) { RouteDetail.Action = "UPD"; res = BALObj.InsertUpdateRouteDetails(RouteDetail); if (res > 0) { RouteDetail.PickDropPointLst.ToList().ForEach(p => { p.RouteID = RouteDetail.RouteID; p.IsActive = "1"; p.SchoolID = _OrgnisationID; p.FinancialYearID = _Financialyearid; p.Action = p.PickDropID == 0 ? "INS" : "UPD"; p.CreatedBy = WebSecurity.CurrentUserName; }); BALObj.InsertUpdatePickDropPointDetails(RouteDetail.PickDropPointLst); } } if (res < 0) { TempData[Constants.MessageInfo.WARNING] = "Route is already exists."; } else if (res == 0) { TempData[Constants.MessageInfo.WARNING] = "Unable to " + collection["btntype"].ToLower(); } else { TempData[Constants.MessageInfo.SUCCESS] = res + ((res == 1) ? " record " : " records ") + collection["btntype"].ToLower() + " successfully."; } } catch (Exception ex) { ExecptionLogger.FileHandling("Transport(AddDriver_Post)", "Error_014", ex, "Transport"); } return(RedirectToAction("RouteMaster")); }
public ActionResult AddRoute(string RouteID = "", string ActionName = "") { RouteDetails model = new RouteDetails(); try { model.ActionName = Constants.BTN_CREATE; if (ActionName.ToUpper() == "EDIT" && !string.IsNullOrEmpty(RouteID)) { Route _Route = new Route(); _Route.SchoolID = _OrgnisationID; _Route.FinancialYearID = _Financialyearid; _Route.Action = "GET"; model = BALObj.GetRouteList(_Route).Where(x => x.RouteID == Convert.ToInt32(RouteID)).FirstOrDefault(); model.PickDropPointLst = BALObj.GetPickDropPointList(model); model.ActionName = Constants.BTN_EDIT; } else { List <PickDropPoint> _Lst = new List <PickDropPoint>(); _Lst.Add(new PickDropPoint()); model.PickDropPointLst = _Lst; } #region Get Drive List //Driver DriverModel = new Driver(); //DriverModel.SchoolID = _OrgnisationID; //DriverModel.FinancialYearID = _Financialyearid; //DriverModel.Action = "GET"; //var _Dlst = BALObj.GetDriverList(DriverModel); //var DList = new List<SelectListItem>(); //foreach (var lst in _Dlst) //{ // DList.Add(new SelectListItem // { // Value = Convert.ToString(lst.DriverID), // Text = Convert.ToString(lst.DriverID), // }); //} //TempData["ListDrivers"] = DList; #endregion Get Drive List #region Get Vehicle List Vehicle VehicleModel = new Vehicle(); VehicleModel.SchoolID = _OrgnisationID; VehicleModel.FinancialYearID = _Financialyearid; VehicleModel.Action = "GET"; List <VehicleDetails> _Vlst = BALObj.GetVehicleList(VehicleModel); var VList = new List <SelectListItem>(); foreach (var lst in _Vlst) { VList.Add(new SelectListItem { Value = Convert.ToString(lst.VehicleID), Text = lst.State + "-" + lst.Sequential + "-" + lst.RTO + "-" + lst.UniqueNo }); } TempData["ListVehicles"] = VList; #endregion Get Vehicle List } catch { } return(View(model)); }
public int AddRoute(RouteDetails route) { throw new NotImplementedException(); }
public List <PickDropPoint> GetPickDropPointList(RouteDetails model) { DALTransport dal = new DALTransport(ConStr); return(dal.GetPickDropPointList(model)); }
public int InsertUpdateRouteDetails(RouteDetails model) { DALTransport dal = new DALTransport(ConStr); return(dal.InsertUpdateRouteDetails(model)); }