コード例 #1
0
ファイル: Service_Friend.cs プロジェクト: zhangbo27/bbsmax
        public APIResult Friend_DeleteFromBlacklist(int userID, int userIDInBlacklist)
        {
            if (!CheckClient())
            {
                return(null);
            }
            APIResult result = new APIResult();

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = FriendBO.Instance.Server_DeleteFromBlacklist(userID, userIDInBlacklist);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName, error.Message);
                        });
                    }
                }
                catch (Exception ex)
                {
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                    result.ErrorCode = Consts.ExceptionCode;
                }
            }
            return(result);
        }
コード例 #2
0
ファイル: Service_Friend.cs プロジェクト: huchao007/bbsmax
        public APIResult Friend_AcceptAddFriend(int operatorID, int notifyID, int groupIDToAdd)
        {
            if (!CheckClient()) return null;
            APIResult result = new APIResult();
            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = FriendBO.Instance.Server_AcceptAddFriend(operatorID, notifyID, groupIDToAdd);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName,error.Message);
                        });
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorCode = Consts.ExceptionCode;
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                }
            }

            return result;
        }
コード例 #3
0
ファイル: Service_Friend.cs プロジェクト: zhangbo27/bbsmax
        public APIResult Friend_UpdateFriendHot(int userID, int hotType, int friendUserID)
        {
            if (!CheckClient())
            {
                return(null);
            }
            APIResult result = new APIResult();

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = FriendBO.Instance.Server_UpdateFriendHot(userID, (MaxLabs.bbsMax.Enums.HotType)hotType, friendUserID);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName, error.Message);
                        });
                    }
                }
                catch (Exception ex)
                {
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                    result.ErrorCode = Consts.ExceptionCode;
                }
            }
            return(result);
        }
コード例 #4
0
        public APIResult Chat_AdminDeleteSessions(int userID, List <int> sessionIds)
        {
            if (!CheckClient())
            {
                return(null);
            }
            APIResult result = new APIResult();

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    ChatBO.Instance.AdminDeleteSessions(userID, sessionIds);
                    bool hasError = false;
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        hasError = true;
                        result.AddError(error.TatgetName, error.Message);
                    });

                    result.IsSuccess = hasError == false;
                }
                catch (Exception ex)
                {
                    result.ErrorCode = Consts.ExceptionCode;
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                }
            }

            return(result);
        }
コード例 #5
0
ファイル: Service_Friend.cs プロジェクト: zhangbo27/bbsmax
        public APIResult Friend_MoveFriends(int userID, List <int> friendUserIds, int friendGroupID)
        {
            if (!CheckClient())
            {
                return(null);
            }
            APIResult result = new APIResult();

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = FriendBO.Instance.Server_MoveFriends(userID, friendUserIds, friendGroupID);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName, error.Message);
                        });
                    }
                }
                catch (Exception ex)
                {
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                    result.ErrorCode = Consts.ExceptionCode;
                }
            }
            return(result);
        }
コード例 #6
0
        public APIResult Notify_DeleteNotify(int userID, int notifyID)
        {
            if (!CheckClient())
            {
                return(null);
            }
            APIResult result = new APIResult();

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = NotifyBO.Instance.DeleteNotify(UserBO.Instance.GetAuthUser(userID), notifyID);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName, error.Message);
                        });
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorCode = Consts.ExceptionCode;
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                }
            }

            return(result);
        }
コード例 #7
0
ファイル: Service_Friend.cs プロジェクト: zhangbo27/bbsmax
        public APIResult Friend_RenameFriendGroup(int userID, int groupID, string groupName)
        {
            if (!CheckClient())
            {
                return(null);
            }
            APIResult result = new APIResult();

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    int errorCode;
                    result.IsSuccess = FriendBO.Instance.Server_RenameFriendGroup(userID, groupID, groupName, out errorCode);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName, error.Message);
                        });
                    }
                    result.ErrorCode = errorCode;
                }
                catch (Exception ex)
                {
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                    result.ErrorCode = Consts.ExceptionCode;
                }
            }
            return(result);
        }
