//private void updateDoorWidthCalcs() //{ // //reset: // var best = getBestRoutes(); // _controller.CheckClearWidthIssues(best, _inchPerOcc); //} /// <summary> /// retrieve the best route for each room that has a route. /// </summary> /// <returns></returns> private IList <Models.Route> getBestRoutes() { // so there might be if (treeView1.Nodes.Count == 0) { return(new List <Models.Route>()); } List <Models.Route> best = new List <Models.Route>(); foreach (TreeNode roomNode in treeView1.Nodes[0].Nodes) { // for every one, get the shortest route Models.Route bestRoute = null; double shortest = 99999; foreach (TreeNode routeNode in roomNode.Nodes) { Models.Route r = routeNode.Tag as Models.Route; if (r != null) { if (r.TotalDistance < shortest) { shortest = r.TotalDistance; bestRoute = r; } } } if (bestRoute != null) { best.Add(bestRoute); } } return(best); }
public Entities.Context.EntityContext ConvertJsonRouteToEntityContext(Models.InputJson.Json inputJson) { Models.Route jsonRoute = inputJson.Route; Entities.Route entityRoute = new Entities.Route { Id = jsonRoute.Id, Name = jsonRoute.Name, ActiveDays = Enum.Parse <Days>(jsonRoute.ActiveDays), StartDate = jsonRoute.StartDate, EndDate = jsonRoute.EndDate, Rides = MapJsonRides(jsonRoute.Rides, inputJson).ToList() }; Entities.Context.EntityContext entityContext = new Entities.Context.EntityContext() { Routes = new List <Entities.Route> { entityRoute }, PassengerStationRelations = MapJsonPassengersStations(inputJson) }; return(entityContext); }
/// <summary> /// Async Process /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> public override System.Threading.Tasks.Task <System.Net.Http.HttpResponseMessage> ExecuteAsync(System.Threading.CancellationToken cancellationToken) { using (Gale.Db.DataService svc = new Gale.Db.DataService("[PA_MOT_OBT_Ruta]")) { svc.Parameters.Add("USUA_Token", HttpContext.Current.User.PrimarySid()); svc.Parameters.Add("RUTA_Token", this.Model); Gale.Db.EntityRepository rep = this.ExecuteQuery(svc); Models.Route route = rep.GetModel <Models.Route>().FirstOrDefault(); Models.SocialRoute socialRoute = rep.GetModel <Models.SocialRoute>().FirstOrDefault(); List <Models.Coordinates> coords = rep.GetModel <Models.Coordinates>(1); List <Models.RoutePhoto> photos = rep.GetModel <Models.RoutePhoto>(2); //---------------------------------------------------------------------------------------------------- //Create Response var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK) { Content = new ObjectContent <Object>( new { details = route, coordinates = coords, social = socialRoute, photos = photos }, System.Web.Http.GlobalConfiguration.Configuration.Formatters.KqlFormatter() ) }; //Return Task return(Task.FromResult(response)); //---------------------------------------------------------------------------------------------------- } }
/// <summary> /// 还原网址 /// </summary> /// <param name="route"></param> /// <returns></returns> public JsonResult ToLong(Models.Route route) { bool res = false; string msg = ""; if (string.IsNullOrEmpty(route.Short)) { msg = "请输入您要转换的短网址!"; goto Last; } int index = route.Short.LastIndexOf('/'); route.Short = route.Short.Substring(index + 1); string sql = "SELECT Long FROM Route WHERE Short = '" + route.Short + "'"; sql = (new DBHelper()).GetFirst(sql).ToString(); if (sql == "") { msg = "您输入的短网址不存在!"; } else { res = true; msg = sql; } Last : return(Json(new { result = res, message = msg })); }
public DodgingBranches.Models.Route GetRoute(int id) { DodgingBranches.Models.Route returnRoute = new Models.Route(); returnRoute = _routeRepo.GetRoute(id); return(returnRoute); }
public DodgingBranches.Models.Route GetRoute(int id) { DodgingBranches.Models.Route returnRoute = new Models.Route(); returnRoute = _routeRepo.GetRoute(id); return returnRoute; }
public void DeleteRouteMethod(Models.Route SelectedItem) { MakeLogEntry(8, null, null, "open DeleteRoute. Start deleting route"); MessageBoxResult res = DeleteEntry <Models.Route>(SelectedItem); if (res == MessageBoxResult.No) { MakeLogEntry(8, null, null, "open DeleteRoute. Cancel deleting route"); } }
public void AddRoute(Models.Route route) { DodgingBranches.Data.Route myRoute = MapRouteModelToDb(route); using (var db = new RouteContext()) { db.Routes.Add(myRoute); db.SaveChanges(); } }
private void reCheckMaxPath() { if (treeView1.Nodes.Count == 0) { return; } UpdateStatus("Checking max travel..."); foreach (TreeNode room in treeView1.Nodes[0].Nodes) { Models.Node roomNode = room.Tag as Models.Node; if (roomNode == null) { continue; } // find the minimum double min = 9999; int childRoutes = 0; foreach (TreeNode child in room.Nodes) { Models.Route r = child.Tag as Models.Route; if (r != null) { childRoutes++; if (r.TotalDistance < min) { min = r.TotalDistance; } if (r.TotalDistance > _maxTravel) { child.BackColor = System.Drawing.Color.Yellow; } else { child.BackColor = Color.White; } } } if ((childRoutes > 0)) { room.Text = roomNode.Name + " Max Travel Dist: " + min.ToString("F1"); if (min > _maxTravel) { room.BackColor = Color.Orange; } else { room.BackColor = Color.White; } } } }
public MarksViewViewModel(Models.Route route) { CurrentRoute = route; CurrnetMarks = new ObservableCollection <Models.Mark>(Marks.Where( o => o.IsDeleted == 0 && o.RouteId == route.Id ).OrderBy(o => o.MarkNumber)); if (CurrentMapCollection == null) { CurrentMapCollection = UpdateMapCollection(); } }
public ActionResult Detail(int?id) { var route = api.GetRoute(id ?? 0); var model = new Models.Route() { Id = route?.Id, RouteId = route?.RouteId, VehicleId = route?.VehicleId, DepartureId = route?.DepartureId, DestinationId = route?.DestinationId }; var parkings = api.GetParkings(); var vehicles = new List <SelectListItem>(); var departures = new List <SelectListItem>(); var destinations = new List <SelectListItem>(); if (route != null) { vehicles.Add(new SelectListItem() { Text = "Current", Value = (model.VehicleId ?? 0).ToString() }); departures.Add(new SelectListItem() { Text = "Current", Value = (model.DepartureId ?? 0).ToString() }); destinations.Add(new SelectListItem() { Text = "Current", Value = (model.DestinationId ?? 0).ToString() }); } vehicles.AddRange(api.GetVehicles().Select(x => new SelectListItem() { Text = x.Name, Value = (x.Id ?? 0).ToString() })); departures.AddRange(parkings.Select(x => new SelectListItem() { Text = x.Name, Value = (x.Id ?? 0).ToString() })); destinations.AddRange(parkings.Select(x => new SelectListItem() { Text = x.Name, Value = (x.Id ?? 0).ToString() })); model.vehicles = vehicles; model.departures = departures; model.destinations = destinations; return(View(model)); }
private void OpenSchedulerWindowMethod(Models.Route SelectedItem) { if (SelectedItem == null) { return; } MakeLogEntry(8, null, null, "open SchedulerWindow"); ViewModels.SchedulerViewModel schedulerViewModel = new SchedulerViewModel(SelectedItem); Views.SchedulerView schedulerView = new Views.SchedulerView(schedulerViewModel); schedulerView.Owner = CurrentWorkWindow; schedulerView.ShowDialog(); }
private void OpenMarkWindowMethod(Models.Route SelectedItem) { if (SelectedItem == null) { return; } MakeLogEntry(8, null, null, "open MarkWindow"); ViewModels.MarksViewViewModel marksViewViewModel = new MarksViewViewModel(SelectedItem); Views.MarksView marksView = new Views.MarksView(marksViewViewModel); marksView.Owner = CurrentWorkWindow; marksView.ShowDialog(); }
public static Models.Route GetCopyOfRoute(Models.Route route) { return(new Route() { AddingDate = route.AddingDate, DeletingDate = route.DeletingDate, Id = route.Id, IsDeleted = route.IsDeleted, Marks = route.Marks, Name = route.Name, }); }
private void UpdateUserSettingWithLastConsecutiveNumbers(Models.User user) { // Get user setting var setting = user.Setting; // Verify whether user setting is not null if (setting != null) { // Get route code from user setting string routeCode = setting.Route; // Verify emptiness of route code if (!string.IsNullOrEmpty(routeCode)) { // Create a new route helper instance Helpers.Route routeHelper = new Helpers.Route(_context); // Get route detail Models.Route route = routeHelper.GetRoute(routeCode); // Verify whether route is not from presale if (route.RouteType.ToUpper() != Constants.PRESALE) { // Get consecutive invoices from route List <ConsecutiveInvoice> consecutiveInvoices = _context .ConsecutiveInvoices .Where(x => x.Route == routeCode) .ToList(); // Verify whether consecutive invoices list is not empty if (consecutiveInvoices.Any()) { // Get last invoice consecutive number int lastInvoiceNumber = consecutiveInvoices .Where(x => x.DocumentTypeId == "1") .Select(x => x.SequenceNumber) .First(); // Get last payment consecutive number int lastPaymentNumber = consecutiveInvoices .Where(x => x.DocumentTypeId == "2") .Select(x => x.SequenceNumber) .First(); // Assing values found to user setting setting.LastInvoiceNumber = lastInvoiceNumber; setting.LastPaymentNumber = lastPaymentNumber; } } } } }
private void performGetAllRoutes() { try { DateTime start = DateTime.Now; var egresses = _controller.GetEgressNodes(); double total = (double)treeView1.Nodes[0].Nodes.Count; UpdateStatus("Calculating Egress Routes to " + egresses.Count + " egress locations..."); double count = 0; double percent = 0.0; foreach (TreeNode child in treeView1.Nodes[0].Nodes) { percent = count / total * 100.0; count++; UpdateStatus("Calculating Egress Routes to " + egresses.Count + " egress locations...(" + percent.ToString("F0") + "%)"); child.Nodes.Clear(); Models.Node roomNode = child.Tag as Models.Node; foreach (var egress in egresses) { ExternalApp.Log("PathFinding " + roomNode + " to " + egress); try { Models.Route r = Utilities.GraphUtility.FindShortest(roomNode, egress); if (r != null) { addRouteNode(child, egress, r); } } catch (Exception ex) { ExternalApp.Log("Exception while pathfinding: " + ex.GetType().Name + ": " + ex.Message); ExternalApp.Log(ex.StackTrace); } } } reCheckMaxPath(); reCheckDoorCW(); TimeSpan analysis = DateTime.Now - start; UpdateStatus("Analysis Completed in " + analysis); } catch (Exception ex) { Autodesk.Revit.UI.TaskDialog td = new Autodesk.Revit.UI.TaskDialog("Error"); td.MainContent = "Unexpected error: " + ex.GetType().Name + ": " + ex.Message; td.ExpandedContent = ex.StackTrace; td.Show(); } }
public SchedulerViewModel(Models.Route route) { CurrentRoute = route; CurrnetRouteScheduler = new ObservableCollection <Models.RouteScheduler>(RouteSchedulers.Where( o => o.IsDeleted == 0 && o.RouteId == CurrentRoute.Id ).OrderBy(o => o.StartTime).OrderBy(o => o.DayOfWeek)); CurrnetDetailRouteScheduler = new ObservableCollection <DataGridSchedulerDetail>(); foreach (Models.RouteScheduler rsch in CurrnetRouteScheduler) { AddSchedulerEntryToDetail(rsch); } }
public void AddRouteMethod() { ViewModels.AddRouteViewModel addRouteViewModel = new AddRouteViewModel(new Models.Route()); Views.AddRouteView addRouteView = new Views.AddRouteView( addRouteViewModel ); addRouteView.Owner = CurrentWorkWindow; MakeLogEntry(8, null, null, "open AddRoute. Start adding route"); if ((bool)addRouteView.ShowDialog()) { Models.Route route_to_base = Models.Route.GetCopyOfRoute(addRouteViewModel.CurrentRoute); AddEntry <Models.Route>(route_to_base); } else { MakeLogEntry(8, null, null, "open AddRoute. Cancel adding route"); } }
private void addRouteNode(TreeNode parent, Models.Node egress, Models.Route route) { TreeNode routeNode = parent.Nodes.Add("Route to " + egress.NodeType + ": " + egress.Name); routeNode.Tag = route; if (route != null) { routeNode.Text += ": " + route.TotalDistance.ToString("F2") + "ft."; //_controller.DrawRoute(route); StringBuilder sb = new StringBuilder(); foreach (var node in route.Nodes) { sb.Append(node.Name + " - "); } routeNode.ToolTipText = sb.ToString(); } }
public ActionResult Detail(Models.Route route) { if (ModelState.IsValid) { Services.WebApi.Models.ApiRoute apiRoute = new Services.WebApi.Models.ApiRoute() { Id = route.Id, RouteId = route.RouteId, VehicleId = route.VehicleId, DepartureId = route.DepartureId, DestinationId = route.DestinationId }; api.SetRoute(apiRoute); return(RedirectToAction("Index")); } return(View(route)); }
private Boolean IsPresaleRoute(string routeCode) { // Create a new route helper instance Helpers.Route routeHelper = new Helpers.Route(_context); // Save route type var isPresaleRoute = false; // Get route detail Models.Route route = routeHelper.GetRoute(routeCode); // Verify whether the route found is empty or not if (route != null) { // Verify if route is for delivery or not isPresaleRoute = route.RouteType.ToUpper() == Constants.PRESALE; } return(isPresaleRoute); }
private Boolean IsDeliveryRoute(string routeCode) { // Create a new route helper instance Helpers.Route routeHelper = new Helpers.Route(_distributionContext); // Save route type var isDeliveryRoute = true; // Get route detail Models.Route route = routeHelper.GetRoute(routeCode); // Verify whether the route found is empty or not if (route != null) { // Verify if route is for delivery or not isDeliveryRoute = route.RouteType.ToUpper() == Constants.DELIVERY; } return(isDeliveryRoute); }
private void performDrawRoute() { try { Models.Route r = treeView1.SelectedNode.Tag as Models.Route; if (r == null) { return; } _controller.DrawRoute(r); } catch (Exception ex) { Autodesk.Revit.UI.TaskDialog td = new Autodesk.Revit.UI.TaskDialog("Error"); td.MainContent = "Unexpected error: " + ex.GetType().Name + ": " + ex.Message; td.ExpandedContent = ex.StackTrace; td.Show(); } }
public void EditRouteMethod(Models.Route SelectedItem) { if (SelectedItem == null) { return; } Models.Route route_to_view = Models.Route.GetCopyOfRoute(SelectedItem); ViewModels.AddRouteViewModel addRouteViewModel = new AddRouteViewModel(route_to_view); Views.AddRouteView addRouteView = new Views.AddRouteView( addRouteViewModel ); addRouteView.Owner = CurrentWorkWindow; MakeLogEntry(8, null, null, "open AddRoute. Start editing route"); if ((bool)addRouteView.ShowDialog()) { Models.Route route_to_base = Models.Route.GetCopyOfRoute(addRouteViewModel.CurrentRoute); EditEntry <Models.Route>(route_to_base); } else { MakeLogEntry(8, null, null, "open AddRoute. Cancel editing route"); } }
public void EditRoute(Models.Route route) { repoRoute.Update(route); }
public void DeleteRoute(Models.Route route) { repoRoute.Delete(route); }
private void LoadDataFromCSVFiles() { GLData guestLogixData = new GLData(); using (var reader = new StreamReader(this.AirlineCSVFilePath)) { bool skipHeading = true; while (!reader.EndOfStream) { var line = reader.ReadLine(); if (skipHeading == false) { var values = line.Split(','); var airline = new Airline(); airline.Name = values[0]; airline.TwoDigitCode = values[1]; airline.ThreeDigitCode = values[2]; airline.Country = values[3]; guestLogixData.Airlines.Add(airline); } else { skipHeading = false; } } reader.Close(); } using (var reader = new StreamReader(this.AirportCSVFilePath)) { bool skipHeading = true; while (!reader.EndOfStream) { var line = reader.ReadLine(); if (skipHeading == false) { var values = line.Split(','); var airport = new Airport(); airport.Name = values[0]; airport.City = values[1]; airport.Country = values[2]; airport.IATACode = values[3]; airport.Latitute = values[4]; airport.Longitude = values[5]; guestLogixData.Airports.Add(airport); } else { skipHeading = false; } } reader.Close(); } using (var reader = new StreamReader(this.RoutesCSVFilePath)) { bool skipHeading = true; while (!reader.EndOfStream) { var line = reader.ReadLine(); if (skipHeading == false) { var values = line.Split(','); var route = new Models.Route(); route.AirlineID = values[0]; route.Origin = values[1]; route.Destination = values[2]; guestLogixData.Routes.Add(route); } else { skipHeading = false; } } reader.Close(); } AppPersistentData.GuestLogixData = guestLogixData; }
public async Task DeleteData(String[][] primaryKeys, String email) { List <DatabaseChange> databaseChanges = new List <DatabaseChange>(); String changeType = "DELETE"; String changeData = ""; for (var i = 0; i < primaryKeys.Length; i++) { for (var j = 1; j < primaryKeys[i].Length; j++) { switch (primaryKeys[i][0]) { case "stops": Stop foundStop = await _db.Stops.FindAsync(Int32.Parse(primaryKeys[i][j])); if (foundStop == null) { break; } changeData = "Stop: " + foundStop.Name; _db.Stops.Remove(foundStop); break; case "routes": // Route.Label is a foreign key in several tables, and each connection need be set to null // However, a table in a database may have a "on delete set null" setting Models.Route foundRoute = await _db.Routes.FindAsync(primaryKeys[i][j]); if (foundRoute == null) { break; } changeData = "Route: " + foundRoute.Label; foreach (var stop in _db.Stops) { if (stop.Route.Equals(foundRoute)) { stop.Route = null; } } foreach (var routeTable in _db.RouteTables) { if (routeTable.Route.Equals(foundRoute)) { routeTable.Route = null; } } foreach (var tick in _db.Tickets) { if (tick.Route.Equals(foundRoute)) { tick.Route = null; } } _db.Routes.Remove(foundRoute); break; case "route-tables": RouteTable foundRouteTable = await _db.RouteTables.FindAsync(Int32.Parse(primaryKeys[i][j])); if (foundRouteTable == null) { break; } changeData = "RouteTable: " + foundRouteTable.Id + " " + foundRouteTable.StartTime; _db.RouteTables.Remove(foundRouteTable); break; case "tickets": // Disallow remove break; case "ticket-types": TicketType foundTicketType = await _db.TicketTypes.FindAsync(primaryKeys[i][j]); if (foundTicketType == null) { break; } changeData = "TicketType: " + foundTicketType.Label; _db.TicketTypes.Remove(foundTicketType); break; case "ticket-type-compositions": // Disallow remove break; case "users": // Skip first element as it is a default admin user User foundUser = await _db.Users.FindAsync(Int32.Parse(primaryKeys[i][j])); if (foundUser == null) { break; } if (foundUser.Id != 1) { _db.Users.Remove(foundUser); changeData = "User: "******"INVALID ACTION"; changeData = "Tried to delete main admin account"; } break; default: throw new Exception(); } databaseChanges.Add(new DatabaseChange { Type = changeType, Change = changeData }); } } await _db.SaveChangesAsync(); await LogDatabaseAccess(email, changeType, databaseChanges); }
private Models.Route MapDbToRouteModel(Route route) { var returnRoute = new Models.Route(); returnRoute.Name = route.Name; returnRoute.RouteId = route.RouteId; if (route.StartPoint != null) { returnRoute.StartPoint = new Models.MapPoint {Latitude = route.StartPoint.Latitude.Value, Longitude = route.StartPoint.Longitude.Value }; } if (route.EndPoint != null) { returnRoute.EndPoint = new Models.MapPoint { Latitude = route.EndPoint.Latitude.Value, Longitude = route.EndPoint.Longitude.Value }; } returnRoute.UserId = route.UserId; returnRoute.Comments = route.Comments.Select(x => new Models.Comment() { CommentId = x.CommentId, CommentText = x.CommentText, ParentCommentId = x.ParentCommentId, UserId = x.UserId, DateEntered = x.DateEntered, RouteId = x.RouteId }).ToList(); returnRoute.DateEntered = route.DateEntered; returnRoute.Description = route.Description; if (route.StartLocation != null) { returnRoute.StartLocation = new Models.Address { Address1 = route.StartLocation.Address1, City = route.StartLocation.City, AddressId = route.StartLocation.AddressId, State = route.StartLocation.State, ZipCode = route.StartLocation.ZipCode }; } if (route.EndLocation != null) { returnRoute.EndLocation = new Models.Address { Address1 = route.EndLocation.Address1, City = route.EndLocation.City, AddressId = route.EndLocation.AddressId, State = route.EndLocation.State, ZipCode = route.EndLocation.ZipCode }; } returnRoute.Tags = route.Tags.Select(x => new Models.Tag { TagId = x.TagId, TagText = x.TagText }).ToList(); return returnRoute; }
public void AddRoute(Models.Route route) { repoRoute.Create(route); }
/// <summary> /// 缩短操作 /// </summary> /// <param name="route"></param> /// <returns></returns> public JsonResult ToShort(Models.Route route) { bool res = false; string msg = ""; //验证 if (string.IsNullOrEmpty(route.Long)) { msg = "请输入需要转换的源地址!"; goto Last; } if (!UrlIsOK(route.Long)) { msg = "您输入的地址无法访问!"; goto Last; } DBHelper db = new DBHelper(); //检测存在 string sqlURL = "SELECT Short FROM Route WHERE Long = '" + route.Long + "'"; string url = db.GetFirst(sqlURL).ToString(); if (url != "") { res = true; msg = url; goto Last; } //是否自动生成短网址 route.IP = Request.UserHostAddress.ToString(); if (string.IsNullOrEmpty(route.Short)) { string name = MakeName(route.Long, route.IP); res = name == "False" ? false : true; if (res) { msg = name; } else { msg = "系统发生异常,转换失败!"; } } else { if (route.Short.ToLower() == "admin" || route.Short.ToLower() == "manager") { msg = "您输入的域名已被占用!"; goto Last; } //执行增加 string sql = "SELECT Short FROM Route WHERE Short ='" + route.Short + "'"; if (db.GetFirst(sql) != "") { msg = "您输入的域名已被占用!"; goto Last; } sql = "INSERT INTO Route VALUES(NULL,'" + route.Long + "','" + route.Short + "',DATETIME('now'),'" + route.IP + "')"; if (db.GetLine(sql) == 1) { res = true; msg = route.Short;; } else { res = false; msg = "系统发生异常,转换失败!"; } } Last : return(Json( new { result = res, message = msg })); }
public void AddRoute(Models.Route r) { routeDictionary.Add(r); }