/// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public CiParameterEntity GetEntity(UserInfo userInfo, string id)
        {
            CiParameterEntity sequenceEntity = null;
            var parameter = ParameterUtil.CreateWithOutMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName);

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

            return(sequenceEntity);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="categoryKey">类别主键</param>
        /// <param name="parameterId">标记主键</param>
        /// <param name="parameterCode">标记编码</param>
        /// <param name="parameterContent">标记内容</param>
        /// <param name="worked">工作状态</param>
        /// <param name="enabled">有效</param>
        /// <returns>主键</returns>
        public string Add(string categoryKey, string parameterId, string parameterCode, string parameterContent, bool worked, bool enabled)
        {
            CiParameterEntity parameterEntity = new CiParameterEntity
            {
                CategoryKey      = categoryKey,
                ParameterId      = parameterId,
                ParameterCode    = parameterCode,
                ParameterContent = parameterContent,
                Worked           = worked ? 1 : 0,
                Enabled          = enabled ? 1 : 0
            };

            return(this.Add(parameterEntity));
        }
Exemplo n.º 3
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="sqlBuilder">SQL语句生成器</param>
 /// <param name="ciParameterEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, CiParameterEntity ciParameterEntity)
 {
     sqlBuilder.SetValue(CiParameterTable.FieldCategoryKey, ciParameterEntity.CategoryKey);
     sqlBuilder.SetValue(CiParameterTable.FieldParameterId, ciParameterEntity.ParameterId);
     sqlBuilder.SetValue(CiParameterTable.FieldParameterCode, ciParameterEntity.ParameterCode);
     sqlBuilder.SetValue(CiParameterTable.FieldParameterContent, ciParameterEntity.ParameterContent);
     sqlBuilder.SetValue(CiParameterTable.FieldWorked, ciParameterEntity.Worked);
     sqlBuilder.SetValue(CiParameterTable.FieldEnabled, ciParameterEntity.Enabled);
     sqlBuilder.SetValue(CiParameterTable.FieldAllowEdit, ciParameterEntity.AllowEdit);
     sqlBuilder.SetValue(CiParameterTable.FieldAllowDelete, ciParameterEntity.AllowDelete);
     sqlBuilder.SetValue(CiParameterTable.FieldDescription, ciParameterEntity.Description);
     sqlBuilder.SetValue(CiParameterTable.FieldSortCode, ciParameterEntity.SortCode);
     sqlBuilder.SetValue(CiParameterTable.FieldDeleteMark, ciParameterEntity.DeleteMark);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="ciParameterEntity">实体</param>
        public int UpdateEntity(CiParameterEntity ciParameterEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, ciParameterEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CiParameterTable.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(CiParameterTable.FieldModifiedOn);
            sqlBuilder.SetWhere(CiParameterTable.FieldId, ciParameterEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="parameterEntity">参数基类表结构定义</param>
        /// <returns>影响行数</returns>
        public int Update(CiParameterEntity parameterEntity)
        {
            int returnValue = 0;

            // 检查编号是否重复
            if (this.Exists(new KeyValuePair <string, object>(CiParameterTable.FieldParameterCode, parameterEntity.ParameterCode), parameterEntity.Id))
            {
                // 文件夹名已重复
                this.ReturnStatusCode = StatusCode.ErrorCodeExist.ToString();
            }
            else
            {
                // 进行更新操作
                returnValue           = this.UpdateEntity(parameterEntity);
                this.ReturnStatusCode = returnValue == 1 ? StatusCode.OKUpdate.ToString() : StatusCode.ErrorDeleted.ToString();
            }
            return(returnValue);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新参数设置
        /// </summary>
        /// <param name="categoryKey">类别主键</param>
        /// <param name="parameterId">标志主键</param>
        /// <param name="parameterCode">编码</param>
        /// <param name="parameterContent">参数内容</param>
        /// <returns>影响行数</returns>
        public int SetParameter(string categoryKey, string parameterId, string parameterCode, string parameterContent, int allowEdit = 0, int allowDelete = 0)
        {
            int returnValue = 0;

            List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>(CiParameterTable.FieldCategoryKey, categoryKey),
                new KeyValuePair <string, object>(CiParameterTable.FieldParameterId, parameterId),
                new KeyValuePair <string, object>(CiParameterTable.FieldParameterCode, parameterCode),
                new KeyValuePair <string, object>(CiParameterTable.FieldDeleteMark, 0)
            };

            // 检测是否无效数据
            if (string.IsNullOrEmpty(parameterContent))
            {
                returnValue = this.Delete(parameters);
            }
            else
            {
                // 检测是否存在
                returnValue = this.SetProperty(parameters, new KeyValuePair <string, object>(CiParameterTable.FieldParameterContent, parameterContent));
                if (returnValue == 0)
                {
                    // 进行增加操作
                    CiParameterEntity parameterEntity = new CiParameterEntity
                    {
                        CategoryKey      = categoryKey,
                        ParameterId      = parameterId,
                        ParameterCode    = parameterCode,
                        ParameterContent = parameterContent,
                        AllowDelete      = allowDelete,
                        AllowEdit        = allowEdit,
                        Enabled          = 1,
                        Worked           = 0,
                        DeleteMark       = 0
                    };
                    this.AddEntity(parameterEntity);
                    returnValue = 1;
                }
            }
            return(returnValue);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 添加内容
        /// </summary>
        /// <param name="parameterEntity">内容</param>
        /// <returns>主键</returns>
        public string Add(CiParameterEntity parameterEntity)
        {
            string returnValue = string.Empty;
            // 此处检查this.exist()
            List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>(CiParameterTable.FieldCategoryKey, parameterEntity.CategoryKey),
                new KeyValuePair <string, object>(CiParameterTable.FieldParameterId, parameterEntity.ParameterId),
                new KeyValuePair <string, object>(CiParameterTable.FieldParameterCode, parameterEntity.ParameterCode)
            };

            if (this.Exists(parameters))
            {
                // 编号已重复
                this.ReturnStatusCode = StatusCode.ErrorCodeExist.ToString();
            }
            else
            {
                returnValue = this.AddEntity(parameterEntity);
                // 运行成功
                this.ReturnStatusCode = StatusCode.OKAdd.ToString();
            }
            return(returnValue);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="ciParameterEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主键</param>
 /// <returns>主键</returns>
 public string Add(CiParameterEntity ciParameterEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(ciParameterEntity));
 }
Exemplo n.º 9
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="ciParameterEntity">实体</param>
        public string AddEntity(CiParameterEntity ciParameterEntity)
        {
            string sequence = string.Empty;

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

            sqlBuilder.BeginInsert(this.CurrentTableName, CiParameterTable.FieldId);

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

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

            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }