public ActionResult MyHome(string spaceKey) { User user = userService.GetFullUser(spaceKey); ViewData["user"] = user; IUser currentUser = UserContext.CurrentUser; if (currentUser == null || currentUser.UserId != user.UserId) { return RedirectToAction("SpaceHome"); } #region 显示用户资料向导 int integrity = 0; if (user.Profile != null) { integrity = user.Profile.Integrity; } UserProfileSettings userProfileSetting = new UserProfileSettings(); if (integrity < userProfileSetting.MinIntegrity && !user.Profile.IsNeedGuide) { //读取Cookie,判断是否显示用户资料向导 HttpCookie GuideDisplayed = Request.Cookies.Get("GuideDisplayed"); if (GuideDisplayed == null) { GuideDisplayed = new HttpCookie("GuideDisplayed", "true"); GuideDisplayed.Expires = DateTime.Now.Date.AddDays(1); GuideDisplayed.HttpOnly = true; Response.Cookies.Add(GuideDisplayed); return RedirectToAction("UserProfileGuideAvatar", "UserSpaceSettings"); } } ViewData["integrity"] = integrity; #endregion #region Title pageResourceManager.InsertTitlePart("我的首页"); ViewBag.Title = user.DisplayName + "的首页"; #endregion #region 分组栏 List<Category> categoriesShow = null;//前三个分组 List<Category> categoriesMore = null;//更多分组 IEnumerable<Category> categories = categoryService.GetOwnerCategories(user.UserId, TenantTypeIds.Instance().User()); if (categories != null) { categoriesShow = categories.Take(3).ToList(); categoriesMore = categories.Skip(3).ToList(); } ViewData["categoriesShow"] = categoriesShow; if (categoriesMore != null && categoriesMore.Count > 0) ViewData["menuItem"] = categoriesMore.Select(n => new MenuItem { Text = n.CategoryName, Value = n.CategoryId.ToString(), Url = SiteUrls.Instance()._MyTimeline(Url.SpaceKey(), n.CategoryId) }); #endregion #region 导航&应用 NavigationService service = DIContainer.Resolve<NavigationService>(); ViewData["applications"] = applicationService.GetAll(true); IEnumerable<ApplicationModel> apps = applicationService.GetAll(true); IEnumerable<PresentAreaNavigation> navigations = service.GetRootPresentAreaNavigations(PresentAreaKeysOfBuiltIn.UserSpace, user.UserId); if (navigations != null && apps != null) { ViewData["navigations"] = navigations .ToDictionary(v => v, k => { var app = apps.FirstOrDefault(n => k.ApplicationId == n.ApplicationId); if (app != null) return app.ApplicationKey; return string.Empty; }); } #endregion #region 气泡 //获取内容数的链接 string tenantTypeId = TenantTypeIds.Instance().User(); Dictionary<int, List<OwnerStatisticData>> OwnerStatisticDataDictionary = new Dictionary<int, List<OwnerStatisticData>>(); Dictionary<int, string> dictionary = new Dictionary<int, string>(); IEnumerable<string> dataKeys = OwnerDataSettings.GetDataKeys(tenantTypeId); IEnumerable<ApplicationBase> applicationBase = applicationService.GetInstalledApplicationsOfOwner(PresentAreaKeysOfBuiltIn.UserSpace, user.UserId); foreach (var application in applicationBase) { var applicationDataKeys = dataKeys.Where(n => n.StartsWith(application.ApplicationKey)); var ownerStatisticDataList = new List<OwnerStatisticData>(); foreach (var dataKey in applicationDataKeys) { OwnerStatisticData ownerStatisticData = new OwnerStatisticData(); IOwnerDataGetter dataGetter = OwnerDataGetterFactory.Get(dataKey); if (dataGetter != null) { ownerStatisticData.DataName = dataGetter.DataName; ownerStatisticData.DataUrl = dataGetter.GetDataUrl(spaceKey, user.UserId); ownerStatisticData.ContentCount = new OwnerDataService(TenantTypeIds.Instance().User()).GetLong(user.UserId, dataKey); ownerStatisticDataList.Add(ownerStatisticData); } } dictionary[application.ApplicationId] = application.Config.ApplicationName; OwnerStatisticDataDictionary[application.ApplicationId] = ownerStatisticDataList; } ViewData["OwnerStatisticDataDictionary"] = OwnerStatisticDataDictionary; ViewData["dictionary"] = dictionary; ViewData["applicationBase"] = applicationBase.Where(n => n.IsEnabled).ToList(); #endregion return View(); }
/// <summary> /// 用户内容数的气泡 /// </summary> /// <param name="spaceKey"></param> /// <returns></returns> public ActionResult _ContentPop(string spaceKey) { User user = userService.GetFullUser(spaceKey); if (user == null) return HttpNotFound(); IUser currentUser = UserContext.CurrentUser; //获取内容数的链接 string tenantTypeId = TenantTypeIds.Instance().User(); Dictionary<int, List<OwnerStatisticData>> OwnerStatisticDataDictionary = new Dictionary<int, List<OwnerStatisticData>>(); Dictionary<int, string> dictionary = new Dictionary<int, string>(); IEnumerable<string> dataKeys = OwnerDataSettings.GetDataKeys(tenantTypeId); IEnumerable<ApplicationBase> applicationBase = applicationService.GetInstalledApplicationsOfOwner(PresentAreaKeysOfBuiltIn.UserSpace, user.UserId).Where(n => n.ApplicationKey != "PointMall"); foreach (var application in applicationBase) { var applicationDataKeys = dataKeys.Where(n => n.StartsWith(application.ApplicationKey)); var ownerStatisticDataList = new List<OwnerStatisticData>(); foreach (var dataKey in applicationDataKeys) { OwnerStatisticData ownerStatisticData = new OwnerStatisticData(); IOwnerDataGetter dataGetter = OwnerDataGetterFactory.Get(dataKey); if (dataGetter != null) { ownerStatisticData.DataName = dataGetter.DataName; ownerStatisticData.DataUrl = dataGetter.GetDataUrl(spaceKey, user.UserId); ownerStatisticData.ContentCount = new OwnerDataService(TenantTypeIds.Instance().User()).GetLong(user.UserId, dataKey); ownerStatisticDataList.Add(ownerStatisticData); } } dictionary[application.ApplicationId] = application.Config.ApplicationName; OwnerStatisticDataDictionary[application.ApplicationId] = ownerStatisticDataList; } ViewData["OwnerStatisticDataDictionary"] = OwnerStatisticDataDictionary; ViewData["dictionary"] = dictionary; ViewData["applicationBase"] = applicationBase.Where(n => n.IsEnabled).ToList(); return View(user); }