コード例 #8
0
ファイル: Service_Friend.cs プロジェクト: zhangbo27/bbsmax
        public APIResult Friend_AcceptAddFriend(int operatorID, int notifyID, int groupIDToAdd)
        {
            if (!CheckClient())
            {
                return(null);
            }
            APIResult result = new APIResult();

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = FriendBO.Instance.Server_AcceptAddFriend(operatorID, notifyID, groupIDToAdd);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName, error.Message);
                        });
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorCode = Consts.ExceptionCode;
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                }
            }

            return(result);
        }
コード例 #9
0
        public APIResult Chat_DeleteChatSessions(int userID, List <int> targetUserIds)
        {
            if (!CheckClient())
            {
                return(null);
            }
            APIResult result = new APIResult();

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = ChatBO.Instance.DeleteChatSessions(userID, targetUserIds);

                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName, error.Message);
                        });
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorCode = Consts.ExceptionCode;
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                }
            }

            return(result);
        }
コード例 #10
0
ファイル: Service_Friend.cs プロジェクト: zhangbo27/bbsmax
        public APIResult Friend_CreateFriendGroup(int userID, string groupName, out FriendGroupProxy friendGroup)
        {
            friendGroup = null;
            if (!CheckClient())
            {
                return(null);
            }
            APIResult   result   = new APIResult();
            FriendGroup newGroup = null;
            int         errorCode;

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = FriendBO.Instance.Server_AddFriendGroup(userID, groupName, out newGroup, out errorCode);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName, error.Message);
                        });
                    }
                    result.ErrorCode = errorCode;
                }
                catch (Exception ex)
                {
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                    result.ErrorCode = Consts.ExceptionCode;
                }
                friendGroup = ProxyConverter.GetFriendGroupProxy(newGroup);
            }
            return(result);
        }
コード例 #11
0
        public APIResult User_ChangePhoneBySmsCode(int userid, string newMobilePhone, string oldSmsCode, string newSmsCode)
        {
            if (!CheckClient())
            {
                return(null);
            }

            AuthUser user = UserBO.Instance.GetAuthUser(userid);

            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.ChangePhoneBySmsCode(user, newMobilePhone, oldSmsCode, newSmsCode);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    else
                    {
                        user.MobilePhone = long.Parse(newMobilePhone);
                    }
                    return(result);
                }
            }
            return(null);
        }
コード例 #12
0
        public APIResult User_SendUnbindPhoneSms(int userID)
        {
            if (!CheckClient())
            {
                return(null);
            }

            AuthUser user = UserBO.Instance.GetAuthUser(userID);

            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.SendUnbindPhoneSms(user);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    return(result);
                }
            }
            return(null);
        }
コード例 #13
0
        public APIResult User_UpdateUserProFile(int userID, bbsMax.Enums.Gender gender, Int16 birthYear, short birthMonth, Int16 birthday, string signature, float timeZone, Passport.Proxy.UserExtendedValueProxy[] extendedFields)
        {
            if (!CheckClient())
            {
                return(null);
            }

            UserExtendedValueCollection fields = new UserExtendedValueCollection();

            foreach (UserExtendedValueProxy proxy in extendedFields)
            {
                fields.Add(UserBO.Instance.GetUserExtendedValue(proxy));
            }

            AuthUser user = UserBO.Instance.GetAuthUser(userID);

            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.Server_UpdateUserProfile(user, gender, birthYear, birthMonth, birthday, signature, timeZone, fields);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    return(result);
                }
            }
            return(null);
        }
