Beispiel #1
0
        /**************************************
        *      Delete开头的函数删除数据      *
        **************************************/

        /// <summary>
        /// 删除记录
        /// </summary>
        /// <param name="operatorID">操作者ID</param>
        /// <param name="doingID">所要删除的记录ID</param>
        public bool DeleteDoing(int operatorID, int doingID)
        {
            if (ValidateUserID(operatorID) == false)
            {
                return(false);
            }

            Doing doing = DoingBO.Instance.GetDoing(doingID);

            if (ValidateDoingDeletePermission(operatorID, doing) == false)
            {
                return(false);
            }

            DoingDao.Instance.DeleteDoing(doingID);

            ClearCachedEveryoneData();

            ClearCachedUserData(doing.UserID);

            FeedBO.Instance.DeleteFeed(AppActionType.UpdateDoing, doing.UserID);

            Logs.LogManager.LogOperation(
                new Doing_DeleteDoing(
                    operatorID,
                    UserBO.Instance.GetUser(operatorID).Name,
                    IPUtil.GetCurrentIP(),
                    doingID,
                    doing.UserID,
                    UserBO.Instance.GetUser(doing.UserID).Name
                    )
                );

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// 后台批量删除记录
        /// </summary>
        /// <param name="doingIDs"></param>
        public bool DeleteDoings(int operatorID, int[] doingIDs, bool isUpdatePoint)
        {
            bool result = ProcessDeleteDoings(operatorID, isUpdatePoint, delegate(Guid[] excludeRoleIDs)
            {
                return(DoingDao.Instance.DeleteDoings(operatorID, doingIDs, excludeRoleIDs));
            });

            if (result)
            {
                Logs.LogManager.LogOperation(
                    new Doing_DeleteDoingByIDs(
                        operatorID,
                        UserBO.Instance.GetUser(operatorID).Name,
                        IPUtil.GetCurrentIP(),
                        doingIDs
                        )
                    );
            }

            return(result);
        }
Beispiel #3
0
        public bool CreateClub(int operatorID, int categoryID, string clubName, out int newClubID)
        {
            newClubID = 0;

            if (ValidateUserID(operatorID) == false)
            {
                return(false);
            }

            if (ValidateClubCategoryID(categoryID) == false)
            {
                return(false);
            }

            if (ValidateClubName(clubName) == false)
            {
                return(false);
            }

            //TODO:检查是否达到创建群组数上限

            bool   isApproced = true;
            string operatorIP = IPUtil.GetCurrentIP();

            CreateClubResult result = ClubDao.Instance.CreateClub(operatorID, categoryID, clubName, isApproced, operatorIP, out newClubID);

            //TODO:创建动态

            if (result == CreateClubResult.HasSameNameClub)
            {
                //TODO:抛错
                return(false);
            }

            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// 添加版主
        /// </summary>
        /// <param name="operatorUserID"></param>
        /// <param name="userID"></param>
        /// <param name="forumIds"></param>
        /// <param name="modetatorsType"></param>
        public void AddModerators(AuthUser operatorUser, ModeratorCollection moderators)
        {
            //AuthUser user = UserBO.Instance.GetUser(operatorUserID);
            //if (user == null)
            //    return;
            if (!AllSettings.Current.BackendPermissions.Can(operatorUser, BackendPermissions.Action.Manage_Moderator))
            {
                ThrowError <NoPermissionManageModerator>(new NoPermissionManageModerator());
                return;
            }

            foreach (Moderator m in moderators)
            {
                if (m.IsNew)
                {
                    m.AppointorID = operatorUser.UserID;
                    m.IsNew       = false;
                }
            }

            if (moderators.Count == 0)
            {
                return;
            }

            if (ForumDaoV5.Instance.AddModerators(moderators))
            {
                this.ClearModeratorCache();
                //User operatorUser = UserBO.Instance.GetUser(operatorUserID);

                foreach (Moderator m in moderators)
                {
                    Logs.LogManager.LogOperation(new Logs.ModeratorAppoint(operatorUser.UserID, operatorUser.Username, m.UserID, m.User.Username, m.ForumID, m.Name, IPUtil.GetCurrentIP()));
                }
            }
        }
Beispiel #5
0
        public void Update(AuthUser my, RequestVariable request, OnlineAction action, int forumID, int threadID, string subject)
        {
            subject = StringUtil.CutString(subject, 20);



            int    userID = my.UserID;
            string ip     = request.IpAddress;

            bool addnew = false;

            //已经登录的用户
            if (userID > 0)
            {
                #region 已经登录的用户的处理

                OnlineMember onlineMember;
                if (m_OnlineMemberTable.TryGetValue(userID, out onlineMember) == false)
                {
                    string       location = IPUtil.GetIpArea(ip);
                    RoleInOnline role     = GetUserRoleInOnline(userID);
                    lock (m_OnlineMembers_Locker)
                    {
                        if (m_OnlineMemberTable.TryGetValue(userID, out onlineMember) == false)
                        {
                            #region 增加一个OnlineMember

                            DateTime now = DateTimeUtil.Now;

                            onlineMember        = new OnlineMember();
                            onlineMember.UserID = userID;

                            onlineMember.Action = action;

                            onlineMember.Username    = my.Username;
                            onlineMember.IsInvisible = my.IsInvisible;

                            onlineMember.IP       = ip;
                            onlineMember.Location = location;

                            onlineMember.ForumID       = forumID;
                            onlineMember.ThreadID      = threadID;
                            onlineMember.ThreadSubject = subject;


                            onlineMember.Platform             = request.Platform;
                            onlineMember.Browser              = request.Browser;
                            onlineMember.CreateDate           = now;
                            onlineMember.UpdateDate           = now;
                            onlineMember.RoleSortOrder        = role.SortOrder;
                            onlineMember.RoleIdentityIDString = my.RoleIdentityIDString;

                            m_OnlineMemberTable.Add(userID, onlineMember);
                            OnlineMemberCollection newOnlineMembers = new OnlineMemberCollection(m_OnlineMembers);
                            newOnlineMembers.Add(onlineMember);
                            m_OnlineMembers = newOnlineMembers;

                            if (forumID != 0)
                            {
                                lock (GetForumOnlineMemberLocker(forumID))
                                {
                                    //加入新的版块
                                    AddForumOnlineMember(forumID, onlineMember);
                                }
                            }

                            #endregion

                            addnew = true;
                        }
                    }
                }

                if (addnew == false)
                {
                    lock (onlineMember)
                    {
                        //ForumID为-1意味着其实已经删除,无需再更新
                        if (onlineMember.ForumID != -1)
                        {
                            #region 更新原来OnlineMember的值

                            onlineMember.Action = action;

                            onlineMember.Username    = my.Username;
                            onlineMember.IsInvisible = my.IsInvisible;

                            if (my.RoleIdentityIDString != onlineMember.RoleIdentityIDString)
                            {
                                RoleInOnline role = GetUserRoleInOnline(userID);
                                onlineMember.RoleSortOrder        = role.SortOrder;
                                onlineMember.RoleIdentityIDString = my.RoleIdentityIDString;
                            }

                            if (onlineMember.IP != ip)
                            {
                                onlineMember.IP       = ip;
                                onlineMember.Location = IPUtil.GetIpArea(ip);
                            }

                            //-----------------

                            int oldForumID = onlineMember.ForumID;
                            onlineMember.ThreadID      = threadID;
                            onlineMember.ThreadSubject = subject;

                            if (oldForumID != forumID)
                            {
                                if (oldForumID != 0 && forumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(oldForumID))
                                    {
                                        lock (GetForumOnlineMemberLocker(forumID))
                                        {
                                            //从原来的版块移除
                                            RemoveForumOnlineMember(oldForumID, onlineMember);
                                            //加入新的版块
                                            AddForumOnlineMember(forumID, onlineMember);
                                        }
                                    }
                                }
                                else if (oldForumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(oldForumID))
                                    {
                                        //从原来的版块移除
                                        RemoveForumOnlineMember(oldForumID, onlineMember);
                                    }
                                }
                                else if (forumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(forumID))
                                    {
                                        //加入新的版块
                                        AddForumOnlineMember(forumID, onlineMember);
                                    }
                                }
                                onlineMember.ForumID = forumID;
                            }


                            onlineMember.Platform   = request.Platform;
                            onlineMember.Browser    = request.Browser;
                            onlineMember.UpdateDate = DateTimeUtil.Now;

                            #endregion
                        }
                        else
                        {
                            LogHelper.CreateDebugLog("OnlineMember线程同步监视1");
                        }
                    }
                }

                #endregion

                //如果是已登陆状态,但客户端仍然提交了GuestID,则把这个GuestID移除
                //if (my.MachineIDIsNew == false)

                string guestID = my.GuestID;

                if (guestID != null)
                {
                    RemoveOnlineGuest(guestID);
                }
            }
            else
            //尚未登录的用户
            {
                //TODO : 暂不统计游客在线情况,因为可能存在溢出,下个版本改进



                #region 尚未登录的用户的处理


                bool   isSpider = request.IsSpider;
                string guestID  = my.BuildGuestID();

                OnlineGuest onlineGuest;
                if (m_OnlineGuestTable.TryGetValue(guestID, out onlineGuest) == false)
                {
                    string location = IPUtil.GetIpArea(ip);

                    lock (m_OnlineGuests_Locker)
                    {
                        //假如游客列表中还没有这个游客
                        if (m_OnlineGuestTable.TryGetValue(guestID, out onlineGuest) == false)
                        {
                            bool success = UpdateOnlineGuestIP(guestID, null, ip, isSpider);// AddGuestToIP(guestID, ip, request.IsSpider);
                            //bool success = true;

                            if (success)
                            {
                                #region 增加一个OnlineGuest

                                DateTime now = DateTimeUtil.Now;

                                onlineGuest          = new OnlineGuest();
                                onlineGuest.GuestID  = my.GuestID;
                                onlineGuest.IsSpider = isSpider;

                                onlineGuest.Action = action;

                                onlineGuest.IP       = ip;
                                onlineGuest.Location = location;


                                onlineGuest.Platform   = request.Platform;
                                onlineGuest.Browser    = request.Browser;
                                onlineGuest.CreateDate = now;
                                onlineGuest.UpdateDate = now;

                                onlineGuest.ForumID       = forumID;
                                onlineGuest.ThreadID      = threadID;
                                onlineGuest.ThreadSubject = subject;

                                m_OnlineGuestTable.Add(guestID, onlineGuest);
                                OnlineGuestCollection newOnlineGuests = new OnlineGuestCollection(m_OnlineGuests);
                                newOnlineGuests.Add(onlineGuest);
                                m_OnlineGuests = newOnlineGuests;

                                if (forumID != 0)
                                {
                                    lock (GetForumOnlineGuestLocker(forumID))
                                    {
                                        //加入新的版块
                                        AddForumOnlineGuest(forumID, onlineGuest);
                                    }
                                }

                                #endregion

                                addnew = true;
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                }

                //如果只是更新原来的值,那么开始更新
                if (addnew == false)
                {
                    lock (onlineGuest)
                    {
                        //ForumID为-1表示其实这个对象已经从在线列表中移除了
                        if (onlineGuest.ForumID != -1)
                        {
                            #region 更新原来OnlineGuest的值

                            onlineGuest.Action = action;

                            //如果这个游客仅仅发生了IP变化,那么要更新IP表
                            if (onlineGuest.IP != ip)
                            {
                                UpdateOnlineGuestIP(guestID, onlineGuest.IP, ip, isSpider);

                                //RemoveGuestFromIP(guestID, onlineGuest.IP);
                                onlineGuest.IsSpider = isSpider;
                                onlineGuest.IP       = ip;
                                onlineGuest.Location = IPUtil.GetIpArea(ip);
                                //AddGuestToIP(guestID, onlineGuest.IP, request.IsSpider);
                            }

                            //----------------------

                            int oldForumID = onlineGuest.ForumID;

                            if (oldForumID != forumID)
                            {
                                if (oldForumID != 0 && forumID != 0)
                                {
                                    lock (GetForumOnlineGuestLocker(oldForumID))
                                    {
                                        lock (GetForumOnlineGuestLocker(forumID))
                                        {
                                            //从原来的版块移除
                                            RemoveForumOnlineGuest(oldForumID, onlineGuest);
                                            //加入新的版块
                                            AddForumOnlineGuest(forumID, onlineGuest);
                                        }
                                    }
                                }
                                else if (oldForumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(oldForumID))
                                    {
                                        //从原来的版块移除
                                        RemoveForumOnlineGuest(oldForumID, onlineGuest);
                                    }
                                }
                                else if (forumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(forumID))
                                    {
                                        //加入新的版块
                                        AddForumOnlineGuest(forumID, onlineGuest);
                                    }
                                }

                                onlineGuest.ForumID = forumID;
                            }


                            onlineGuest.Platform   = request.Platform;
                            onlineGuest.Browser    = request.Browser;
                            onlineGuest.UpdateDate = DateTimeUtil.Now;

                            onlineGuest.ThreadID      = threadID;
                            onlineGuest.ThreadSubject = subject;
                            #endregion
                        }
                        else
                        {
                            LogHelper.CreateDebugLog("OnlineGuest线程同步监视1");
                        }
                    }
                }

                #endregion
            }
        }
Beispiel #6
0
        public void UpdateSystemNotify(int operatorUserID, string subject, int notifyID, string Content, IEnumerable <Guid> receiveRoles, IEnumerable <int> receiveUserIDs, DateTime beginDate, DateTime endDate)
        {
            if (subject == string.Empty)
            {
                subject = string.Format("{0:yyyy-MM-dd HH:mm}", DateTimeUtil.Now);
            }

            if (AllSettings.Current.BackendPermissions.Can(operatorUserID, BackendPermissions.Action.Manage_SystemNotify))
            {
                if (ValidateSystemNotifyData(Content, receiveRoles, receiveUserIDs, beginDate, endDate))
                {
                    SystemNotify notify = NotifyDao.Instance.UpdateSystemNotify(notifyID, subject, Content, receiveRoles, receiveUserIDs, beginDate, endDate, operatorUserID, IPUtil.GetCurrentIP());
                    SystemNotifyProvider.Update();

                    if (OnSystemNotifyUpdated != null)
                    {
                        OnSystemNotifyUpdated(notify);
                    }
                }
            }
            else
            {
                ThrowError(new NoPermissionManageSystemNoyify());
            }
        }