Пример #1
0
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="userEntity"></param>
        /// <param name="unitEntity"></param>
        /// <param name="roleEntity"></param>
        public void AddUser(ref T_UserEntity userEntity, t_unitEntity unitEntity, T_RoleEntity roleEntity)
        {
            //新增员工
            userEntity.user_status      = "1";
            userEntity.user_status_desc = "有效";

            userEntity.user_id        = Guid.NewGuid().ToString("N");
            userEntity.user_password  = "******"; //888888
            userEntity.fail_date      = DateTime.Now.AddYears(20).ToString("yyyy-MM-dd");
            userEntity.customer_id    = CurrentUserInfo.ClientID;
            userEntity.create_user_id = "open";
            userEntity.create_time    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            Create(userEntity);

            //新增员工角色
            var userRoleEntity = new TUserRoleEntity();

            userRoleEntity.user_role_id   = Guid.NewGuid().ToString();
            userRoleEntity.user_id        = userEntity.user_id;
            userRoleEntity.role_id        = roleEntity.role_id;
            userRoleEntity.unit_id        = unitEntity.unit_id;
            userRoleEntity.status         = "1";
            userRoleEntity.create_time    = DateTime.Now;
            userRoleEntity.create_user_id = "open";
            userRoleEntity.modify_time    = DateTime.Now;
            userRoleEntity.modify_user_id = "open";
            userRoleEntity.default_flag   = "1";
            AddUserRole(userRoleEntity);
        }
Пример #2
0
        /// <summary>
        /// 添加员工角色
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="clientID"></param>
        public void AddUserRole(TUserRoleEntity entity)
        {
            var sqlText = @"
                        INSERT INTO dbo.T_User_Role
                                ( user_role_id ,
                                  user_id ,
                                  role_id ,
                                  unit_id ,
                                  status ,
                                  create_time ,
                                  create_user_id ,
                                  modify_time ,
                                  modify_user_id ,
                                  default_flag
                                )
                        VALUES  ( @user_role_id,
                                  @user_id,
                                  @role_id,
                                  @unit_id,
                                  @status,
                                  @create_time,
                                  @create_user_id,
                                  @modify_time,
                                  @modify_user_id,
                                  @default_flag
                                )
                       ";
            var pars    = new SqlParameter[]
            {
                new SqlParameter("@user_role_id", SqlDbType.NVarChar),
                new SqlParameter("@user_id", SqlDbType.NVarChar),
                new SqlParameter("@role_id", SqlDbType.NVarChar),
                new SqlParameter("@unit_id", SqlDbType.NVarChar),
                new SqlParameter("@status", SqlDbType.Int),
                new SqlParameter("@create_time", SqlDbType.NVarChar),
                new SqlParameter("@create_user_id", SqlDbType.NVarChar),
                new SqlParameter("@modify_time", SqlDbType.NVarChar),
                new SqlParameter("@modify_user_id", SqlDbType.NVarChar),
                new SqlParameter("@default_flag", SqlDbType.Int)
            };

            pars[0].Value = entity.user_role_id;
            pars[1].Value = entity.user_id;
            pars[2].Value = entity.role_id;
            pars[3].Value = entity.unit_id;
            pars[4].Value = entity.status;
            pars[5].Value = entity.create_time;
            pars[6].Value = entity.create_user_id;
            pars[7].Value = entity.modify_time;
            pars[8].Value = entity.modify_user_id;
            pars[9].Value = entity.default_flag;

            this.SQLHelper.ExecuteNonQuery(CommandType.Text, sqlText.ToString(), pars);
        }
