Exemplo n.º 1
0
 public void TestInitialize()
 {
     webApiMapper = new WebApiMapper();
     topic        = new TopicEntity
     {
         Id           = 1,
         Name         = "Contenedores de basura",
         AreaEntityId = 1,
         RequestTypes = new List <TypeReqEntity>()
     };
     topicModelIn = new TopicModelIn
     {
         Id           = 1,
         Name         = "Contenedores de basura",
         AreaEntityId = 1
     };
     topicModelOut = new TopicModelOut
     {
         Id           = 1,
         Name         = "Contenedores de basura",
         AreaEntityId = 1
     };
     topicLogic      = new Mock <ITopicLogic>();
     topicController = new TopicController(topicLogic.Object, webApiMapper);
 }
Exemplo n.º 2
0
        public ActionResult _TopicMenu(string spaceKey)
        {
            long        groupId = TopicIdToTopicKeyDictionary.GetTopicId(spaceKey);
            TopicEntity 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.TopicId);

            if (navigation != null && navigation.Children.Count() > 0)
            {
                navigations = navigation.Children;
            }
            else
            {
                navigations = navigationService.GetRootNavigations(PresentAreaKeysOfBuiltIn.GroupSpace, group.TopicId);
            }

            return(View(navigations));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 专题增量索引
        /// </summary>
        private void TopicEntity_After(TopicEntity group, CommonEventArgs eventArgs)
        {
            if (group == null)
            {
                return;
            }

            if (groupSearcher == null)
            {
                groupSearcher = (TopicSearcher)SearcherFactory.GetSearcher(TopicSearcher.CODE);
            }

            //添加索引
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                groupSearcher.Insert(group);
            }

            //删除索引
            if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                groupSearcher.Delete(group.TopicId);
            }

            //更新索引
            if (eventArgs.EventOperationType == EventOperationType.Instance().Update() || eventArgs.EventOperationType == EventOperationType.Instance().Approved() || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                groupSearcher.Update(group);
            }
        }
Exemplo n.º 4
0
        public ActionResult _EditAnnouncement(string spaceKey)
        {
            TopicEntity group = groupService.Get(spaceKey);

            ViewData["announcement"] = group.Announcement;
            return(View());
        }
Exemplo n.º 5
0
        /// <summary>
        /// 我关注的专题成员
        /// </summary>
        /// <param name="spaceKey"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public ActionResult MyFollowedUsers(string spaceKey, int pageIndex = 1)
        {
            TopicEntity group = groupService.Get(spaceKey);

            if (group == null)
            {
                return(HttpNotFound());
            }
            var currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(Redirect(SiteUrls.Instance().Login(true)));
            }

            pageResourceManager.InsertTitlePart(group.TopicName);
            pageResourceManager.InsertTitlePart("管理成员列表页");

            long groupId = TopicIdToTopicKeyDictionary.GetTopicId(spaceKey);
            IEnumerable <TopicMember>   groupMember  = groupService.GetTopicMembersAlsoIsMyFollowedUser(groupId, currentUser.UserId);
            PagingDataSet <TopicMember> groupMembers = new PagingDataSet <TopicMember>(groupMember);

            if (currentUser.IsFollowed(group.User.UserId))
            {
                ViewData["groupOwner"] = group.User;
            }



            return(View(groupMembers));
        }
Exemplo n.º 6
0
        public ActionResult DeleteTopicVisitor(string spaceKey)
        {
            TopicEntity group = groupService.Get(spaceKey);

            if (group == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "找不到专题!")));
            }

            //如何做

            //已修复
            long userId = Request.Form.Get <long>("userId", 0);
            long id     = Request.Form.Get <long>("id", 0);

            if (authorizer.Topic_DeleteVisitor(group.TopicId, userId))
            {
                visitService.Delete(id);
                return(RedirectToAction("_LastTopicVisitors"));
            }
            else
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "没有删除该条访客记录的权限!")));
            }
        }
Exemplo n.º 7
0
        public void CreateShoudCreateTopic()
        {
            //ARRANGE
            var model = new TopicEntity
            {
                Description = "Topic one"
            };

            var logic = new Mock <ITopicLogic>();

            logic
            .Setup(x => x.Create(It.IsAny <TopicEntity>()))
            .Verifiable("should save topic");

            var controller = new TopicController(logic.Object, null, null, null);

            //ACT
            var result = controller.Create(model) as RedirectToRouteResult;

            //ASSERT
            logic.Verify();

            Assert.NotNull(result);
            Assert.AreEqual("Index", result.RouteValues["Action"]);
        }
