/// <summary>Collects the table lock request(s) for an Update operation</summary> /// <param name="adoTransaction">A list of locks required for this operation.</param> public static void Archive(AdoTransaction adoTransaction) { // These table lock(s) are required for the 'Archive' operation. adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.Stylesheet)); Account.ArchiveChildren(adoTransaction); Blotter.ArchiveChildren(adoTransaction); }
/// <summary>Collects the table lock request(s) for an Update operation</summary> /// <param name="adoTransaction">A list of locks required for this operation.</param> public static void Delete(AdoTransaction adoTransaction) { // These table lock(s) are required for the 'Delete' operation. adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.Algorithm)); Blotter.ArchiveChildren(adoTransaction); Model.ArchiveChildren(adoTransaction); }
/// <summary>Archives a Stylesheet 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="stylesheetId">The value for the StylesheetId column.</param> /// <param name="archive">true to archive the object, false to unarchive it.</param> public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int stylesheetId) { // Accessor for the Stylesheet Table. ServerDataModel.StylesheetDataTable stylesheetTable = ServerDataModel.Stylesheet; // Rule #1: Make sure the record exists before updating it. ServerDataModel.StylesheetRow stylesheetRow = stylesheetTable.FindByStylesheetId(stylesheetId); if ((stylesheetRow == null)) { throw new Exception(string.Format("The Stylesheet table does not have an element identified by {0}", stylesheetId)); } // Rule #2: Optimistic Concurrency Check if ((stylesheetRow.RowVersion != rowVersion)) { throw new System.Exception("This record is busy. Please try again later."); } // Archive the child records. for (int index = 0; (index < stylesheetRow.GetAccountRows().Length); index = (index + 1)) { ServerDataModel.AccountRow childAccountRow = stylesheetRow.GetAccountRows()[index]; Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId); } for (int index = 0; (index < stylesheetRow.GetBlotterRowsByFKStylesheetBlotterBlockOrderStylesheetId().Length); index = (index + 1)) { ServerDataModel.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByFKStylesheetBlotterBlockOrderStylesheetId()[index]; Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId); } for (int index = 0; (index < stylesheetRow.GetBlotterRowsByFKStylesheetBlotterPlacementStylesheetId().Length); index = (index + 1)) { ServerDataModel.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByFKStylesheetBlotterPlacementStylesheetId()[index]; Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId); } for (int index = 0; (index < stylesheetRow.GetBlotterRowsByFKStylesheetBlotterExecutionStylesheetId().Length); index = (index + 1)) { ServerDataModel.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByFKStylesheetBlotterExecutionStylesheetId()[index]; Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId); } for (int index = 0; (index < stylesheetRow.GetBlotterRowsByFKStylesheetBlotterTicketStylesheetId().Length); index = (index + 1)) { ServerDataModel.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByFKStylesheetBlotterTicketStylesheetId()[index]; Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId); } // Increment the row version rowVersion = ServerDataModel.RowVersion.Increment(); // Delete the record in the ADO database. stylesheetRow[stylesheetTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(stylesheetRow); stylesheetRow.Delete(); // Archive the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Stylesheet\" set \"IsArchived\" = 1 where \"StylesheetId\"=@stylesheetId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@stylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, stylesheetId)); sqlCommand.ExecuteNonQuery(); }
/// <summary>Inserts a Blotter record using Metadata Parameters.</summary> /// <param name="parameters">Contains the metadata parameters.</param> public new 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 blotterId = parameters["blotterId"]; // Call the internal method to complete the operation. Blotter.Archive(adoTransaction, sqlTransaction, rowVersion, blotterId); }
/// <summary>Collects the table lock request(s) for an Update operation</summary> /// <param name="adoTransaction">A list of locks required for this operation.</param> public static void Archive(AdoTransaction adoTransaction) { // These table lock(s) are required for the 'Archive' operation. adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.Object)); Folder.ArchiveChildren(adoTransaction); Account.ArchiveChildren(adoTransaction); Blotter.ArchiveChildren(adoTransaction); Broker.ArchiveChildren(adoTransaction); Issuer.ArchiveChildren(adoTransaction); User.ArchiveChildren(adoTransaction); Model.ArchiveChildren(adoTransaction); ObjectTree.Archive(adoTransaction); Scheme.ArchiveChildren(adoTransaction); Sector.ArchiveChildren(adoTransaction); Security.ArchiveChildren(adoTransaction); }
/// <summary>Archives a Algorithm 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="algorithmId">The value for the AlgorithmId column.</param> /// <param name="archive">true to archive the object, false to unarchive it.</param> public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int algorithmId) { // Accessor for the Algorithm Table. ServerDataModel.AlgorithmDataTable algorithmTable = ServerDataModel.Algorithm; // Rule #1: Make sure the record exists before updating it. ServerDataModel.AlgorithmRow algorithmRow = algorithmTable.FindByAlgorithmId(algorithmId); if ((algorithmRow == null)) { throw new Exception(string.Format("The Algorithm table does not have an element identified by {0}", algorithmId)); } // Rule #2: Optimistic Concurrency Check if ((algorithmRow.RowVersion != rowVersion)) { throw new System.Exception("This record is busy. Please try again later."); } // Archive the child records. for (int index = 0; (index < algorithmRow.GetBlotterRows().Length); index = (index + 1)) { ServerDataModel.BlotterRow childBlotterRow = algorithmRow.GetBlotterRows()[index]; Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId); } for (int index = 0; (index < algorithmRow.GetModelRows().Length); index = (index + 1)) { ServerDataModel.ModelRow childModelRow = algorithmRow.GetModelRows()[index]; Model.ArchiveChildren(adoTransaction, sqlTransaction, childModelRow.RowVersion, childModelRow.ModelId); } // Increment the row version rowVersion = ServerDataModel.RowVersion.Increment(); // Delete the record in the ADO database. algorithmRow[algorithmTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(algorithmRow); algorithmRow.Delete(); // Archive the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Algorithm\" set \"IsArchived\" = 1 where \"AlgorithmId\"=@algorithmId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@algorithmId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, algorithmId)); sqlCommand.ExecuteNonQuery(); }
/// <summary>Inserts a Blotter record using Metadata Parameters.</summary> /// <param name="parameters">Contains the metadata parameters.</param> public new static void Insert(ParameterList parameters) { // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; object description = parameters["description"].Value; object externalId0 = parameters["externalId0"].Value; object externalId1 = parameters["externalId1"].Value; object externalId2 = parameters["externalId2"].Value; object externalId3 = parameters["externalId3"].Value; object externalId4 = parameters["externalId4"].Value; object externalId5 = parameters["externalId5"].Value; object externalId6 = parameters["externalId6"].Value; object externalId7 = parameters["externalId7"].Value; object groupPermission = parameters["groupPermission"].Value; object hidden = parameters["hidden"].Value; string name = parameters["name"]; object owner = parameters["owner"].Value; object ownerPermission = parameters["ownerPermission"].Value; object readOnly = parameters["readOnly"].Value; object worldPermission = parameters["worldPermission"].Value; object blockOrderStylesheetId = parameters["blockOrderStylesheetId"].Value; object placementStylesheetId = parameters["placementStylesheetId"].Value; object executionStylesheetId = parameters["executionStylesheetId"].Value; object ticketStylesheetId = parameters["ticketStylesheetId"].Value; object algorithmId = parameters["algorithmId"].Value; object typeCode = parameters["typeCode"].Value; int blotterTypeCode = parameters["blotterTypeCode"]; object defaultBlotter = parameters["defaultBlotter"].Value; // 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. int blotterId = Blotter.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, blockOrderStylesheetId, placementStylesheetId, executionStylesheetId, ticketStylesheetId, algorithmId, typeCode, blotterTypeCode, defaultBlotter); // Return values. parameters["rowVersion"] = rowVersion; parameters.Return = blotterId; }
/// <summary>Inserts a Blotter record using Metadata Parameters.</summary> /// <param name="parameters">Contains the metadata parameters.</param> public new static void Update(ParameterList parameters) { // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; long rowVersion = parameters["rowVersion"]; object description = parameters["description"].Value; object externalId0 = parameters["externalId0"].Value; object externalId1 = parameters["externalId1"].Value; object externalId2 = parameters["externalId2"].Value; object externalId3 = parameters["externalId3"].Value; object externalId4 = parameters["externalId4"].Value; object externalId5 = parameters["externalId5"].Value; object externalId6 = parameters["externalId6"].Value; object externalId7 = parameters["externalId7"].Value; object groupPermission = parameters["groupPermission"].Value; object hidden = parameters["hidden"].Value; object name = parameters["name"].Value; object owner = parameters["owner"].Value; object ownerPermission = parameters["ownerPermission"].Value; object readOnly = parameters["readOnly"].Value; object worldPermission = parameters["worldPermission"].Value; int blotterId = parameters["blotterId"]; object blockOrderStylesheetId = parameters["blockOrderStylesheetId"].Value; object placementStylesheetId = parameters["placementStylesheetId"].Value; object executionStylesheetId = parameters["executionStylesheetId"].Value; object ticketStylesheetId = parameters["ticketStylesheetId"].Value; object algorithmId = parameters["algorithmId"].Value; object typeCode = parameters["typeCode"].Value; object blotterTypeCode = parameters["blotterTypeCode"].Value; object defaultBlotter = parameters["defaultBlotter"].Value; // Call the internal method to complete the operation. Blotter.Update(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, blotterId, blockOrderStylesheetId, placementStylesheetId, executionStylesheetId, ticketStylesheetId, algorithmId, typeCode, blotterTypeCode, defaultBlotter); // Return values. parameters["rowVersion"] = rowVersion; }
/// <summary>Deletes a BlotterType 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="blotterTypeCode">The value for the BlotterTypeCode column.</param> /// <param name="archive">true to archive the object, false to unarchive it.</param> public static void Delete(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int blotterTypeCode) { // Accessor for the BlotterType Table. ServerDataModel.BlotterTypeDataTable blotterTypeTable = ServerDataModel.BlotterType; // Rule #1: Make sure the record exists before updating it. ServerDataModel.BlotterTypeRow blotterTypeRow = blotterTypeTable.FindByBlotterTypeCode(blotterTypeCode); if ((blotterTypeRow == null)) { throw new Exception(string.Format("The BlotterType table does not have an element identified by {0}", blotterTypeCode)); } // Rule #2: Optimistic Concurrency Check if ((blotterTypeRow.RowVersion != rowVersion)) { throw new System.Exception("This record is busy. Please try again later."); } // Delete the child records. for (int index = 0; (index < blotterTypeRow.GetBlotterRows().Length); index = (index + 1)) { ServerDataModel.BlotterRow childBlotterRow = blotterTypeRow.GetBlotterRows()[index]; Blotter.DeleteChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId); } // Increment the row version rowVersion = ServerDataModel.RowVersion.Increment(); // Delete the record in the ADO database. blotterTypeRow[blotterTypeTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(blotterTypeRow); blotterTypeRow.Delete(); // Delete the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"BlotterType\" set \"IsDeleted\" = 1 where \"BlotterTypeCode\"=@blotterTypeCode" + ""); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@blotterTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blotterTypeCode)); 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> public static void Update(AdoTransaction adoTransaction) { // These table lock(s) are required for the 'Update' operation. adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.BlotterType)); Blotter.UpdateChildren(adoTransaction); }
/// <summary>Archives a Object 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="objectId">The value for the ObjectId column.</param> /// <param name="archive">true to archive the object, false to unarchive it.</param> public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int objectId) { // Accessor for the Object Table. ServerDataModel.ObjectDataTable objectTable = ServerDataModel.Object; // Rule #1: Make sure the record exists before updating it. ServerDataModel.ObjectRow objectRow = objectTable.FindByObjectId(objectId); if ((objectRow == null)) { throw new Exception(string.Format("The Object table does not have an element identified by {0}", objectId)); } // Rule #2: Optimistic Concurrency Check if ((objectRow.RowVersion != rowVersion)) { throw new System.Exception("This record is busy. Please try again later."); } // Archive the child records. for (int index = 0; (index < objectRow.GetFolderRows().Length); index = (index + 1)) { ServerDataModel.FolderRow childFolderRow = objectRow.GetFolderRows()[index]; Folder.ArchiveChildren(adoTransaction, sqlTransaction, childFolderRow.RowVersion, childFolderRow.FolderId); } for (int index = 0; (index < objectRow.GetAccountRows().Length); index = (index + 1)) { ServerDataModel.AccountRow childAccountRow = objectRow.GetAccountRows()[index]; Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId); } for (int index = 0; (index < objectRow.GetBlotterRows().Length); index = (index + 1)) { ServerDataModel.BlotterRow childBlotterRow = objectRow.GetBlotterRows()[index]; Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId); } for (int index = 0; (index < objectRow.GetBrokerRows().Length); index = (index + 1)) { ServerDataModel.BrokerRow childBrokerRow = objectRow.GetBrokerRows()[index]; Broker.ArchiveChildren(adoTransaction, sqlTransaction, childBrokerRow.RowVersion, childBrokerRow.BrokerId); } for (int index = 0; (index < objectRow.GetIssuerRows().Length); index = (index + 1)) { ServerDataModel.IssuerRow childIssuerRow = objectRow.GetIssuerRows()[index]; Issuer.ArchiveChildren(adoTransaction, sqlTransaction, childIssuerRow.RowVersion, childIssuerRow.IssuerId); } for (int index = 0; (index < objectRow.GetUserRows().Length); index = (index + 1)) { ServerDataModel.UserRow childUserRow = objectRow.GetUserRows()[index]; User.ArchiveChildren(adoTransaction, sqlTransaction, childUserRow.RowVersion, childUserRow.UserId); } for (int index = 0; (index < objectRow.GetModelRows().Length); index = (index + 1)) { ServerDataModel.ModelRow childModelRow = objectRow.GetModelRows()[index]; Model.ArchiveChildren(adoTransaction, sqlTransaction, childModelRow.RowVersion, childModelRow.ModelId); } for (int index = 0; (index < objectRow.GetObjectTreeRowsByFKObjectObjectTreeChildId().Length); index = (index + 1)) { ServerDataModel.ObjectTreeRow childObjectTreeRow = objectRow.GetObjectTreeRowsByFKObjectObjectTreeChildId()[index]; ObjectTree.Archive(adoTransaction, sqlTransaction, childObjectTreeRow.RowVersion, childObjectTreeRow.ParentId, childObjectTreeRow.ChildId); } for (int index = 0; (index < objectRow.GetObjectTreeRowsByFKObjectObjectTreeParentId().Length); index = (index + 1)) { ServerDataModel.ObjectTreeRow childObjectTreeRow = objectRow.GetObjectTreeRowsByFKObjectObjectTreeParentId()[index]; ObjectTree.Archive(adoTransaction, sqlTransaction, childObjectTreeRow.RowVersion, childObjectTreeRow.ParentId, childObjectTreeRow.ChildId); } for (int index = 0; (index < objectRow.GetSchemeRows().Length); index = (index + 1)) { ServerDataModel.SchemeRow childSchemeRow = objectRow.GetSchemeRows()[index]; Scheme.ArchiveChildren(adoTransaction, sqlTransaction, childSchemeRow.RowVersion, childSchemeRow.SchemeId); } for (int index = 0; (index < objectRow.GetSectorRows().Length); index = (index + 1)) { ServerDataModel.SectorRow childSectorRow = objectRow.GetSectorRows()[index]; Sector.ArchiveChildren(adoTransaction, sqlTransaction, childSectorRow.RowVersion, childSectorRow.SectorId); } for (int index = 0; (index < objectRow.GetSecurityRows().Length); index = (index + 1)) { ServerDataModel.SecurityRow childSecurityRow = objectRow.GetSecurityRows()[index]; Security.ArchiveChildren(adoTransaction, sqlTransaction, childSecurityRow.RowVersion, childSecurityRow.SecurityId); } // Increment the row version rowVersion = ServerDataModel.RowVersion.Increment(); // Delete the record in the ADO database. objectRow[objectTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(objectRow); objectRow.Delete(); // Archive the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Object\" set \"IsArchived\" = 1 where \"ObjectId\"=@objectId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@objectId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, objectId)); sqlCommand.ExecuteNonQuery(); }