コード例 #14
0
        public APIResult User_SendEmailValidateCode(int userid, string email)
        {
            if (!CheckClient())
            {
                return(null);
            }

            AuthUser user = UserBO.Instance.GetAuthUser(userid);

            if (user != null)
            {
                APIResult result = new APIResult();
                result.IsSuccess = true;
                using (ErrorScope es = new ErrorScope())
                {
                    if (UserBO.Instance.SendValidateEmail(userid, user.Username, email) == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.IsSuccess = false;
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    return(result);
                }
            }
            return(null);
        }
コード例 #15
0
        public APIResult User_UpdateEmail(int userid, int targetUserID, string email)
        {
            if (!CheckClient())
            {
                return(null);
            }

            AuthUser user = UserBO.Instance.GetAuthUser(userid);

            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.UpdateEmail(user, targetUserID, email);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }

                    return(result);
                }
            }
            return(null);
        }
コード例 #16
0
        public APIResult Notify_DeleteNotifysByType(int userID, int type)
        {
            if (!CheckClient())
            {
                return(null);
            }
            APIResult result = new APIResult();

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    NotifyBO.Instance.DeleteNotifysByType(UserBO.Instance.GetAuthUser(userID), type);
                    result.IsSuccess = true;
                }
                catch (Exception ex)
                {
                    result.ErrorCode = Consts.ExceptionCode;
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                }
            }

            return(result);
        }
コード例 #17
0
        public APIResult User_UnbindPhoneBySmsCode(int userID, string smsCode)
        {
            if (!CheckClient())
            {
                return(null);
            }

            AuthUser user = UserBO.Instance.GetAuthUser(userID);

            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.UnbindPhoneBySmsCode(user, smsCode);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    else
                    {
                        user.MobilePhone = 0;
                    }
                    return(result);
                }
            }
            return(null);
        }
コード例 #18
0
ファイル: Service_Chat.cs プロジェクト: huchao007/bbsmax
        public APIResult Chat_SendMessage(int senderUserID, int recoverUserID,  string contentWithoutEncode, string ip, bool getNewMessages, int lastMessageID, out List<ChatMessageProxy> chatMessages)
        {
            chatMessages = null;
            if (CheckClient())
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    try
                    {
                        ChatMessageCollection messages = ChatBO.Instance.Server_SendMessage(senderUserID, recoverUserID, contentWithoutEncode, ip, getNewMessages, lastMessageID);

                        chatMessages = new List<ChatMessageProxy>();
                        foreach (ChatMessage message in messages)
                        {
                            chatMessages.Add(ProxyConverter.GetChatMessageProxy(message));
                        }

                        bool hasError = false;
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            hasError = true;
                            result.AddError(error.TatgetName,error.Message);
                        });

                        result.IsSuccess = hasError == false;
                    }
                    catch (Exception ex)
                    {
                        result.ErrorCode = Consts.ExceptionCode;
                        result.AddError(ex.Message);
                        result.IsSuccess = false;
                    }
                }

                return result;
            }
            else
            {
                return null;
            }
        }
コード例 #19
0
        public APIResult Chat_SendMessage(int senderUserID, int recoverUserID, string contentWithoutEncode, string ip, bool getNewMessages, int lastMessageID, out List <ChatMessageProxy> chatMessages)
        {
            chatMessages = null;
            if (CheckClient())
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    try
                    {
                        ChatMessageCollection messages = ChatBO.Instance.Server_SendMessage(senderUserID, recoverUserID, contentWithoutEncode, ip, getNewMessages, lastMessageID);

                        chatMessages = new List <ChatMessageProxy>();
                        foreach (ChatMessage message in messages)
                        {
                            chatMessages.Add(ProxyConverter.GetChatMessageProxy(message));
                        }

                        bool hasError = false;
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            hasError = true;
                            result.AddError(error.TatgetName, error.Message);
                        });

                        result.IsSuccess = hasError == false;
                    }
                    catch (Exception ex)
                    {
                        result.ErrorCode = Consts.ExceptionCode;
                        result.AddError(ex.Message);
                        result.IsSuccess = false;
                    }
                }

                return(result);
            }
            else
            {
                return(null);
            }
        }
