예제 #1
0
        /// <summary>
        /// 标签显示群组列表
        /// </summary>
        public ActionResult ListByTag(string tagName, SortBy_Group sortBy = SortBy_Group.DateCreated_Desc, int pageIndex = 1)
        {
            tagName = WebUtility.UrlDecode(tagName);
            var tag = new TagService(TenantTypeIds.Instance().Group()).Get(tagName);

            if (tag == null)
            {
                return HttpNotFound();
            }

            PagingDataSet<GroupEntity> groups = groupService.GetsByTag(tagName, sortBy, pageIndex: pageIndex);
            pageResourceManager.InsertTitlePart(tagName);
            ViewData["tag"] = tag;
            ViewData["sortBy"] = sortBy;
            return View(groups);
        }
예제 #2
0
        /// <summary>
        /// 群组地区导航内容块
        /// </summary>
        /// <returns></returns>
        public ActionResult _AreaGroups(int topNumber, string areaCode, long? categoryId, SortBy_Group sortBy = SortBy_Group.DateCreated_Desc)
        {
            IUser iUser = (User)UserContext.CurrentUser;
            User user = null;
            if (iUser == null)
            {
                user = new User();
            }
            else
            {
                user = userService.GetFullUser(iUser.UserId);
            }
            if (string.IsNullOrEmpty(areaCode) && Request.Cookies["AreaGroupCookie" + user.UserId] != null && !string.IsNullOrEmpty(Request.Cookies["AreaGroupCookie" + user.UserId].Value))
                areaCode = Request.Cookies["AreaGroupCookie" + user.UserId].Value;

            if (string.IsNullOrEmpty(areaCode))
            {
                string ip = WebUtility.GetIP();
                areaCode = IPSeeker.Instance().GetAreaCode(ip);
                if (string.IsNullOrEmpty(areaCode) && user.Profile != null)
                {
                    areaCode = user.Profile.NowAreaCode;
                }
            }
            ViewData["areaCode"] = areaCode;
            if (!string.IsNullOrEmpty(areaCode))
            {
                Area area = areaService.Get(areaCode);
                if (!string.IsNullOrEmpty(area.ParentCode))
                {
                    Area parentArea = areaService.Get(area.ParentCode);
                    ViewData["parentCode"] = parentArea.AreaCode;
                }
            }

            IEnumerable<GroupEntity> groups = groupService.GetTops(topNumber, areaCode, categoryId, sortBy);

            HttpCookie cookie = new HttpCookie("AreaGroupCookie" + user.UserId, areaCode);
            Response.Cookies.Add(cookie);

            return PartialView(groups);
        }
예제 #3
0
        public ActionResult _TopGroups(int topNumber, string areaCode, long? categoryId, SortBy_Group? sortBy, string viewName = "_TopGroups_List")
        {
            var groups = groupService.GetTops(topNumber, areaCode, categoryId, sortBy ?? SortBy_Group.DateCreated_Desc);

            ViewData["SortBy"] = sortBy;
            return PartialView(viewName, groups);
        }