Exemplo n.º 8
0
        public void UpdateShouldSaveTheTopic()
        {
            //ARRANGE
            var id = Guid.NewGuid();

            var model = new TopicEntity
            {
                Id          = id,
                Description = "Topic one"
            };

            var logic = new Mock <ITopicLogic>();

            logic
            .Setup(x => x.Get(id))
            .Returns(new TopicEntity())
            .Verifiable("Should get the topic to edit.");
            logic
            .Setup(x => x.Update(It.IsAny <TopicEntity>()))
            .Verifiable("should save topic");

            var controller = new TopicController(logic.Object, null, null, null);

            //ACT
            var result = controller.Update(model) as RedirectToRouteResult;

            //ASSERT
            logic.Verify();

            Assert.NotNull(result);
            Assert.AreEqual("Index", result.RouteValues["Action"]);
        }
Exemplo n.º 9
0
        public ActionResult DeleteTopic(long id, FormCollection collection)
        {
            try
            {
                TopicFactory DeleteTopic = new TopicFactory();
                TopicEntity  Topic       = new TopicEntity();
                Topic = DeleteTopic.GetTopicById(id);

                DataLayer.tblTopic NewTopic = new DataLayer.tblTopic();
                NewTopic.TopicId     = id;
                NewTopic.ChannelId   = Topic.ChannelId;
                NewTopic.TopicName   = Topic.TopicName;
                NewTopic.CreatedDate = Topic.CreatedDate;
                NewTopic.CreatedBy   = Topic.CreatedBy;
                NewTopic.UpdatedDate = DateTime.Now;
                NewTopic.UpdatedBy   = null;
                NewTopic.IsActive    = false; // IsActive will be false in delete record

                DeleteTopic.SaveTopic(NewTopic);

                return(RedirectToAction("Topic"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult SetManager(string spaceKey, long userId, bool isManager)
        {
            StatusMessageData message = null;
            TopicEntity       group   = groupService.Get(spaceKey);

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

            if (!authorizer.Topic_SetManager(group))
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "您没有设置管理员的权限")));
            }

            bool result = groupService.SetManager(group.TopicId, userId, isManager);

            if (result)
            {
                message = new StatusMessageData(StatusMessageType.Success, "操作成功!");
            }
            else
            {
                message = new StatusMessageData(StatusMessageType.Error, "操作失败!");
            }
            return(Json(message));
        }
Exemplo n.º 11
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            string username = "";
            string plateID  = Request.QueryString["plateID"];

            if (Session["username"] != null)
            {
                if (txtTitle.Value != "" && hidContent.Value != string.Empty)
                {
                    username = Session["username"].ToString();
                    dt       = new AnswerBLL().GetUserID(username);
                    int         userID    = Convert.ToInt32(dt.Rows[0][0]);
                    TopicEntity topicInfo = new TopicEntity();
                    topicInfo.userID       = userID;
                    topicInfo.writeDate    = DateTime.Now;
                    topicInfo.TopicTitle   = txtTitle.Value;
                    topicInfo.plateID      = Convert.ToInt32(plateID);
                    topicInfo.TopicContent = hidContent.Value;
                    topicInfo.lastTime     = DateTime.Now;
                    BLL.TopicBLL.InsertTopicInformation(topicInfo);
                    Response.Write("<script>alert('发帖成功!')</script>");
                    userInfoBLL.UpdateUserInfoAllcount(username);
                }
                else
                {
                    Response.Write("<script>alert('标题或内容不能为空')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('请先登录')</script>");
                Response.Redirect("LoginBBS.aspx");
            }
        }
