Exemple #1
0
        protected override void OnRequest()
        {
            base.OnRequest();

            try
            {
                string accountName     = getParameter("account_name");
                string accountMail     = getParameter("account_mail");
                string accountNickname = getParameter("account_nickname");

                List <ViewUserinfoModel> userinfoList = null;
                using (Controller.Account controllerAccount = new Controller.Account())
                {
                    userinfoList = controllerAccount.GetUserinfoList(accountName, accountMail, accountNickname);
                }
                WriteJson(userinfoList);
            }
            catch (UnfulfilException ex)
            {
                WriteUnfulfil(ex.DisplayMessage);
            }
            catch (Database.Exception ex)
            {
                WriteException(ex);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }
        protected override void OnRequest()
        {
            base.OnRequest();

            try
            {
                List <AccountModel> accountList = null;
                using (Controller.Account controllerAccount = new Controller.Account())
                {
                    accountList = controllerAccount.GetAccountList();
                }
                WriteJson(accountList);
            }
            catch (UnfulfilException ex)
            {
                WriteUnfulfil(ex.DisplayMessage);
            }
            catch (Database.Exception ex)
            {
                WriteException(ex);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }
Exemple #3
0
        protected override void OnRequest()
        {
            base.OnRequest();

            ChatContent chatContent = getModel <ChatContent>();

            try
            {
                if (chatContent != null)
                {
                    UserinfoModel userModel = null;
                    using (Controller.Account controllerAccount = new Controller.Account())
                    {
                        userModel = controllerAccount.GetUserinfo(aid);
                        if (userModel == null)
                        {
                            throw new UnfulfilException(0, "未找到指定用户");
                        }
                    }

                    String sendUserName = userModel.userNickname;
                    new Controller.Message().AddMessage(chatContent.userid, chatContent.content, this.aid, Controller.Message.MESSAGE_STATUS.UNREACH, Controller.Message.MESSAGE_STYLE.INFORMATION, sendUserName, Controller.Message.MESSAGE_TYPE.CHAT);
                    WriteSuccess <string>("发送成功");
                }
                else
                {
                    WriteUnfulfil("");
                }
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }
        protected override void OnRequest()
        {
            base.OnRequest();

            try
            {
                AccountModifyInfo accountModify = getModel <AccountModifyInfo>();

                using (Controller.Account accountController = new Controller.Account())
                {
                    if (!string.IsNullOrWhiteSpace(accountModify.account_password))
                    {
                        accountController.ChangePassword(accountModify.account_name, accountModify.account_password);
                    }
                    ProfileModel profile = new ProfileModel();
                    profile.Nickname    = accountModify.account_nickname;
                    profile.MemberValid = DateTime.Parse(accountModify.account_membervalid);

                    profile.profileid = accountController.GetAccountProfileID(accountModify.account_name);

                    accountController.UpdateProfile(profile);
                }

                WriteSuccess <string>("success");
            }catch (FormatException ex)
            {
                WriteFail("/language/parameter/format_exception");
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }
        protected override void OnRequest()
        {
            base.OnRequest();

            try
            {
                List <uint> accountList = getModel <List <uint> >("account_list");

                using (Controller.Account controllerAccount = new Controller.Account())
                {
                    foreach (uint accountID in accountList)
                    {
                        if (accountID == 1)
                        {
                            throw new Exception("禁止删除管理员账号");
                        }
                        controllerAccount.DeleteAccount(accountID);
                    }
                }

                WriteSuccess <string>("success");
            }
            catch (UnfulfilException ex)
            {
                WriteUnfulfil(ex.DisplayMessage);
            }
            catch (Database.Exception ex)
            {
                WriteException(ex);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }
Exemple #6
0
        protected override void OnRequest()
        {
            string accountName     = getParameter("account");
            string accountPassword = getParameter("password");

            uint         aid     = 0;
            SessionModel session = null;

            try
            {
                aid     = new Controller.Account().CheckAccountPassword(accountName, accountPassword);
                session = new Controller.Session().CreateSession(accountName, aid);

                LoginResponseModel userLogin = new LoginResponseModel();
                userLogin.AccountID = aid;
                userLogin.Username  = accountName;
                userLogin.Token     = session.Token;
                userLogin.Expire    = session.ValidDay.ToString();

                userLogin.Redirect = "Main.html";

                WriteSuccess <LoginResponseModel>(userLogin);
            }
            catch (ExceptionMessage ex)
            {
                WriteFail(ex.Code, ex.DisplayMessage);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }finally
            {
            }
        }
Exemple #7
0
        protected uint GetUserPrivilege(string Token)
        {
            uint aid;
            uint pid;

            using (Controller.Session controllerSession = new Controller.Session())
            {
                aid = controllerSession.GetAccountId(Token);
            }

            using (Controller.Account controllerAccount = new Controller.Account())
            {
                pid = controllerAccount.GetAccountPrivilege(aid);
            }

            return(pid);
        }
        protected override void OnRequest()
        {
            base.OnRequest();
            UserinfoModel userInfo = null;

            uint?userID = getParameterUint("user_id");

            try
            {
                if (userID == null)
                {
                    throw new UnfulfilException(0, "未指定用户");
                }

                using (Controller.Account controllerAccount = new Controller.Account())
                {
                    userInfo = controllerAccount.GetUserinfo((uint)userID);
                    if (userInfo == null)
                    {
                        throw new UnfulfilException(0, "未找到指定用户");
                    }
                }

                WriteSuccess <UserinfoModel>(userInfo);
            }
            catch (UnfulfilException ex)
            {
                WriteUnfulfil(ex.DisplayMessage);
            }
            catch (Database.Exception ex)
            {
                WriteException(ex);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }
Exemple #9
0
        protected override void OnRequest()
        {
            AccountRegisterInfo accountInfo = getModel <AccountRegisterInfo>();

            uint aid = 0;

            try
            {
                if (accountInfo == null)
                {
                    throw new ExceptionMessage("/language/register/account_info_not_complete");
                }

                if (string.IsNullOrWhiteSpace(accountInfo.account_name))
                {
                    throw new ExceptionMessage("/language/register/need_account_name");
                }

                if (string.IsNullOrWhiteSpace(accountInfo.account_password))
                {
                    throw new ExceptionMessage("/language/register/need_password");
                }

                if (string.IsNullOrWhiteSpace(accountInfo.account_nickname))
                {
                    throw new ExceptionMessage("/language/register/need_nickname");
                }

                AccountModel account = new AccountModel();
                account.Name     = accountInfo.account_name;
                account.Password = accountInfo.account_password;
                account.Mail     = accountInfo.account_mail;

                aid = new Controller.Account().AddAccount(account);

                if (!string.IsNullOrWhiteSpace(accountInfo.account_nickname))
                {
                    ProfileModel profile = new ProfileModel();
                    profile.profileid = null;
                    profile.Nickname  = accountInfo.account_nickname;
                    profile.Avatar    = null;
                    uint         profileid     = new Controller.Account().AddProfile(profile);
                    AccountModel accountUpdate = new AccountModel();
                    accountUpdate.aid       = aid;
                    accountUpdate.profileid = profileid;
                    new Controller.Account().UpdateAccountInfo(accountUpdate);
                }

                WriteSuccess <string>("success");
            }
            catch (UnfulfilException ex)
            {
                WriteFail(ex.Code, ex.DisplayMessage);
            }
            catch (ExceptionMessage ex)
            {
                WriteFail(ex.Code, ex.DisplayMessage);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
            finally
            {
            }
        }
Exemple #10
0
        protected override void OnRequest()
        {
            AccountRegisterInfo accountInfo = getModel <AccountRegisterInfo>();

            uint         aid     = 0;
            SessionModel session = null;

            try
            {
                if (accountInfo == null)
                {
                    throw new ExceptionMessage("/language/register/account_info_not_complete");
                }

                if (string.IsNullOrWhiteSpace(accountInfo.account_name))
                {
                    throw new ExceptionMessage("/language/register/need_account_name");
                }

                if (string.IsNullOrWhiteSpace(accountInfo.account_password))
                {
                    throw new ExceptionMessage("/language/register/need_password");
                }

                if (string.IsNullOrWhiteSpace(accountInfo.account_nickname))
                {
                    throw new ExceptionMessage("/language/register/need_nickname");
                }

                AccountModel account = new AccountModel();
                account.Name     = accountInfo.account_name;
                account.Password = accountInfo.account_password;
                account.Mail     = accountInfo.account_mail;

                aid = new Controller.Account().AddAccount(account);

                if (!string.IsNullOrWhiteSpace(accountInfo.account_nickname))
                {
                    ProfileModel profile = new ProfileModel();
                    profile.profileid = null;
                    profile.Nickname  = accountInfo.account_nickname;
                    profile.Avatar    = null;
                    uint         profileid     = new Controller.Account().AddProfile(profile);
                    AccountModel accountUpdate = new AccountModel();
                    accountUpdate.aid       = aid;
                    accountUpdate.profileid = profileid;
                    new Controller.Account().UpdateAccountInfo(accountUpdate);
                }

                session = new Controller.Session().CreateSession(accountInfo.account_name, aid);

                LoginResponseModel userLogin = new LoginResponseModel();
                userLogin.AccountID = aid;
                userLogin.Username  = accountInfo.account_name;
                userLogin.Token     = session.Token;
                userLogin.Expire    = session.ValidDay.ToString();

                userLogin.Redirect = "Main.html";

                WriteSuccess <LoginResponseModel>(userLogin);
            }
            catch (UnfulfilException ex)
            {
                WriteUnfulfil(ex.DisplayMessage);
            }
            catch (ExceptionMessage ex)
            {
                WriteFail(ex.Code, ex.DisplayMessage);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
            finally
            {
            }
        }