コード例 #20
0
        public APIResult User_AdminUpdateUserProFile(
            int operatorUserID
            , int targetUserId
            , string realname
            , string email
            , bbsMax.Enums.Gender gender
            , DateTime birthday
            , string signature
            , bool realnameChecked
            , bool isActive
            , bool emailValidated
            , Passport.Proxy.UserExtendedValueProxy[] extendedFields)
        {
            if (!CheckClient())
            {
                return(null);
            }

            UserExtendedValueCollection fields = new UserExtendedValueCollection();

            foreach (UserExtendedValueProxy proxy in extendedFields)
            {
                fields.Add(UserBO.Instance.GetUserExtendedValue(proxy));
            }

            AuthUser user = UserBO.Instance.GetAuthUser(targetUserId);

            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.AdminUpdateUserProfile(UserBO.Instance.GetAuthUser(operatorUserID)
                                                                              , targetUserId, realname, email, gender, birthday, signature, realnameChecked, isActive, emailValidated, fields);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    return(result);
                }
            }
            return(null);
        }
コード例 #21
0
        public APIResult User_ChangePassword(int userID, string oldPassword, string newPassword)
        {
            if (!CheckClient())
            {
                return(null);
            }
            APIResult result = new APIResult();
            AuthUser  user   = UserBO.Instance.GetAuthUser(userID);

            using (ErrorScope es = new ErrorScope())
            {
                result.IsSuccess = UserBO.Instance.ResetPassword(user, oldPassword, newPassword);
                if (!result.IsSuccess)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error) { result.AddError(error.TatgetName, error.Message); });
                }
            }

            return(result);
        }
コード例 #22
0
ファイル: Service_Friend.cs プロジェクト: zhangbo27/bbsmax
        public APIResult Friend_ShieldFriendGroup(int userID, List <int> groupIds, bool isShield)
        {
            if (!CheckClient())
            {
                return(null);
            }
            APIResult result = new APIResult();

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    FriendBO.Instance.Server_ShieldFriendGroups(userID, groupIds, isShield);
                    result.IsSuccess = true;
                }
                catch (Exception ex)
                {
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                    result.ErrorCode = Consts.ExceptionCode;
                }
            }
            return(result);
        }
コード例 #23
0
ファイル: Service_Friend.cs プロジェクト: huchao007/bbsmax
 public APIResult Friend_RenameFriendGroup(int userID, int groupID, string groupName)
 {
     if (!CheckClient()) return null;
     APIResult result = new APIResult();
     using (ErrorScope es = new ErrorScope())
     {
         try
         {
             int errorCode;
             result.IsSuccess = FriendBO.Instance.Server_RenameFriendGroup(userID, groupID, groupName, out errorCode);
             if (result.IsSuccess == false)
             {
                 es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                 {
                     result.AddError(error.TatgetName,error.Message);
                 });
             }
             result.ErrorCode = errorCode;
         }
         catch (Exception ex)
         {
             result.AddError(ex.Message);
             result.IsSuccess = false;
             result.ErrorCode = Consts.ExceptionCode;
         }
     }
     return result;
 }
コード例 #24
0
ファイル: Service_Notify.cs プロジェクト: huchao007/bbsmax
        public APIResult Notify_DeleteNotify(int userID, int notifyID)
        {
            if (!CheckClient()) return null;
            APIResult result = new APIResult();
            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = NotifyBO.Instance.DeleteNotify(UserBO.Instance.GetAuthUser(userID), notifyID);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName,error.Message);
                        });
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorCode = Consts.ExceptionCode;
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                }
            }

            return result;
        }
コード例 #25
0
ファイル: Service_Notify.cs プロジェクト: huchao007/bbsmax
        public APIResult Notify_DeleteNotifysByType(int userID, int type)
        {
            if (!CheckClient()) return null;
            APIResult result = new APIResult();
            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    NotifyBO.Instance.DeleteNotifysByType(UserBO.Instance.GetAuthUser(userID), type);
                    result.IsSuccess = true;
                }
                catch (Exception ex)
                {
                    result.ErrorCode = Consts.ExceptionCode;
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                }
            }

            return result;
        }