Exemplo n.º 12
0
 public void TestInitialize()
 {
     xmlImporter = new XmlImporter();
     firstArea   = new AreaEntity
     {
         Name = "Area_One",
     };
     secondArea = new AreaEntity
     {
         Name = "Area_Two",
     };
     firstTopic = new TopicEntity
     {
         Name         = "Topic_One",
         AreaEntityId = 2,
     };
     secondTopic = new TopicEntity
     {
         Name         = "Topic_Two",
         AreaEntityId = 2,
     };
     firstTypeReq = new TypeReqEntity
     {
         Name          = "TypeReq_One",
         TopicEntityId = 1,
     };
     secondTypeReq = new TypeReqEntity
     {
         Name          = "TypeReq_Two",
         TopicEntityId = 2,
     };
 }
 public ActionResult Create(TopicCreateViewModel viewModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             TopicEntity topic = new TopicEntity() 
             { 
                 DateAdded = DateTime.Now,
                 UserId = userService.GetByPredicate(u => u.Email == User.Identity.Name).FirstOrDefault().Id,
                 SectionId = 1,
                 Name = viewModel.Name,
                 Text = viewModel.Text,
             };
             topicService.Create(topic);
             return RedirectToAction("Index");
         }
     }
     catch(InvalidOperationException e)
     {
         logger.Error(e.Message, e);
         return View("Error");
     }
     return View();
 }
 /// <summary>
 /// 审核状态发生变化时处理积分
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="eventArgs"></param>
 private void TopicEntityPointModule_After(TopicEntity sender, AuditEventArgs eventArgs)
 {
     string pointItemKey = string.Empty;
     string eventOperationType = string.Empty;
     string description = string.Empty;
     ActivityService activityService = new ActivityService();
     AuditService auditService = new AuditService();
     PointService pointService = new PointService();
     bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);
     if (auditDirection == true) //加积分
     {
         pointItemKey = PointItemKeys.Instance().Topic_CreateTopic();
         if (eventArgs.OldAuditStatus == null)
             eventOperationType = EventOperationType.Instance().Create();
         else
             eventOperationType = EventOperationType.Instance().Approved();
     }
     else if (auditDirection == false) //减积分
     {
         pointItemKey = PointItemKeys.Instance().Topic_DeleteTopic();
         if (eventArgs.NewAuditStatus == null)
             eventOperationType = EventOperationType.Instance().Delete();
         else
             eventOperationType = EventOperationType.Instance().Disapproved();
     }
     if (!string.IsNullOrEmpty(pointItemKey))
     {
         description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "专题", sender.TopicName);
     }
     pointService.GenerateByRole(sender.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == sender.UserId);
 }
        /// <summary>
        /// 动态处理程序
        /// </summary>
        /// <param name="group"></param>
        /// <param name="eventArgs"></param>
        private void TopicEntityActivityModule_After(TopicEntity group, AuditEventArgs eventArgs)
        {
            //生成动态
            ActivityService activityService = new ActivityService();
            AuditService auditService = new AuditService();
            bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);
            if (auditDirection == true) //生成动态
            {
                if (group == null)
                    return;

                //生成Owner为用户的动态
                Activity actvityOfBar = Activity.New();
                actvityOfBar.ActivityItemKey = ActivityItemKeys.Instance().CreateTopic();
                actvityOfBar.ApplicationId = TopicConfig.Instance().ApplicationId;
                actvityOfBar.IsOriginalThread = true;
                actvityOfBar.IsPrivate = !group.IsPublic;
                actvityOfBar.UserId = group.UserId;
                actvityOfBar.ReferenceId = 0;//没有涉及到的实体
                actvityOfBar.ReferenceTenantTypeId = string.Empty;
                actvityOfBar.SourceId = group.TopicId;
                actvityOfBar.TenantTypeId = TenantTypeIds.Instance().Topic();
                actvityOfBar.OwnerId = group.UserId;
                actvityOfBar.OwnerName = group.User.DisplayName;
                actvityOfBar.OwnerType = ActivityOwnerTypes.Instance().User();

                activityService.Generate(actvityOfBar, true);
            }
            else if (auditDirection == false) //删除动态
            {
                activityService.DeleteSource(TenantTypeIds.Instance().Topic(), group.TopicId);
            }
        }
        public ActionResult _ChangeTopicOwner(string spaceKey)
        {
            string returnUrl = Request.QueryString.Get <string>(WebUtility.UrlDecode("returnUrl"));

            var         userIds = Request.Form.Gets <long>("UserId", new List <long>());
            long        userId  = userIds.FirstOrDefault();
            TopicEntity group   = groupService.Get(spaceKey);

            if (group == null)
            {
                return(Content(string.Empty));
            }
            if (userId == 0)
            {
                Tunynet.Utilities.WebUtility.SetStatusCodeForError(Response);
                ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Hint, "您没有选择群主");
                ViewData["returnUrl"]         = returnUrl;
                return(View(group));
            }
            if (group.UserId == userId)
            {
                Tunynet.Utilities.WebUtility.SetStatusCodeForError(Response);
                ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Hint, "您没有更换群主");
                ViewData["returnUrl"]         = returnUrl;
                return(View(group));
            }
            if (!authorizer.Topic_SetManager(group))
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "您没有更换群主的权限")));
            }

            groupService.ChangeTopicOwner(group.TopicId, userId);
            return(Json(new StatusMessageData(StatusMessageType.Success, "更换群主操作成功")));
        }
