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|成功");
            //}
        }
        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());
        }
        public string ModifyUserPersonalInfo(string pRequest)
        {
            var rd     = new APIResponse <ModifyUserPersonalInfoRD>();
            var rdData = new ModifyUserPersonalInfoRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <ModifyUserPersonalInfoRP> >();

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

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

            var loggingSessionInfo = new LoggingSessionManager().CurrentSession;

            try
            {
                T_UserBLL    bll    = new T_UserBLL(loggingSessionInfo);
                T_UserEntity entity = bll.GetUserEntityByID(rp.Parameters.UserID);
                if (entity != null)
                {
                    entity.user_code      = rp.Parameters.UserCode;
                    entity.user_name      = rp.Parameters.UserName;
                    entity.user_gender    = rp.Parameters.UserGender;
                    entity.user_email     = rp.Parameters.UserEmail;
                    entity.user_telephone = rp.Parameters.UserTelephone;
                    //entity.user_status = rp.Parameters.UserStatus;

                    if (!string.IsNullOrEmpty(rp.Parameters.UserNameEn))
                    {
                        entity.user_name_en = rp.Parameters.UserNameEn;
                    }
                    if (!string.IsNullOrEmpty(rp.Parameters.UserBirthday))
                    {
                        entity.user_birthday = rp.Parameters.UserBirthday;
                    }
                    if (!string.IsNullOrEmpty(rp.Parameters.UserPassword))
                    {
                        entity.user_password = MD5Helper.Encryption(rp.Parameters.UserPassword);
                    }
                    if (!string.IsNullOrEmpty(rp.Parameters.UserCellphone))
                    {
                        entity.user_cellphone = rp.Parameters.UserCellphone;
                    }
                    if (!string.IsNullOrEmpty(rp.Parameters.FailDate))
                    {
                        entity.fail_date = rp.Parameters.FailDate;
                    }

                    bll.Update(entity);

                    //更新LineManagerID
                    UserDeptJobMappingBLL    mappingBll    = new UserDeptJobMappingBLL(loggingSessionInfo);
                    UserDeptJobMappingEntity mappingEntity = mappingBll.GetByUserID(entity.user_id);
                    if (mappingEntity != null)
                    {
                        if (!string.IsNullOrEmpty(rp.Parameters.LineManagerID))
                        {
                            mappingEntity.LineManagerID = rp.Parameters.LineManagerID;
                        }
                        if (!string.IsNullOrEmpty(rp.Parameters.UnitID))
                        {
                            mappingEntity.UnitID = rp.Parameters.UnitID;
                        }
                        if (!string.IsNullOrEmpty(rp.Parameters.JobFunctionID))
                        {
                            mappingEntity.JobFunctionID = rp.Parameters.JobFunctionID;
                        }
                        mappingBll.Update(mappingEntity);
                    }
                    else
                    {
                        mappingEntity               = new UserDeptJobMappingEntity();
                        mappingEntity.UserID        = entity.user_id;
                        mappingEntity.USERID        = entity.user_id;
                        mappingEntity.LineManagerID = rp.Parameters.LineManagerID;
                        mappingEntity.UnitID        = rp.Parameters.UnitID;
                        mappingEntity.JobFunctionID = rp.Parameters.JobFunctionID;
                        mappingBll.Create(mappingEntity);
                    }
                    rdData.IsSuccess = true;
                    rd.ResultCode    = 0;
                }
                else
                {
                    rdData.IsSuccess = false;
                    rd.ResultCode    = 101;
                    rd.Message       = "用户不存在";
                }
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }