/// <summary> /// 把InitialNavigation解析成Navigation /// </summary> /// <param name="initialNavigation">InitialNavigation</param> protected Navigation ParseNavigation(InitialNavigation initialNavigation) { if (initialNavigation == null) { return(null); } Navigation nav = new Navigation() { NavigationId = initialNavigation.NavigationId, ParentNavigationId = initialNavigation.ParentNavigationId, Depth = initialNavigation.Depth, PresentAreaKey = initialNavigation.PresentAreaKey, ResourceName = initialNavigation.ResourceName, IconName = initialNavigation.IconName, NavigationUrl = initialNavigation.NavigationUrl, UrlRouteName = initialNavigation.UrlRouteName, ApplicationId = initialNavigation.ApplicationId, NavigationType = initialNavigation.NavigationType, NavigationText = initialNavigation.NavigationText, NavigationTarget = initialNavigation.NavigationTarget, ImageUrl = initialNavigation.ImageUrl, DisplayOrder = initialNavigation.DisplayOrder, OnlyOwnerVisible = initialNavigation.OnlyOwnerVisible, IsLocked = initialNavigation.IsLocked, IsEnabled = initialNavigation.IsEnabled, OwnerId = 0 }; return(nav); }
/// <summary> /// 转换成InitialNavigation /// </summary> /// <returns></returns> internal protected InitialNavigation AsInitialNavigation() { if (NavigationType != UI.NavigationType.Application) { return(null); } InitialNavigation nav = new InitialNavigation() { NavigationId = this.NavigationId, ParentNavigationId = this.ParentNavigationId, Depth = this.Depth, PresentAreaKey = this.PresentAreaKey, ApplicationId = this.ApplicationId, NavigationType = this.NavigationType, ResourceName = this.ResourceName, NavigationUrl = this.NavigationUrl, UrlRouteName = this.UrlRouteName, NavigationText = this.NavigationText, NavigationTarget = this.NavigationTarget, ImageUrl = this.ImageUrl, DisplayOrder = this.DisplayOrder, OnlyOwnerVisible = this.OnlyOwnerVisible, IsLocked = this.IsLocked, IsEnabled = this.IsEnabled }; return(nav); }
/// <summary> /// 删除初始化导航 /// </summary> /// <remarks> /// 对于单实例的呈现区域必须设置forceOwnerUpdate=true /// </remarks> /// <param name="navigationId">导航Id</param> /// <param name="forceOwnerDelete">是否强制呈现区域实例Owner删除</param> /// <exception cref="ArgumentNullException">initialNavigation为空时</exception> /// <exception cref="ApplicationException">initialNavigation被锁定时</exception> public void DeleteInitialNavigation(int navigationId, bool forceOwnerDelete = false) { InitialNavigation initialNavigation = GetInitialNavigation(navigationId); if (initialNavigation == null) { throw new ArgumentNullException(string.Format("NavigationId为{0}的InitialNavigation不存在", navigationId)); } if (initialNavigation.IsLocked) { throw new ApplicationException("锁定状态的InitialNavigation不允许删除"); } List <InitialNavigation> initialNavigationsForDelete = new List <InitialNavigation>(); IEnumerable <InitialNavigation> descendants = GetDescendants(initialNavigation); if (descendants.Count() > 0) { initialNavigationsForDelete.AddRange(descendants); } initialNavigationsForDelete.Add(initialNavigation); if (forceOwnerDelete) { presentAreaNavigationRepository.ForceOwnerDelete(initialNavigationsForDelete); } foreach (var initialNavigationForDelete in initialNavigationsForDelete) { initialNavigationRepository.Delete(initialNavigationForDelete); } }
/// <summary> /// 获取parentInitialNavigation的后代 /// </summary> /// <param name="parentInitialNavigation">父InitialNavigation</param> /// <returns>返回parentInitialNavigation的所有后代</returns> public IEnumerable <InitialNavigation> GetDescendants(InitialNavigation parentInitialNavigation) { List <InitialNavigation> descendants = new List <InitialNavigation>(); IEnumerable <InitialNavigation> initialNavigationsOfPresentArea = GetInitialNavigations(parentInitialNavigation.PresentAreaKey); RecursiveGetChildren(initialNavigationsOfPresentArea, parentInitialNavigation, ref descendants); return(descendants); }
/// <summary> /// 添加呈现区域实例导航 /// </summary> /// <param name="presentAreaNavigation">PresentAreaNavigation</param> /// <exception cref="ArgumentNullException">presentAreaNavigation为空时</exception> /// <exception cref="ArgumentException">presentAreaNavigation的NavigationType不是<see cref="NavigationType"/>.AddedByOwner时</exception> /// <exception cref="ArgumentException">该PresentAreaNavigation此呈现区域实例已经创建时</exception> /// <returns>返回创建的PresentAreaNavigation的Id</returns> public long CreatePresentAreaNavigation(PresentAreaNavigation presentAreaNavigation) { if (presentAreaNavigation == null) { throw new ArgumentNullException("presentAreaNavigation不能为null"); } if (presentAreaNavigation.NavigationType != NavigationType.AddedByOwner) { throw new ArgumentException("仅能处理NavigationType为Application或PresentAreaInitial的navigation"); } IEnumerable <PresentAreaNavigation> presentAreaNavigations = GetPresentAreaNavigations(presentAreaNavigation.PresentAreaKey, presentAreaNavigation.OwnerId); if (presentAreaNavigations.Where(n => n.NavigationId == presentAreaNavigation.NavigationId).Count() > 0) { throw new ArgumentException("NavigationId不允许重复"); } presentAreaNavigation.NavigationType = NavigationType.AddedByOwner; if (presentAreaNavigation.ParentNavigationId > 0) { InitialNavigation parentNavigation = GetInitialNavigation(presentAreaNavigation.ParentNavigationId); if (parentNavigation == null) { throw new ApplicationException(string.Format("initialNavigation的父级 {0} 不存在", presentAreaNavigation.ParentNavigationId)); } presentAreaNavigation.Depth = parentNavigation.Depth + 1; } else { presentAreaNavigation.Depth = 0; } EventBus <PresentAreaNavigation> .Instance().OnBefore(presentAreaNavigation, new CommonEventArgs(EventOperationType.Instance().Create(), presentAreaNavigation.ApplicationId)); var id = Convert.ToInt64(presentAreaNavigationRepository.Insert(presentAreaNavigation)); EventBus <PresentAreaNavigation> .Instance().OnAfter(presentAreaNavigation, new CommonEventArgs(EventOperationType.Instance().Create(), presentAreaNavigation.ApplicationId)); //移除缓存(分布式缓存情况下,本机缓存会有一定延迟) string cacheKey = GetCacheKey_NavigationOfPresentAreaOwner(presentAreaNavigation.PresentAreaKey, presentAreaNavigation.OwnerId); ICacheService cacheService = DIContainer.Resolve <ICacheService>(); cacheService.Remove(cacheKey); return(id); }
/// <summary> /// 强制所有呈现区域实例Owner更新导航 /// </summary> /// <param name="initialNavigation">初始化导航实体</param> public void ForceOwnerUpdate(InitialNavigation initialNavigation) { if (initialNavigation == null) { return; } var sql = PetaPoco.Sql.Builder; sql.Append("update tn_PresentAreaNavigations set NavigationText =@0, ResourceName=@1, NavigationUrl=@2,UrlRouteName=@3,ImageUrl=@4,NavigationTarget=@5,IsEnabled=@6 ", initialNavigation.NavigationText, initialNavigation.ResourceName, initialNavigation.NavigationUrl, initialNavigation.UrlRouteName, initialNavigation.ImageUrl, initialNavigation.NavigationTarget, initialNavigation.IsEnabled) .Append("where NavigationId = @0", initialNavigation.NavigationId); CreateDAO().Execute(sql); }
/// <summary> /// 添加呈现区域实例导航 /// </summary> /// <param name="presentAreaNavigation">PresentAreaNavigation</param> /// <exception cref="ArgumentNullException">presentAreaNavigation为空时</exception> /// <exception cref="ArgumentException">presentAreaNavigation的NavigationType不是<see cref="NavigationType"/>.AddedByOwner时</exception> /// <exception cref="ArgumentException">该PresentAreaNavigation此呈现区域实例已经创建时</exception> /// <returns>返回创建的PresentAreaNavigation的Id</returns> public long CreatePresentAreaNavigation(PresentAreaNavigation presentAreaNavigation) { if (presentAreaNavigation == null) { throw new ArgumentNullException("presentAreaNavigation不能为null"); } if (presentAreaNavigation.NavigationType != NavigationType.AddedByOwner) { throw new ArgumentException("仅能处理NavigationType为Application或PresentAreaInitial的navigation"); } IEnumerable <PresentAreaNavigation> presentAreaNavigations = GetPresentAreaNavigations(presentAreaNavigation.PresentAreaKey, presentAreaNavigation.OwnerId); if (presentAreaNavigations.Where(n => n.NavigationId == presentAreaNavigation.NavigationId).Count() > 0) { throw new ArgumentException("NavigationId不允许重复"); } presentAreaNavigation.NavigationType = NavigationType.AddedByOwner; if (presentAreaNavigation.ParentNavigationId > 0) { InitialNavigation parentNavigation = GetInitialNavigation(presentAreaNavigation.ParentNavigationId); if (parentNavigation == null) { throw new ApplicationException(string.Format("initialNavigation的父级 {0} 不存在", presentAreaNavigation.ParentNavigationId)); } presentAreaNavigation.Depth = parentNavigation.Depth + 1; } else { presentAreaNavigation.Depth = 0; } EventBus <PresentAreaNavigation> .Instance().OnBefore(presentAreaNavigation, new CommonEventArgs(EventOperationType.Instance().Create(), presentAreaNavigation.ApplicationId)); var id = Convert.ToInt64(presentAreaNavigationRepository.Insert(presentAreaNavigation)); EventBus <PresentAreaNavigation> .Instance().OnAfter(presentAreaNavigation, new CommonEventArgs(EventOperationType.Instance().Create(), presentAreaNavigation.ApplicationId)); EntityData.ForType(typeof(PresentAreaNavigation)).RealTimeCacheHelper.IncreaseAreaVersion("OwnerId", presentAreaNavigation.OwnerId); EntityData.ForType(typeof(Navigation)).RealTimeCacheHelper.IncreaseAreaVersion("OwnerId", presentAreaNavigation.OwnerId); return(id); }
/// <summary> /// 更新初始化导航 /// </summary> /// <remarks> /// 对于单实例的呈现区域必须设置forceOwnerUpdate=true /// </remarks> /// <param name="initialNavigation">初始化导航</param> /// <param name="forceOwnerUpdate">是否强制呈现区域实例Owner更新</param> public void UpdateInitialNavigation(InitialNavigation initialNavigation, bool forceOwnerUpdate = false) { if (initialNavigation == null) { return; } EventBus <InitialNavigation> .Instance().OnBefore(initialNavigation, new CommonEventArgs(EventOperationType.Instance().Update(), initialNavigation.ApplicationId)); initialNavigationRepository.Update(initialNavigation); EventBus <InitialNavigation> .Instance().OnAfter(initialNavigation, new CommonEventArgs(EventOperationType.Instance().Update(), initialNavigation.ApplicationId)); if (forceOwnerUpdate) { presentAreaNavigationRepository.ForceOwnerUpdate(initialNavigation); } }
/// <summary> /// 添加初始化导航 /// </summary> /// <remarks> /// 对于单实例的呈现区域必须设置forceOwnerCreate=true /// </remarks> /// <param name="initialNavigation">初始化导航</param> /// <param name="forceOwnerCreate">是否强制呈现区域实例Owner安装</param> /// <exception cref="ArgumentNullException">initialNavigation为空时</exception> /// <exception cref="ArgumentException">InitialNavigation已经存在时</exception> /// <exception cref="ApplicationException">initialNavigation的ParentNavigationId大于0但是相应的InitialNavigation不存在时</exception> /// <returns>返回创建的InitialNavigation的Id</returns> public long CreateInitialNavigation(InitialNavigation initialNavigation, bool forceOwnerCreate = false) { if (initialNavigation == null) { throw new ArgumentNullException("initialNavigation不能为null"); } if (initialNavigationRepository.Exists(initialNavigation.NavigationId)) { throw new ArgumentException("NavigationId不允许重复"); } initialNavigation.NavigationType = NavigationType.PresentAreaInitial; if (initialNavigation.ParentNavigationId > 0) { InitialNavigation parentNavigation = GetInitialNavigation(initialNavigation.ParentNavigationId); if (parentNavigation == null) { throw new ApplicationException(string.Format("initialNavigation的父级 {0} 不存在", initialNavigation.ParentNavigationId)); } initialNavigation.Depth = parentNavigation.Depth + 1; } else { initialNavigation.Depth = 0; } EventBus <InitialNavigation> .Instance().OnBefore(initialNavigation, new CommonEventArgs(EventOperationType.Instance().Create(), initialNavigation.ApplicationId)); var id = Convert.ToInt64(initialNavigationRepository.Insert(initialNavigation)); EventBus <InitialNavigation> .Instance().OnAfter(initialNavigation, new CommonEventArgs(EventOperationType.Instance().Create(), initialNavigation.ApplicationId)); if (forceOwnerCreate) { presentAreaNavigationRepository.ForceOwnerCreate(initialNavigation); } return(id); }
/// <summary> /// 强制所有呈现区域实例Owner安装导航 /// </summary> /// <param name="initialNavigation">初始化导航实体</param> public void ForceOwnerCreate(InitialNavigation initialNavigation) { if (initialNavigation == null) { return; } var sql = PetaPoco.Sql.Builder; PresentAreaNavigation presentAreaNavigation = initialNavigation.AsPresentAreaNavigation(); sql.Append("insert into tn_PresentAreaNavigations (OwnerId,PresentAreaKey,NavigationId,ParentNavigationId,Depth," + "ApplicationId,NavigationType,NavigationText,ResourceName,NavigationUrl," + "UrlRouteName,ImageUrl,NavigationTarget,DisplayOrder,OnlyOwnerVisible,IsLocked,IsEnabled) " + "select distinct OwnerId,@0,@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13,@14,@15 " + "from tn_PresentAreaNavigations where PresentAreaKey=@0", initialNavigation.PresentAreaKey, initialNavigation.NavigationId, initialNavigation.ParentNavigationId, initialNavigation.Depth, initialNavigation.ApplicationId, initialNavigation.NavigationType, initialNavigation.NavigationText, initialNavigation.ResourceName, initialNavigation.NavigationUrl, initialNavigation.UrlRouteName, initialNavigation.ImageUrl, initialNavigation.NavigationTarget, initialNavigation.DisplayOrder, initialNavigation.OnlyOwnerVisible, initialNavigation.IsLocked, initialNavigation.IsEnabled ); CreateDAO().Execute(sql); }
/// <summary> /// 添加初始化导航 /// </summary> /// <remarks> /// 对于单实例的呈现区域必须设置forceOwnerCreate=true /// </remarks> /// <param name="initialNavigation">初始化导航</param> /// <param name="forceOwnerCreate">是否强制呈现区域实例Owner安装</param> /// <exception cref="ArgumentNullException">initialNavigation为空时</exception> /// <exception cref="ArgumentException">InitialNavigation已经存在时</exception> /// <exception cref="ApplicationException">initialNavigation的ParentNavigationId大于0但是相应的InitialNavigation不存在时</exception> /// <returns>返回创建的InitialNavigation的Id</returns> public long CreateInitialNavigation(InitialNavigation initialNavigation, bool forceOwnerCreate = false) { if (initialNavigation == null) throw new ArgumentNullException("initialNavigation不能为null"); if (initialNavigationRepository.Exists(initialNavigation.NavigationId)) throw new ArgumentException("NavigationId不允许重复"); initialNavigation.NavigationType = NavigationType.PresentAreaInitial; if (initialNavigation.ParentNavigationId > 0) { InitialNavigation parentNavigation = GetInitialNavigation(initialNavigation.ParentNavigationId); if (parentNavigation == null) throw new ApplicationException(string.Format("initialNavigation的父级 {0} 不存在", initialNavigation.ParentNavigationId)); initialNavigation.Depth = parentNavigation.Depth + 1; } else { initialNavigation.Depth = 0; } EventBus<InitialNavigation>.Instance().OnBefore(initialNavigation, new CommonEventArgs(EventOperationType.Instance().Create(), initialNavigation.ApplicationId)); var id = Convert.ToInt64(initialNavigationRepository.Insert(initialNavigation)); EventBus<InitialNavigation>.Instance().OnAfter(initialNavigation, new CommonEventArgs(EventOperationType.Instance().Create(), initialNavigation.ApplicationId)); if (forceOwnerCreate) presentAreaNavigationRepository.ForceOwnerCreate(initialNavigation); return id; }
/// <summary> /// 把PresentAreaNavigation解析成Navigation /// </summary> /// <remarks> /// NavigationType = NavigationType.Application的PresentAreaNavigation需要与相应的InitialNavigation合并 /// </remarks> /// <param name="presentAreaNavigation">PresentAreaNavigation</param> protected Navigation ParseNavigation(PresentAreaNavigation presentAreaNavigation) { if (presentAreaNavigation == null) { return(null); } Navigation nav = new Navigation() { OwnerId = presentAreaNavigation.OwnerId, NavigationText = presentAreaNavigation.NavigationText, NavigationTarget = presentAreaNavigation.NavigationTarget, ImageUrl = presentAreaNavigation.ImageUrl, IconName = presentAreaNavigation.IconName, DisplayOrder = presentAreaNavigation.DisplayOrder }; InitialNavigation initialNavigation = null; if (presentAreaNavigation.IsLocked) { initialNavigation = initialNavigationRepository.Get(presentAreaNavigation.NavigationId); if (initialNavigation == null) { return(null); } nav.NavigationId = initialNavigation.NavigationId; nav.ParentNavigationId = initialNavigation.ParentNavigationId; nav.Depth = initialNavigation.Depth; nav.PresentAreaKey = initialNavigation.PresentAreaKey; nav.ApplicationId = initialNavigation.ApplicationId; nav.ResourceName = initialNavigation.ResourceName; nav.IconName = initialNavigation.IconName; nav.NavigationUrl = initialNavigation.NavigationUrl; nav.UrlRouteName = initialNavigation.UrlRouteName; nav.RouteDataName = initialNavigation.RouteDataName; nav.OnlyOwnerVisible = initialNavigation.OnlyOwnerVisible; nav.NavigationType = initialNavigation.NavigationType; nav.IsLocked = true; } else { nav.NavigationId = presentAreaNavigation.NavigationId; nav.ParentNavigationId = presentAreaNavigation.ParentNavigationId; nav.Depth = presentAreaNavigation.Depth; nav.PresentAreaKey = presentAreaNavigation.PresentAreaKey; nav.ApplicationId = presentAreaNavigation.ApplicationId; nav.ResourceName = presentAreaNavigation.ResourceName; nav.IconName = presentAreaNavigation.IconName; nav.NavigationUrl = presentAreaNavigation.NavigationUrl; nav.UrlRouteName = presentAreaNavigation.UrlRouteName; nav.RouteDataName = presentAreaNavigation.RouteDataName; nav.OnlyOwnerVisible = presentAreaNavigation.OnlyOwnerVisible; nav.NavigationType = presentAreaNavigation.NavigationType; nav.IsLocked = presentAreaNavigation.IsLocked; } #region 设置IsEnabled if (presentAreaNavigation.NavigationType == NavigationType.Application) { ApplicationBase app = ApplicationService.Get(presentAreaNavigation.ApplicationId); if (app == null) { return(null); } if (!app.IsEnabled) { nav.IsEnabled = false; return(nav); } } if (presentAreaNavigation.NavigationType == NavigationType.Application || presentAreaNavigation.NavigationType == NavigationType.PresentAreaInitial) { if (initialNavigation != null && !initialNavigation.IsEnabled) { nav.IsEnabled = false; return(nav); } } nav.IsEnabled = presentAreaNavigation.IsEnabled; return(nav); #endregion }
/// <summary> /// 更新初始化导航 /// </summary> /// <remarks> /// 对于单实例的呈现区域必须设置forceOwnerUpdate=true /// </remarks> /// <param name="initialNavigation">初始化导航</param> /// <param name="forceOwnerUpdate">是否强制呈现区域实例Owner更新</param> public void UpdateInitialNavigation(InitialNavigation initialNavigation, bool forceOwnerUpdate = false) { if (initialNavigation == null) return; EventBus<InitialNavigation>.Instance().OnBefore(initialNavigation, new CommonEventArgs(EventOperationType.Instance().Update(), initialNavigation.ApplicationId)); initialNavigationRepository.Update(initialNavigation); EventBus<InitialNavigation>.Instance().OnAfter(initialNavigation, new CommonEventArgs(EventOperationType.Instance().Update(), initialNavigation.ApplicationId)); if (forceOwnerUpdate) presentAreaNavigationRepository.ForceOwnerUpdate(initialNavigation); }
/// <summary> /// 递归获取parentInitialNavigation所有子InitialNavigation /// </summary> private void RecursiveGetChildren(IEnumerable <InitialNavigation> allInitialNavigations, InitialNavigation parentInitialNavigation, ref List <InitialNavigation> allDescendants) { IEnumerable <InitialNavigation> children = allInitialNavigations.Where(n => n.ParentNavigationId == parentInitialNavigation.NavigationId); if (children.Count() > 0) { allDescendants.AddRange(children); foreach (var child in children) { RecursiveGetChildren(allInitialNavigations, child, ref allDescendants); } } }
/// <summary> /// 把InitialNavigation解析成Navigation /// </summary> /// <param name="initialNavigation">InitialNavigation</param> protected Navigation ParseNavigation(InitialNavigation initialNavigation) { if (initialNavigation == null) return null; Navigation nav = new Navigation() { NavigationId = initialNavigation.NavigationId, ParentNavigationId = initialNavigation.ParentNavigationId, Depth = initialNavigation.Depth, PresentAreaKey = initialNavigation.PresentAreaKey, ResourceName = initialNavigation.ResourceName, IconName = initialNavigation.IconName, NavigationUrl = initialNavigation.NavigationUrl, UrlRouteName = initialNavigation.UrlRouteName, ApplicationId = initialNavigation.ApplicationId, NavigationType = initialNavigation.NavigationType, NavigationText = initialNavigation.NavigationText, NavigationTarget = initialNavigation.NavigationTarget, ImageUrl = initialNavigation.ImageUrl, DisplayOrder = initialNavigation.DisplayOrder, OnlyOwnerVisible = initialNavigation.OnlyOwnerVisible, IsLocked = initialNavigation.IsLocked, IsEnabled = initialNavigation.IsEnabled, OwnerId = 0 }; return nav; }
/// <summary> /// 在后台管理呈现区域默认导航时,获取InitialNavigation /// </summary> /// <param name="navigationId">导航Id</param> /// <returns>返回navigationId对应的初始化导航实体</returns> public InitialNavigation GetInitialNavigation(int navigationId) { InitialNavigation presentAreaInitialNavigation = initialNavigationRepository.Get(navigationId); return(presentAreaInitialNavigation); }
/// <summary> /// 递归获取parentInitialNavigation所有子InitialNavigation /// </summary> private void RecursiveGetChildren(IEnumerable<InitialNavigation> allInitialNavigations, InitialNavigation parentInitialNavigation, ref List<InitialNavigation> allDescendants) { IEnumerable<InitialNavigation> children = allInitialNavigations.Where(n => n.ParentNavigationId == parentInitialNavigation.NavigationId); if (children.Count() > 0) { allDescendants.AddRange(children); foreach (var child in children) { RecursiveGetChildren(allInitialNavigations, child, ref allDescendants); } } }
/// <summary> /// 转换为InitialNavigation用于数据库存储 /// </summary> /// <returns></returns> public InitialNavigation AsInitialNavigation() { InitialNavigation initialNavigation = new InitialNavigation(); initialNavigation.NavigationId = this.NavigationId; initialNavigation.ApplicationId = this.ApplicationId; //判断应用 if (this.ApplicationId == 0) { initialNavigation.NavigationType = NavigationType.PresentAreaInitial; } else { initialNavigation.NavigationType = NavigationType.Application; } //使用资源项 if (this.IsUseResourceItem) { initialNavigation.ResourceName = this.ResourceName; initialNavigation.NavigationText = string.Empty; } else { initialNavigation.NavigationText = this.NavigationText; initialNavigation.ResourceName = string.Empty; } //使用路由 if (this.IsUseRoute) { initialNavigation.UrlRouteName = this.UrlRouteName ?? string.Empty; initialNavigation.NavigationUrl = string.Empty; } else { initialNavigation.NavigationUrl = this.NavigationUrl ?? string.Empty; initialNavigation.UrlRouteName = string.Empty; } if (IsIconName) { initialNavigation.IconName = this.IconName; initialNavigation.ImageUrl = null; } else { initialNavigation.IconName = null; if (this.IsWholeLink) { initialNavigation.ImageUrl = this.ImageUrl; } else { if (ImageName != null) { initialNavigation.ImageUrl = "~/Uploads/NavigationImage/" + this.ImageName; } else { initialNavigation.ImageUrl = null; } } } initialNavigation.NavigationTarget = this.NavigationTarget; initialNavigation.DisplayOrder = this.NavigationId; initialNavigation.OnlyOwnerVisible = this.OnlyOwnerVisible; initialNavigation.IsEnabled = this.IsEnabled; return initialNavigation; }
/// <summary> /// 获取parentInitialNavigation的后代 /// </summary> /// <param name="parentInitialNavigation">父InitialNavigation</param> /// <returns>返回parentInitialNavigation的所有后代</returns> public IEnumerable<InitialNavigation> GetDescendants(InitialNavigation parentInitialNavigation) { List<InitialNavigation> descendants = new List<InitialNavigation>(); IEnumerable<InitialNavigation> initialNavigationsOfPresentArea = GetInitialNavigations(parentInitialNavigation.PresentAreaKey); RecursiveGetChildren(initialNavigationsOfPresentArea, parentInitialNavigation, ref descendants); return descendants; }
/// <summary> /// 转换成InitialNavigation /// </summary> /// <returns></returns> protected internal InitialNavigation AsInitialNavigation() { if (NavigationType != UI.NavigationType.Application) return null; InitialNavigation nav = new InitialNavigation() { NavigationId = this.NavigationId, ParentNavigationId = this.ParentNavigationId, Depth = this.Depth, PresentAreaKey = this.PresentAreaKey, ApplicationId = this.ApplicationId, NavigationType = this.NavigationType, ResourceName = this.ResourceName, NavigationUrl = this.NavigationUrl, UrlRouteName = this.UrlRouteName, NavigationText = this.NavigationText, NavigationTarget = this.NavigationTarget, ImageUrl = this.ImageUrl, DisplayOrder = this.DisplayOrder, OnlyOwnerVisible = this.OnlyOwnerVisible, IsLocked = this.IsLocked, IsEnabled = this.IsEnabled }; return nav; }