示例#1
0
 /// <summary>
 /// 添加用户信息 2014-09-07 14:58:50 By 唐有炜
 /// </summary>
 /// <param name="sysUser"></param>
 /// <returns></returns>
 public bool AddUser(TSysUser sysUser)
 {
     try
     {
         SysUserDao.InsertEntity(sysUser);
         LogHelper.Debug("用户添加成功!");
         return true;
     }
     catch (Exception ex)
     {
         LogHelper.Error("用户添加失败!",ex);
         return false;
     }
 }
示例#2
0
 /// <summary>
 /// 修改实体
 /// </summary>
 /// <param name="entity">实体对象</param>
 public bool UpadateEntity(TSysUser entity)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
        int rows= db.TSysUsers.Update(entity);
        if (rows > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
示例#3
0
        /// <summary>
        /// 公共注册 2014-08-24 14:58:50 By 唐有炜
        /// </summary>
        /// <param name="httpContext">HttpContext</param>
        /// <param name="userName">用户名</param>
        /// <param name="phone">手机号</param>
        /// <param name="userPassword">密码</param>
        /// <param name="userTname">真实姓名</param>
        /// <returns>ResponseMessage</returns>
        public ResponseMessage PublicRegister(HttpContext httpContext, string userName, string phone,
            string userPassword,
            string userTname = null)
        {
//            ResponseMessage rmsg1 = ValidateAccount("register", null,  userName + "@10000", userPassword);
//            if (!rmsg1.Status)
//            {
//                return rmsg1;
//            }
//            ResponseMessage rmsg2 = ValidateAccount("register", null,  phone, userPassword);
//            if (!rmsg2.Status)
//            {
//                rmsg2.Msg = "对不起该手机号已存在!";
//                return rmsg2;
//            }
//            ResponseMessage rmsg = rmsg2;
//            if (rmsg1.Status && rmsg2.Status)
//            {
            ResponseMessage rmsg = new ResponseMessage();
            try
            {
                //注册提交
                var dbPassword = DESEncrypt.Encrypt(userPassword);
                TSysUser sysUser = new TSysUser()
                {
                    CompNum = "10000",
                    UserLname = userName,
                    UserPassword = dbPassword,
                    UserPhone = phone,
                    UserTname = userTname, //存储真实姓名,便于日后升级
                    RoleId = 1, //默认角色
                    DepId = 1 //默认部门
                };

                if (SysUserDao.InsertEntity(sysUser))
                {
                    rmsg.Status = true;
                    rmsg.Msg = "注册成功";
                }
                else
                {
                    rmsg.Status = false;
                    rmsg.Msg = "注册失败";
                }
            }
            catch (Exception ex)
            {
                rmsg.Status = false;
                rmsg.Msg = "注册失败";
                LogHelper.Error("注册失败:", ex);
            }

            //注册成功
            if (rmsg.Status)
            {
                //获取用户信息
                var compUser = GetVCompanyUserByAccountTypeAndUserName("phone", phone);
                //书写SessionCookie
                WriteSessionCookie(httpContext, compUser, userName + "@10000", userPassword);
            }

            return rmsg;
        }
示例#4
0
        /// <summary>
        /// 公司注册 2014-08-21 14:58:50 By 唐有炜
        /// </summary>
        /// <param name="httpContext">HttpContext</param>
        /// <param name="accountType">账号类型(email,phone)</param>
        /// <param name="userName">用户名</param>
        /// <param name="userPassword">密码</param>
        /// <returns>ResponseMessage</returns>
        public ResponseMessage Register(HttpContext httpContext, string accountType, string userName,
            string userPassword)
        {
            ResponseMessage rmsg = ValidateAccount("register", null, userName, userPassword);
            if (rmsg.Status)
            {
                //注册验证成功成功
                //随机编号
                var compNum = RandomHelper.GetComoanyNumber();
                TSysCompany sysCompany = new TSysCompany()
                {
                    CompNum = compNum
                };

                userPassword = DESEncrypt.Encrypt(userPassword);
                string userEmail = null;
                string userPhone = null;
                switch (accountType)
                {
                    case "email":
                        userEmail = userName;
                        break;
                    case "phone":
                        userPhone = userName;
                        break;
                    default:
                        break;
                }
                TSysUser sysUser = new TSysUser()
                {
                    CompNum = compNum,
                    UserLname = "admin", //默认公司超级管理员用户名是admin
                    UserPassword = userPassword,
                    UserEmail = userEmail,
                    UserPhone = userPhone,
                    RoleId = 1, //默认角色
                    DepId = 1 //默认部门
                };

                if (CompanyUserDao.InsertEntities(sysCompany, sysUser))
                {
                    rmsg.Status = true;
                    rmsg.Msg = "注册成功";
                }
                else
                {
                    rmsg.Status = false;
                    rmsg.Msg = "注册失败";
                }
            }

            //注册成功
            if (rmsg.Status)
            {
                //获取用户信息
                var compUser = GetVCompanyUserByAccountTypeAndUserName(accountType, userName);
                //书写SessionCookie
                WriteSessionCookie(httpContext, compUser, userName, userPassword);
            }

            return rmsg;
        }
示例#5
0
 /// <summary>
 /// 修改用户信息 2014-09-07 14:58:50 By 唐有炜
 /// </summary>
 /// <param name="sysUser"></param>
 /// <returns></returns>
 public bool UpdateUser(TSysUser sysUser)
 {
     return SysUserDao.UpadateEntity(sysUser);
 }
示例#6
0
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="sysCompany"></param>
 /// <param name="sysUser"></param>
 public bool InsertEntities(TSysCompany sysCompany, TSysUser sysUser)
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         if (db.Connection.State != ConnectionState.Open)
         {
             db.Connection.Open();
         }
         var tran = db.Connection.BeginTransaction();
         try
         {
             db.TSysCompanies.Insert(sysCompany);
             db.TSysUsers.Insert(sysUser);
             tran.Commit();
             return true;
         }
         catch (Exception ex)
         {
             tran.Rollback();
             LogHelper.Error("注册失败,",ex);
             return false;
         }
         finally
         {
             if (db.Connection.State != ConnectionState.Closed)
             {
                 db.Connection.Close();
             }
         }
     }
 }