/// <summary>
        /// 取得实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主鍵</param>
        /// <returns>实体</returns>
        public CiTableColumnsEntity GetEntity(UserInfo userInfo, string id)
        {
            CiTableColumnsEntity entity = null;
            var parameter = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                entity = new TableColumnsManager(dbProvider, userInfo).GetEntity(id);
            });

            return(entity);
        }
Example #2
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="ciTableColumnsEntity">实体</param>
        public int UpdateEntity(CiTableColumnsEntity ciTableColumnsEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, ciTableColumnsEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CiTableColumnsTable.FieldModifiedBy, UserInfo.RealName);
                sqlBuilder.SetValue(CiTableColumnsTable.FieldModifiedUserId, UserInfo.Id);
            }
            sqlBuilder.SetDBNow(CiTableColumnsTable.FieldModifiedOn);
            sqlBuilder.SetWhere(CiTableColumnsTable.FieldId, ciTableColumnsEntity.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 Add(UserInfo userInfo, CiTableColumnsEntity entity, out string statusCode, out string statusMessage)
        {
            string returnValue   = string.Empty;
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;
            var    parameter     = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.TableColumnsService_Add);

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var manager   = new TableColumnsManager(dbProvider, userInfo);
                returnValue   = manager.AddEntity(entity);
                returnMessage = manager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(returnValue);
        }
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>影响行数</returns>
        public int Update(UserInfo userInfo, CiTableColumnsEntity entity, out string statusCode, out string statusMessage)
        {
            var    returnValue   = 0;
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;
            var    parameter     = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var manager   = new TableColumnsManager(dbProvider, userInfo);
                returnValue   = manager.UpdateEntity(entity);
                returnMessage = manager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(returnValue);
        }
        /// <summary>
        /// 批量进行保存
        /// </summary>
        /// <param name="dataTable">数据表</param>
        /// <returns>影响行数</returns>
        public override int BatchSave(DataTable dataTable)
        {
            int returnValue = 0;

            foreach (DataRow dataRow in dataTable.Rows)
            {
                // 删除状态
                if (dataRow.RowState == DataRowState.Deleted)
                {
                    string id = dataRow[CiTableColumnsTable.FieldId, DataRowVersion.Original].ToString();
                    if (id.Length > 0)
                    {
                        returnValue += this.DeleteEntity(id);
                    }
                }
                // 被修改过
                if (dataRow.RowState == DataRowState.Modified)
                {
                    string id = dataRow[CiTableColumnsTable.FieldId, DataRowVersion.Original].ToString();
                    if (id.Length > 0)
                    {
                        CiTableColumnsEntity entity = BaseEntity.Create <CiTableColumnsEntity>(dataRow);
                        returnValue += this.UpdateEntity(entity);
                    }
                }
                // 添加状态
                if (dataRow.RowState == DataRowState.Added)
                {
                    CiTableColumnsEntity staffEntity = BaseEntity.Create <CiTableColumnsEntity>(dataRow);
                    returnValue += this.AddEntity(staffEntity).Length > 0 ? 1 : 0;
                }
                if (dataRow.RowState == DataRowState.Unchanged)
                {
                    continue;
                }
                if (dataRow.RowState == DataRowState.Detached)
                {
                    continue;
                }
            }
            this.ReturnStatusCode = StatusCode.OK.ToString();
            return(returnValue);
        }
Example #6
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="entity">SQL语句生成器</param>
 /// <param name="entity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, CiTableColumnsEntity entity)
 {
     sqlBuilder.SetValue(CiTableColumnsTable.FieldTableCode, entity.TableCode);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldTableName, entity.TableName);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldColumnCode, entity.ColumnCode);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldColumnName, entity.ColumnName);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldIsPublic, entity.IsPublic);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldColumnAccess, entity.ColumnAccess);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldColumnEdit, entity.ColumnEdit);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldColumnDeney, entity.ColumnDeney);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldUseConstraint, entity.UseConstraint);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldDataType, entity.DataType);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldTargetTable, entity.TargetTable);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldIsSearchColumn, entity.IsSearchColumn);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldIsExhibitColumn, entity.IsExhibitColumn);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldEnabled, entity.Enabled);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldAllowEdit, entity.AllowEdit);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldAllowDelete, entity.AllowDelete);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldSortCode, entity.SortCode);
     sqlBuilder.SetValue(CiTableColumnsTable.FieldDescription, entity.Description);
 }
Example #7
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="ciTableColumnsEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(CiTableColumnsEntity ciTableColumnsEntity)
 {
     return(this.AddEntity(ciTableColumnsEntity));
 }
Example #8
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="ciTableColumnsEntity">实体</param>
        public string AddEntity(CiTableColumnsEntity ciTableColumnsEntity)
        {
            string sequence = string.Empty;

            if (ciTableColumnsEntity.SortCode == null || ciTableColumnsEntity.SortCode == 0)
            {
                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                ciTableColumnsEntity.SortCode = int.Parse(sequence);
            }
            this.Identity = false;
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, CiTableColumnsTable.FieldId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(ciTableColumnsEntity.Id))
                {
                    sequence = BusinessLogic.NewGuid();
                    ciTableColumnsEntity.Id = sequence;
                }
                sqlBuilder.SetValue(CiTableColumnsTable.FieldId, ciTableColumnsEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(CiTableColumnsTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(CiTableColumnsTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (ciTableColumnsEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            ciTableColumnsEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(CiTableColumnsTable.FieldId, ciTableColumnsEntity.Id);
                    }
                }
            }

            this.SetEntity(sqlBuilder, ciTableColumnsEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CiTableColumnsTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(CiTableColumnsTable.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(CiTableColumnsTable.FieldCreateBy, UserInfo.RealName);
                sqlBuilder.SetValue(CiTableColumnsTable.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(CiTableColumnsTable.FieldCreateOn);
            sqlBuilder.SetDBNow(CiTableColumnsTable.FieldModifiedOn);

            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
Example #9
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="ciTableColumnsEntity">实体</param>
 public int Update(CiTableColumnsEntity ciTableColumnsEntity)
 {
     return(this.UpdateEntity(ciTableColumnsEntity));
 }
Example #10
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="ciTableColumnsEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主键</param>
 /// <returns>主键</returns>
 public string Add(CiTableColumnsEntity ciTableColumnsEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(ciTableColumnsEntity));
 }