Ejemplo n.º 1
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="queryEngineDefineEntity">实体</param>
        /// <param name="statusCode">返回代码</param>
        /// <returns>主键</returns>
        public string Add(QueryEngineDefineEntity queryEngineDefineEntity, out string statusCode)
        {
            string returnValue = this.AddEntity(queryEngineDefineEntity);

            statusCode = !string.IsNullOrEmpty(returnValue) ? StatusCode.OKAdd.ToString() : StatusCode.Error.ToString();
            return(returnValue);
        }
        /// <summary>
        /// 得到查询引擎定义实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主鍵</param>
        /// <returns>实体</returns>
        public QueryEngineDefineEntity GetQueryEngineDefineEntity(UserInfo userInfo, string id)
        {
            QueryEngineDefineEntity entity = null;
            var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.QueryEnginService_GetEntity);

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                entity = new QueryEngineDefineManager(dbProvider, userInfo).GetEntity(id);
            });
            return(entity);
        }
        /// <summary>
        /// 更新查询引擎定义
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">查询引擎定义实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>影响行数</returns>
        public int UpdateQueryEngineDefine(UserInfo userInfo, QueryEngineDefineEntity entity, out string statusCode, out string statusMessage)
        {
            int    returnValue   = 0;
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;
            var    parameter     = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.QueryEnginService_Update);

            ServiceUtil.ProcessRDIWriteDb(userInfo, parameter, dbProvider =>
            {
                var manager   = new QueryEngineDefineManager(dbProvider, userInfo);
                returnValue   = manager.UpdateEntity(entity, out returnCode);
                returnMessage = manager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(returnValue);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="queryEngineDefineEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>影响行数</returns>
        public int UpdateEntity(QueryEngineDefineEntity queryEngineDefineEntity, out string statusCode)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, queryEngineDefineEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(QueryEngineDefineTable.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(QueryEngineDefineTable.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(QueryEngineDefineTable.FieldModifiedOn);
            sqlBuilder.SetWhere(QueryEngineDefineTable.FieldId, queryEngineDefineEntity.Id);
            int returnValue = sqlBuilder.EndUpdate();

            statusCode = returnValue == 1 ? StatusCode.OKUpdate.ToString() : StatusCode.ErrorDeleted.ToString();
            return(returnValue);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="sqlBuilder">sql语句生成器</param>
 /// <param name="queryEngineDefineEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, QueryEngineDefineEntity queryEngineDefineEntity)
 {
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldQueryEngineId, queryEngineDefineEntity.QueryEngineId);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldCode, queryEngineDefineEntity.Code);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldFullName, queryEngineDefineEntity.FullName);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldDataBaseLinkName, queryEngineDefineEntity.DataBaseLinkName);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldDataSourceType, queryEngineDefineEntity.DataSourceType);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldDataSourceName, queryEngineDefineEntity.DataSourceName);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldQueryStringKey, queryEngineDefineEntity.QueryStringKey);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldSelectedField, queryEngineDefineEntity.SelectedField);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldOrderByField, queryEngineDefineEntity.OrderByField);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldQueryString, queryEngineDefineEntity.QueryString);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldAllowEdit, queryEngineDefineEntity.AllowEdit);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldAllowDelete, queryEngineDefineEntity.AllowDelete);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldDeleteMark, queryEngineDefineEntity.DeleteMark);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldDescription, queryEngineDefineEntity.Description);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldEnabled, queryEngineDefineEntity.Enabled);
     sqlBuilder.SetValue(QueryEngineDefineTable.FieldSortCode, queryEngineDefineEntity.SortCode);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="queryEngineDefineEntity">实体</param>
        public string AddEntity(QueryEngineDefineEntity queryEngineDefineEntity)
        {
            string sequence = string.Empty;

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

            sqlBuilder.BeginInsert(this.CurrentTableName, QueryEngineDefineTable.FieldId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(queryEngineDefineEntity.Id))
                {
                    sequence = BusinessLogic.NewGuid();
                    queryEngineDefineEntity.Id = sequence;
                }
                sqlBuilder.SetValue(QueryEngineDefineTable.FieldId, queryEngineDefineEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(QueryEngineDefineTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(QueryEngineDefineTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(queryEngineDefineEntity.Id))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            queryEngineDefineEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(QueryEngineDefineTable.FieldId, queryEngineDefineEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, queryEngineDefineEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(QueryEngineDefineTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(QueryEngineDefineTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(QueryEngineDefineTable.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(QueryEngineDefineTable.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(QueryEngineDefineTable.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(QueryEngineDefineTable.FieldModifiedOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public QueryEngineDefineEntity GetEntity(string id)
        {
            QueryEngineDefineEntity queryEngineDefineEntity = BaseEntity.Create <QueryEngineDefineEntity>(this.GetDT(new KeyValuePair <string, object>(QueryEngineDefineTable.FieldId, id)));

            return(queryEngineDefineEntity);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="queryEngineDefineEntity">实体</param>
 /// <returns>影响行数</returns>
 public int Update(QueryEngineDefineEntity queryEngineDefineEntity)
 {
     return(this.UpdateEntity(queryEngineDefineEntity));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="queryEngineDefineEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主键</param>
 /// <returns>主键</returns>
 public string Add(QueryEngineDefineEntity queryEngineDefineEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(queryEngineDefineEntity));
 }