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); }
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; }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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; } }
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); } }
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); }
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); }
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); }
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; }
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; }
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; }
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; }
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; }
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; }
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); }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }