Exemple #1
0
 /// <summary>
 /// 获取当前的用户的iD跟UserName
 /// </summary>
 /// <returns></returns>
 public SmsAccountInfo GetCurrentUser()
 {
     if (!string.IsNullOrEmpty(Cookie.GetCookie("userid")))
     {
         SmsAccountInfo user       = new SmsAccountInfo();
         var            httpCookie = Cookie.GetCookie("userid");
         if (httpCookie != null)
         {
             user.ID = int.Parse(httpCookie);
         }
         var cookie = Cookie.GetCookie("account");
         if (cookie != null)
         {
             user.Account = cookie;
         }
         if (Session.GetSession(AppContent.USER_KEY) == null)
         {
             AccountHandler handler = new AccountHandler();
             user = handler.GetAccount(user.ID);
             Session.SetSession(AppContent.USER_KEY, user);
         }
         else
         {
             user = Session.GetSession(AppContent.USER_KEY) as SmsAccountInfo;
             if (user.ID != int.Parse(httpCookie))
             {
                 AccountHandler handler = new AccountHandler();
                 user = handler.GetAccount(int.Parse(httpCookie));
                 Session.SetSession(AppContent.USER_KEY, user);
             }
         }
         return(user);
     }
     return(null);
 }
Exemple #2
0
 public HandlerResponse EditAccount()
 {
     SmsAccountInfo info = new SmsAccountInfo();
     info.Account = Request.Form["account"];
     info.Signature = Request.Params["signature"];
     info.ID = Convert.ToInt32(Request.Params["id"]);
     SmsAccountManage.Instance.EditAccount(info);
     return CreateHandler(1, "修改成功");
 }
Exemple #3
0
        public bool CheckUser(int accountId)
        {
            SmsAccountInfo info = SmsAccountManage.Instance.FindById(accountId);

            if (info == null || info.State == 0)
            {
                return(false);
            }
            return(true);
        }
Exemple #4
0
        public HandlerResponse EditAccount()
        {
            SmsAccountInfo info = new SmsAccountInfo();

            info.Account   = Request.Form["account"];
            info.Signature = Request.Params["signature"];
            info.ID        = Convert.ToInt32(Request.Params["id"]);
            SmsAccountManage.Instance.EditAccount(info);
            return(CreateHandler(1, "修改成功"));
        }
Exemple #5
0
 public HandlerResponse AddAccount()
 {
     SmsAccountInfo info = new SmsAccountInfo();
     info.EnterpriseID = int.Parse(Request.Params["enterpriseid"]);
     info.Account = Request.Form["account"];
     info.Password = "******";
     info.Signature = Request.Params["signature"];
     info.Createtime = DateTime.Now;
     info.State = 1;
     SmsAccountManage.Instance.AddAccount(info);
     return CreateHandler(1, "添加成功");
 }
Exemple #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AccountHandler handler = new AccountHandler();
            SmsAccountInfo info    = handler.GetAccount(int.Parse(Request.QueryString["id"]));

            if (info != null)
            {
                account = info.Account;
                sign    = info.Signature;
            }
            Page.DataBind();
        }
Exemple #7
0
        public HandlerResponse AddAccount()
        {
            SmsAccountInfo info = new SmsAccountInfo();

            info.EnterpriseID = int.Parse(Request.Params["enterpriseid"]);
            info.Account      = Request.Form["account"];
            info.Password     = "******";
            info.Signature    = Request.Params["signature"];
            info.Createtime   = DateTime.Now;
            info.State        = 1;
            SmsAccountManage.Instance.AddAccount(info);
            return(CreateHandler(1, "添加成功"));
        }
Exemple #8
0
        public HandlerResponse Login()
        {
            string username = Request.Params["username"];
            string password = Request.Params["password"];

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                return(CreateHandler(0, "用户名或密码不能为空"));
            }
            SmsAccountInfo info = SmsAccountManage.Instance.GetAccountInfo(username, password);

            if (info == null)
            {
                return(CreateHandler(0, "用户名或密码错误"));
            }
            AppContent.Current.LoginUser(info, DateTime.Now.AddDays(10));
            return(CreateHandler(1, "登录成功"));
        }
Exemple #9
0
        /// <summary>
        /// 验证账号是否合法
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static bool CheckAccount(string username, string password)
        {
            if (string.IsNullOrEmpty(username) ||
                string.IsNullOrEmpty(password) ||
                password.Length < 32)
            {
                return(false);
            }
            SmsAccountInfo account = CacheHelper.Get <SmsAccountInfo>(AcctountCachePre + username);

            if (account == null)
            {
                account = SmsAccountManage.Instance.GetAccountInfo(username, password);
            }
            if (account == null || account.EnterpriseID == 0)
            {
                return(false);
            }
            CacheHelper.Insert(AcctountCachePre + username, account);
            return(true);
        }
Exemple #10
0
 /// <summary>
 /// 用户的登录处理
 /// </summary>
 /// <param name="user"></param>
 /// <param name="expriseTime"></param>
 public void LoginUser(SmsAccountInfo user, DateTime expriseTime)
 {
     Cookie.SaveCookie("userid", user.ID.ToString(), 20);
     Cookie.SaveCookie("account", user.Account, 20);
     Session.SetSession(AppContent.USER_KEY, user);
 }
Exemple #11
0
 /// <summary>
 /// 用户的登录处理
 /// </summary>
 /// <param name="user"></param>
 /// <param name="expriseTime"></param>
 public void LoginUser(SmsAccountInfo user, DateTime expriseTime)
 {
     Cookie.SaveCookie("userid", user.ID.ToString(), 20);
     Cookie.SaveCookie("account", user.Account, 20);
     Session.SetSession(AppContent.USER_KEY, user);
 }
Exemple #12
0
 /// <summary>
 /// 获取当前的用户的iD跟UserName
 /// </summary>
 /// <returns></returns>
 public SmsAccountInfo GetCurrentUser()
 {
     if (!string.IsNullOrEmpty(Cookie.GetCookie("userid")))
     {
         SmsAccountInfo user = new SmsAccountInfo();
         var httpCookie = Cookie.GetCookie("userid");
         if (httpCookie != null)
             user.ID = int.Parse(httpCookie);
         var cookie = Cookie.GetCookie("account");
         if (cookie != null)
             user.Account = cookie;
         if (Session.GetSession(AppContent.USER_KEY) == null)
         {
             AccountHandler handler = new AccountHandler();
             user = handler.GetAccount(user.ID);
             Session.SetSession(AppContent.USER_KEY, user);
         }
         else
         {
             user = Session.GetSession(AppContent.USER_KEY) as SmsAccountInfo;
             if (user.ID != int.Parse(httpCookie))
             {
                 AccountHandler handler = new AccountHandler();
                 user = handler.GetAccount(int.Parse(httpCookie));
                 Session.SetSession(AppContent.USER_KEY, user);
             }
         }
         return user;
     }
     return null;
 }