Exemplo n.º 17
0
        public TopicEntity GetByName(string name)
        {
            ValidateTopicNameExistance(name);
            TopicEntity result = unitOfWork.TopicRepository.FirstOrDefault(u => u.Name == name);

            return(result);
        }
Exemplo n.º 18
0
        public ServiceMessage Create(TopicCreateDTO topicDTO)
        {
            List <string> errors    = new List <string>();
            bool          succeeded = Validate(topicDTO, errors);

            if (succeeded)
            {
                try
                {
                    UserEntity  userEntity  = unitOfWork.Users.Get(topicDTO.CreatorLogin);
                    TopicEntity topicEntity = new TopicEntity
                    {
                        Creator           = userEntity,
                        DateCreated       = DateTime.Now,
                        DateOfLastMessage = DateTime.Now,
                        Title             = topicDTO.Title,
                        Description       = topicDTO.Description
                    };

                    unitOfWork.Topics.Add(topicEntity);
                    unitOfWork.Commit();
                }
                catch (Exception ex)
                {
                    succeeded = false;
                    ExceptionMessageBuilder.FillErrors(ex, errors);
                }
            }

            return(new ServiceMessage
            {
                Errors = errors,
                Succeeded = succeeded
            });
        }
Exemplo n.º 19
0
        public ActionResult _ValidateQuestion(long groupId)
        {
            TopicEntity group = topicService.Get(groupId);

            ViewData["Question"] = group.Question;
            return(View());
        }
Exemplo n.º 20
0
        public JsonResult ValidateTopicKey(string topicKey, long topicId)
        {
            bool result = false;

            if (topicId > 0)
            {
                result = true;
            }
            else
            {
                TopicEntity topic = topicService.Get(topicKey);
                if (topic != null)
                {
                    return(Json("此专题Key已存在", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    result = Regex.IsMatch(topicKey, @"^[A-Za-z0-9_\-\u4e00-\u9fa5]+$", RegexOptions.IgnoreCase);
                    if (!result)
                    {
                        return(Json("只能输入字母数字汉字或-号", JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 21
0
        public ActionResult _ApplyJoinButton(long topicId, bool showQuit = false, string buttonName = null)
        {
            TopicEntity group = topicService.Get(topicId);

            if (group == null)
            {
                return(new EmptyResult());
            }
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(new EmptyResult());
            }
            bool isApplied = topicService.IsApplied(currentUser.UserId, topicId);
            bool isMember  = topicService.IsMember(group.TopicId, currentUser.UserId);
            bool isOwner   = topicService.IsOwner(group.TopicId, currentUser.UserId);
            bool isManager = topicService.IsManager(group.TopicId, currentUser.UserId);

            ViewData["isMember"]   = isMember;
            ViewData["showQuit"]   = showQuit;
            ViewData["buttonName"] = buttonName;
            ViewData["isOwner"]    = isOwner;
            ViewData["isManager"]  = isManager;
            ViewData["isApplied"]  = isApplied;
            return(View(group));
        }
Exemplo n.º 22
0
        public JsonResult _QuitTopic(long groupId)
        {
            StatusMessageData message = new StatusMessageData(StatusMessageType.Success, "退出专题成功!");
            TopicEntity       group   = topicService.Get(groupId);

            if (group == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "找不到专题!")));
            }
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "您尚未登录!")));
            }
            try
            {
                topicService.DeleteTopicMember(group.TopicId, currentUser.UserId);
            }
            catch
            {
                message = new StatusMessageData(StatusMessageType.Error, "退出专题失败!");
            }
            return(Json(message));
        }
        public ActionResult _Menu_Manage(string spaceKey)
        {
            long        groupId = TopicIdToTopicKeyDictionary.GetTopicId(spaceKey);
            TopicEntity 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.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"] = groupService.GetMemberApplyCount(group.TopicId);

            return(View(navigations));
        }
