/// <summary>ArchiveChildrens a Sector record.</summary> /// <param name="transaction">Commits or rejects a set of commands as a unit</param> /// <param name="rowVersion">the version number of this row.</param> /// <param name="sectorId">The value for the SectorId column.</param> /// <param name="archive">true to archive the object, false to unarchive it.</param> internal static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int sectorId) { // Accessor for the Sector Table. ServerDataModel.SectorDataTable sectorTable = ServerDataModel.Sector; // This record can be used to iterate through all the children. ServerDataModel.SectorRow sectorRow = sectorTable.FindBySectorId(sectorId); // Archive the child records. for (int index = 0; (index < sectorRow.GetSectorTargetRows().Length); index = (index + 1)) { ServerDataModel.SectorTargetRow childSectorTargetRow = sectorRow.GetSectorTargetRows()[index]; SectorTarget.Archive(adoTransaction, sqlTransaction, childSectorTargetRow.RowVersion, childSectorTargetRow.ModelId, childSectorTargetRow.SectorId); } // Increment the row version rowVersion = ServerDataModel.RowVersion.Increment(); // Delete the record in the ADO database. sectorRow[sectorTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(sectorRow); sectorRow.Delete(); // Archive the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Sector\" set \"IsArchived\" = 1 where \"SectorId\"=@sectorId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@sectorId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sectorId)); sqlCommand.ExecuteNonQuery(); }
/// <summary>Collects the table lock request(s) for an Update operation</summary> /// <param name="adoTransaction">A list of locks required for this operation.</param> internal static void ArchiveChildren(AdoTransaction adoTransaction) { // These table lock(s) are required for the 'Archive' operation. adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.Model)); Account.ArchiveChildren(adoTransaction); PositionTarget.Archive(adoTransaction); SectorTarget.Archive(adoTransaction); }
/// <summary>Inserts a SectorTarget record using Metadata Parameters.</summary> /// <param name="parameters">Contains the metadata parameters.</param> public static void Archive(ParameterList parameters) { // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; long rowVersion = parameters["rowVersion"]; int modelId = parameters["modelId"]; int sectorId = parameters["sectorId"]; // Call the internal method to complete the operation. SectorTarget.Archive(adoTransaction, sqlTransaction, rowVersion, modelId, sectorId); }
/// <summary>Inserts a SectorTarget record using Metadata Parameters.</summary> /// <param name="parameters">Contains the metadata parameters.</param> public static void Update(ParameterList parameters) { // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; long rowVersion = parameters["rowVersion"]; int modelId = parameters["modelId"]; int sectorId = parameters["sectorId"]; object percent = parameters["percent"].Value; // Call the internal method to complete the operation. SectorTarget.Update(adoTransaction, sqlTransaction, ref rowVersion, modelId, sectorId, percent); // Return values. parameters["rowVersion"] = rowVersion; }
/// <summary>Inserts a SectorTarget record using Metadata Parameters.</summary> /// <param name="parameters">Contains the metadata parameters.</param> public static void Insert(ParameterList parameters) { // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; int modelId = parameters["modelId"]; int sectorId = parameters["sectorId"]; decimal percent = parameters["percent"]; // The rowVersion is passed back to the caller in the event it's needed for additional commands in the batch. long rowVersion = long.MinValue; // Call the internal method to complete the operation. SectorTarget.Insert(adoTransaction, sqlTransaction, ref rowVersion, modelId, sectorId, percent); // Return values. parameters["rowVersion"] = rowVersion; }
/// <summary>ArchiveChildrens a Model record.</summary> /// <param name="transaction">Commits or rejects a set of commands as a unit</param> /// <param name="rowVersion">the version number of this row.</param> /// <param name="modelId">The value for the ModelId column.</param> /// <param name="archive">true to archive the object, false to unarchive it.</param> internal static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int modelId) { // Accessor for the Model Table. ServerDataModel.ModelDataTable modelTable = ServerDataModel.Model; // This record can be used to iterate through all the children. ServerDataModel.ModelRow modelRow = modelTable.FindByModelId(modelId); // Archive the child records. for (int index = 0; (index < modelRow.GetAccountRows().Length); index = (index + 1)) { ServerDataModel.AccountRow childAccountRow = modelRow.GetAccountRows()[index]; Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId); } for (int index = 0; (index < modelRow.GetPositionTargetRows().Length); index = (index + 1)) { ServerDataModel.PositionTargetRow childPositionTargetRow = modelRow.GetPositionTargetRows()[index]; PositionTarget.Archive(adoTransaction, sqlTransaction, childPositionTargetRow.RowVersion, childPositionTargetRow.ModelId, childPositionTargetRow.SecurityId, childPositionTargetRow.PositionTypeCode); } for (int index = 0; (index < modelRow.GetSectorTargetRows().Length); index = (index + 1)) { ServerDataModel.SectorTargetRow childSectorTargetRow = modelRow.GetSectorTargetRows()[index]; SectorTarget.Archive(adoTransaction, sqlTransaction, childSectorTargetRow.RowVersion, childSectorTargetRow.ModelId, childSectorTargetRow.SectorId); } // Increment the row version rowVersion = ServerDataModel.RowVersion.Increment(); // Delete the record in the ADO database. modelRow[modelTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(modelRow); modelRow.Delete(); // Archive the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Model\" set \"IsArchived\" = 1 where \"ModelId\"=@modelId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@modelId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modelId)); sqlCommand.ExecuteNonQuery(); }
/// <summary>Collects the table lock request(s) for an Update operation</summary> /// <param name="adoTransaction">A list of locks required for this operation.</param> internal static void DeleteChildren(AdoTransaction adoTransaction) { // These table lock(s) are required for the 'Delete' operation. adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.Sector)); SectorTarget.Delete(adoTransaction); }