예제 #1
0
        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));
        }
        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 EditTopic(TagEditModel tagEditModel)
        {
            System.IO.Stream stream = null;

            //是否创建
            bool isCreate = tagEditModel.TagId == 0;

            if (isCreate)
            {
                ViewData["editTopicTitle"] = "创建话题";
            }
            else
            {
                ViewData["editTopicTitle"] = "编辑话题";
            }

            TagService tagService = new TagService(tagEditModel.TenantTypeId);
            IEnumerable<long> userIds = Request.Form.Gets<long>("RelatedObjectIds");
            //是特色标签
            if (tagEditModel.IsFeatured)
            {

                HttpPostedFileBase tagLogo = Request.Files["tagLogo"];
                string fileName = tagLogo == null ? "" : tagLogo.FileName;
                if (string.IsNullOrEmpty(fileName) && string.IsNullOrEmpty(tagEditModel.FeaturedImage))
                {

                    //标签分组下拉框
                    SelectList topicGroups = GetTagGroupSelectList(tagEditModel.TopicGroupId, tagEditModel.TenantTypeId);
                    ViewData["topicGroups"] = topicGroups;

                    //取到用户设置的相关标签
                    ViewData["seletedUserIds"] = userIds;

                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "图片不能为空");

                    return View(tagEditModel);
                }
                else if (!string.IsNullOrEmpty(fileName))
                {
                    //校验附件的扩展名
                    LogoSettings logoSettings = DIContainer.Resolve<ISettingsManager<LogoSettings>>().Get();
                    if (!logoSettings.ValidateFileExtensions(fileName))
                    {
                        //标签分组下拉框
                        SelectList topicGroups = GetTagGroupSelectList(tagEditModel.TopicGroupId, tagEditModel.TenantTypeId);
                        ViewData["topicGroups"] = topicGroups;

                        //取到用户设置的相关标签
                        ViewData["seletedUserIds"] = userIds;

                        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 topicGroups = GetTagGroupSelectList(tagEditModel.TopicGroupId, tagEditModel.TenantTypeId);
                        ViewData["topicGroups"] = topicGroups;

                        //取到用户设置的相关标签
                        ViewData["seletedUserIds"] = userIds;

                        ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}KB", tenantLogoSettings.MaxLogoLength));

                        return View(tagEditModel);
                    }

                    stream = tagLogo.InputStream;
                    tagEditModel.FeaturedImage = fileName;

                }
            }

            //获取相关微博
            IEnumerable<long> seletedUserIds = userIds;

            //创建
            if (isCreate)
            {
                Tag tag = tagEditModel.AsTag();
                tagService.Create(tag, stream);

                //添加到分组
                if (tagEditModel.TopicGroupId > 0)
                {
                    tagService.BatchAddGroupsToTag(new List<long>() { tagEditModel.TopicGroupId }, tagEditModel.TagName);
                }

            }//更新
            else
            {
                Tag tag = tagEditModel.AsTag();
                tagService.Update(tag, stream);

                //添加到分组
                if (tagEditModel.TopicGroupId > 0)
                {
                    tagService.BatchAddGroupsToTag(new List<long>() { tagEditModel.TopicGroupId }, tagEditModel.TagName);
                }
            }

            return RedirectToAction("ManageMicroblogTopics");
        }
        public ActionResult EditTopic(long topicId = 0)
        {
            TagEditModel tagEditModel = null;
            //创建
            if (topicId == 0)
            {
                tagEditModel = new TagEditModel();

                //标签分组下拉框
                SelectList topicGroups = GetTagGroupSelectList(0, TenantTypeIds.Instance().Microblog());
                ViewData["topicGroups"] = topicGroups;

                ViewData["editTopicTitle"] = "创建话题";

                pageResourceManager.InsertTitlePart("创建话题");

            }//编辑
            else
            {
                Tag tag = tagService.Get(topicId);
                tagEditModel = tag.AsTagEditModel();

                //话题分组下拉框
                SelectList topicGroups = GetTagGroupSelectList(tagEditModel.TopicGroupId, tagEditModel.TenantTypeId);
                ViewData["topicGroups"] = topicGroups;

                //取相关微博
                string users = tagEditModel.RelatedObjectIds.TrimStart(',').TrimEnd(',');
                if (!string.IsNullOrEmpty(users))
                {
                    IEnumerable<long> seletedUserIds = tagEditModel.RelatedObjectIds.TrimStart(',').TrimEnd(',').Split(',').Select(t => Convert.ToInt64(t));
                    ViewData["seletedUserIds"] = seletedUserIds;
                }

                ViewData["editTopicTitle"] = "编辑话题";

                pageResourceManager.InsertTitlePart("编辑话题");
            }

            return View(tagEditModel);
        }
예제 #5
0
 /// <summary>
 /// 编辑我的标签页
 /// </summary>
 public ActionResult _EditMyTag(string spaceKey, long tagId, string tenantTypeId)
 {
     TagEditModel tagEditModel = new TagEditModel();
     tagEditModel.TagId = tagId;
     if (tagId > 0)
     {
         TagService tagService = new TagService(tenantTypeId);
         var tag = tagService.Get(tagId);
         if (tag == null)
             return HttpNotFound();
         tagEditModel.TagName = tag.TagName;
     }
     tagEditModel.TenantTypeId = tenantTypeId;
     return View(tagEditModel);
 }
예제 #6
0
 public ActionResult _EditMyTag(string spaceKey, TagEditModel tagEditModel, string tenantTypeId)
 {
     IUser currentUser = UserContext.CurrentUser;
     if (currentUser != null && tagEditModel.TagId > 0 && !string.IsNullOrEmpty(tagEditModel.TagName))
     {
         TagService tagService = new TagService(tenantTypeId);
         tagService.DeleteOwnerTag(tagEditModel.TagId);
         tagService.AddTagInOwner(tagEditModel.TagName, tenantTypeId, currentUser.UserId);
         return Json(new { MessageType = StatusMessageType.Success, MessageContent = "更新成功!" }, JsonRequestBehavior.AllowGet);
     }
     else
     {
         return Json(new StatusMessageData(StatusMessageType.Error, "更新失败!"), JsonRequestBehavior.AllowGet);
     }
 }
예제 #7
0
 /// <summary>
 /// 创建标签页
 /// </summary>
 /// <returns></returns>
 public ActionResult _CreateMyTag(string spaceKey, string tenantTypeId)
 {
     TagEditModel tagEditModel = new TagEditModel();
     return View(tagEditModel);
 }
예제 #8
0
        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))
                {
                    return Content(System.Web.Helpers.Json.Encode(new StatusMessageData(StatusMessageType.Error, "请选择上传的图片!")));
                }
                else if (!string.IsNullOrEmpty(fileName))
                {
                    //校验附件的扩展名
                    ISettingsManager<LogoSettings> logoSettingsManager = DIContainer.Resolve<ISettingsManager<LogoSettings>>();
                    if (!logoSettingsManager.Get().ValidateFileExtensions(fileName))
                    {
                        return Content(System.Web.Helpers.Json.Encode(new StatusMessageData(StatusMessageType.Error, "只允许上传后缀名为 .gif .jpg .jpeg .png 的文件!")));
                    }

                    //校验附件的大小
                    TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().Tag());
                    if (!tenantLogoSettings.ValidateFileLength(tagLogo.ContentLength))
                    {
                        return Content(System.Web.Helpers.Json.Encode(new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}KB", tenantLogoSettings.MaxLogoLength))));
                    }

                    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 Content(System.Web.Helpers.Json.Encode(new StatusMessageData(StatusMessageType.Success, "操作成功!")));
        }
        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))
                {
                    return(Content(System.Web.Helpers.Json.Encode(new StatusMessageData(StatusMessageType.Error, "请选择上传的图片!"))));
                }
                else if (!string.IsNullOrEmpty(fileName))
                {
                    //校验附件的扩展名
                    ISettingsManager <LogoSettings> logoSettingsManager = DIContainer.Resolve <ISettingsManager <LogoSettings> >();
                    if (!logoSettingsManager.Get().ValidateFileExtensions(fileName))
                    {
                        return(Content(System.Web.Helpers.Json.Encode(new StatusMessageData(StatusMessageType.Error, "只允许上传后缀名为 .gif .jpg .jpeg .png 的文件!"))));
                    }

                    //校验附件的大小
                    TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().Tag());
                    if (!tenantLogoSettings.ValidateFileLength(tagLogo.ContentLength))
                    {
                        return(Content(System.Web.Helpers.Json.Encode(new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}KB", tenantLogoSettings.MaxLogoLength)))));
                    }

                    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(Content(System.Web.Helpers.Json.Encode(new StatusMessageData(StatusMessageType.Success, "操作成功!"))));
        }
예제 #10
0
        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"));
        }