コード例 #26
0
ファイル: Service_User.cs プロジェクト: huchao007/bbsmax
        public APIResult User_AdminUpdateUserProFile(
              int operatorUserID
            , int targetUserId
            , string realname
            , string email
            ,bbsMax.Enums.Gender gender
            , DateTime birthday
            , string signature
            , bool realnameChecked
            , bool isActive
            , bool emailValidated
            , Passport.Proxy.UserExtendedValueProxy[] extendedFields)
        {
            if (!CheckClient())
                return null;

            UserExtendedValueCollection fields = new UserExtendedValueCollection();

            foreach (UserExtendedValueProxy proxy in extendedFields)
            {
                fields.Add(UserBO.Instance.GetUserExtendedValue(proxy));
            }

            AuthUser user = UserBO.Instance.GetAuthUser(targetUserId);
            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.AdminUpdateUserProfile(UserBO.Instance.GetAuthUser(operatorUserID)
                        , targetUserId, realname, email, gender, birthday, signature, realnameChecked,isActive,emailValidated, fields);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    return result;
                }
            }
            return null;
        }
コード例 #27
0
ファイル: Service_Friend.cs プロジェクト: huchao007/bbsmax
 public APIResult Friend_DeleteFromBlacklist(int userID, int userIDInBlacklist)
 {
     if (!CheckClient()) return null;
     APIResult result = new APIResult();
     using (ErrorScope es = new ErrorScope())
     {
         try
         {
             result.IsSuccess = FriendBO.Instance.Server_DeleteFromBlacklist(userID, userIDInBlacklist);
             if (result.IsSuccess == false)
             {
                 es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                 {
                     result.AddError(error.TatgetName,error.Message);
                 });
             }
         }
         catch (Exception ex)
         {
             result.AddError(ex.Message);
             result.IsSuccess = false;
             result.ErrorCode = Consts.ExceptionCode;
         }
     }
     return result;
 }
コード例 #28
0
ファイル: Service_Chat.cs プロジェクト: huchao007/bbsmax
        public APIResult Chat_AdminDeleteSessions(int userID, List<int> sessionIds)
        {
            if (!CheckClient()) return null;
            APIResult result = new APIResult();
            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    ChatBO.Instance.AdminDeleteSessions(userID, sessionIds);
                    bool hasError = false;
                    es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        hasError = true;
                        result.AddError(error.TatgetName,error.Message);
                    });

                    result.IsSuccess = hasError == false;
                }
                catch (Exception ex)
                {
                    result.ErrorCode = Consts.ExceptionCode;
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                }
            }

            return result;
        }
コード例 #29
0
ファイル: Service_Passport.cs プロジェクト: zhangbo27/bbsmax
        public APIResult Passport_RegiserClient(string ownerUsername, string ownerPassword, string clientName, string url, string apiFilePath, string accessKey, int[] instructList, out int clientID)
        {
            APIResult result = new APIResult();

            string ip    = Context.Request.UserHostAddress; //获取客户端ip
            int    count = 0;
            KeyValuePair <string, int> tryer = new KeyValuePair <string, int>();

            foreach (KeyValuePair <string, int> c in clientTryRegCounter)
            {
                if (c.Key == ip)
                {
                    tryer = c;
                    break;
                }
            }

            count = tryer.Value;


            if (count > 10) //最多一个IP10次尝试
            {
                result.IsSuccess = false;
                result.Messages.Add("超过允许的尝试注册次数!请联系Passport管理员");
                clientID = 0;
                return(result);
            }

            if (clientTryRegCounter.Count > 100)  //每次超过100个客户端要注册, 认为是不正常的
            {
                throw new Exception("接口出现异常,已关闭注册。 请联系服务器管理员");
            }

            clientID = 0;

            AuthUser user = UserBO.Instance.GetAuthUser(ownerUsername);

            if (user == null ||
                user == MaxLabs.bbsMax.Entities.User.Guest ||
                !user.IsOwner ||
                !SecurityUtil.ComparePassword(user.PasswordFormat, ownerPassword, user.Password))
            {
                result.IsSuccess = false;
                result.Messages.Add("Passport创始人信息无效!");

                if (string.IsNullOrEmpty(tryer.Key))
                {
                    tryer = new KeyValuePair <string, int>(ip, 1);
                    clientTryRegCounter.Add(tryer);
                }
                else
                {
                    clientTryRegCounter.Remove(tryer);
                    clientTryRegCounter.Add(new KeyValuePair <string, int>(ip, count + 1));
                }

                return(result);
            }

            using (ErrorScope es = new ErrorScope())
            {
                InstructType[] instrcuts = new InstructType[instructList == null ? 0 : instructList.Length];

                for (int i = 0; i < instrcuts.Length; i++)
                {
                    instrcuts[i] = (InstructType)instructList[i];
                }

                PassportClient client = PassportBO.Instance.CreatePassportClient(clientName, url, apiFilePath, accessKey, instrcuts);
                if (client == null)
                {
                    result.IsSuccess = false;

                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        result.AddError(error.TatgetName, error.Message);
                    }
                                              );
                }
                else
                {
                    clientID         = client.ClientID;
                    result.IsSuccess = true;
                }
            }

            return(result);
        }
