/// <summary>
        /// 添加用户组织机构关系
        /// </summary>
        /// <param name="entity">用户组织机构实体</param>
        /// <param name="statusCode">状态码</param>
        /// <returns>主键</returns>
        public string Add(BaseUserOrganizeEntity entity, out string statusCode)
        {
            string result = string.Empty;
            // 判断数据是否重复了
            List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();

            parameters.Add(new KeyValuePair <string, object>(BaseUserOrganizeEntity.FieldDeletionStateCode, 0));
            parameters.Add(new KeyValuePair <string, object>(BaseUserOrganizeEntity.FieldEnabled, 1));
            parameters.Add(new KeyValuePair <string, object>(BaseUserOrganizeEntity.FieldUserId, entity.UserId));
            parameters.Add(new KeyValuePair <string, object>(BaseUserOrganizeEntity.FieldCompanyId, entity.CompanyId));
            parameters.Add(new KeyValuePair <string, object>(BaseUserOrganizeEntity.FieldDepartmentId, entity.DepartmentId));
            parameters.Add(new KeyValuePair <string, object>(BaseUserOrganizeEntity.FieldWorkgroupId, entity.WorkgroupId));
            if (this.Exists(parameters))
            {
                // 用户名已重复
                statusCode = Status.Exist.ToString();
            }
            else
            {
                result = this.AddObject(entity);
                // 运行成功
                statusCode = Status.OKAdd.ToString();
            }
            return(result);
        }
Esempio n. 2
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="userOrganizeEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseUserOrganizeEntity userOrganizeEntity)
 {
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldUserId, userOrganizeEntity.UserId);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldCompanyId, userOrganizeEntity.CompanyId);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldDepartmentId, userOrganizeEntity.DepartmentId);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldWorkgroupId, userOrganizeEntity.WorkgroupId);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldRoleId, userOrganizeEntity.RoleId);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldEnabled, userOrganizeEntity.Enabled);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldDescription, userOrganizeEntity.Description);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldDeletionStateCode, userOrganizeEntity.DeletionStateCode);
     SetEntityExpand(sqlBuilder, userOrganizeEntity);
 }
Esempio n. 3
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="entity">实体</param>
 private void SetObject(SQLBuilder sqlBuilder, BaseUserOrganizeEntity entity)
 {
     SetObjectExpand(sqlBuilder, entity);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldUserId, entity.UserId);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldCompanyId, entity.CompanyId);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldSubCompanyId, entity.SubCompanyId);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldDepartmentId, entity.DepartmentId);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldWorkgroupId, entity.WorkgroupId);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldEnabled, entity.Enabled);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldDescription, entity.Description);
     sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldDeletionStateCode, entity.DeletionStateCode);
 }
Esempio n. 4
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="userOrganizeEntity">实体</param>
        public int UpdateEntity(BaseUserOrganizeEntity userOrganizeEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, userOrganizeEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseUserOrganizeEntity.FieldModifiedOn);
            sqlBuilder.SetWhere(BaseUserOrganizeEntity.FieldId, userOrganizeEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
        /// <summary>
        /// 把用户添加到组织机构
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">用户组织机构关系</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        public string AddUserToOrganize(BaseUserInfo userInfo, BaseUserOrganizeEntity entity, out string statusCode, out string statusMessage)
        {
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;
            string result        = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var userOrganizeManager = new BaseUserOrganizeManager(dbHelper, userInfo);
                result        = userOrganizeManager.Add(entity, out returnCode);
                returnMessage = userOrganizeManager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// 把用户添加到组织机构
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userOrganizeEntity">用户组织机构关系</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        public string AddUserToOrganize(BaseUserInfo userInfo, BaseUserOrganizeEntity userOrganizeEntity, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserOrganizeManager userOrganizeManager = new BaseUserOrganizeManager(dbHelper, userInfo);
                    returnValue   = userOrganizeManager.Add(userOrganizeEntity, out statusCode);
                    statusMessage = userOrganizeManager.GetStateMessage(statusCode);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return(returnValue);
        }
Esempio n. 7
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="userOrganizeEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseUserOrganizeEntity userOrganizeEntity)
 {
     return(this.AddEntity(userOrganizeEntity));
 }
Esempio n. 8
0
 partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseUserOrganizeEntity userOrganizeEntity);
Esempio n. 9
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="userOrganizeEntity">实体</param>
        public string AddEntity(BaseUserOrganizeEntity userOrganizeEntity)
        {
            string     sequence   = string.Empty;
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseUserOrganizeEntity.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldId, userOrganizeEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(BaseUserOrganizeEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(BaseUserOrganizeEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (userOrganizeEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            userOrganizeEntity.Id = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldId, userOrganizeEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, userOrganizeEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseUserOrganizeEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseUserOrganizeEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseUserOrganizeEntity.FieldModifiedOn);
            if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
Esempio n. 10
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="id">主键</param>
        public BaseUserOrganizeEntity GetEntity(int id)
        {
            BaseUserOrganizeEntity userOrganizeEntity = new BaseUserOrganizeEntity(this.GetDataTable(new KeyValuePair <string, object>(BaseUserOrganizeEntity.FieldId, id)));

            return(userOrganizeEntity);
        }
Esempio n. 11
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="userOrganizeEntity">实体</param>
 public int Update(BaseUserOrganizeEntity userOrganizeEntity)
 {
     return(this.UpdateEntity(userOrganizeEntity));
 }
Esempio n. 12
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="userOrganizeEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主鍵</param>
 /// <returns>主键</returns>
 public string Add(BaseUserOrganizeEntity userOrganizeEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(userOrganizeEntity));
 }
Esempio n. 13
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseUserOrganizeEntity entity)
 {
     return(this.AddObject(entity));
 }
Esempio n. 14
0
 // 这个是声明扩展方法
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseUserOrganizeEntity entity);
Esempio n. 15
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="entity">实体</param>
 public int Update(BaseUserOrganizeEntity entity)
 {
     return(this.UpdateObject(entity));
 }