Exemplo n.º 1
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="moduleEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>返回</returns>
        public int Update(PiModuleEntity moduleEntity, out string statusCode)
        {
            int returnValue = 0;

            // 检查是否已被其他人修改
            //if (DbLogic.IsModifed(DBProvider, PiModuleTable.TableName, moduleEntity.Id, moduleEntity.ModifiedUserId, moduleEntity.ModifiedOn))
            //{
            //    // 数据已经被修改
            //    statusCode = StatusCode.ErrorChanged.ToString();
            //}
            //else
            //{
            string[] names  = { PiModuleTable.FieldDeleteMark, PiModuleTable.FieldCode, PiModuleTable.FieldFullName };
            object[] values = { 0, moduleEntity.Code, moduleEntity.FullName };

            // 检查编号是否重复
            if ((moduleEntity.Code.Length > 0) && (this.Exists(names, values, moduleEntity.Id)))
            {
                // 编号已重复
                statusCode = StatusCode.ErrorCodeExist.ToString();
            }
            else
            {
                returnValue = this.UpdateEntity(moduleEntity);
                statusCode  = returnValue == 1 ? StatusCode.OKUpdate.ToString() : StatusCode.ErrorDeleted.ToString();
            }
            //}
            return(returnValue);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="sqlBuilder">SQL语句生成器</param>
 /// <param name="moduleEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, PiModuleEntity moduleEntity)
 {
     sqlBuilder.SetValue(PiModuleTable.FieldParentId, moduleEntity.ParentId);
     sqlBuilder.SetValue(PiModuleTable.FieldCode, moduleEntity.Code);
     sqlBuilder.SetValue(PiModuleTable.FieldFullName, moduleEntity.FullName);
     sqlBuilder.SetValue(PiModuleTable.FieldCategory, moduleEntity.Category);
     sqlBuilder.SetValue(PiModuleTable.FieldModuleType, moduleEntity.ModuleType);
     sqlBuilder.SetValue(PiModuleTable.FieldImageIndex, moduleEntity.ImageIndex);
     sqlBuilder.SetValue(PiModuleTable.FieldSelectedImageIndex, moduleEntity.SelectedImageIndex);
     sqlBuilder.SetValue(PiModuleTable.FieldNavigateUrl, moduleEntity.NavigateUrl);
     sqlBuilder.SetValue(PiModuleTable.FieldMvcNavigateUrl, moduleEntity.MvcNavigateUrl);
     sqlBuilder.SetValue(PiModuleTable.FieldIconCss, moduleEntity.IconCss);
     sqlBuilder.SetValue(PiModuleTable.FieldIconUrl, moduleEntity.IconUrl);
     sqlBuilder.SetValue(PiModuleTable.FiledFormName, moduleEntity.FormName);
     sqlBuilder.SetValue(PiModuleTable.FiledAssemblyName, moduleEntity.AssemblyName);
     sqlBuilder.SetValue(PiModuleTable.FieldTarget, moduleEntity.Target);
     sqlBuilder.SetValue(PiModuleTable.FieldIsPublic, moduleEntity.IsPublic);
     sqlBuilder.SetValue(PiModuleTable.FieldIsMenu, moduleEntity.IsMenu);
     sqlBuilder.SetValue(PiModuleTable.FieldExpand, moduleEntity.Expand);
     sqlBuilder.SetValue(PiModuleTable.FieldPermissionItemCode, moduleEntity.PermissionItemCode);
     sqlBuilder.SetValue(PiModuleTable.FieldPermissionScopeTables, moduleEntity.PermissionScopeTables);
     sqlBuilder.SetValue(PiModuleTable.FieldAllowEdit, moduleEntity.AllowEdit);
     sqlBuilder.SetValue(PiModuleTable.FieldAllowDelete, moduleEntity.AllowDelete);
     sqlBuilder.SetValue(PiModuleTable.FieldSortCode, moduleEntity.SortCode);
     sqlBuilder.SetValue(PiModuleTable.FieldDeleteMark, moduleEntity.DeleteMark);
     sqlBuilder.SetValue(PiModuleTable.FieldEnabled, moduleEntity.Enabled);
     sqlBuilder.SetValue(PiModuleTable.FieldDescription, moduleEntity.Description);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Add 添加的主键
        /// </summary>
        /// <param name="fullName">对象</param>
        /// <returns>主键</returns>
        public string Add(string fullName)
        {
            string         statusCode   = string.Empty;
            PiModuleEntity moduleEntity = new PiModuleEntity();

            moduleEntity.FullName = fullName;
            return(this.Add(moduleEntity, out statusCode));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public PiModuleEntity GetEntity(UserInfo userInfo, string id)
        {
            var            parameter    = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_GetEntity);
            PiModuleEntity moduleEntity = null;

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var moduleManager = new PiModuleManager(dbProvider, userInfo);
                moduleEntity      = moduleManager.GetEntity(id);
            });
            return(moduleEntity);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 批量进行保存
        /// </summary>
        /// <param name="dataTable">数据表</param>
        /// <returns>影响行数</returns>
        public override int BatchSave(DataTable dataTable)
        {
            int            returnValue  = 0;
            PiModuleEntity moduleEntity = new PiModuleEntity();

            foreach (DataRow dataRow in dataTable.Rows)
            {
                // 删除状态
                if (dataRow.RowState == DataRowState.Deleted)
                {
                    string id = dataRow[PiModuleTable.FieldId, DataRowVersion.Original].ToString();
                    if (id.Length > 0)
                    {
                        if (dataRow[PiModuleTable.FieldAllowDelete, DataRowVersion.Original].ToString().Equals("1"))
                        {
                            returnValue += this.DeleteEntity(id);
                        }
                    }
                }
                // 被修改过
                if (dataRow.RowState == DataRowState.Modified)
                {
                    string id = dataRow[PiModuleTable.FieldId, DataRowVersion.Original].ToString();
                    if (id.Length > 0)
                    {
                        moduleEntity.GetFrom(dataRow);
                        // 判断是否允许编辑
                        if (moduleEntity.AllowEdit == 1)
                        {
                            returnValue += this.UpdateEntity(moduleEntity);
                        }
                    }
                }
                // 添加状态
                if (dataRow.RowState == DataRowState.Added)
                {
                    moduleEntity.GetFrom(dataRow);
                    returnValue += this.AddEntity(moduleEntity).Length > 0 ? 1 : 0;
                }
                if (dataRow.RowState == DataRowState.Unchanged)
                {
                    continue;
                }
                if (dataRow.RowState == DataRowState.Detached)
                {
                    continue;
                }
            }
            this.ReturnStatusCode = StatusCode.OK.ToString();
            return(returnValue);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="moduleEntity">实体</param>
        public int UpdateEntity(PiModuleEntity moduleEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, moduleEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(PiModuleTable.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(PiModuleTable.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(PiModuleTable.FieldModifiedOn);
            sqlBuilder.SetWhere(PiModuleTable.FieldId, moduleEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
Exemplo n.º 7
0
        /// <summary>
        /// 更新模块菜单
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="moduleEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状消息</param>
        /// <returns>影响行数</returns>
        public int Update(UserInfo userInfo, PiModuleEntity moduleEntity, out string statusCode, out string statusMessage)
        {
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;
            int    returnValue   = 0;
            var    parameter     = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_Update);

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var moduleManager = new PiModuleManager(dbProvider, userInfo);
                // 调用方法,并且返回运行结果
                returnValue = moduleManager.Update(moduleEntity, out returnCode);
                // 获得状态消息
                returnMessage = moduleManager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(returnValue);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="moduleEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>返回</returns>
        public string Add(PiModuleEntity moduleEntity, out string statusCode)
        {
            string returnValue = string.Empty;

            // 检查名称是否重复
            string[] names  = { PiModuleTable.FieldDeleteMark, PiModuleTable.FieldCode, PiModuleTable.FieldFullName };
            object[] values = { 0, moduleEntity.Code, moduleEntity.FullName };
            if (this.Exists(names, values))
            {
                // 名称已重复
                statusCode = StatusCode.ErrorCodeExist.ToString();
            }
            else
            {
                returnValue = this.AddEntity(moduleEntity);
                // 运行成功
                statusCode = StatusCode.OKAdd.ToString();
            }
            return(returnValue);
        }
Exemplo n.º 9
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="moduleEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(PiModuleEntity moduleEntity)
 {
     return(this.AddEntity(moduleEntity));
 }
Exemplo n.º 10
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="moduleEntity">实体</param>
        public string AddEntity(PiModuleEntity moduleEntity)
        {
            string sequence = string.Empty;

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

            sqlBuilder.BeginInsert(this.CurrentTableName, PiModuleTable.FieldId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(moduleEntity.Id))
                {
                    sequence        = BusinessLogic.NewGuid();
                    moduleEntity.Id = sequence;
                }
                sqlBuilder.SetValue(PiModuleTable.FieldId, moduleEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(PiModuleTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(PiModuleTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (moduleEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            moduleEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(PiModuleTable.FieldId, moduleEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, moduleEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(PiModuleTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(PiModuleTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(PiModuleTable.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(PiModuleTable.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(PiModuleTable.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(PiModuleTable.FieldModifiedOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
Exemplo n.º 11
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="moduleEntity">实体</param>
 public int Update(PiModuleEntity moduleEntity)
 {
     return(this.UpdateEntity(moduleEntity));
 }
Exemplo n.º 12
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="moduleEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主鍵</param>
 /// <returns>主键</returns>
 public string Add(PiModuleEntity moduleEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(moduleEntity));
 }