Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string oldpass = Request.Form["oldpass"];
                string newpass = Request.Form["newpass"];

                MyCreek.Platform.Users busers = new MyCreek.Platform.Users();
                var user = MyCreek.Platform.Users.CurrentUser;
                if (user != null)
                {
                    if (string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(), oldpass.Trim()), false) != 0)
                    {
                        MyCreek.Platform.Log.Add("修改密码失败", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码失败,旧密码错误!"), MyCreek.Platform.Log.Types.用户登录);
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('旧密码错误!');", true);
                    }
                    else
                    {
                        busers.UpdatePassword(newpass.Trim(), user.ID);
                        MyCreek.Platform.Log.Add("修改密码成功", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码成功!"), MyCreek.Platform.Log.Types.用户登录);
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('密码修改成功!');new RoadUI.Window().close();", true);
                    }
                }
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Account.Attributes.Add("validate_url", "CheckAccount.ashx");
            MyCreek.Platform.Organize borganize = new MyCreek.Platform.Organize();
            MyCreek.Platform.Users    busers    = new MyCreek.Platform.Users();

            string id = Request.QueryString["id"];

            string name    = string.Empty;
            string account = string.Empty;
            string status  = string.Empty;
            string note    = string.Empty;
            Guid   parentID;

            if (IsPostBack && id.IsGuid(out parentID))
            {
                name    = Request.Form["Name"];
                account = Request.Form["Account"];
                status  = Request.Form["Status"];
                note    = Request.Form["Note"];

                Guid   userID  = Guid.NewGuid();
                string userXML = string.Empty;
                using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                {
                    //添加人员
                    MyCreek.Data.Model.Users user = new MyCreek.Data.Model.Users();
                    user.Account  = account.Trim();
                    user.Name     = name.Trim();
                    user.Note     = note.IsNullOrEmpty() ? null : note;
                    user.Password = busers.GetUserEncryptionPassword(userID.ToString(), busers.GetInitPassword());
                    user.Sort     = 1;
                    user.Status   = status.IsInt() ? status.ToInt() : 0;
                    user.ID       = userID;
                    busers.Add(user);

                    //添加关系
                    MyCreek.Data.Model.UsersRelation userRelation = new MyCreek.Data.Model.UsersRelation();
                    userRelation.IsMain     = 1;
                    userRelation.OrganizeID = parentID;
                    userRelation.Sort       = new MyCreek.Platform.UsersRelation().GetMaxSort(parentID);
                    userRelation.UserID     = userID;
                    new MyCreek.Platform.UsersRelation().Add(userRelation);

                    //更新父级[ChildsLength]字段
                    borganize.UpdateChildsLength(parentID);

                    //更新角色
                    new MyCreek.Platform.UsersRole().UpdateByUserID(userID);

                    userXML = user.Serialize();
                    scope.Complete();
                }

                MyCreek.Platform.Log.Add("添加了人员", userXML, MyCreek.Platform.Log.Types.组织机构);
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');parent.frames[0].reLoad('" + id + "');window.location=window.location;", true);
            }
            this.StatusRadios.Text = borganize.GetStatusRadio("Status", "0", "validate=\"radio\"");
        }
Exemple #3
0
        public ActionResult UserAdd(FormCollection collection)
        {
            MyCreek.Platform.Organize borganize = new MyCreek.Platform.Organize();
            MyCreek.Platform.Users    busers    = new MyCreek.Platform.Users();

            string id = Request.QueryString["id"];

            string name    = string.Empty;
            string account = string.Empty;
            string status  = string.Empty;
            string note    = string.Empty;
            Guid   parentID;

            if (collection != null && id.IsGuid(out parentID))
            {
                name    = Request.Form["Name"];
                account = Request.Form["Account"];
                status  = Request.Form["Status"];
                note    = Request.Form["Note"];

                Guid   userID  = Guid.NewGuid();
                string userXML = string.Empty;
                using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                {
                    //添加人员
                    MyCreek.Data.Model.Users user = new MyCreek.Data.Model.Users();
                    user.Account  = account.Trim();
                    user.Name     = name.Trim();
                    user.Note     = note.IsNullOrEmpty() ? null : note;
                    user.Password = busers.GetUserEncryptionPassword(userID.ToString(), busers.GetInitPassword());
                    user.Sort     = 1;
                    user.Status   = status.IsInt() ? status.ToInt() : 0;
                    user.ID       = userID;
                    busers.Add(user);

                    //添加关系
                    MyCreek.Data.Model.UsersRelation userRelation = new MyCreek.Data.Model.UsersRelation();
                    userRelation.IsMain     = 1;
                    userRelation.OrganizeID = parentID;
                    userRelation.Sort       = new MyCreek.Platform.UsersRelation().GetMaxSort(parentID);
                    userRelation.UserID     = userID;
                    new MyCreek.Platform.UsersRelation().Add(userRelation);

                    //更新父级[ChildsLength]字段
                    borganize.UpdateChildsLength(parentID);

                    //更新角色
                    new MyCreek.Platform.UsersRole().UpdateByUserID(userID);

                    userXML = user.Serialize();
                    scope.Complete();
                }

                MyCreek.Platform.Log.Add("添加了人员", userXML, MyCreek.Platform.Log.Types.组织机构);
                ViewBag.Script = "alert('添加成功!');parent.frames[0].reLoad('" + id + "');window.location=window.location;";
            }
            ViewBag.StatusRadios = borganize.GetStatusRadio("Status", "0", "validate=\"radio\"");
            return(View());
        }
