/// <summary> /// 页头 /// </summary> /// <returns></returns> public ActionResult _Header(string spaceKey) { if (UserContext.CurrentUser != null) { MessageService messageService = new MessageService(); InvitationService invitationService = new InvitationService(); NoticeService noticeService = new NoticeService(); long userId = UserIdToUserNameDictionary.GetUserId(UserContext.CurrentUser.UserName); int count = 0; count = invitationService.GetUnhandledCount(userId); count += messageService.GetUnreadCount(userId); count += noticeService.GetUnhandledCount(userId); ViewData["PromptCount"] = count; } //获取当前是在哪个应用下搜索 RouteValueDictionary routeValueDictionary = Request.RequestContext.RouteData.DataTokens; string areaName = routeValueDictionary.Get<string>("area", null) + "Search"; ViewData["search"] = areaName; //查询用于快捷搜索的搜索器 IEnumerable<ISearcher> searchersQuickSearch = SearcherFactory.GetQuickSearchers(4); ViewData["searchersQuickSearch"] = searchersQuickSearch; NavigationService service = new NavigationService(); ViewData["Navigations"] = service.GetRootNavigations(PresentAreaKeysOfBuiltIn.Channel).Where(n => n.IsVisible(UserContext.CurrentUser) == true); return PartialView(); }
/// <summary> /// 转换为InitialNavigation用于数据库存储 /// </summary> /// <returns></returns> public InitialNavigation AsInitialNavigation() { //从数据库取出一遍原版内容 InitialNavigation initialNavigation = new NavigationService().GetInitialNavigation(NavigationId); //使用资源项 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 (this.ImageName != null) { initialNavigation.ImageUrl = "~/Uploads/NavigationImage/" + this.ImageName; } else { initialNavigation.ImageUrl = null; } } } initialNavigation.NavigationTarget = this.NavigationTarget; initialNavigation.OnlyOwnerVisible = this.OnlyOwnerVisible; initialNavigation.IsEnabled = this.IsEnabled; return initialNavigation; }
/// <summary> /// 页头 /// </summary> /// <returns></returns> public ActionResult _Header() { NavigationService service = new NavigationService(); if (RouteData.Values != null && RouteData.Values.ContainsKey("CurrentNavigationId")) { int currentNavigationId = Convert.ToInt32(RouteData.Values["CurrentNavigationId"].ToString()); IEnumerable<int> currentNavigationPath = service.GetCurrentNavigationPath(PresentAreaKeysOfBuiltIn.ControlPanel, 0, currentNavigationId); if (currentNavigationPath != null && currentNavigationPath.Count() > 0) ViewData["CurrentNavigationId"] = currentNavigationPath.First(); } ViewData["rootnavigations"] = service.GetRootNavigations(PresentAreaKeysOfBuiltIn.ControlPanel); return View(); }
/// <summary> /// 侧边菜单 /// </summary> /// <returns></returns> public ActionResult _AsideMenu() { NavigationService service = new NavigationService(); int currentNavigationId = RouteData.Values.Get<int>("CurrentNavigationId", 0); IEnumerable<Navigation> navigations = null; if (currentNavigationId > 0) { IEnumerable<int> currentNavigationPath = service.GetCurrentNavigationPath(PresentAreaKeysOfBuiltIn.ControlPanel, 0, currentNavigationId); IEnumerable<Navigation> rootNavigations = service.GetRootNavigations(PresentAreaKeysOfBuiltIn.ControlPanel); Navigation parentNavigation = null; int parentNavigationId = 0; if (currentNavigationPath.Count() > 1) { parentNavigationId = currentNavigationPath.ElementAt(currentNavigationPath.Count() - 2); } else if (currentNavigationPath.Count() == 1) { parentNavigationId = currentNavigationPath.First(); } parentNavigation = service.GetNavigation(PresentAreaKeysOfBuiltIn.ControlPanel, parentNavigationId); if (parentNavigation != null) { if (parentNavigation.Depth > 0) { Navigation navigation = service.GetNavigation(PresentAreaKeysOfBuiltIn.ControlPanel, parentNavigation.ParentNavigationId); navigations = navigation.Children; } else { navigations = parentNavigation.Children; } } } return View(navigations); }
public ActionResult _TopicMenu(string spaceKey) { long topicId = TopicIdToTopicKeyDictionary.GetTopicId(spaceKey); TopicEntity topic = topicService.Get(topicId); if (topic == null) return Content(string.Empty); int currentNavigationId = RouteData.Values.Get<int>("CurrentNavigationId", 0); IEnumerable<Navigation> navigations = new List<Navigation>(); NavigationService navigationService = new NavigationService(); Navigation navigation = navigationService.GetNavigation(PresentAreaKeysOfExtension.TopicSpace, currentNavigationId, topic.TopicId); if (navigation != null && navigation.Children.Count() > 0) { navigations = navigation.Children; } else { navigations = navigationService.GetRootNavigations(PresentAreaKeysOfExtension.TopicSpace, topic.TopicId); } return View(navigations); }
public PresentAreaNavigation AsPresentAreaNavigation() { PresentAreaNavigation presentAreaNavigation = null; if (Id==0) { presentAreaNavigation = new PresentAreaNavigation(); presentAreaNavigation.ResourceName = string.Empty; presentAreaNavigation.NavigationUrl = NavigationUrl; presentAreaNavigation.RouteDataName = string.Empty; presentAreaNavigation.UrlRouteName = string.Empty; } else { presentAreaNavigation = new NavigationService().GetPresentAreaNavigation(Id); } presentAreaNavigation.NavigationText = NavigationText; presentAreaNavigation.ImageUrl = ImageUrl; presentAreaNavigation.NavigationUrl = NavigationUrl!=null?NavigationUrl:string.Empty; presentAreaNavigation.NavigationTarget = NavigationTarget; if (!presentAreaNavigation.IsLocked) { presentAreaNavigation.IsEnabled = IsEnabled; } presentAreaNavigation.PresentAreaKey = PresentAreaKeysOfBuiltIn.UserSpace; if (NavigationType == NavigationType.AddedByOwner) { presentAreaNavigation.NavigationType = NavigationType.AddedByOwner; } presentAreaNavigation.OwnerId = UserContext.CurrentUser.UserId; Random rd=new Random(); string rdStr=null; for (int i = 0; i < 8; i++) { rdStr+=rd.Next(9).ToString(); } presentAreaNavigation.NavigationId = int.Parse(rdStr); return presentAreaNavigation; }
public ActionResult ChangePresentAreaNavigationOrder(string spaceKey, int fromId, int toId) { User user = userService.GetFullUser(spaceKey); if (user == null) return HttpNotFound(); PresentAreaNavigation fromPan = new NavigationService().GetPresentAreaNavigation(fromId); PresentAreaNavigation toPan = new NavigationService().GetPresentAreaNavigation(toId); int temp = fromPan.DisplayOrder; fromPan.DisplayOrder = toPan.DisplayOrder; new NavigationService().UpdatePresentAreaNavigation(fromPan); toPan.DisplayOrder = temp; new NavigationService().UpdatePresentAreaNavigation(toPan); return Json(new StatusMessageData(StatusMessageType.Success, "交换成功!")); }
//[HttpGet] public ActionResult _Menu_Manage(string spaceKey) { long topicId = TopicIdToTopicKeyDictionary.GetTopicId(spaceKey); TopicEntity topic = topicService.Get(topicId); if (topic == null) return Content(string.Empty); int currentNavigationId = RouteData.Values.Get<int>("CurrentNavigationId", 0); NavigationService navigationService = new NavigationService(); Navigation navigation = navigationService.GetNavigation(PresentAreaKeysOfExtension.TopicSpace, currentNavigationId, topic.TopicId); IEnumerable<Navigation> navigations = new List<Navigation>(); if (navigation != null) { if (navigation.Depth >= 1 && navigation.Parent != null) { navigations = navigation.Parent.Children; } else if (navigation.Depth == 0) { navigations = navigation.Children; } } ViewData["MemberApplyCount"] = topicService.GetMemberApplyCount(topic.TopicId); return View(navigations); }
public JsonResult SetPresentAreaNavigationTargetStatus(string spaceKey, int Id, string navigationTarget) { User user = userService.GetFullUser(spaceKey); if (user == null) return Json(new StatusMessageData(StatusMessageType.Error, "用户不存在!")); PresentAreaNavigation navigation = new NavigationService().GetPresentAreaNavigation(Id); if (navigation == null) return Json(new StatusMessageData(StatusMessageType.Error, "找不到导航!")); navigation.NavigationTarget = navigationTarget; new NavigationService().UpdatePresentAreaNavigation(navigation); return Json(new StatusMessageData(StatusMessageType.Success, "设置成功!")); }
/// <summary> /// 选择菜单控件 /// </summary> public ActionResult _SelectMenu(string spaceKey) { User user = userService.GetFullUser(spaceKey); if (user == null) return new EmptyResult(); ViewData["user"] = user; IEnumerable<Navigation> navigations = new NavigationService().GetRootNavigations(PresentAreaKeysOfBuiltIn.UserSpace, user.UserId); return View(navigations); }
public ActionResult _MyHomeNavigations(string spaceKey, bool showOperation = false) { User user = userService.GetFullUser(spaceKey); if (user == null) return HttpNotFound(); IEnumerable<ApplicationModel> apps = applicationService.GetAll(true); ViewData["MicroblogApplication"] = applicationService.Get("Microblog"); IEnumerable<Navigation> navigations = new NavigationService().GetRootNavigations(PresentAreaKeysOfBuiltIn.UserSpace, user.UserId); navigations = navigations.Where(n => n.ApplicationId == 0 || (apps != null && apps.Select(s => s.ApplicationId).Contains(n.ApplicationId))); ViewData["navigations"] = navigations; if (showOperation) { IEnumerable<ApplicationManagementOperation> operations = new ManagementOperationService().GetShortcuts(PresentAreaKeysOfBuiltIn.UserSpace, true); operations = operations.Where(n => n.ApplicationId == 0 || (apps != null && apps.Select(s => s.ApplicationId).Contains(n.ApplicationId))); ViewData["ApplicationManagementOperations"] = operations; ViewData["ShowOperation"] = showOperation; } ViewData["user"] = user; return View(); }
/// <summary> /// 专题空间主导航 /// </summary> /// <param name="spaceKey">专题空间标识</param> /// <returns></returns> //[HttpGet] public ActionResult _Menu_Main(string spaceKey) { long topicId = TopicIdToTopicKeyDictionary.GetTopicId(spaceKey); TopicEntity topic = topicService.Get(topicId); if (topic == null) return Content(string.Empty); ManagementOperationService managementOperationService = new ManagementOperationService(); ViewData["ApplicationManagementOperations"] = managementOperationService.GetShortcuts(PresentAreaKeysOfExtension.TopicSpace, false); NavigationService navigationService = new NavigationService(); return View(navigationService.GetRootNavigations(PresentAreaKeysOfExtension.TopicSpace, topic.TopicId)); }
/// <summary> /// 判断是否属于当前导航 /// </summary> /// <remarks> /// 单元测试用例,仅需测试NavigationService.GetCurrentNavigationPath() /// </remarks> /// <param name="currentNavigationId"></param> /// <returns></returns> public bool IsCurrent(int currentNavigationId) { NavigationService navigationService = new NavigationService(); IEnumerable<int> currentNavigationPath = navigationService.GetCurrentNavigationPath(this.PresentAreaKey, this.OwnerId, currentNavigationId); return currentNavigationPath.Contains(this.NavigationId) || NavigationId == currentNavigationId; }
public ActionResult _Menu_Manage(string spaceKey) { long groupId = GroupIdToGroupKeyDictionary.GetGroupId(spaceKey); GroupEntity group = groupService.Get(groupId); if (group == null) return Content(string.Empty); int currentNavigationId = RouteData.Values.Get<int>("CurrentNavigationId", 0); NavigationService navigationService = new NavigationService(); Navigation navigation = navigationService.GetNavigation(PresentAreaKeysOfBuiltIn.GroupSpace, currentNavigationId, group.GroupId); IEnumerable<Navigation> navigations = new List<Navigation>(); if (navigation != null) { if (navigation.Depth >= 1 && navigation.Parent != null) { navigations = navigation.Parent.Children; } else if (navigation.Depth == 0) { navigations = navigation.Children; } } ViewData["MemberApplyCount"] = groupService.GetMemberApplyCount(group.GroupId); return View(navigations); }
public ActionResult _Menu_App(string spaceKey) { long groupId = GroupIdToGroupKeyDictionary.GetGroupId(spaceKey); GroupEntity group = groupService.Get(groupId); if (group == null) return Content(string.Empty); int currentNavigationId = RouteData.Values.Get<int>("CurrentNavigationId", 0); NavigationService navigationService = new NavigationService(); Navigation navigation = navigationService.GetNavigation(PresentAreaKeysOfBuiltIn.GroupSpace, currentNavigationId, group.GroupId); IEnumerable<Navigation> navigations = new List<Navigation>(); if (navigation != null) { if (navigation.Depth >= 1 && navigation.Parent != null) { navigations = navigation.Parent.Children; } else if (navigation.Depth == 0) { navigations = navigation.Children; } ManagementOperationService managementOperationService = new ManagementOperationService(); IEnumerable<ApplicationManagementOperation> applicationManagementOperations = managementOperationService.GetShortcuts(PresentAreaKeysOfBuiltIn.GroupSpace, false); if (applicationManagementOperations != null) { ViewData["ApplicationManagementOperations"] = applicationManagementOperations.Where(n => n.ApplicationId == navigation.ApplicationId); } } return View(navigations); }
/// <summary> /// 创建编辑呈现区域导航(页面) /// </summary> public ActionResult _EditPresentAreaNavigation(string spaceKey, long? id) { User user = userService.GetFullUser(spaceKey); if (user == null) return HttpNotFound(); PresentAreaNavigationEditModel editModel = null; //创建 if (id == null) { editModel = new PresentAreaNavigationEditModel(); editModel.NavigationType = NavigationType.AddedByOwner; return View(editModel); } //编辑 else { PresentAreaNavigation model = new NavigationService().GetPresentAreaNavigation(id.Value); return View(model.AsPresentAreaNavigationEditModel()); } }
public ActionResult _Menu_Main(string spaceKey) { long groupId = GroupIdToGroupKeyDictionary.GetGroupId(spaceKey); GroupEntity group = groupService.Get(groupId); if (group == null) return Content(string.Empty); ManagementOperationService managementOperationService = new ManagementOperationService(); ViewData["ApplicationManagementOperations"] = managementOperationService.GetShortcuts(PresentAreaKeysOfBuiltIn.GroupSpace, false); NavigationService navigationService = new NavigationService(); return View(navigationService.GetRootNavigations(PresentAreaKeysOfBuiltIn.GroupSpace, group.GroupId)); }
public ActionResult _GroupMenu(string spaceKey) { long groupId = GroupIdToGroupKeyDictionary.GetGroupId(spaceKey); GroupEntity group = groupService.Get(groupId); if (group == null) return Content(string.Empty); int currentNavigationId = RouteData.Values.Get<int>("CurrentNavigationId", 0); IEnumerable<Navigation> navigations = new List<Navigation>(); NavigationService navigationService = new NavigationService(); Navigation navigation = navigationService.GetNavigation(PresentAreaKeysOfBuiltIn.GroupSpace, currentNavigationId, group.GroupId); if (navigation != null && navigation.Children.Count() > 0) { navigations = navigation.Children; } else { navigations = navigationService.GetRootNavigations(PresentAreaKeysOfBuiltIn.GroupSpace, group.GroupId); } return View(navigations); }