예제 #4
0
        /// <summary>
        /// 发现群组
        /// </summary>
        /// <returns></returns>
        public ActionResult FindGroup(string nameKeyword, string areaCode, long? categoryId, SortBy_Group? sortBy, int pageIndex = 1)
        {
            nameKeyword = WebUtility.UrlDecode(nameKeyword);
            string pageTitle = string.Empty;
            IEnumerable<Category> childCategories = null;
            if (categoryId.HasValue && categoryId.Value > 0)
            {
                var category = categoryService.Get(categoryId.Value);
                if (category != null)
                {

                    if (category.ChildCount > 0)
                    {
                        childCategories = category.Children;
                    }
                    else//若是叶子节点,则取同辈分类
                    {
                        if (category.Parent != null)
                            childCategories = category.Parent.Children;
                    }
                    List<Category> allParentCategories = new List<Category>();
                    //递归获取所有父级类别,若不是叶子节点,则包含其自身
                    RecursiveGetAllParentCategories(category.ChildCount > 0 ? category : category.Parent, ref allParentCategories);
                    ViewData["allParentCategories"] = allParentCategories;
                    ViewData["currentCategory"] = category;
                    pageTitle = category.CategoryName;
                }
            }

            if (childCategories == null)
                childCategories = categoryService.GetRootCategories(TenantTypeIds.Instance().Group());

            ViewData["childCategories"] = childCategories;

            AreaSettings areaSettings = DIContainer.Resolve<ISettingsManager<AreaSettings>>().Get();
            IEnumerable<Area> childArea = null;
            if (!string.IsNullOrEmpty(areaCode))
            {
                var area = areaService.Get(areaCode);
                if (area != null)
                {

                    if (area.ChildCount > 0)
                    {
                        childArea = area.Children;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(area.ParentCode))
                        {
                            var parentArea = areaService.Get(area.ParentCode);
                            if (parentArea != null)
                                childArea = parentArea.Children;
                        }
                    }
                }
                List<Area> allParentAreas = new List<Area>();
                RecursiveGetAllParentArea(area.ChildCount > 0 ? area : areaService.Get(area.ParentCode), areaSettings.RootAreaCode, ref allParentAreas);
                ViewData["allParentAreas"] = allParentAreas;
                ViewData["currentArea"] = area;
                if (!string.IsNullOrEmpty(pageTitle))
                    pageTitle += ",";
                pageTitle += area.Name;
            }

            if (childArea == null)
            {
                Area rootArea = areaService.Get(areaSettings.RootAreaCode);
                if (rootArea != null)
                    childArea = rootArea.Children;
                else
                    childArea = areaService.GetRoots();
            }

            ViewData["childArea"] = childArea;

            if (!string.IsNullOrEmpty(nameKeyword))
            {
                if (!string.IsNullOrEmpty(pageTitle))
                    pageTitle += ",";
                pageTitle += nameKeyword;
            }

            if (string.IsNullOrEmpty(pageTitle))
                pageTitle = "发现群组";
            pageResourceManager.InsertTitlePart(pageTitle);
            PagingDataSet<GroupEntity> groups = groupService.Gets(areaCode, categoryId, sortBy ?? SortBy_Group.DateCreated_Desc, pageIndex: pageIndex);
            if (Request.IsAjaxRequest())
            {
                return PartialView("_List", groups);
            }

            return View(groups);
        }
예제 #5
0
파일: SiteUrls.cs 프로젝트: hbulzy/SYS
 /// <summary>
 /// 标签下的群组
 /// </summary>
 /// <param name="siteUrls"></param>
 /// <param name="tagName"></param>
 /// <param name="sortBy"></param>
 /// <returns></returns>
 public static string ListByTag(this SiteUrls siteUrls, string tagName, SortBy_Group? sortBy = null)
 {
     RouteValueDictionary routeValueDictionary = new RouteValueDictionary();
     if (sortBy.HasValue)
     {
         routeValueDictionary.Add("sortBy", sortBy);
     }
     routeValueDictionary.Add("tagName", tagName);
     return CachedUrlHelper.Action("ListByTag", "ChannelGroup", GroupAreaName, routeValueDictionary);
 }
예제 #6
0
파일: SiteUrls.cs 프로젝트: hbulzy/SYS
 /// <summary>
 /// 群组地区导航内容块
 /// </summary>
 /// <returns></returns>
 public static string _AreaGroups(this SiteUrls siteUrls, long topNumber = 5, string areaCode = null, long? categoryId = null, SortBy_Group? sortBy = null)
 {
     RouteValueDictionary routeValueDictionary = new RouteValueDictionary();
     if (!string.IsNullOrEmpty(areaCode))
         routeValueDictionary.Add("areaCode", areaCode);
     if (categoryId.HasValue && categoryId.Value > 0)
         routeValueDictionary.Add("categoryId", categoryId);
     if (sortBy.HasValue)
         routeValueDictionary.Add("sortBy", sortBy);
     if (topNumber != 0)
     {
         routeValueDictionary.Add("topNumber", topNumber);
     }
     return CachedUrlHelper.Action("_AreaGroups", "ChannelGroup", GroupAreaName, routeValueDictionary);
 }
