public ActionResult ManageUserCategories(string keyword, string tenantTypeId, AuditStatus?auditStatus = null, string ownerId = null, int pageIndex = 1, int pageSize = 20) { pageResourceManager.InsertTitlePart("用户类别管理"); //所属下拉框 SelectList tenants = GetTenantSelectList(MultiTenantServiceKeys.Instance().UserCategory(), tenantTypeId); ViewData["tenants"] = tenants; long userId = 0; if (!string.IsNullOrEmpty(ownerId)) { ownerId = ownerId.Trim(','); if (!string.IsNullOrEmpty(ownerId)) { userId = long.Parse(ownerId); } } PubliclyAuditStatus?publiclyAuditStatus = null; if (auditStatus != null) { publiclyAuditStatus = (PubliclyAuditStatus?)auditStatus; } CategoryService categoryService = new CategoryService(); PagingDataSet <Category> categorys = categoryService.GetOwnerCategories(publiclyAuditStatus, tenantTypeId, keyword, userId, pageSize, pageIndex); ViewData["userId"] = userId; return(View(categorys)); }
public ActionResult ManageComments(AuditStatus?auditStatus = null, string tenantTypeId = null, string userId = null, DateTime?startDate = null, DateTime?endDate = null, int pageSize = 20, int pageIndex = 1) { pageResourceManager.InsertTitlePart("评论管理"); long?userId2 = null; if (!string.IsNullOrEmpty(userId)) { userId = userId.Trim(','); if (!string.IsNullOrEmpty(userId)) { userId2 = long.Parse(userId); } } if (endDate.HasValue) { endDate = endDate.Value.AddDays(1); } ViewData["tenants"] = GetTenantSelectList(MultiTenantServiceKeys.Instance().Comment(), tenantTypeId); ViewData["userId"] = userId2; PagingDataSet <Comment> comments = commentService.GetComments((PubliclyAuditStatus?)auditStatus, tenantTypeId, userId2, startDate, endDate, pageSize, pageIndex); return(View(comments)); }
/// <summary> /// 删除垃圾数据 /// </summary> /// <param name="serviceKey">服务标识</param> public void DeleteTrashDatas() { IEnumerable <TenantType> tenantTypes = new TenantTypeService().Gets(MultiTenantServiceKeys.Instance().Tag()); List <Sql> sqls = new List <Sql>(); foreach (var tenantType in tenantTypes) { Type type = Type.GetType(tenantType.ClassType); if (type == null) { continue; } var pd = PetaPoco.Database.PocoData.ForType(type); if (tenantType.TenantTypeId == TenantTypeIds.Instance().User() || tenantType.TenantTypeId == TenantTypeIds.Instance().Group()) { sqls.Add(Sql.Builder.Append("delete from tn_TagsInOwners") .Where("not exists (select 1 from " + pd.TableInfo.TableName + " where OwnerId = " + pd.TableInfo.PrimaryKey + ") and TenantTypeId = @0" , tenantType.TenantTypeId)); } else { sqls.Add(Sql.Builder.Append("delete from tn_ItemsInTags") .Where("not exists (select 1 from " + pd.TableInfo.TableName + " where ItemId = " + pd.TableInfo.PrimaryKey + ") and TenantTypeId = @0" , tenantType.TenantTypeId)); } } CreateDAO().Execute(sqls); }
public ActionResult ManageSiteCategories(string tenantTypeId) { IUser currentUser = UserContext.CurrentUser; if (currentUser == null) { return(HttpNotFound()); } var authorizer = DIContainer.Resolve <Authorizer>(); pageResourceManager.InsertTitlePart("站点类别管理"); List <TenantType> managedTenantTypes = new List <TenantType>(); IEnumerable <TenantType> allTenantTypes = tenantTypeService.Gets(MultiTenantServiceKeys.Instance().SiteCategory()); foreach (var tenantType in allTenantTypes) { if (authorizer.IsAdministrator(tenantType.ApplicationId)) { managedTenantTypes.Add(tenantType); } } SelectList tenantList = new SelectList(managedTenantTypes.Select(n => new { text = n.Name, value = n.TenantTypeId }), "value", "text", tenantTypeId); if (string.IsNullOrEmpty(tenantTypeId)) { tenantTypeId = tenantList.First().Value; } IEnumerable <Category> categorys = categoryService.GetOwnerCategories(0, tenantTypeId); ViewData["tenantList"] = tenantList; ViewData["tenantTypeId"] = tenantTypeId; return(View(categorys)); }
public ActionResult ManageTags(string keyword, string tenantTypeId, bool?isFeatured, AuditStatus?auditStatus = null, int pageIndex = 1, int pageSize = 20) { pageResourceManager.InsertTitlePart("标签管理"); TagService tagService = new TagService(tenantTypeId); PubliclyAuditStatus?publiclyAuditStatus = null; if (auditStatus != null) { publiclyAuditStatus = (PubliclyAuditStatus?)auditStatus; } TagQuery tagQuery = new TagQuery(); tagQuery.PubliclyAuditStatus = publiclyAuditStatus; tagQuery.Keyword = keyword; tagQuery.TenantTypeId = tenantTypeId; if (isFeatured.HasValue) { tagQuery.IsFeatured = isFeatured.Value; } PagingDataSet <Tag> tags = tagService.GetTags(tagQuery, pageIndex, pageSize); AuthorizationService authorizationService = new AuthorizationService(); //所属下拉框 List <TenantType> tenantTypesList = tenantTypeService.Gets(MultiTenantServiceKeys.Instance().Tag()).ToList <TenantType>(); List <TenantType> newTenantTypesList = new List <TenantType>(); if (UserContext.CurrentUser.IsInRoles(RoleNames.Instance().SuperAdministrator(), RoleNames.Instance().ContentAdministrator())) { newTenantTypesList.Insert(0, new TenantType { ApplicationId = 0, Name = "不限", TenantTypeId = "" }); newTenantTypesList.AddRange(tenantTypesList); } else { foreach (var item in tenantTypesList) { if (new AuthorizationService().IsApplicationManager(UserContext.CurrentUser, item.ApplicationId)) { newTenantTypesList.Add(item); } } } SelectList tenants = new SelectList(newTenantTypesList.Select(n => new { text = n.Name, value = n.TenantTypeId }), "value", "text", tenantTypeId); ViewData["tenants"] = tenants; //所属名称 Dictionary <string, string> tenantsDictionary = tenantTypesList.ToDictionary(n => n.TenantTypeId, n => n.Name); ViewData["tenantsDictionary"] = tenantsDictionary; return(View(tags)); }
public ActionResult EditTag(long tagId = 0) { TagService tagService = new TagService(string.Empty); TagEditModel tagEditModel = null; //创建 if (tagId == 0) { tagEditModel = new TagEditModel(); ViewData["seletedTagNames"] = new List <string>(); //所属租户类型下拉框 SelectList tenants = GetTenantSelectList(MultiTenantServiceKeys.Instance().Tag(), null); ViewData["tenants"] = tenants; //标签分组下拉框 SelectList tagGroups = GetTagGroupSelectList(0, tenants.First().Value); ViewData["tagGroups"] = tagGroups; ViewData["editTagTitle"] = "创建标签"; pageResourceManager.InsertTitlePart("添加标签"); }//编辑 else { Tag tag = tagService.Get(tagId); tagEditModel = tag.AsTagEditModel(); //所属租户类型下拉框 SelectList tenants = GetTenantSelectList(MultiTenantServiceKeys.Instance().Tag(), tagEditModel.TenantTypeId); ViewData["tenants"] = tenants; //标签分组下拉框 SelectList tagGroups = GetTagGroupSelectList(tagEditModel.GroupId, tagEditModel.TenantTypeId); ViewData["tagGroups"] = tagGroups; //取相关标签 IEnumerable <string> seletedTagNames = tagService.GetRelatedTags(tagId).Select(n => n.TagName); ViewData["seletedTagNames"] = seletedTagNames; ViewData["editTagTitle"] = "编辑标签"; pageResourceManager.InsertTitlePart("编辑标签"); } return(View(tagEditModel)); }
/// <summary> /// 日志管理 /// </summary> /// <param name="auditStatus">审批状态</param> /// <param name="categoryId">日志类别id</param> /// <param name="subjectKeywords">标题关键字</param> /// <param name="isEssential">是否加精</param> /// <param name="userId">作者id</param> /// <param name="pageSize">分页大小</param> /// <param name="pageIndex">页码</param> public ActionResult ManageBlogs(AuditStatus?auditStatus = null, long?categoryId = null, string subjectKeywords = null, bool?isEssential = null, string userId = null, string tenantTypeId = null, int pageSize = 20, int pageIndex = 1) { long?blogUserId = null; if (!string.IsNullOrEmpty(userId)) { userId = userId.Trim(','); if (!string.IsNullOrEmpty(userId)) { blogUserId = long.Parse(userId); } } //获取类别 IEnumerable <Category> categorys = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().BlogThread()); SelectList categoryList = new SelectList(categorys.Select(n => new { text = n.CategoryName, value = n.CategoryId }), "value", "text", categoryId); ViewData["categoryList"] = categoryList; //组装是否加精 List <SelectListItem> selectListIsEssential = new List <SelectListItem> { new SelectListItem { Text = "是", Value = true.ToString() }, new SelectListItem { Text = "否", Value = false.ToString() } }; ViewData["isEssential"] = new SelectList(selectListIsEssential, "Value", "Text", isEssential); ViewData["userId"] = blogUserId; //获取租户类型 IEnumerable <TenantType> tenantTypes = tenantTypeService.Gets(MultiTenantServiceKeys.Instance().Blog()); SelectList tenants = null; tenants = new SelectList(tenantTypes.Select(n => new { text = n.Name, value = n.TenantTypeId }), "value", "text", tenantTypeId); ViewData["tenants"] = tenants; ViewData["tenantscount"] = tenantTypes.Count(); PagingDataSet <BlogThread> blogs = blogService.GetsForAdmin(null, auditStatus, categoryId, isEssential, blogUserId, subjectKeywords, pageSize, pageIndex); pageResourceManager.InsertTitlePart("日志管理"); return(View(blogs)); }
public ActionResult ManageTagGroups(string tenantTypeId = "") { pageResourceManager.InsertTitlePart("标签分组管理"); TagService tagService = new TagService(tenantTypeId); IEnumerable <TagGroup> tagGroups = tagService.GetGroups(tenantTypeId); //所属下拉框 SelectList tenants = GetTenantSelectList(MultiTenantServiceKeys.Instance().Tag(), tenantTypeId); ViewData["tenants"] = tenants; //所属名称 Dictionary <string, string> tenantsDictionary = tenants.ToDictionary(n => n.Value, n => n.Text); ViewData["tenantsDictionary"] = tenantsDictionary; return(View(tagGroups)); }
public ActionResult _EditTag(long tagId = 0) { TagService tagService = new TagService(string.Empty); TagEditModel tagEditModel = null; Tag tag = null; //创建 if (tagId == 0) { tag = Tag.New(); tagEditModel = tag.AsTagEditModel();// new TagEditModel(); ViewData["seletedTagNames"] = new List <string>(); //所属租户类型下拉框 SelectList tenants = GetTenantSelectList(MultiTenantServiceKeys.Instance().Tag(), null, true); ViewData["tenants"] = tenants; //标签分组下拉框 SelectList tagGroups = GetTagGroupSelectList(0, tenants.First().Value); ViewData["tagGroups"] = tagGroups; }//编辑 else { tag = tagService.Get(tagId); tagEditModel = tag.AsTagEditModel(); var tenantType = tenantTypeService.Get(tagEditModel.TenantTypeId); if (tenantType != null) { ViewData["tenantTypeName"] = tenantType.Name; } //标签分组下拉框 SelectList tagGroups = GetTagGroupSelectList(tagEditModel.GroupId, tagEditModel.TenantTypeId); ViewData["tagGroups"] = tagGroups; //取相关标签 IEnumerable <string> seletedTagNames = tagService.GetRelatedTags(tagId).Select(n => n.TagName); ViewData["seletedTagNames"] = seletedTagNames; } return(View(tagEditModel)); }
public ActionResult ManageTags(string keyword, string tenantTypeId, bool?isFeatured, AuditStatus?auditStatus = null, int pageIndex = 1, int pageSize = 20) { pageResourceManager.InsertTitlePart("标签管理"); TagService tagService = new TagService(tenantTypeId); PubliclyAuditStatus?publiclyAuditStatus = null; if (auditStatus != null) { publiclyAuditStatus = (PubliclyAuditStatus?)auditStatus; } TagQuery tagQuery = new TagQuery(); tagQuery.PubliclyAuditStatus = publiclyAuditStatus; tagQuery.Keyword = keyword; tagQuery.TenantTypeId = tenantTypeId; if (isFeatured.HasValue) { tagQuery.IsFeatured = isFeatured.Value; } PagingDataSet <Tag> tags = tagService.GetTags(tagQuery, pageIndex, pageSize); //所属下拉框 List <TenantType> tenantTypesList = tenantTypeService.Gets(MultiTenantServiceKeys.Instance().Tag()).ToList <TenantType>(); tenantTypesList.Insert(0, new TenantType { ApplicationId = 0, Name = "不限", TenantTypeId = "" }); SelectList tenants = new SelectList(tenantTypesList.Select(n => new { text = n.Name, value = n.TenantTypeId }), "value", "text", tenantTypeId); ViewData["tenants"] = tenants; //所属名称 Dictionary <string, string> tenantsDictionary = tenantTypesList.ToDictionary(n => n.TenantTypeId, n => n.Name); ViewData["tenantsDictionary"] = tenantsDictionary; return(View(tags)); }
/// <summary> /// 删除垃圾数据 /// </summary> public void DeleteTrashDatas() { IEnumerable <TenantType> tenantTypes = new TenantTypeService().Gets(MultiTenantServiceKeys.Instance().Recommend()); List <Sql> sqls = new List <Sql>(); foreach (var tenantType in tenantTypes) { Type type = Type.GetType(tenantType.ClassType); if (type == null) { continue; } var pd = TableInfo.FromPoco(type); sqls.Add(Sql.Builder.Append("delete from tn_RecommendItems") .Where("not exists (select 1 from " + pd.TableName + " where ItemId = " + pd.PrimaryKey + ") and TenantTypeId = @0" , tenantType.TenantTypeId)); } CreateDAO().Execute(sqls); }
/// <summary> /// 删除垃圾数据 /// </summary> public void DeleteTrashDatas() { IEnumerable <TenantType> tenantTypes = new TenantTypeService().Gets(MultiTenantServiceKeys.Instance().Comment()); List <Sql> sqls = new List <Sql>(); sqls.Add(Sql.Builder.Append("delete from tn_Comments where not exists (select 1 from tn_Users where UserId = tn_Comments.UserId)")); foreach (var tenantType in tenantTypes) { Type type = Type.GetType(tenantType.ClassType); if (type == null) { continue; } var pd = PetaPoco.Database.PocoData.ForType(type); sqls.Add(Sql.Builder.Append("delete from tn_Comments") .Where("not exists (select 1 from " + pd.TableInfo.TableName + " where CommentedObjectId = " + pd.TableInfo.PrimaryKey + ") and TenantTypeId = @0" , tenantType.TenantTypeId)); } CreateDAO().Execute(sqls); }
public ActionResult _EditTagGroup(long tagGroupId = 0, string tenantTypeId = "") { TagGroupEditModel tagGroupEditModel = null; //添加 if (tagGroupId == 0) { tagGroupEditModel = new TagGroupEditModel(); tagGroupEditModel.TenantTypeId = tenantTypeId; }//编辑 else { TagService tagService = new TagService(string.Empty); tagGroupEditModel = tagService.GetGroup(tagGroupId).AsTagGroupEditModel(); } //所属下拉框 SelectList tenants = GetTenantSelectList(MultiTenantServiceKeys.Instance().Tag(), tagGroupEditModel.TenantTypeId, true); ViewData["tenants"] = tenants; return(View(tagGroupEditModel)); }
public ActionResult EditTag(TagEditModel tagEditModel) { System.IO.Stream stream = null; //是否创建 bool isCreate = tagEditModel.TagId == 0; if (isCreate) { ViewData["editTagTitle"] = "创建标签"; } else { ViewData["editTagTitle"] = "编辑标签"; } TagService tagService = new TagService(tagEditModel.TenantTypeId); //是特色标签 if (tagEditModel.IsFeatured) { HttpPostedFileBase tagLogo = Request.Files["tagLogo"]; string fileName = tagLogo == null ? "" : tagLogo.FileName; if (string.IsNullOrEmpty(fileName) && string.IsNullOrEmpty(tagEditModel.FeaturedImage)) { //所属租户类型下拉框 SelectList tenants = GetTenantSelectList(MultiTenantServiceKeys.Instance().Tag(), tagEditModel.TenantTypeId); ViewData["tenants"] = tenants; //标签分组下拉框 SelectList tagGroups = GetTagGroupSelectList(tagEditModel.GroupId, tagEditModel.TenantTypeId); ViewData["tagGroups"] = tagGroups; //取到用户设置的相关标签 ViewData["seletedTagNames"] = tagEditModel.RelatedTags[1].Split(',').ToList <string>(); ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "图片不能为空"); return(View(tagEditModel)); } else if (!string.IsNullOrEmpty(fileName)) { //校验附件的扩展名 ILogoSettingsManager logoSettingsManager = DIContainer.Resolve <ILogoSettingsManager>(); if (!logoSettingsManager.Get().ValidateFileExtensions(fileName)) { //所属租户类型下拉框 SelectList tenants = GetTenantSelectList(MultiTenantServiceKeys.Instance().Tag(), tagEditModel.TenantTypeId); ViewData["tenants"] = tenants; //标签分组下拉框 SelectList tagGroups = GetTagGroupSelectList(tagEditModel.GroupId, tagEditModel.TenantTypeId); ViewData["tagGroups"] = tagGroups; //取到用户设置的相关标签 ViewData["seletedTagNames"] = tagEditModel.RelatedTags[1].Split(',').ToList <string>(); ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "只允许上传后缀名为 .gif .jpg .jpeg .png 的文件"); return(View(tagEditModel)); } //校验附件的大小 TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().Tag()); if (!tenantLogoSettings.ValidateFileLength(tagLogo.ContentLength)) { //所属租户类型下拉框 SelectList tenants = GetTenantSelectList(MultiTenantServiceKeys.Instance().Tag(), tagEditModel.TenantTypeId); ViewData["tenants"] = tenants; //标签分组下拉框 SelectList tagGroups = GetTagGroupSelectList(tagEditModel.GroupId, tagEditModel.TenantTypeId); ViewData["tagGroups"] = tagGroups; //取到用户设置的相关标签 ViewData["seletedTagNames"] = tagEditModel.RelatedTags[1].Split(',').ToList <string>(); ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}KB", tenantLogoSettings.MaxLogoLength)); return(View(tagEditModel)); } stream = tagLogo.InputStream; tagEditModel.FeaturedImage = fileName; } } //获取相关标签 string relatedTags = tagEditModel.RelatedTags[1]; //创建 if (isCreate) { Tag tag = tagEditModel.AsTag(); tagService.Create(tag, stream); //添加到分组 if (tagEditModel.GroupId > 0) { tagService.BatchAddGroupsToTag(new List <long>() { tagEditModel.GroupId }, tagEditModel.TagName); } //创建相关标签 if (!string.IsNullOrEmpty(relatedTags)) { tagService.AddRelatedTagsToTag(relatedTags, 0, tag.TagId); } }//更新 else { Tag tag = tagEditModel.AsTag(); tagService.Update(tag, stream); //添加到分组 if (tagEditModel.GroupId > 0) { tagService.BatchAddGroupsToTag(new List <long>() { tagEditModel.GroupId }, tagEditModel.TagName); } //创建相关标签 if (!string.IsNullOrEmpty(relatedTags)) { tagService.ClearRelatedTagsFromTag(tagEditModel.TagId); tagService.AddRelatedTagsToTag(relatedTags, 0, tagEditModel.TagId); } } return(RedirectToAction("ManageTags")); }