public ActionContext( HttpContext httpContext, RouteEntity routeEntity) { HttpContext = httpContext ?? throw new ArgumentNullException(nameof(httpContext)); RouteEntity = routeEntity ?? throw new ArgumentNullException(nameof(httpContext)); }
/// <summary> /// Constructs the topic text for a route /// </summary> /// <param name="route">route information</param> /// <returns>topic text</returns> private string TopicText(RouteEntity route) { // in the common case, the topic text will be: // Discuss the LongName route string text = string.Empty; if (!string.IsNullOrWhiteSpace(route.ShortName) || !string.IsNullOrWhiteSpace(route.LongName)) { text += "Discuss the "; } if (!string.IsNullOrWhiteSpace(route.LongName)) { text += route.LongName; } else if (!string.IsNullOrWhiteSpace(route.ShortName)) { text += route.ShortName; } if (!string.IsNullOrWhiteSpace(text)) { text += " route"; } return(TopicUtils.RemoveHashtags(text)); }
public void Update(RouteEntity route) { using (var transaction = Context.Database.BeginTransaction()) { try { RouteEntity forUpdate = Get(route.Id); forUpdate.Distance = route.Distance; if (forUpdate.Start.Id != route.Start.Id) { forUpdate.Start = Context.Cities.Where(c => c.Id == route.Start.Id).FirstOrDefault(); } if (forUpdate.End.Id != route.End.Id) { forUpdate.End = Context.Cities.Where(c => c.Id == route.End.Id).FirstOrDefault(); } forUpdate.Name = route.Name; forUpdate.ModifiedOn = DateTime.Now; Context.SaveChanges(); transaction.Commit(); } catch (Exception) { transaction.Rollback(); } } }
/// <summary> /// 构造函数。 /// </summary> /// <param name="route">表示途程信息的实体对象。</param> public RouteViewContent(RouteEntity route) : base() { if (null != route && route.RouteName.Length > 0) { this.TitleName = StringParser.Parse("${res:FanHai.Hemera.Addins.FMM.RouteViewContent.TitleName}") + "_" + route.RouteName + "." + route.RouteVersion; } else { this.TitleName = StringParser.Parse("${res:FanHai.Hemera.Addins.FMM.RouteViewContent.TitleName}"); } Panel panel = new Panel(); //set panel dock style panel.Dock = DockStyle.Fill; //set panel BorderStyle panel.BorderStyle = BorderStyle.FixedSingle; RouteCtrl routeCtrl = new RouteCtrl(route); routeCtrl.Dock = DockStyle.Fill; //将控件对象加入到Panel中。 //设置Panel为该视图对象的控件对象,用于在应用程序平台上显示可视化的视图界面。 panel.Controls.Add(routeCtrl); //set panel to view content this.control = panel; }
public OkResult Update([FromBody] RouteViewModel city) { RouteEntity entity = mapper.Map <RouteEntity>(city); this.routeService.UpdateRoute(entity); return(Ok()); }
/// <summary> /// 检查计量单位编码是否已存在 /// </summary> /// <param name="unit"></param> /// <returns></returns> private bool IsCodeExists(RouteEntity unit) { IMapper map = DatabaseInstance.Instance(); string id = map.ExecuteScalar <string>("select RT_CODE from WM_ROUTE where RT_CODE = @COD", new { COD = unit.RouteCode }); return(!string.IsNullOrEmpty(id)); }
/// <summary> /// Get a particular route from table storage /// </summary> /// <param name="regionId">region Id</param> /// <param name="agencyId">agency Id</param> /// <param name="id">route Id</param> /// <returns>route entity</returns> public RouteEntity Get(string regionId, string agencyId, string id) { RouteEntity partialRoute = new RouteEntity { Id = id, RegionId = regionId, AgencyId = agencyId, RecordType = Enum.GetName(typeof(RecordType), RecordType.Route) }; var retrievedRoutes = (from entry in this.Table.CreateQuery <DynamicTableEntity>() where entry.PartitionKey == partialRoute.PartitionKey && entry.RowKey == partialRoute.RowKey && entry.Properties["RecordType"].StringValue == RecordType.Route.ToString() select entry).Resolve(AbstractEntityAdapter.AdapterResolver <RouteEntity>).ToList(); // return null if no records were retrieved if (retrievedRoutes == null || retrievedRoutes.Count == 0) { return(null); } // throw an exception if more than 1 record was received if (retrievedRoutes.Count > 1) { throw new Exception("Expected 1 record but retrieved " + retrievedRoutes.Count + " records."); } return(retrievedRoutes[0]); }
/// <summary> /// 添加或编辑计量单位 /// </summary> /// <param name="entity"></param> /// <param name="isNew">添加或编辑</param> /// <returns></returns> public int Save(RouteEntity entity, bool isNew) { IMapper map = DatabaseInstance.Instance(); int ret = -2; if (isNew) { //检查编号是否已经存在 if (IsCodeExists(entity)) { return(-1); } ret = map.Execute(string.Format("insert into WM_ROUTE(RT_CODE, RT_NAME, LAST_UPDATETIME) " + "values(@COD, @NAM, {0})", map.GetSysDateString()), new { COD = entity.RouteCode, NAM = entity.RouteName }); } else { //更新 ret = map.Execute(string.Format("update WM_ROUTE set RT_NAME = @NAM, LAST_UPDATETIME = {0} where RT_CODE = @COD", map.GetSysDateString()), new { COD = entity.RouteCode, NAM = entity.RouteName }); } return(ret); }
private ActionResult Details(RouteEntity entity, string category, string slug) { if (entity is Photoshop) { var data = new ProductViewData { Menu = ObjectExtension.As <IList <MenuItemViewModel> >(_context.AbstractMenuItem.Where(x => x.RouteID == entity.ID)) }; this.SetTheme(entity); var link = entity as Photoshop; data.Route = ObjectExtension.As <PhotoshopViewModel.Summary>(entity); data.PhototechnicsViewModel = ObjectExtension.As <PhototechnicsViewModel.Details>(_context.PricePositions.Where(x => x.PhotoshopID == entity.ID && x.Phototechnics.Shortcut == slug) .Include(x => x.Phototechnics.ParameterValues).Include(x => x.Phototechnics.ParameterValues.Select(y => y.Parameter)).FirstOrDefault()); return(View("Details", data)); } if (entity is Photorent) { var data = new ProductViewData { Menu = ObjectExtension.As <IList <MenuItemViewModel> >(_context.AbstractMenuItem.Where(x => x.RouteID == entity.ID)) }; this.SetTheme(entity); var link = entity as Photorent; data.Route = ObjectExtension.As <PhotorentViewModel.Details>(entity); data.Categorieses = ObjectExtension.As <IList <CategoryViewModel> >(_context.Categories.ToList()); data.PhototechnicsViewModel = ObjectExtension.As <PhototechnicsViewModel.Details>(link.RentCalendars.SingleOrDefault(x => x.Phototechnics.Shortcut == slug)); return(View("Details", data)); } return(View("Details")); }
public OkResult Post([FromBody] RouteViewModel route) { RouteEntity entity = mapper.Map <RouteEntity>(route); this.routeService.AddRoute(entity); return(Ok()); }
/* This method applies Prim's algorithm to the cities and routes * saved in the database*/ private List <RouteEntity> ApplyPrim(CityEntity node) { int allNodes = dataAccessService.CityRepository.GetCount(); List <RouteEntity> treeRoutes = new List <RouteEntity>(); List <RouteEntity> available = new List <RouteEntity>(); List <CityEntity> visitedCities = new List <CityEntity>(); List <RouteEntity> routes = dataAccessService.RouteRepository.GetRoutesByCity(node.Id, visitedCities.Select(c => c.Id).ToArray()); //getting available routes available.AddRange(routes); /*until all the routes are visited or the tree routes are not as many as * the number of the cities - 1*/ while (treeRoutes.Count != allNodes - 1 && available.Count != 0) { //selecting the min route RouteEntity forAdd = available.Where(a => a.Distance == available.Min(a2 => a2.Distance)).FirstOrDefault(); if (forAdd != null) { treeRoutes.Add(forAdd); available.Remove(forAdd); if (visitedCities.Contains(forAdd.Start)) { visitedCities.Add(forAdd.End); } else if (visitedCities.Contains(forAdd.End)) { visitedCities.Add(forAdd.Start); } else { visitedCities.Add(node); } if (forAdd.End?.Id != node.Id) { node = forAdd.End; } else { node = forAdd.Start; } } routes = dataAccessService.RouteRepository.GetRoutesByCity(node.Id, visitedCities.Select(c => c.Id).ToArray()); foreach (var route in routes) { if (!available.Contains(route)) { available.Add(route); } } //removing routes that connect already visited cities List <RouteEntity> forRemoval = available.Where(r => visitedCities.Select(c => c.Id).ToArray().Contains(r.Start.Id) && visitedCities.Select(c => c.Id).ToArray().Contains(r.End.Id)).ToList(); foreach (var item in forRemoval) { available.Remove(item); } } return(treeRoutes); }
/// <summary> /// Stores a list of OBA client routes in Azure Tables /// </summary> /// <param name="routes">list of routes</param> /// <param name="regionId">uniquely identifies the region that these routes belong to</param> /// <param name="agencyId">uniquely identifies the agency that these routes belong to</param> /// <returns>task that stores the entities</returns> public async Task Insert(IEnumerable <OBAClient.Model.Route> routes, string regionId, string agencyId) { // convert the input routes into route entities List <RouteEntity> routeEntities = new List <RouteEntity>(); foreach (OBAClient.Model.Route route in routes) { RouteEntity routeEntity = new RouteEntity { Id = route.Id, ShortName = route.ShortName, LongName = route.LongName, Description = route.Description, Url = route.Url, AgencyId = agencyId, RegionId = regionId, RecordType = RecordType.Route.ToString(), RowState = DataRowState.Default.ToString(), RawContent = route.RawContent, }; routeEntities.Add(routeEntity); } // issue the insert call await this.Insert(routeEntities); }
private void OnCreateChanage(object sender, EventArgs e) { RouteEntity newEntity = (RouteEntity)sender; bindingSource1.Add(newEntity); bindingSource1.ResetBindings(false); }
/// <summary> /// Delete a published route from Embedded Social. /// The way we delete a route is to simply indicate it as deleted /// in the Embedded Social topic title. That way, existing /// comments live on, and users who visit the topic will know /// that this route is no longer valid. /// </summary> /// <param name="route">route that no longer exists</param> /// <returns>task that deletes the route</returns> public async Task DeleteRoute(RouteEntity route) { // check the input this.CheckInputEntity(route); // update the topic title to indicate this has been deleted await this.UpdateTopic(this.TopicName(route), DeletedTopicTitlePrefix + this.TopicTitle(route), this.TopicText(route), route.RegionId); }
/// <summary> /// Publish an updated route to Embedded Social /// </summary> /// <param name="route">updated route information</param> /// <returns>task that updates the route</returns> public async Task UpdateRoute(RouteEntity route) { // check the input this.CheckInputEntity(route); // update the topic await this.UpdateTopic(this.TopicName(route), this.TopicTitle(route), this.TopicText(route), route.RegionId); }
/// <summary> /// Constructs the topic name for a route /// </summary> /// <param name="route">route information</param> /// <returns>topic name</returns> private string TopicName(RouteEntity route) { string name = "route_" + route.RegionId + "_" + route.Id; // Embedded Social's named topics can store only strings that are safe as an Azure Table key. name = name.StringToTableKey(); return(name); }
public bool ProcessNode(RouteEntity route, UserInformation user, Order order) { var engine = new Engine() .SetValue("route", route) .SetValue("user", user) .SetValue("order", order); engine.Execute(Script); return(true); }
public ActionResult Detailswl(string category, string slug, string whitelabel) { if (whitelabel == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RouteEntity photoshop = _context.Routes.SingleOrDefault(x => x.Domain == whitelabel); return(photoshop != null?Details(category, slug, photoshop.Shortcut) : new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
public ActionResult Indexwl(string whitelabel) { if (whitelabel == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RouteEntity entity = _context.Routes.Include(x => x.Raiting).SingleOrDefault(x => x.Domain == whitelabel); return(Index(entity)); }
public static void RegisterRoute(string routeName, RoutingInfo routingInfo) { TableServiceContext tableContext = GetTableContext(); RouteEntity entity = new RouteEntity(routeName, routingInfo); //this performs an Upsert (InsertOrRepalce) tableContext.AttachTo(_tableName, entity, null); tableContext.UpdateObject(entity); tableContext.SaveChanges(); _configCache.Remove(_partitionKey); }
public static void UnregisterRoute(string routeName) { TableServiceContext tableContext = GetTableContext(); RouteEntity entity = new RouteEntity(routeName, null); tableContext.AttachTo(_tableName, entity, "*"); tableContext.DeleteObject(entity); tableContext.SaveChanges(); _configCache.Remove(_partitionKey); }
public RouteEntity CreateRoute(RouteViewModel routeViewModel) { var cityOrigin = _cityService.FindByCode(routeViewModel.CityOrigin); var cityDestination = _cityService.FindByCode(routeViewModel.CityDestination); var distance = routeViewModel.Distance; var routeEntity = new RouteEntity(cityOrigin, cityDestination, distance); _context.Routes.Add(routeEntity); return(routeEntity); }
public bool ProcessCheckout(RouteEntity route, UserInformation info, Order order) { new JintNode() { Script = @" if(user.Penalties.length>0) order.Status.ID " }; return true; }
/// <summary> /// Setup routeName to acces a file location /// </summary> /// <param name="controller">this contoller, to called to set route</param> /// <param name="etity">entity to type defined</param> public static void SetRoute(this Controller controller, RouteEntity etity) { var requestContext = controller.Request.RequestContext; var baseType = etity.GetType().BaseType; if (baseType != null) { requestContext.HttpContext.Items["routeName"] = baseType.Name; } }
public ActionResult Category(string category, string shortcut) { if (shortcut == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RouteEntity entity = _context.Routes.SingleOrDefault(x => x.Shortcut == shortcut); return(entity == null?HttpNotFound() : Category(entity, category)); }
/// <summary> /// Updates a route in Azure Tables /// </summary> /// <param name="route">route</param> /// <returns>task that updates the entity</returns> public async Task Update(RouteEntity route) { // note: this is dangerous because RouteEntity is actually not a table entity. // hence it does not contain an Etag that would be used for concurrency control. ITableEntity entity = new EntityAdapter <RouteEntity>(route); entity.ETag = "*"; TableOperation replace = TableOperation.Replace(entity); await this.Table.ExecuteAsync(replace); }
public RouteEntity PrepareSave() { RouteEntity editEntity = routeEntity; if (editEntity == null) { editEntity = new RouteEntity(); } editEntity.RouteCode = txtCode.Text.Trim(); editEntity.RouteName = txtName.Text.Trim(); return(editEntity); }
/// <summary> /// Publish a new route to Embedded Social /// </summary> /// <param name="route">new route information</param> /// <returns>task that publishes a new route and returns the topic name</returns> public async Task <string> CreateRoute(RouteEntity route) { // check the input this.CheckInputEntity(route); // publish the new topic string topicName = this.TopicName(route); await this.CreateTopic(topicName, this.TopicTitle(route), this.TopicText(route), route.RegionId); // return the topic name return(topicName); }
public Route UpdateRoute(JObject item, int id) { RouteEntity route = _routeRepository.UpdateRoute(item, id); if (route != null) { return(_routeRepository.GetById(id).ToDomain()); } else { return(null); } }
///<summary> ///查询所有路线 ///</summary> ///<returns></returns> public List <RouteEntity> GetAll() { List <RouteEntity> list = new List <RouteEntity>(); try { #region 请求数据 System.Text.StringBuilder loStr = new System.Text.StringBuilder(); //loStr.Append("groupCode=").Append(groupCode); string jsonQuery = WebWork.SendRequest(string.Empty, WebWork.URL_GetAllRoute); if (string.IsNullOrEmpty(jsonQuery)) { MsgBox.Warn(WebWork.RESULT_NULL); //LogHelper.InfoLog(WebWork.RESULT_NULL); return(list); } #endregion #region 正常错误处理 JsonGetAllRoute bill = JsonConvert.DeserializeObject <JsonGetAllRoute>(jsonQuery); if (bill == null) { MsgBox.Warn(WebWork.JSON_DATA_NULL); return(list); } if (bill.flag != 0) { MsgBox.Warn(bill.error); return(list); } #endregion #region 赋值数据 foreach (JsonGetAllRouteResult jbr in bill.result) { RouteEntity asnEntity = new RouteEntity(); asnEntity.RouteCode = jbr.rtCode; asnEntity.RouteName = jbr.rtName; list.Add(asnEntity); } return(list); #endregion } catch (Exception ex) { MsgBox.Err(ex.Message); } return(list); }
public RouteEntity(RouteEntity entity) { this._route = entity._route; }