/// <summary> /// 添加实体 /// </summary> /// <param name="operatorInstanceEntity">实体</param> public string AddEntity(OperatorInstanceEntity operatorInstanceEntity) { var sequence = string.Empty; this.Identity = false; if (operatorInstanceEntity.OperatorInsId != null) { sequence = operatorInstanceEntity.OperatorInsId.ToString(); } var sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId); sqlBuilder.BeginInsert(this.CurrentTableName, OperatorInstanceTable.FieldOperatorInsId); if (!this.Identity) { if (string.IsNullOrEmpty(operatorInstanceEntity.OperatorInsId)) { sequence = BusinessLogic.NewGuid(); operatorInstanceEntity.OperatorInsId = sequence; } sqlBuilder.SetValue(OperatorInstanceTable.FieldOperatorInsId, operatorInstanceEntity.OperatorInsId); } else { if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2)) { if (DBProvider.CurrentDbType == CurrentDbType.Oracle) { sqlBuilder.SetFormula(OperatorInstanceTable.FieldOperatorInsId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL "); } if (DBProvider.CurrentDbType == CurrentDbType.DB2) { sqlBuilder.SetFormula(OperatorInstanceTable.FieldOperatorInsId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper()); } } else { if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2)) { if (string.IsNullOrEmpty(operatorInstanceEntity.OperatorInsId)) { if (string.IsNullOrEmpty(sequence)) { var sequenceManager = new CiSequenceManager(DBProvider, this.Identity); sequence = sequenceManager.GetSequence(this.CurrentTableName); } operatorInstanceEntity.OperatorInsId = sequence; } sqlBuilder.SetValue(OperatorInstanceTable.FieldOperatorInsId, operatorInstanceEntity.OperatorInsId); } } } this.SetEntity(sqlBuilder, operatorInstanceEntity); if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access)) { sequence = sqlBuilder.EndInsert().ToString(); } else { sqlBuilder.EndInsert(); } return(sequence); }
/// <summary> /// 添加实体 /// </summary> /// <param name="piRoleEntity">实体</param> public string AddEntity(PiRoleEntity piRoleEntity) { string sequence = string.Empty; if (piRoleEntity.SortCode == null || piRoleEntity.SortCode == 0) { CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity); sequence = sequenceManager.GetSequence(this.CurrentTableName, sequenceManager.DefaultSequence); piRoleEntity.SortCode = int.Parse(sequence); } this.Identity = false; SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId); sqlBuilder.BeginInsert(this.CurrentTableName, PiRoleTable.FieldId); if (!this.Identity) { if (String.IsNullOrEmpty(piRoleEntity.Id)) { sequence = BusinessLogic.NewGuid(); piRoleEntity.Id = sequence; } sqlBuilder.SetValue(PiRoleTable.FieldId, piRoleEntity.Id); } else { if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2)) { if (DBProvider.CurrentDbType == CurrentDbType.Oracle) { sqlBuilder.SetFormula(PiRoleTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL "); } if (DBProvider.CurrentDbType == CurrentDbType.DB2) { sqlBuilder.SetFormula(PiRoleTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper()); } } else { if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2)) { if (piRoleEntity.Id == null) { if (string.IsNullOrEmpty(sequence)) { CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity); sequence = sequenceManager.GetSequence(this.CurrentTableName); } piRoleEntity.Id = sequence; } sqlBuilder.SetValue(PiRoleTable.FieldId, piRoleEntity.Id); } } } this.SetEntity(sqlBuilder, piRoleEntity); if (UserInfo != null) { sqlBuilder.SetValue(PiRoleTable.FieldCreateUserId, UserInfo.Id); sqlBuilder.SetValue(PiRoleTable.FieldCreateBy, UserInfo.RealName); } sqlBuilder.SetDBNow(PiRoleTable.FieldCreateOn); if (UserInfo != null) { sqlBuilder.SetValue(PiRoleTable.FieldModifiedUserId, UserInfo.Id); sqlBuilder.SetValue(PiRoleTable.FieldModifiedBy, UserInfo.RealName); } sqlBuilder.SetDBNow(PiRoleTable.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="workLinkEntity">实体</param> public string AddEntity(WorkLinkEntity workLinkEntity) { string sequence = string.Empty; this.Identity = false; if (!string.IsNullOrEmpty(workLinkEntity.WorkLinkId)) { sequence = workLinkEntity.WorkLinkId.ToString(CultureInfo.InvariantCulture); } SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId); sqlBuilder.BeginInsert(this.CurrentTableName, WorkLinkTable.FieldWorkLinkId); if (!this.Identity) { if (string.IsNullOrEmpty(workLinkEntity.WorkLinkId)) { sequence = BusinessLogic.NewGuid(); workLinkEntity.WorkLinkId = sequence; } sqlBuilder.SetValue(WorkLinkTable.FieldWorkLinkId, workLinkEntity.WorkLinkId); } else { if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2)) { if (DBProvider.CurrentDbType == CurrentDbType.Oracle) { sqlBuilder.SetFormula(WorkLinkTable.FieldWorkLinkId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL "); } if (DBProvider.CurrentDbType == CurrentDbType.DB2) { sqlBuilder.SetFormula(WorkLinkTable.FieldWorkLinkId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper()); } } else { if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2)) { if (string.IsNullOrEmpty(workLinkEntity.WorkLinkId)) { if (string.IsNullOrEmpty(sequence)) { CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity); sequence = sequenceManager.GetSequence(this.CurrentTableName); } workLinkEntity.WorkLinkId = sequence; } sqlBuilder.SetValue(WorkLinkTable.FieldWorkLinkId, workLinkEntity.WorkLinkId); } } } this.SetEntity(sqlBuilder, workLinkEntity); if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access)) { sequence = sqlBuilder.EndInsert().ToString(); } else { sqlBuilder.EndInsert(); } return(sequence); }