/// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="userOrganizeEntity">用户组织机构实体</param>
 /// <param name="statusCode">状态码</param>
 /// <returns>主键</returns>
 public string Add(BaseUserOrganizeEntity userOrganizeEntity, out string statusCode)
 {
     string returnValue = 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, userOrganizeEntity.UserId));
     parameters.Add(new KeyValuePair<string, object>(BaseUserOrganizeEntity.FieldCompanyId, userOrganizeEntity.CompanyId));
     parameters.Add(new KeyValuePair<string, object>(BaseUserOrganizeEntity.FieldDepartmentId, userOrganizeEntity.DepartmentId));
     parameters.Add(new KeyValuePair<string, object>(BaseUserOrganizeEntity.FieldWorkgroupId, userOrganizeEntity.WorkgroupId));
     parameters.Add(new KeyValuePair<string, object>(BaseUserOrganizeEntity.FieldRoleId, userOrganizeEntity .RoleId));
     if (this.Exists(parameters))
     {
         // 用户名已重复
         statusCode = StatusCode.Exist.ToString();
     }
     else
     {
         returnValue = this.AddEntity(userOrganizeEntity);
         // 运行成功
         statusCode = StatusCode.OKAdd.ToString();
     }
     return returnValue;
 }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
 /// <summary>
 /// 获取用户数据
 /// </summary>
 /// <returns>用户实体</returns>
 private BaseUserOrganizeEntity GetEntity()
 {
     // 获取用户数据
     BaseUserOrganizeEntity userOrganizeEntity = new BaseUserOrganizeEntity();
     if (!string.IsNullOrEmpty(this.UserId))
     {
         userOrganizeEntity.UserId = int.Parse(this.UserId);
     }
     userOrganizeEntity.CompanyId = null;
     if (!string.IsNullOrEmpty(this.ucCompany.SelectedId))
     {
         userOrganizeEntity.CompanyId = int.Parse(this.ucCompany.SelectedId);
     }
     userOrganizeEntity.DepartmentId = null;
     if (!string.IsNullOrEmpty(this.ucDepartment.SelectedId))
     {
         userOrganizeEntity.DepartmentId = int.Parse(this.ucDepartment.SelectedId);
     }
     userOrganizeEntity.WorkgroupId = null;
     if (!string.IsNullOrEmpty(this.ucWorkgroup.SelectedId))
     {
         userOrganizeEntity.WorkgroupId = int.Parse(this.ucWorkgroup.SelectedId);
     }
     if (this.cmbRole.SelectedValue == null || this.cmbRole.SelectedValue.ToString().Length == 0)
     {
         userOrganizeEntity.RoleId = null;
     }
     else
     {
         userOrganizeEntity.RoleId = int.Parse(this.cmbRole.SelectedValue.ToString());
     }
     userOrganizeEntity.DeletionStateCode = 0;
     return userOrganizeEntity;
 }
partial         void SetEntityExpand(SQLBuilder sqlBuilder, BaseUserOrganizeEntity userOrganizeEntity);
 /// <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="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);
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="userOrganizeEntity">实体</param>
 public int Update(BaseUserOrganizeEntity userOrganizeEntity)
 {
     return this.UpdateEntity(userOrganizeEntity);
 }
 /// <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;
 }
 /// <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 == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2))
         {
             if (DbHelper.CurrentDbType == DbTypes.Oracle)
             {
                 sqlBuilder.SetFormula(BaseUserOrganizeEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
             }
             if (DbHelper.CurrentDbType == DbTypes.DB2)
             {
                 sqlBuilder.SetFormula(BaseUserOrganizeEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
             }
         }
         else
         {
             if (this.Identity && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.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 == DbTypes.SqlServer && this.Identity)
     {
         sequence = sqlBuilder.EndInsert().ToString();
     }
     else
     {
         sqlBuilder.EndInsert();
     }
     return sequence;
 }
 /// <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);
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="userOrganizeEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseUserOrganizeEntity userOrganizeEntity)
 {
     return this.AddEntity(userOrganizeEntity);
 }