/// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="ciSequenceEntity">实体</param>
        public string AddEntity(CiSequenceEntity ciSequenceEntity)
        {
            string sequence = string.Empty;

            this.Identity = false;
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, CiSequenceTable.FieldId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(ciSequenceEntity.Id))
                {
                    sequence            = BusinessLogic.NewGuid();
                    ciSequenceEntity.Id = sequence;
                }
                sqlBuilder.SetValue(CiSequenceTable.FieldId, ciSequenceEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(CiSequenceTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(CiSequenceTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(ciSequenceEntity.Id.ToString()))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            ciSequenceEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(CiSequenceTable.FieldId, ciSequenceEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, ciSequenceEntity);
            sqlBuilder.SetDBNow(CiSequenceTable.FieldCreateOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
示例#2
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="testdemoEntity">实体</param>
        public string AddEntity(testdemoEntity testdemoEntity)
        {
            string     sequence   = string.Empty;
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, testdemoTable.FieldID);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(testdemoTable.FieldID, testdemoEntity.ID);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(testdemoTable.FieldID, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(testdemoTable.FieldID, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (testdemoEntity.ID == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            testdemoEntity.ID = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(testdemoTable.FieldID, testdemoEntity.ID);
                    }
                }
            }
            this.SetEntity(sqlBuilder, testdemoEntity);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
        /// <summary>
        /// 重置排序码
        /// </summary>
        public override int ResetSortCode()
        {
            int       returnValue = 0;
            DataTable dataTable   = this.GetDT();
            string    id          = string.Empty;
            string    sortCode    = string.Empty;

            foreach (DataRow dataRow in dataTable.Rows)
            {
                id = dataRow[PiStaffTable.FieldId].ToString();
                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider);
                sortCode     = sequenceManager.GetSequence(PiStaffTable.TableName);
                returnValue += this.SetProperty(id, PiStaffTable.FieldSortCode, sortCode);
            }
            return(returnValue);
        }
示例#4
0
        /// <summary>
        /// Add 添加的主键
        /// </summary>
        /// <param name="folderEntity">文件夹对象</param>
        /// <returns>主键</returns>
        public string AddEntity(CiFolderEntity folderEntity)
        {
            var sequence = string.Empty;

            if (folderEntity.SortCode == null || folderEntity.SortCode == 0)
            {
                var sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                sequence = sequenceManager.GetSequence(this.CurrentTableName, sequenceManager.DefaultSequence);
                folderEntity.SortCode = BusinessLogic.ConvertToNullableInt32(sequence);
            }

            this.Identity = false;
            var sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(CiFolderTable.TableName, CiFolderTable.FieldId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(folderEntity.Id))
                {
                    sequence        = BusinessLogic.NewGuid();
                    folderEntity.Id = sequence;
                }
                sqlBuilder.SetValue(CiFolderTable.FieldId, folderEntity.Id);
            }

            this.SetEntity(sqlBuilder, folderEntity);
            sqlBuilder.SetValue(CiFolderTable.FieldCreateUserId, UserInfo.Id);
            sqlBuilder.SetValue(CiFolderTable.FieldCreateBy, UserInfo.RealName);
            sqlBuilder.SetDBNow(CiFolderTable.FieldCreateOn);
            sqlBuilder.SetValue(CiFolderTable.FieldModifiedUserId, UserInfo.Id);
            sqlBuilder.SetValue(CiFolderTable.FieldModifiedBy, UserInfo.RealName);
            sqlBuilder.SetDBNow(CiFolderTable.FieldModifiedOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }

            return(sequence);
        }
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="userEntity">实体</param>
        public string AddEntity(PiUserEntity userEntity)
        {
            string sequence = string.Empty;

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

            sqlBuilder.BeginInsert(this.CurrentTableName, PiUserTable.FieldId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(userEntity.Id))
                {
                    sequence      = BusinessLogic.NewGuid();
                    userEntity.Id = sequence;
                }
                sqlBuilder.SetValue(PiUserTable.FieldId, userEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(PiUserTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(PiUserTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (userEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            userEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(PiUserTable.FieldId, userEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, userEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(PiUserTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(PiUserTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(PiUserTable.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(PiUserTable.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(PiUserTable.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(PiUserTable.FieldModifiedOn);
            if (DBProvider.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
示例#6
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="workTaskInsNextOperEntity">实体</param>
        public string AddEntity(WorkTaskInsNextOperEntity workTaskInsNextOperEntity)
        {
            var sequence = string.Empty;

            this.Identity = false;
            if (!string.IsNullOrEmpty(workTaskInsNextOperEntity.NextOperId))
            {
                sequence = workTaskInsNextOperEntity.NextOperId.ToString();
            }
            var sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, WorkTaskInsNextOperTable.FieldNextOperId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(workTaskInsNextOperEntity.NextOperId))
                {
                    sequence = BusinessLogic.NewGuid();
                    workTaskInsNextOperEntity.NextOperId = sequence;
                }
                sqlBuilder.SetValue(WorkTaskInsNextOperTable.FieldNextOperId, workTaskInsNextOperEntity.NextOperId);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(WorkTaskInsNextOperTable.FieldNextOperId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(WorkTaskInsNextOperTable.FieldNextOperId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(workTaskInsNextOperEntity.NextOperId))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                var sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            workTaskInsNextOperEntity.NextOperId = sequence;
                        }
                        sqlBuilder.SetValue(WorkTaskInsNextOperTable.FieldNextOperId, workTaskInsNextOperEntity.NextOperId);
                    }
                }
            }
            this.SetEntity(sqlBuilder, workTaskInsNextOperEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(WorkTaskInsNextOperTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(WorkTaskInsNextOperTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(WorkTaskInsNextOperTable.FieldCreateOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
示例#7
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="subWorkFlowEntity">实体</param>
        public string AddEntity(SubWorkFlowEntity subWorkFlowEntity)
        {
            var sequence = string.Empty;

            this.Identity = false;
            if (subWorkFlowEntity.SubId != null)
            {
                sequence = subWorkFlowEntity.SubId.ToString();
            }
            var sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, SubWorkFlowTable.FieldSubId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(subWorkFlowEntity.SubId))
                {
                    sequence = BusinessLogic.NewGuid();
                    subWorkFlowEntity.SubId = sequence;
                }
                sqlBuilder.SetValue(SubWorkFlowTable.FieldSubId, subWorkFlowEntity.SubId);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(SubWorkFlowTable.FieldSubId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(SubWorkFlowTable.FieldSubId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(subWorkFlowEntity.SubId))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                var sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            subWorkFlowEntity.SubId = sequence;
                        }
                        sqlBuilder.SetValue(SubWorkFlowTable.FieldSubId, subWorkFlowEntity.SubId);
                    }
                }
            }
            this.SetEntity(sqlBuilder, subWorkFlowEntity);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
示例#8
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="workFlowEventEntity">实体</param>
        public string AddEntity(WorkFlowEventEntity workFlowEventEntity)
        {
            string sequence = string.Empty;

            this.Identity = false;
            if (!string.IsNullOrEmpty(workFlowEventEntity.Guid))
            {
                sequence = workFlowEventEntity.Guid.ToString(CultureInfo.InvariantCulture);
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, WorkFlowEventTable.FieldGuid);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(workFlowEventEntity.Guid))
                {
                    sequence = BusinessLogic.NewGuid();
                    workFlowEventEntity.Guid = sequence;
                }
                sqlBuilder.SetValue(WorkFlowEventTable.FieldGuid, workFlowEventEntity.Guid);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(WorkFlowEventTable.FieldGuid, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(WorkFlowEventTable.FieldGuid, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(workFlowEventEntity.Guid))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            workFlowEventEntity.Guid = sequence;
                        }
                        sqlBuilder.SetValue(WorkFlowEventTable.FieldGuid, workFlowEventEntity.Guid);
                    }
                }
            }
            this.SetEntity(sqlBuilder, workFlowEventEntity);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
示例#9
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddEntity(CiItemsEntity entity)
        {
            var sequence = string.Empty;

            if (string.IsNullOrEmpty(entity.SortCode.ToString()) || entity.SortCode == 0)
            {
                var sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                sequence        = sequenceManager.GetSequence(this.CurrentTableName);
                entity.SortCode = int.Parse(sequence);
            }
            this.Identity = false;
            var sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, CiItemsTable.FieldId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(entity.Id))
                {
                    sequence  = BusinessLogic.NewGuid();
                    entity.Id = sequence;
                }
                sqlBuilder.SetValue(CiItemsTable.FieldId, entity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(CiItemsTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(CiItemsTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(sequence))
                        {
                            var sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                            sequence = sequenceManager.GetSequence(this.CurrentTableName);
                        }
                        entity.Id = sequence;
                        sqlBuilder.SetValue(CiItemsTable.FieldId, entity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CiItemsTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(CiItemsTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(CiItemsTable.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CiItemsTable.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(CiItemsTable.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(CiItemsTable.FieldModifiedOn);
            if (DBProvider.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
示例#10
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="piPlatFormAddInEntity">实体</param>
        public string AddEntity(PiPlatFormAddInEntity piPlatFormAddInEntity)
        {
            string sequence = string.Empty;

            this.Identity = false;
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, PiPlatFormAddInTable.FieldId);
            if (!this.Identity)
            {
                if (String.IsNullOrEmpty(piPlatFormAddInEntity.Id))
                {
                    sequence = BusinessLogic.NewGuid();
                    piPlatFormAddInEntity.Id = sequence;
                }
                sqlBuilder.SetValue(PiPlatFormAddInTable.FieldId, piPlatFormAddInEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(PiPlatFormAddInTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(PiPlatFormAddInTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (piPlatFormAddInEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            piPlatFormAddInEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(PiPlatFormAddInTable.FieldId, piPlatFormAddInEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, piPlatFormAddInEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(PiPlatFormAddInTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(PiPlatFormAddInTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(PiPlatFormAddInTable.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(PiPlatFormAddInTable.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(PiPlatFormAddInTable.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(PiPlatFormAddInTable.FieldModifiedOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="fileEntity">实体</param>
        public string AddEntity(CiFileEntity fileEntity)
        {
            var sequence = string.Empty;

            if (fileEntity.SortCode == null || fileEntity.SortCode == 0)
            {
                var sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                sequence            = sequenceManager.GetSequence(this.CurrentTableName, sequenceManager.DefaultSequence);
                fileEntity.SortCode = BusinessLogic.ConvertToNullableInt32(sequence);
            }
            this.Identity = false;
            var sqlBuilder = new SQLBuilder(DBProvider, this.Identity, false);

            sqlBuilder.BeginInsert(this.CurrentTableName, CiFileTable.FieldId);
            if (!this.Identity)
            {
                if (String.IsNullOrEmpty(fileEntity.Id))
                {
                    sequence      = BusinessLogic.NewGuid();
                    fileEntity.Id = sequence;
                }
                sqlBuilder.SetValue(CiFileTable.FieldId, fileEntity.Id);
            }
            else
            {
                if (!this.ReturnId && DBProvider.CurrentDbType == CurrentDbType.Oracle)
                {
                    sqlBuilder.SetFormula(CiFileTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                }
                else
                {
                    if (this.Identity && DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        if (string.IsNullOrEmpty(fileEntity.Id))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                var sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            fileEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(CiFileTable.FieldId, fileEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, fileEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CiFileTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(CiFileTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(CiFileTable.FieldCreateOn);

            /*
             * if (UserInfo != null)
             * {
             *  sqlBuilder.SetValue(CiFileTable.FieldModifiedUserId, UserInfo.Id);
             *  sqlBuilder.SetValue(CiFileTable.FieldModifiedBy, UserInfo.RealName);
             * }
             * sqlBuilder.SetDBNow(CiFileTable.FieldModifiedOn);
             */
            if (DBProvider.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
示例#12
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="piOrganizeEntity">实体</param>
        public string AddEntity(PiOrganizeEntity piOrganizeEntity, out string statusCode)
        {
            string sequence = string.Empty;

            statusCode = string.Empty;
            string[] names  = new string[] { PiOrganizeTable.FieldParentId, PiOrganizeTable.FieldFullName, PiOrganizeTable.FieldDeleteMark };
            object[] values = new object[] { piOrganizeEntity.ParentId, piOrganizeEntity.FullName, piOrganizeEntity.DeleteMark };
            if (this.Exists(names, values))
            {
                // 名称已重复
                statusCode = StatusCode.ErrorNameExist.ToString();
            }
            else
            {
                if (piOrganizeEntity.SortCode == null || piOrganizeEntity.SortCode == 0)
                {
                    CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                    sequence = sequenceManager.GetSequence(this.CurrentTableName, sequenceManager.DefaultSequence);
                    piOrganizeEntity.SortCode = int.Parse(sequence);
                }
                this.Identity = false;
                SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);
                sqlBuilder.BeginInsert(this.CurrentTableName, PiOrganizeTable.FieldId);
                if (!this.Identity)
                {
                    if (String.IsNullOrEmpty(piOrganizeEntity.Id))
                    {
                        sequence            = BusinessLogic.NewGuid();
                        piOrganizeEntity.Id = sequence;
                    }
                    sqlBuilder.SetValue(PiOrganizeTable.FieldId, piOrganizeEntity.Id);
                }
                else
                {
                    if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                        {
                            sqlBuilder.SetFormula(PiOrganizeTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                        }
                        if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                        {
                            sqlBuilder.SetFormula(PiOrganizeTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                        }
                    }
                    else
                    {
                        if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                        {
                            if (piOrganizeEntity.Id == null)
                            {
                                if (string.IsNullOrEmpty(sequence))
                                {
                                    CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                    sequence = sequenceManager.GetSequence(this.CurrentTableName);
                                }
                                piOrganizeEntity.Id = sequence;
                            }
                            sqlBuilder.SetValue(PiOrganizeTable.FieldId, piOrganizeEntity.Id);
                        }
                    }
                }
                this.SetEntity(sqlBuilder, piOrganizeEntity);
                //if (UserInfo != null)
                //{
                //    sqlBuilder.SetValue(PiOrganizeTable.FieldCreateUserId, UserInfo.Id);
                //    sqlBuilder.SetValue(PiOrganizeTable.FieldCreateBy, UserInfo.RealName);
                //}
                sqlBuilder.SetDBNow(PiOrganizeTable.FieldCreateOn);
                sqlBuilder.SetDBNow(PiOrganizeTable.FieldModifiedOn);
                if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
                {
                    sequence = sqlBuilder.EndInsert().ToString();
                    // 运行成功
                    statusCode = StatusCode.OKAdd.ToString();
                }
                else
                {
                    sqlBuilder.EndInsert();
                    // 运行成功
                    statusCode = StatusCode.OKAdd.ToString();
                }
            }
            return(sequence);
        }
        /// <summary>
        /// 获取序列号
        /// </summary>
        /// <param name="dbProvider">数据库连接</param>
        /// <param name="userInfo">用户</param>
        /// <param name="fullName">序列名称</param>
        /// <returns>序列号</returns>
        public string GetSequence(IDbProvider dbProvider, UserInfo userInfo, string fullName)
        {
            var sequenceManager = new CiSequenceManager(dbProvider);

            return(sequenceManager.GetSequence(fullName));
        }