コード例 #30
0
ファイル: Service_User.cs プロジェクト: huchao007/bbsmax
        public APIResult User_ChangePhoneBySmsCode(int userid, string newMobilePhone, string oldSmsCode, string newSmsCode)
        {
            if (!CheckClient())
                return null;

            AuthUser user = UserBO.Instance.GetAuthUser(userid);
            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.ChangePhoneBySmsCode(user, newMobilePhone, oldSmsCode, newSmsCode);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    else
                    {
                        user.MobilePhone = long.Parse(newMobilePhone);
                    }
                    return result;
                }
            }
            return null;
        }
コード例 #31
0
ファイル: Service_User.cs プロジェクト: huchao007/bbsmax
        public APIResult User_UnbindPhoneBySmsCode(int userID, string smsCode)
        {
            if (!CheckClient())
                return null;

            AuthUser user = UserBO.Instance.GetAuthUser(userID);
            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.UnbindPhoneBySmsCode(user, smsCode);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    else
                    {
                        user.MobilePhone = 0;
                    }
                    return result;
                }
            }
            return null;
        }
コード例 #32
0
ファイル: Service_User.cs プロジェクト: huchao007/bbsmax
        public APIResult User_SendUnbindPhoneSms(int userID)
        {
            if (!CheckClient())
                return null;

            AuthUser user = UserBO.Instance.GetAuthUser(userID);
            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.SendUnbindPhoneSms(user);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    return result;
                }
            }
            return null;
        }
コード例 #33
0
ファイル: Service_User.cs プロジェクト: huchao007/bbsmax
        public APIResult User_ChangePassword(int userID, string oldPassword, string newPassword)
        {
            if (!CheckClient())
                return null;
            APIResult result = new APIResult();
            AuthUser user = UserBO.Instance.GetAuthUser(userID);
            using (ErrorScope es = new ErrorScope())
            {
                result.IsSuccess = UserBO.Instance.ResetPassword(user, oldPassword, newPassword);
                if (!result.IsSuccess)
                {
                    es.CatchError<ErrorInfo>(delegate(ErrorInfo error) { result.AddError( error.TatgetName, error.Message); });
                }
            }

            return result;
        }
コード例 #34
0
ファイル: Service_Friend.cs プロジェクト: huchao007/bbsmax
        public APIResult Friend_CreateFriendGroup(int userID, string groupName, out FriendGroupProxy friendGroup)
        {
            friendGroup = null;
            if (!CheckClient()) return null;
            APIResult result= new APIResult();
            FriendGroup newGroup = null;
            int errorCode;

            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = FriendBO.Instance.Server_AddFriendGroup(userID, groupName, out newGroup, out errorCode);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName,error.Message);
                        });
                    }
                    result.ErrorCode = errorCode;
                }
                catch (Exception ex)
                {
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                    result.ErrorCode = Consts.ExceptionCode;
                }
                friendGroup = ProxyConverter.GetFriendGroupProxy(newGroup);
            }
            return result;
        }
コード例 #35
0
ファイル: Service_Friend.cs プロジェクト: huchao007/bbsmax
 public APIResult Friend_ShieldFriendGroup(int userID, List<int> groupIds, bool isShield)
 {
     if (!CheckClient()) return null;
     APIResult result = new APIResult();
     using (ErrorScope es = new ErrorScope())
     {
         try
         {
             FriendBO.Instance.Server_ShieldFriendGroups(userID, groupIds, isShield);
             result.IsSuccess = true;
         }
         catch (Exception ex)
         {
             result.AddError(ex.Message);
             result.IsSuccess = false;
             result.ErrorCode = Consts.ExceptionCode;
         }
     }
     return result;
 }
コード例 #36
0
ファイル: Service_User.cs プロジェクト: huchao007/bbsmax
        public APIResult User_UpdateEmail(int userid,int targetUserID, string email)
        {
            if (!CheckClient())
                return null;

            AuthUser user = UserBO.Instance.GetAuthUser(userid);
            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.UpdateEmail(user,targetUserID, email);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }

                    return result;
                }
            }
            return null;
        }
コード例 #37
0
ファイル: Service_Passport.cs プロジェクト: huchao007/bbsmax
        public APIResult Passport_RegiserClient( string ownerUsername,string ownerPassword, string clientName,string url,string apiFilePath,string accessKey,int[] instructList,out int clientID)
        {
            APIResult result = new APIResult();

            string ip = Context.Request.UserHostAddress; //获取客户端ip
            int count=0;
            KeyValuePair<string, int> tryer = new KeyValuePair<string, int>();
            foreach ( KeyValuePair<string,int> c in clientTryRegCounter)
            {
                if (c.Key == ip)
                {
                    tryer = c;
                    break;
                }
            }

            count = tryer.Value;
            

            if (count > 10) //最多一个IP10次尝试
            {
                result.IsSuccess = false;
                result.Messages.Add("超过允许的尝试注册次数!请联系Passport管理员");
                clientID = 0;
                return result;
            }

            if (clientTryRegCounter.Count > 100)  //每次超过100个客户端要注册, 认为是不正常的
            {
                throw new Exception("接口出现异常,已关闭注册。 请联系服务器管理员");
            }

            clientID = 0;
      
            AuthUser user = UserBO.Instance.GetAuthUser(ownerUsername);
            if (user == null
                || user == MaxLabs.bbsMax.Entities.User.Guest
                || !user.IsOwner
                || !SecurityUtil.ComparePassword( user.PasswordFormat, ownerPassword, user.Password))
            {
                result.IsSuccess = false;
                result.Messages .Add( "Passport创始人信息无效!");

                if (string.IsNullOrEmpty(tryer.Key))
                {
                    tryer = new KeyValuePair<string, int>(ip, 1);
                    clientTryRegCounter.Add(tryer);
                }
                else
                {
                    clientTryRegCounter.Remove(tryer);
                    clientTryRegCounter.Add(new KeyValuePair<string, int>(ip, count + 1));
                }

                return result;
            }

            using (ErrorScope es = new ErrorScope())
            {
                InstructType[] instrcuts = new InstructType[instructList == null ? 0 : instructList.Length];

                for (int i = 0; i < instrcuts.Length; i++)
                    instrcuts[i] = (InstructType) instructList[i];

                PassportClient client = PassportBO.Instance.CreatePassportClient(clientName, url, apiFilePath, accessKey, instrcuts);
                if (client == null)
                {
                    result.IsSuccess = false;

                    es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        result.AddError(error.TatgetName,error.Message);
                    }
                    );
                }
                else
                {
                    clientID = client.ClientID;
                    result.IsSuccess = true;
                }
            }

            return result;
        }
