示例#1
0
        public HttpResponseMessage SaveZhuCeInfoOfLoginName(string LoginName, string Pwd, string callback)
        {
            var      res       = new { Result = "OK" };
            string   salt      = Hant.Frame.Helper.EncryptPwd.CreateSalt();
            string   SHA512Pwd = Hant.Frame.Helper.EncryptPwd.CreatePwdHashSHA512(Pwd, salt);
            string   UserID    = new BLL.Common.Common().GetUserID();
            sys_user i1        = new sys_user
            {
                UserID     = UserID,
                UserName   = LoginName,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Status     = 1
            };

            db.Sys_userRepository.Insert(i1);
            sys_user_authorization i2 = new sys_user_authorization
            {
                UserID     = UserID,
                LoginName  = LoginName,
                LoginPwd   = SHA512Pwd,
                Salt       = salt,
                LoginType  = (int)LoginType.LoginName,
                Status     = 1,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now
            };

            db.Sys_user_authorizationRepository.Insert(i2);
            db.Save();
            return(new Models.JsonpResultAPI_JSONP <object>(res, callback));
        }
示例#2
0
        public HttpResponseMessage SaveUserInfo(string name, string phone, string role, string ou)
        {
            var      res       = new { Result = "OK" };
            string   salt      = Hant.Frame.Helper.EncryptPwd.CreateSalt();
            string   SHA512Pwd = Hant.Frame.Helper.EncryptPwd.CreatePwdHashSHA512("123456", salt);
            string   UserID    = new BLL.Common.Common().GetUserID();
            sys_user i1        = new sys_user
            {
                UserID     = UserID,
                UserName   = name,
                Mobile     = phone,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Status     = 1
            };

            db.Sys_userRepository.Insert(i1);
            sys_user_authorization i2 = new sys_user_authorization
            {
                UserID     = UserID,
                LoginName  = name,
                LoginPwd   = SHA512Pwd,
                Salt       = salt,
                LoginType  = (int)LoginType.LoginName,
                Status     = 1,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now
            };

            db.Sys_user_authorizationRepository.Insert(i2);
            foreach (string r in role.Split(','))
            {
                sys_user_role_relation i3 = new sys_user_role_relation
                {
                    RoleID     = r,
                    UserID     = UserID,
                    CreateTime = DateTime.Now,
                    UpdateTime = DateTime.Now
                };
                db.Sys_user_role_relationRepository.Insert(i3);
            }
            sys_user_group_relation i4 = new sys_user_group_relation
            {
                OuID       = ou,
                UserID     = UserID,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now
            };

            db.Sys_user_group_relationRepository.Insert(i4);
            db.Save();
            return(new Models.JsonpResultAPI <object>(res));
        }
示例#3
0
        public HttpResponseMessage DeleteUserInfo([FromBody] int[] id)
        {
            foreach (int i in id)
            {
                sys_user user = db.Sys_userRepository.Find(i);
                if (user != null)
                {
                    sys_user_authorization user_author = db.Sys_user_authorizationRepository.Get(e => e.UserID == user.UserID).FirstOrDefault();
                    if (user_author != null)
                    {
                        db.Sys_user_authorizationRepository.Delete(user_author.ID);
                    }
                    db.Sys_userRepository.Delete(i);
                }
            }
            db.Save();
            var res = new { Result = "OK" };

            return(new Models.JsonpResultAPI <object>(res));
        }