Exemple #4
0
        public ActionResult EditPass(FormCollection collection)
        {
            string oldpass = Request.Form["oldpass"];
            string newpass = Request.Form["newpass"];

            MyCreek.Platform.Users busers = new MyCreek.Platform.Users();
            var user = MyCreek.Platform.Users.CurrentUser;

            if (user != null)
            {
                if (string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(), oldpass.Trim()), false) != 0)
                {
                    MyCreek.Platform.Log.Add("修改密码失败", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码失败,旧密码错误!"), MyCreek.Platform.Log.Types.用户登录);
                    ViewBag.Script = "alert('旧密码错误!');";
                }
                else
                {
                    busers.UpdatePassword(newpass.Trim(), user.ID);
                    MyCreek.Platform.Log.Add("修改密码成功", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码成功!"), MyCreek.Platform.Log.Types.用户登录);
                    ViewBag.Script = "alert('密码修改成功!');new RoadUI.Window().close();";
                }
            }
            return(View());
        }
        public ActionResult Login(FormCollection collection)
        {
            string isVcodeSessionKey = MyCreek.Utility.Keys.SessionKeys.IsValidateCode.ToString();
            string vcodeSessionKey   = MyCreek.Utility.Keys.SessionKeys.ValidateCode.ToString();

            ViewBag.Forcescript       = "";
            ViewBag.IsVcodeSessionKey = isVcodeSessionKey;
            ViewBag.ErrMsg            = "";
            string account       = collection["Account"];
            string password      = collection["Password"];
            string force         = collection["Force"];
            string vcode         = collection["VCode"];
            bool   isSessionLost = "1" == Request.QueryString["session"];//是否是超时后再登录

            if (System.Web.HttpContext.Current.Session[isVcodeSessionKey] != null &&
                "1" == System.Web.HttpContext.Current.Session[isVcodeSessionKey].ToString() &&
                (System.Web.HttpContext.Current.Session[vcodeSessionKey] == null ||
                 string.Compare(System.Web.HttpContext.Current.Session[vcodeSessionKey].ToString(), vcode.Trim(), true) != 0))
            {
                ViewBag.ErrMsg = "alert('验证码错误!');";
            }
            else if (account.IsNullOrEmpty() || password.IsNullOrEmpty())
            {
                Session[isVcodeSessionKey] = "1";
                MyCreek.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号或密码为空"), MyCreek.Platform.Log.Types.用户登录);
                ViewBag.ErrMsg = "alert('帐号或密码不能为空!');";
            }
            else
            {
                MyCreek.Platform.Users busers = new MyCreek.Platform.Users();
                var user = busers.GetByAccount(account.Trim());
                if (user == null || string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(), password.Trim()), false) != 0)
                {
                    System.Web.HttpContext.Current.Session[isVcodeSessionKey] = "1";
                    MyCreek.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号或密码错误"), MyCreek.Platform.Log.Types.用户登录);
                    ViewBag.ErrMsg = "alert('帐号或密码错误!');";
                }
                else if (user.Status == 1)
                {
                    System.Web.HttpContext.Current.Session[isVcodeSessionKey] = "1";
                    MyCreek.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号已被冻结"), MyCreek.Platform.Log.Types.用户登录);
                    ViewBag.ErrMsg = "alert('帐号已被冻结!');";
                }
                else
                {
                    MyCreek.Platform.OnlineUsers bou = new MyCreek.Platform.OnlineUsers();
                    var onUser = bou.Get(user.ID);
                    if (onUser != null && "1" != force)
                    {
                        string ip = onUser.IP;
                        System.Web.HttpContext.Current.Session.Remove(isVcodeSessionKey);
                        ViewBag.Forcescript = "if(confirm('当前帐号已经在" + ip + "登录,您要强行登录吗?')){$('#Account').val('" + account + "');$('#Password').val('" + password + "');$('#Force').val('1');$('#form1').submit();}";
                    }
                    else
                    {
                        Guid uniqueID = Guid.NewGuid();
                        System.Web.HttpContext.Current.Session[MyCreek.Utility.Keys.SessionKeys.UserID.ToString()]       = user.ID;
                        System.Web.HttpContext.Current.Session[MyCreek.Utility.Keys.SessionKeys.UserUniqueID.ToString()] = uniqueID;
                        System.Web.HttpContext.Current.Session[MyCreek.Utility.Keys.SessionKeys.BaseUrl.ToString()]      = Url.Content("~/");
                        bou.Add(user, uniqueID);
                        System.Web.HttpContext.Current.Session.Remove(isVcodeSessionKey);
                        MyCreek.Platform.Log.Add("用户登录成功", string.Concat("用户:", user.Name, "(", user.ID, ")登录成功"), MyCreek.Platform.Log.Types.用户登录);
                        if (isSessionLost)
                        {
                            ViewBag.Forcescript = "alert('登录成功!');new RoadUI.Window().close();";
                        }
                        else
                        {
                            ViewBag.Forcescript = "top.location='" + Url.Content("~/Home") + "';";
                        }
                    }
                }
            }
            return(View());
        }
Exemple #6
0
        private void check()
        {
            string isVcodeSessionKey = MyCreek.Utility.Keys.SessionKeys.IsValidateCode.ToString();
            string vcodeSessionKey   = MyCreek.Utility.Keys.SessionKeys.ValidateCode.ToString();

            string account       = Request.Form["Account"];
            string password      = Request.Form["Password"];
            string force         = Request.Form["Force"];
            string vcode         = Request.Form["VCode"];
            bool   isSessionLost = "1" == Request.QueryString["session"];//是否是超时后再登录

            if (Session[isVcodeSessionKey] != null &&
                "1" == Session[isVcodeSessionKey].ToString() &&
                (Session[vcodeSessionKey] == null ||
                 string.Compare(Session[vcodeSessionKey].ToString(), vcode.Trim(), true) != 0))
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "error", "alert('验证码错误!');", true);
            }
            else if (account.IsNullOrEmpty() || password.IsNullOrEmpty())
            {
                Session[isVcodeSessionKey] = "1";
                MyCreek.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号或密码为空"), MyCreek.Platform.Log.Types.用户登录);
                Script = "alert('帐号或密码不能为空!');";
            }
            else
            {
                MyCreek.Platform.Users busers = new MyCreek.Platform.Users();
                var user = busers.GetByAccount(account.Trim());
                if (user == null || string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(), password.Trim()), false) != 0)
                {
                    Session[isVcodeSessionKey] = "1";
                    MyCreek.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号或密码错误"), MyCreek.Platform.Log.Types.用户登录);
                    Script = "alert('帐号或密码错误!');";
                }
                else if (user.Status == 1)
                {
                    Session[isVcodeSessionKey] = "1";
                    MyCreek.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号已被冻结"), MyCreek.Platform.Log.Types.用户登录);
                    Script = "alert('帐号已被冻结!');";
                }
                else
                {
                    MyCreek.Platform.OnlineUsers bou = new MyCreek.Platform.OnlineUsers();
                    var onUser = bou.Get(user.ID);
                    if (onUser != null && "1" != force)
                    {
                        string ip = onUser.IP;
                        Session.Remove(isVcodeSessionKey);
                        Script = "if(confirm('当前帐号已经在" + ip + "登录,您要强行登录吗?')){$('#Account').val('" + account + "');$('#Password').val('" + password + "');$('#Force').val('1');$('#form1').submit();}";
                    }
                    else
                    {
                        Guid uniqueID = Guid.NewGuid();
                        Session[MyCreek.Utility.Keys.SessionKeys.UserID.ToString()]       = user.ID;
                        Session[MyCreek.Utility.Keys.SessionKeys.UserUniqueID.ToString()] = uniqueID;
                        bou.Add(user, uniqueID);
                        Session.Remove(isVcodeSessionKey);
                        MyCreek.Platform.Log.Add("用户登录成功", string.Concat("用户:", user.Name, "(", user.ID, ")登录成功"), MyCreek.Platform.Log.Types.用户登录);
                        if (isSessionLost)
                        {
                            Script = "alert('登录成功!');new RoadUI.Window().close();";
                        }
                        else
                        {
                            Script = "top.location='" + Common.Tools.BaseUrl + "Default.aspx';";
                        }
                    }
                }
            }
        }