/// <summary>Loads a BlotterMap record using Metadata Parameters.</summary> /// <param name="transaction">Contains the parameters and exceptions for this command.</param> public static void Load(ParameterList parameters) { // Accessor for the BlotterMap Table. ServerDataModel.BlotterMapDataTable blotterMapTable = ServerDataModel.BlotterMap; // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; object configurationId = parameters["configurationId"].Value; object externalBlotterMapId = parameters["blotterMapId"].Value; string externalSecurityId = parameters["securityId"]; string externalBlotterId = parameters["blotterId"]; object minimumQuantity = parameters["minimumQuantity"].Value; object maximumQuantity = parameters["maximumQuantity"].Value; object externalId0 = parameters["externalId0"].Value; object externalId1 = parameters["externalId1"].Value; // The row versioning is largely disabled for external operations. The value is returned to the caller in the // event it's needed for operations within the batch. long rowVersion = long.MinValue; // Resolve External Identifiers int blotterMapId = BlotterMap.FindKey(configurationId, "blotterMapId", externalBlotterMapId); int securityId = Security.FindRequiredKey(configurationId, "securityId", externalSecurityId); int blotterId = Blotter.FindRequiredKey(configurationId, "blotterId", externalBlotterId); // The load operation will create a record if it doesn't exist, or update an existing record. The external // identifier is used to determine if a record exists with the same key. if ((blotterMapId == int.MinValue)) { // Populate the 'externalId' varaibles so that the external identifier can be used to find the row when an // external method is called with the same 'configurationId' parameter. int externalKeyIndex = BlotterMap.GetExternalKeyIndex(configurationId, "blotterMapId"); object[] externalIdArray = new object[2]; externalIdArray[externalKeyIndex] = externalBlotterMapId; externalId0 = externalIdArray[0]; externalId1 = externalIdArray[1]; // Call the internal method to complete the operation. MarkThree.Quasar.Core.BlotterMap.Insert(adoTransaction, sqlTransaction, ref rowVersion, securityId, blotterId, minimumQuantity, maximumQuantity, externalId0, externalId1); } else { // While the optimistic concurrency checking is disabled for the external methods, the internal methods // still need to perform the check. This ncurrency checking logic by finding the current row version to be // will bypass the coused when the internal method is called. ServerDataModel.BlotterMapRow blotterMapRow = blotterMapTable.FindByBlotterMapId(blotterMapId); rowVersion = ((long)(blotterMapRow[blotterMapTable.RowVersionColumn])); // Call the internal method to complete the operation. MarkThree.Quasar.Core.BlotterMap.Update(adoTransaction, sqlTransaction, ref rowVersion, blotterMapId, securityId, blotterId, minimumQuantity, maximumQuantity, externalId0, externalId1); } // Return values. parameters["rowVersion"] = rowVersion; }
/// <summary>Archives a Blotter record using Metadata Parameters.</summary> /// <param name="transaction">Contains the parameters and exceptions for this command.</param> public new static void Archive(ParameterList parameters) { // Accessor for the Blotter Table. ServerDataModel.BlotterDataTable blotterTable = ServerDataModel.Blotter; // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; object configurationId = parameters["configurationId"].Value; string externalBlotterId = parameters["blotterId"]; // The row versioning is largely disabled for external operations. The value is returned to the caller in the // event it's needed for operations within the batch. long rowVersion = long.MinValue; // Find the internal identifier using the primary key elements. // identifier is used to determine if a record exists with the same key. int blotterId = Blotter.FindRequiredKey(configurationId, "blotterId", externalBlotterId); // This disables the concurrency checking logic by finding the current row version and passing it to the // internal method. ServerDataModel.BlotterRow blotterRow = blotterTable.FindByBlotterId(blotterId); rowVersion = ((long)(blotterRow[blotterTable.RowVersionColumn])); // Call the internal method to complete the operation. MarkThree.Quasar.Core.Blotter.Archive(adoTransaction, sqlTransaction, rowVersion, blotterId); }