Пример #3
0
        public string AddUser(string pRequest)
        {
            var rd     = new APIResponse <AddUserRD>();
            var rdData = new AddUserRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <AddUserRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var       loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);
            T_UserBLL bll = new T_UserBLL(loggingSessionInfo);

            try
            {
                string       email = rp.Parameters.UserEmail, customerID = rp.CustomerID;
                T_UserEntity tue = new T_UserEntity();
                tue = bll.GetUserEntityByEmail(rp.Parameters.UserEmail, customerID);
                if (tue == null)
                {
                    DateTime dt = DateTime.Now;

                    #region 保存用户
                    string userId = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
                    tue = new T_UserEntity()
                    {
                        user_id          = userId,
                        user_code        = rp.Parameters.UserCode,
                        user_name        = rp.Parameters.UserName,
                        user_name_en     = rp.Parameters.UserNameEn,
                        user_email       = rp.Parameters.UserEmail,
                        user_password    = MD5Helper.Encryption("123"),//默认密码
                        user_gender      = rp.Parameters.UserGender,
                        user_birthday    = rp.Parameters.UserBirthday,
                        user_telephone   = rp.Parameters.UserTelephone,
                        user_cellphone   = rp.Parameters.UserCellphone,
                        user_status      = "1",
                        user_status_desc = "正常",
                        fail_date        = string.IsNullOrEmpty(rp.Parameters.FailDate) == true ? "2020-01-01" : rp.Parameters.FailDate,
                        customer_id      = customerID,
                        create_time      = dt.ToString("yyyy-MM-dd HH:mm:ss"),
                        create_user_id   = rp.UserID,
                        modify_time      = dt.ToString("yyyy-MM-dd HH:mm:ss"),
                        modify_user_id   = rp.UserID
                    };
                    //T_User表
                    //Create(tue, tran);
                    bll.Create(tue);
                    #endregion

                    #region 保存用户角色
                    //T_User_Role 表
                    TUserRoleEntity ture = new TUserRoleEntity
                    {
                        user_role_id   = Guid.NewGuid().ToString(),
                        user_id        = userId,
                        role_id        = rp.Parameters.RoleID,
                        unit_id        = rp.Parameters.UnitID,
                        status         = "1",
                        create_time    = dt,
                        create_user_id = rp.UserID,
                        modify_time    = dt,
                        modify_user_id = rp.UserID,
                        default_flag   = "1"
                    };
                    bll.InsertUserRole(ture);
                    #endregion

                    #region 保存部门、职衔
                    UserDeptJobMappingBLL deptJobMapBll = new UserDeptJobMappingBLL(loggingSessionInfo);
                    //UserDeptJobMapping表
                    UserDeptJobMappingEntity udjme = new UserDeptJobMappingEntity
                    {
                        UserDeptID       = Guid.NewGuid(),
                        UserID           = userId,
                        JobFunctionID    = rp.Parameters.JobFunctionID,
                        USERID           = userId,
                        CustomerID       = customerID,
                        CreateTime       = dt,
                        CreateUserID     = rp.UserID,
                        LastUpdateTime   = dt,
                        LastUpdateUserID = rp.UserID,
                        IsDelete         = 0,
                        UnitID           = rp.Parameters.UnitID,
                        LineManagerID    = rp.Parameters.LineManagerID,
                        UserLevel        = "0"//默认0
                    };
                    deptJobMapBll.Create(udjme);
                    #endregion

                    rdData.UserID = userId;
                    rd.ResultCode = 0;
                }
                else
                {
                    rd.ResultCode = 101;
                    rd.Message    = "邮箱已存在";
                }
                rd.Data = rdData;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            return(rd.ToJSON());
        }
Пример #4
0
 public void InsertUserRole(TUserRoleEntity entity)
 {
     _currentDAO.InsertUserRole(entity);
 }
        public string ExportData(string pCustomerID, LoggingSessionInfo pLoggingSessionInfo, DataTable pExportData, JobFunctionEntity[] pJobFuncE, TUnitEntity[] pDeptE, IList <RoleModel> pRoleE)
        {
            T_UserBLL             tubll         = new T_UserBLL(pLoggingSessionInfo);
            UserDeptJobMappingBLL deptJobMapBll = new UserDeptJobMappingBLL(pLoggingSessionInfo);
            //客户id
            string customerID = pCustomerID;

            //var tran = this.SQLHelper.CreateTransaction();
            //using (tran.Connection)
            //{
            try
            {
                string   createUserID     = pLoggingSessionInfo.CurrentUser.User_Id;
                string   lastUpdateUserID = pLoggingSessionInfo.CurrentUser.User_Id;
                DateTime dt = DateTime.Now;
                int      existsEmaliNum = 0, notExistsEmailNum = 0;
                string   email = string.Empty;

                if (pExportData != null && pExportData.Rows.Count > 0)
                {
                    DataTable    dTable = pExportData;
                    T_UserEntity tue    = null;
                    foreach (DataRow row in dTable.Rows)
                    {
                        dt = DateTime.Now;
                        //检测邮箱是否存在
                        if (row["邮箱"] == null || string.IsNullOrEmpty(row["邮箱"].ToString()))
                        {
                            continue;
                        }
                        email = row["邮箱"].ToString().Trim().ToLower();
                        tue   = tubll.GetUserEntityByEmail(email, customerID);
                        if (tue != null)
                        {
                            //存在
                            existsEmaliNum++;
                            continue;
                        }
                        else
                        {
                            //不存在
                            notExistsEmailNum++;
                            #region 保存用户
                            tue = new T_UserEntity();
                            string userId = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
                            tue.user_id = userId;
                            if (email != null && !string.IsNullOrEmpty(email))
                            {
                                tue.user_email = email;
                            }
                            tue.user_name    = row["用户名称"].ToString();
                            tue.user_name_en = row["英文名"].ToString();
                            if (row["性别"] != null && !string.IsNullOrEmpty(row["性别"].ToString()))
                            {
                                if (row["性别"].ToString().Trim() == "男")
                                {
                                    tue.user_gender = "1";
                                }
                                else if (row["性别"].ToString().Trim() == "女")
                                {
                                    tue.user_gender = "2";
                                }
                                else
                                {
                                    tue.user_gender = "0"; //未知
                                }
                            }
                            else
                            {
                                tue.user_gender = "0";
                            }
                            if (row["生日"] != null && !string.IsNullOrEmpty(row["生日"].ToString()))
                            {
                                tue.user_birthday = Convert.ToDateTime(row["生日"]).ToString("yyyy-MM-dd");
                            }
                            if (row["手机"] != null && !string.IsNullOrEmpty(row["手机"].ToString()))
                            {
                                tue.user_telephone = row["手机"].ToString();
                            }
                            if (row["固话"] != null && !string.IsNullOrEmpty(row["固话"].ToString()))
                            {
                                tue.user_cellphone = row["固话"].ToString();
                            }
                            if (row["用户编码"] != null && !string.IsNullOrEmpty(row["用户编码"].ToString()))
                            {
                                tue.user_code = row["用户编码"].ToString();
                            }

                            tue.user_status      = "1";
                            tue.user_status_desc = "正常";
                            tue.fail_date        = "2020-01-02";
                            tue.user_address     = "";
                            tue.user_password    = MD5Helper.Encryption("123");//默认密码
                            tue.customer_id      = customerID;
                            tue.create_user_id   = tue.modify_user_id = createUserID;
                            tue.create_time      = tue.modify_time = dt.ToString("yyyy-MM-dd HH:mm:ss");
                            tue.msn           = "";
                            tue.qq            = "";
                            tue.blog          = "";
                            tue.user_postcode = "";
                            tue.user_remark   = "";
                            //T_User表
                            //Create(tue, tran);
                            tubll.Create(tue);
                            #endregion

                            #region 保存用户角色
                            //T_User_Role 表
                            string          deptID = pDeptE.Where(a => a.UnitName == row["部门"].ToString().Trim()).First().UnitID.ToString();
                            RoleModel       rm     = pRoleE.Where(a => a.Role_Name == row["角色"].ToString().Trim()).First();
                            TUserRoleEntity ture   = new TUserRoleEntity
                            {
                                user_role_id   = Guid.NewGuid().ToString(),
                                user_id        = userId,
                                role_id        = rm.Role_Id,
                                unit_id        = deptID,
                                status         = "1",
                                create_time    = dt,
                                create_user_id = createUserID,
                                modify_time    = dt,
                                modify_user_id = lastUpdateUserID,
                                default_flag   = "1"
                            };
                            tubll.InsertUserRole(ture);
                            #endregion

                            #region 保存部门、职衔
                            //UserDeptJobMapping表
                            string jobFuncID = pJobFuncE.Where(a => a.Name == row["职衔"].ToString().Trim()).First().JobFunctionID.ToString();
                            UserDeptJobMappingEntity udjme = new UserDeptJobMappingEntity
                            {
                                UserDeptID       = Guid.NewGuid(),
                                UserID           = userId,
                                JobFunctionID    = jobFuncID,
                                USERID           = userId,
                                CustomerID       = customerID,
                                CreateTime       = dt,
                                CreateUserID     = createUserID,
                                LastUpdateTime   = dt,
                                LastUpdateUserID = lastUpdateUserID,
                                IsDelete         = 0,
                                UnitID           = deptID
                            };
                            deptJobMapBll.Create(udjme);
                            #endregion
                        }
                    }
                    Loggers.DEFAULT.Debug(new DebugLogInfo()
                    {
                        Message = "重复:" + existsEmaliNum + "条,新增:" + notExistsEmailNum + "条,共:" + dTable.Rows.Count
                    });
                }
                //tran.Commit();
            }
            catch (Exception ex)
            {
                //回滚&转抛异常
                //tran.Rollback();
                throw;
            }
            return("1|成功");
            //}
        }
Пример #6
0
 public void AddUserRole(TUserRoleEntity entity)
 {
     _currentDAO.AddUserRole(entity);
 }