コード例 #38
0
ファイル: Service_User.cs プロジェクト: huchao007/bbsmax
        public APIResult User_SendEmailValidateCode(int userid, string email)
        {
            if (!CheckClient())
                return null;

            AuthUser user = UserBO.Instance.GetAuthUser(userid);
            if (user != null)
            {
                APIResult result = new APIResult();
                result.IsSuccess = true;
                using (ErrorScope es = new ErrorScope())
                {
                    if (UserBO.Instance.SendValidateEmail(userid, user.Username, email) == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo err)
                       {
                            result.IsSuccess = false;
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    return result;
                }
            }
            return null; 
        }
コード例 #39
0
ファイル: Service_Chat.cs プロジェクト: huchao007/bbsmax
        public APIResult Chat_DeleteChatSessions(int userID, List<int> targetUserIds)
        {
            if (!CheckClient()) return null;
            APIResult result = new APIResult();
            using (ErrorScope es = new ErrorScope())
            {
                try
                {
                    result.IsSuccess = ChatBO.Instance.DeleteChatSessions(userID, targetUserIds);

                    if (result.IsSuccess == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            result.AddError(error.TatgetName,error.Message);
                        });
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorCode = Consts.ExceptionCode;
                    result.AddError(ex.Message);
                    result.IsSuccess = false;
                }
            }

            return result;
        }
コード例 #40
0
ファイル: Service_User.cs プロジェクト: huchao007/bbsmax
        public APIResult User_UpdateUserProFile(int userID,bbsMax.Enums.Gender gender, Int16 birthYear, short birthMonth, Int16 birthday, string signature, float timeZone, Passport.Proxy.UserExtendedValueProxy[] extendedFields)
        {
            if (!CheckClient())
                return null;

            UserExtendedValueCollection fields = new UserExtendedValueCollection();

            foreach (UserExtendedValueProxy proxy in extendedFields)
            {
                fields.Add(UserBO.Instance.GetUserExtendedValue(proxy));
            }

            AuthUser user = UserBO.Instance.GetAuthUser(userID);
            if (user != null)
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    result.IsSuccess = UserBO.Instance.Server_UpdateUserProfile(user, gender, birthYear, birthMonth, birthday, signature, timeZone, fields);
                    if (result.IsSuccess == false)
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo err)
                        {
                            result.AddError(err.TatgetName, err.Message);
                        });
                    }
                    return result;

                }
            }
            return null;
        }
コード例 #41
0
ファイル: Service_Friend.cs プロジェクト: huchao007/bbsmax
 public APIResult Friend_UpdateFriendHot(int userID, int hotType, int friendUserID)
 {
     if (!CheckClient()) return null;
     APIResult result = new APIResult();
     using (ErrorScope es = new ErrorScope())
     {
         try
         {
             result.IsSuccess = FriendBO.Instance.Server_UpdateFriendHot(userID, (MaxLabs.bbsMax.Enums.HotType)hotType, friendUserID);
             if (result.IsSuccess == false)
             {
                 es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                 {
                     result.AddError(error.TatgetName,error.Message);
                 });
             }
         }
         catch (Exception ex)
         {
             result.AddError(ex.Message);
             result.IsSuccess = false;
             result.ErrorCode = Consts.ExceptionCode;
         }
     }
     return result;
 }
コード例 #42
0
ファイル: Service_Friend.cs プロジェクト: huchao007/bbsmax
 public APIResult Friend_MoveFriends(int userID, List<int> friendUserIds, int friendGroupID)
 {
     if (!CheckClient()) return null;
     APIResult result = new APIResult();
     using (ErrorScope es = new ErrorScope())
     {
         try
         {
             result.IsSuccess = FriendBO.Instance.Server_MoveFriends(userID, friendUserIds, friendGroupID);
             if (result.IsSuccess == false)
             {
                 es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                 {
                     result.AddError(error.TatgetName,error.Message);
                 });
             }
         }
         catch (Exception ex)
         {
             result.AddError(ex.Message);
             result.IsSuccess = false;
             result.ErrorCode = Consts.ExceptionCode;
         }
     }
     return result;
 }