/// <summary>Inserts a Issuer 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 issuerId = parameters["issuerId"]; // Call the internal method to complete the operation. Issuer.Archive(adoTransaction, sqlTransaction, rowVersion, issuerId); }
/// <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.AddWriterLock(ServerMarketData.ObjectLock); AccountBase.ArchiveChildren(adoTransaction); Blotter.ArchiveChildren(adoTransaction); Folder.ArchiveChildren(adoTransaction); Issuer.ArchiveChildren(adoTransaction); ObjectTree.Archive(adoTransaction); Security.ArchiveChildren(adoTransaction); User.ArchiveChildren(adoTransaction); }
/// <summary>Inserts a Issuer 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 address0 = parameters["address0"].Value; object address1 = parameters["address1"].Value; object address2 = parameters["address2"].Value; object city = parameters["city"].Value; object countryId = parameters["countryId"].Value; object postalCode = parameters["postalCode"].Value; object provinceId = parameters["provinceId"].Value; object rating0 = parameters["rating0"].Value; object rating1 = parameters["rating1"].Value; object rating2 = parameters["rating2"].Value; object rating3 = parameters["rating3"].Value; object typeCode = parameters["typeCode"].Value; object userData0 = parameters["userData0"].Value; object userData1 = parameters["userData1"].Value; object userData2 = parameters["userData2"].Value; object userData3 = parameters["userData3"].Value; object userData4 = parameters["userData4"].Value; object userData5 = parameters["userData5"].Value; object userData6 = parameters["userData6"].Value; object userData7 = parameters["userData7"].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 issuerId = Issuer.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, address0, address1, address2, city, countryId, postalCode, provinceId, rating0, rating1, rating2, rating3, typeCode, userData0, userData1, userData2, userData3, userData4, userData5, userData6, userData7); // Return values. parameters["rowVersion"] = rowVersion; parameters.Return = issuerId; }
/// <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. ServerMarketData.ObjectDataTable objectTable = ServerMarketData.Object; // Rule #1: Make sure the record exists before updating it. ServerMarketData.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.GetAccountBaseRows().Length); index = (index + 1)) { ServerMarketData.AccountBaseRow childAccountBaseRow = objectRow.GetAccountBaseRows()[index]; AccountBase.ArchiveChildren(adoTransaction, sqlTransaction, childAccountBaseRow.RowVersion, childAccountBaseRow.AccountBaseId); } for (int index = 0; (index < objectRow.GetBlotterRows().Length); index = (index + 1)) { ServerMarketData.BlotterRow childBlotterRow = objectRow.GetBlotterRows()[index]; Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId); } for (int index = 0; (index < objectRow.GetFolderRows().Length); index = (index + 1)) { ServerMarketData.FolderRow childFolderRow = objectRow.GetFolderRows()[index]; Folder.ArchiveChildren(adoTransaction, sqlTransaction, childFolderRow.RowVersion, childFolderRow.FolderId); } for (int index = 0; (index < objectRow.GetIssuerRows().Length); index = (index + 1)) { ServerMarketData.IssuerRow childIssuerRow = objectRow.GetIssuerRows()[index]; Issuer.ArchiveChildren(adoTransaction, sqlTransaction, childIssuerRow.RowVersion, childIssuerRow.IssuerId); } for (int index = 0; (index < objectRow.GetObjectTreeRowsByObjectObjectTreeChildId().Length); index = (index + 1)) { ServerMarketData.ObjectTreeRow childObjectTreeRow = objectRow.GetObjectTreeRowsByObjectObjectTreeChildId()[index]; ObjectTree.Archive(adoTransaction, sqlTransaction, childObjectTreeRow.RowVersion, childObjectTreeRow.ObjectTreeId); } for (int index = 0; (index < objectRow.GetObjectTreeRowsByObjectObjectTreeParentId().Length); index = (index + 1)) { ServerMarketData.ObjectTreeRow childObjectTreeRow = objectRow.GetObjectTreeRowsByObjectObjectTreeParentId()[index]; ObjectTree.Archive(adoTransaction, sqlTransaction, childObjectTreeRow.RowVersion, childObjectTreeRow.ObjectTreeId); } for (int index = 0; (index < objectRow.GetSecurityRows().Length); index = (index + 1)) { ServerMarketData.SecurityRow childSecurityRow = objectRow.GetSecurityRows()[index]; Security.ArchiveChildren(adoTransaction, sqlTransaction, childSecurityRow.RowVersion, childSecurityRow.SecurityId); } for (int index = 0; (index < objectRow.GetUserRows().Length); index = (index + 1)) { ServerMarketData.UserRow childUserRow = objectRow.GetUserRows()[index]; User.ArchiveChildren(adoTransaction, sqlTransaction, childUserRow.RowVersion, childUserRow.UserId); } // Increment the row version rowVersion = ServerMarketData.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(); }