/// <summary>
        /// 增加用户账号
        /// 传入dbhelper 方法调用使用事务 避免部分同步成功
        /// </summary>
        /// <param name="userEntity"></param>
        /// <param name="userContact"></param>
        /// <param name="userCenterDbHelper"></param>
        /// <param name="k8DbHelper"></param>
        /// <returns></returns>
        public bool AddUser(BaseUserEntity userEntity, BaseUserContactEntity userContact, IDbHelper userCenterDbHelper, IDbHelper k8DbHelper)
        {
            //1、先往中天里添加账号
            BaseUserManager userManager = new BaseUserManager(userCenterDbHelper);

            userEntity.UserFrom     = "Security";
            userEntity.CreateBy     = Utilities.UserInfo.RealName;
            userEntity.CreateUserId = Utilities.UserInfo.Id;
            bool identity = false;

            if (string.IsNullOrEmpty(userEntity.Id))
            {
                identity = true;
            }
            userEntity.Id = userManager.Add(userEntity, identity, true);
            //添加用户密码表
            BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager(userCenterDbHelper);
            BaseUserLogOnEntity  userLogOnEntity  = userLogOnManager.GetObject(userEntity.Id);

            userLogOnEntity    = new BaseUserLogOnEntity();
            userLogOnEntity.Id = userEntity.Id;
            //是否验证邦定mac地址,默认绑定
            userLogOnEntity.CheckIPAddress = 1;
            //产生盐
            var salt = BaseRandom.GetRandomString(20);

            userLogOnEntity.Salt         = salt;
            userLogOnEntity.UserPassword = userManager.EncryptUserPassword(userEntity.UserPassword, salt);
            //是否检查机器码MAC地址
            userLogOnManager.AddObject(userLogOnEntity);
            //添加用户的联系方式
            BaseUserContactManager userContactManager = new BaseUserContactManager(userCenterDbHelper);

            userContact.MobileValiated = 1;
            userContactManager.AddObject(userContact);

            //2、再往K8里加用户
            TAB_USERManager tabUserManager = new TAB_USERManager(k8DbHelper);
            TAB_USEREntity  tabUserEntity  = new TAB_USEREntity();

            tabUserEntity.OWNER_SITE        = userEntity.CompanyName;
            tabUserEntity.DEPT_NAME         = userEntity.DepartmentName;
            tabUserEntity.USER_NAME         = userEntity.UserName.ToLower();
            tabUserEntity.EMPLOYEE_CODE     = userEntity.Code;
            tabUserEntity.EMPLOYEE_NAME     = userEntity.RealName;
            tabUserEntity.REAL_NAME         = userEntity.RealName;
            tabUserEntity.ONLY_USER_NAME    = userEntity.NickName.ToLower();
            tabUserEntity.ID_CARD           = userEntity.IDCard;
            tabUserEntity.MOBILE            = userContact.Mobile;
            tabUserEntity.CREATE_SITE       = Utilities.UserInfo.CompanyName;
            tabUserEntity.CREATE_USER       = Utilities.UserInfo.RealName;
            tabUserEntity.CREATE_DATE       = DateTime.Now;
            tabUserEntity.BL_LOCK_FLAG      = 1;
            tabUserEntity.BL_TYPE           = 0;
            tabUserEntity.BL_CHECK_COMPUTER = 1;
            tabUserEntity.BL_CHECK_NAME     = 1;
            tabUserEntity.ID        = decimal.Parse(userEntity.Id);
            tabUserEntity.USER_DATE = DateTime.Now.AddYears(3);
            tabUserManager.Add(tabUserEntity, false, true);
            //更新密码和盐
            var sql = string.Format(" UPDATE TAB_USER SET USER_PASSWORD=NULL,USER_PASSWD='{0}',SALT ='{1}',  CHANGEPASSWORDDATE=to_date('{2}','yyyy-mm-dd-hh24:mi:ss')  WHERE ID = '{3}'",
                                    userEntity.UserPassword, salt, DateTime.Now, tabUserEntity.ID);

            tabUserManager.ExecuteNonQuery(sql);

            //3、新增账号的时候默认增加新员工的权限为网点员工
            var roleMenus = GetMenusByUserCode(k8DbHelper, "网点员工", "", "上海");
            TAB_USERPOPEDOMManager userMenuManager = new TAB_USERPOPEDOMManager(k8DbHelper);

            foreach (var roleMenu in roleMenus)
            {
                TAB_USERPOPEDOMEntity userPOPEDOM = new TAB_USERPOPEDOMEntity();
                userPOPEDOM.BL_INSERT  = roleMenu.BL_INSERT;
                userPOPEDOM.BL_UPDATE  = roleMenu.BL_UPDATE;
                userPOPEDOM.BL_DELETE  = roleMenu.BL_DELETE;
                userPOPEDOM.USER_NAME  = tabUserEntity.USER_NAME;
                userPOPEDOM.OWNER_SITE = tabUserEntity.OWNER_SITE;
                userPOPEDOM.MENU_GUID  = roleMenu.MENU_GUID;
                userMenuManager.Add(userPOPEDOM);
            }
            return(true);
        }
        /// <summary>
        /// 增加用户账号
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool AddUser(TAB_USEREntity user)
        {
            //1、先往中天里添加账号
            BaseUserEntity       userEntity       = new BaseUserEntity();
            BaseUserManager      userManager      = new BaseUserManager();
            BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();

            userEntity.UserFrom    = "K8";
            userEntity.UserName    = user.USER_NAME;
            userEntity.Code        = user.EMPLOYEE_CODE;
            userEntity.RealName    = user.REAL_NAME;
            userEntity.CompanyName = user.OWNER_SITE;
            var organize = new BaseOrganizeManager().GetObjectByName(user.OWNER_SITE);

            if (organize != null)
            {
                userEntity.CompanyId = organize.Id.ToString();
            }
            userEntity.Description       = user.REMARK;
            userEntity.DeletionStateCode = 0;
            userEntity.DepartmentName    = user.DEPT_NAME;
            userEntity.Enabled           = int.Parse(user.BL_LOCK_FLAG.ToString());
            bool identity = false;

            if (!string.IsNullOrEmpty(userEntity.Id))
            {
                identity = true;
            }
            userEntity.Id = userManager.Add(userEntity, identity, true);

            //添加用户密码表
            BaseUserLogOnEntity userLogOnEntity = userLogOnManager.GetObject(userEntity.Id);

            userLogOnEntity    = new BaseUserLogOnEntity();
            userLogOnEntity.Id = userEntity.Id;
            //邦定mac地址
            userLogOnEntity.CheckIPAddress = 1;
            var salt = BaseRandom.GetRandomString(20);

            userLogOnEntity.Salt         = salt;
            userLogOnEntity.UserPassword = userManager.EncryptUserPassword(user.USER_PASSWD, salt);

            //是否检查机器码 MAC地址
            int checkIPAddress = 1;

            int.TryParse(user.BL_CHECK_COMPUTER.ToString(), out checkIPAddress);
            userLogOnEntity.CheckIPAddress = checkIPAddress;
            userLogOnManager.AddObject(userLogOnEntity);

            //用户的联系方式
            BaseUserContactManager userContactManager = new BaseUserContactManager();
            BaseUserContactEntity  userContactEntity  = new BaseUserContactEntity();

            userContactEntity.Id = userEntity.Id;
            if (!string.IsNullOrEmpty(user.MOBILE))
            {
                userContactEntity.Mobile = user.MOBILE;
            }
            userContactManager.AddObject(userContactEntity);

            //2、再往K8里加用户
            TAB_USERManager        tabUserManager  = new TAB_USERManager();
            TAB_USERPOPEDOMManager userMenuManager = new TAB_USERPOPEDOMManager();

            user.CREATE_SITE = Utilities.UserInfo.CompanyName;
            user.CREATE_USER = Utilities.UserInfo.RealName;
            user.CREATE_DATE = DateTime.Now;
            user.USER_NAME   = user.USER_NAME.Trim();
            user.ID          = decimal.Parse(userEntity.Id);
            tabUserManager.Add(user, false, true);
            var sql = string.Format(" UPDATE TAB_USER SET USER_PASSWORD=NULL,USER_PASSWD='{0}',SALT ='{1}',  CHANGEPASSWORDDATE=to_date('{2}','yyyy-mm-dd-hh24:mi:ss')  WHERE ID = '{3}'",
                                    userEntity.UserPassword, salt, DateTime.Now, user.ID);

            tabUserManager.ExecuteNonQuery(sql);

            //3、新增账号的时候默认增加新员工的权限为网点员工
            var roleMenus = GetMenusByUserCode("网点员工", "", "上海");

            foreach (var roleMenu in roleMenus)
            {
                TAB_USERPOPEDOMEntity userPOPEDOM = new TAB_USERPOPEDOMEntity();
                userPOPEDOM.BL_INSERT  = roleMenu.BL_INSERT;
                userPOPEDOM.BL_UPDATE  = roleMenu.BL_UPDATE;
                userPOPEDOM.BL_DELETE  = roleMenu.BL_DELETE;
                userPOPEDOM.USER_NAME  = user.USER_NAME;
                userPOPEDOM.OWNER_SITE = user.OWNER_SITE;
                userPOPEDOM.MENU_GUID  = roleMenu.MENU_GUID;
                userMenuManager.Add(userPOPEDOM);
            }
            return(true);
        }