Exemplo n.º 24
0
        /// <summary>
        /// 屏蔽专题
        /// </summary>
        /// <param name="spaceKey">空间名</param>
        /// <returns>屏蔽专题名</returns>
        public ActionResult _BlockTopics(string spaceKey)
        {
            long userId = UserIdToUserNameDictionary.GetUserId(spaceKey);

            if (UserContext.CurrentUser == null || (UserContext.CurrentUser.UserId != userId && authorizer.IsAdministrator(new TenantTypeService().Get(TenantTypeIds.Instance().Topic()).ApplicationId)))
            {
                return(Content(string.Empty));
            }

            IEnumerable <UserBlockedObject> blockedTopics = new UserBlockService().GetBlockedTopics(userId);

            List <UserBlockedObjectViewModel> blockedObjectes = new List <UserBlockedObjectViewModel>();

            if (blockedTopics != null && blockedTopics.Count() > 0)
            {
                topicService.GetTopicEntitiesByIds(blockedTopics.Select(n => n.ObjectId));
                foreach (var item in blockedTopics)
                {
                    TopicEntity group = topicService.Get(item.ObjectId);
                    if (group == null)
                    {
                        continue;
                    }

                    UserBlockedObjectViewModel entitiy = item.AsViewModel();
                    entitiy.Logo = group.Logo;
                    blockedObjectes.Add(entitiy);
                }
            }

            return(View(blockedObjectes));
        }
Exemplo n.º 25
0
        public string TopicValidity(string TopicName, long?TopicId)
        {
            List <TopicEntity> usrList = new List <TopicEntity>();
            TopicEntity        Topic   = new TopicEntity();

            if (TopicId != null)
            {
                Topic = db.tblTopics.Where(x => x.TopicName.ToLower() == TopicName.ToLower() && x.TopicId != TopicId).Select(x => new TopicEntity()
                {
                    TopicName = x.TopicName,
                }).FirstOrDefault();
            }
            else
            {
                Topic = db.tblTopics.Where(x => x.TopicName.ToLower() == TopicName.ToLower()).Select(x => new TopicEntity()
                {
                    TopicName = x.TopicName,
                }).FirstOrDefault();
            }

            // var Usr = usrList.FirstOrDefault(x => x.TopicName.ToLower() == TopicName.ToLower());
            if (Topic != null)
            {
                return("Topic already exist.");
            }
            else
            {
                return("Success");
            }
        }
Exemplo n.º 26
0
        public ICollection <TopicEntity> GetTopics(ICollection <Parameter> parameters)
        {
            try
            {
                var            pathJsonFile = parameters.OfType <Parameter>().FirstOrDefault().Value;
                var            jsonText     = File.ReadAllText(pathJsonFile);
                JObject        dataIn       = JObject.Parse(jsonText);
                IList <JToken> results      = dataIn["TopicEntity"].Children().ToList();

                var result = new List <TopicEntity>();
                foreach (JToken topicIn in results)
                {
                    TopicEntity newTopic = new TopicEntity();
                    newTopic.Name         = topicIn.ToObject <TopicEntity>().Name;
                    newTopic.AreaEntityId = topicIn.ToObject <TopicEntity>().AreaEntityId;
                    result.Add(newTopic);
                }

                return(result);
            }
            catch (ArgumentException)
            {
                throw new ArgumentException("Path invalido");
            }
        }
Exemplo n.º 27
0
 private void ValidateRepeatedTopicNameInArea(TopicEntity topic)
 {
     if (TopicNameIsRepeatedInArea(topic))
     {
         throw new ArgumentException($"There is already a topic with name {topic.Name} in the area with id: {topic.AreaEntityId}");
     }
 }
Exemplo n.º 28
0
        public ActionResult _ValidateQuestion(long topicId)
        {
            TopicEntity topic = topicService.Get(topicId);

            ViewData["Question"] = topic.Question;
            return(View());
        }
Exemplo n.º 29
0
 private void ValidateAreaForTopicExists(TopicEntity topic)
 {
     if (!AreaForTopicExists(topic))
     {
         throw new ArgumentException($"Area with id: {topic.AreaEntityId} does not exist");
     }
 }
Exemplo n.º 30
0
 private void ValidateTopicIsNotRepeated(TopicEntity topic)
 {
     if (TopicExists(topic.Id))
     {
         throw new ArgumentException($"Topic with id: {topic.Id} already exist");
     }
 }
Exemplo n.º 31
0
        public void Post_Throws_WhenMessageNull()
        {
            var entity = new TopicEntity("", new string[0]);

            Should.Throw <ArgumentNullException>(() => entity.Post(null))
            .ParamName.ShouldBe("message");
        }
Exemplo n.º 32
0
        public ActionResult BlockTopics(string spaceKey, List <long> groupIds)
        {
            int addCount = 0;

            long             userId  = UserIdToUserNameDictionary.GetUserId(spaceKey);
            UserBlockService service = new UserBlockService();

            if (userId > 0 && groupIds != null && groupIds.Count > 0)
            {
                foreach (var groupId in groupIds)
                {
                    TopicEntity group = topicService.Get(groupId);
                    if (group == null || service.IsBlockedTopic(userId, groupId))
                    {
                        continue;
                    }
                    service.BlockTopic(userId, group.TopicId, group.TopicName);
                    addCount++;
                }
            }
            if (addCount > 0)
            {
                TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, string.Format("成功添加{0}个专题添加到屏蔽列表", addCount));
            }
            else
            {
                TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "没有任何专题被添加到屏蔽列表中");
            }
            return(Redirect(SiteUrls.Instance().BlockGroups(spaceKey)));
        }
Exemplo n.º 33
0
        public void Post_Throws_WhenObjectDisposed()
        {
            var entity = new TopicEntity("a", new string[0]);

            entity.Dispose();

            Should.Throw <ObjectDisposedException>(() => entity.Post(new Amqp.Message()));
        }
        /// <summary>
        /// 专题操作日志事件处理
        /// </summary>
        private void TopicOperationLogEventModule_After(TopicEntity senders, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()
               || eventArgs.EventOperationType == EventOperationType.Instance().Approved()
               || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved()
               || eventArgs.EventOperationType == EventOperationType.Instance().SetEssential()
               || eventArgs.EventOperationType == EventOperationType.Instance().SetSticky()
               || eventArgs.EventOperationType == EventOperationType.Instance().CancelEssential()
               || eventArgs.EventOperationType == EventOperationType.Instance().CancelSticky())
            {
                OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo);
                entry.ApplicationId = entry.ApplicationId;
                entry.Source = TopicConfig.Instance().ApplicationName;
                entry.OperationType = eventArgs.EventOperationType;
                entry.OperationObjectName = senders.TopicName;
                entry.OperationObjectId = senders.TopicId;
                entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType, entry.ApplicationId), "专题", entry.OperationObjectName);

                OperationLogService logService = Tunynet.DIContainer.Resolve<OperationLogService>();
                logService.Create(entry);
            }
        }
 /// <summary>
 /// 自动安装专题的相关应用
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="eventArgs"></param>
 private void InstallApplicationsModule_After(TopicEntity sender, CommonEventArgs eventArgs)
 {
     ApplicationService applicationService = new ApplicationService();
     if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
     {
         applicationService.InstallApplicationsOfPresentAreaOwner(PresentAreaKeysOfExtension.TopicSpace, sender.TopicId);
     }
     else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
     {
         applicationService.DeleteApplicationsOfPresentAreaOwner(PresentAreaKeysOfExtension.TopicSpace, sender.TopicId);
     }
 }
 /// <summary>
 /// 修改皮肤文件的使用人数
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="eventArgs"></param>
 private void ChangeThemeAppearanceUserCountModule_After(TopicEntity sender, CommonEventArgs eventArgs)
 {
     var themeService = new ThemeService();
     PresentAreaService presentAreaService = new PresentAreaService();
     if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
     {
         var presentArea = presentAreaService.Get(PresentAreaKeysOfExtension.TopicSpace);
         themeService.ChangeThemeAppearanceUserCount(PresentAreaKeysOfExtension.TopicSpace, null, presentArea.DefaultThemeKey + "," + presentArea.DefaultAppearanceKey);
     }
     else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
     {
         var presentArea = presentAreaService.Get(PresentAreaKeysOfExtension.TopicSpace);
         string defaultThemeAppearance = presentArea.DefaultThemeKey + "," + presentArea.DefaultAppearanceKey;
         if (!sender.IsUseCustomStyle)
             themeService.ChangeThemeAppearanceUserCount(PresentAreaKeysOfExtension.TopicSpace, !string.IsNullOrEmpty(sender.ThemeAppearance) ? sender.ThemeAppearance : defaultThemeAppearance, null);
     }
 }