예제 #7
0
파일: SiteUrls.cs 프로젝트: hbulzy/SYS
 /// <summary>
 /// 发现群组
 /// </summary>
 /// <param name="siteUrls"></param>
 /// <param name="nameKeyword"></param>
 /// <param name="areaCode"></param>
 /// <param name="categoryId"></param>
 /// <param name="sortBy"></param>
 /// <returns></returns>
 public static string FindGroup(this SiteUrls siteUrls, string areaCode = null, long? categoryId = null, SortBy_Group? sortBy = null, string nameKeyword = null)
 {
     RouteValueDictionary routeValueDictionary = new RouteValueDictionary();
     if (!string.IsNullOrEmpty(areaCode))
         routeValueDictionary.Add("areaCode", areaCode);
     if (categoryId.HasValue && categoryId.Value > 0)
         routeValueDictionary.Add("categoryId", categoryId);
     if (sortBy.HasValue)
         routeValueDictionary.Add("sortBy", sortBy);
     if (!string.IsNullOrEmpty(nameKeyword))
         routeValueDictionary.Add("nameKeyword", WebUtility.UrlEncode(nameKeyword));
     return CachedUrlHelper.Action("FindGroup", "ChannelGroup", GroupAreaName, routeValueDictionary);
 }
 /// <summary>
 /// 根据标签名获取群组分页集合
 /// </summary>
 /// <param name="tagName">标签名</param></param>
 /// <param name="sortBy">排序依据</param>
 /// <param name="pageSize">每页记录数</param>
 /// <param name="pageIndex">页码</param>
 /// <returns>分页列表</returns>
 public PagingDataSet<GroupEntity> GetsByTag(string tagName, SortBy_Group sortBy, int pageSize = 20, int pageIndex = 1)
 {
     //无需维护缓存即时性
     return groupRepository.GetsByTag(tagName, sortBy, pageSize, pageIndex);
 }
 /// <summary>
 /// 分页获取排行数据
 /// </summary>
 /// <param name="areaCode">地区代码</param>
 /// <param name="categoryId">类别Id</param>
 /// <param name="sortBy">排序字段</param>
 /// <param name="pageSize">每页记录数</param>
 /// <param name="pageIndex">页码</param>
 /// <returns></returns>
 public PagingDataSet<GroupEntity> Gets(string areaCode, long? categoryId, SortBy_Group sortBy, int pageSize = 20, int pageIndex = 1)
 {
     //无需维护缓存即时性
     return groupRepository.Gets(areaCode, categoryId, sortBy, pageSize, pageIndex);
 }
예제 #10
0
 /// <summary>
 /// 获取匹配的前N个排行群组
 /// </summary>
 /// <param name="topNumber">前多少个</param>
 /// <param name="areaCode">地区代码</param>
 /// <param name="categoryId">类别Id</param>
 /// <param name="sortBy">排序字段</param>
 /// <returns></returns>
 public IEnumerable<GroupEntity> GetMatchTops(int topNumber, string keyword, string areaCode, long? categoryId, SortBy_Group sortBy)
 {
     return groupRepository.GetMatchTops(topNumber, keyword, areaCode, categoryId, sortBy);
 }
예제 #11
0
 /// <summary>
 /// 获取前N个排行群组
 /// </summary>
 /// <param name="topNumber">前多少个</param>
 /// <param name="areaCode">地区代码</param>
 /// <param name="categoryId">类别Id</param>
 /// <param name="sortBy">排序字段</param>
 /// <returns></returns>
 public IEnumerable<GroupEntity> GetTops(int topNumber, string areaCode, long? categoryId, SortBy_Group sortBy)
 {
     //设计要点
     //1、查询areaCode时需要包含后代地区;
     //2、查询categoryId时需要包含后代类别;
     //3、无需维护缓存即时性
     return groupRepository.GetTops(topNumber, areaCode, categoryId, sortBy);
 }