コード例 #1
0
        /// <summary>Archives a PartyType 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="partyTypeCode">The value for the PartyTypeCode 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 partyTypeCode)
        {
            // Accessor for the PartyType Table.
            ServerMarketData.PartyTypeDataTable partyTypeTable = ServerMarketData.PartyType;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.PartyTypeRow partyTypeRow = partyTypeTable.FindByPartyTypeCode(partyTypeCode);
            if ((partyTypeRow == null))
            {
                throw new Exception(string.Format("The PartyType table does not have an element identified by {0}", partyTypeCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((partyTypeRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < partyTypeRow.GetBlotterRows().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = partyTypeRow.GetBlotterRows()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            partyTypeRow[partyTypeTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(partyTypeRow);
            partyTypeRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"PartyType\" set \"IsArchived\" = 1 where \"PartyTypeCode\"=@partyTypeCode");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@partyTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, partyTypeCode));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #2
0
ファイル: Blotter.cs プロジェクト: DonaldAirey/quasar
 /// <summary>Updates a Blotter record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public new static void Update(ParameterList parameters)
 {
     // Accessor for the Blotter Table.
     ServerMarketData.BlotterDataTable blotterTable = ServerMarketData.Blotter;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].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;
     object externalAdvertisementStylesheetId = parameters["advertisementStylesheetId"].Value;
     string externalBlotterId = ((string)(parameters["blotterId"]));
     object externalDestinationOrderDetailStylesheetId = parameters["destinationOrderDetailStylesheetId"].Value;
     object externalDestinationOrderStylesheetId = parameters["destinationOrderStylesheetId"].Value;
     object externalExecutionDetailStylesheetId = parameters["executionDetailStylesheetId"].Value;
     object externalExecutionStylesheetId = parameters["executionStylesheetId"].Value;
     object externalMatchStylesheetId = parameters["matchStylesheetId"].Value;
     object externalMatchHistoryStylesheetId = parameters["matchHistoryStylesheetId"].Value;
     object externalPartyTypeCode = parameters["partyTypeCode"].Value;
     object externalSourceOrderDetailStylesheetId = parameters["sourceOrderDetailStylesheetId"].Value;
     object externalSourceOrderStylesheetId = parameters["sourceOrderStylesheetId"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     object externalWorkingOrderStylesheetId = parameters["workingOrderStylesheetId"].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
     object advertisementStylesheetId = Stylesheet.FindOptionalKey(configurationId, "advertisementStylesheetId", externalAdvertisementStylesheetId);
     int blotterId = Object.FindRequiredKey(configurationId, "blotterId", externalBlotterId);
     object destinationOrderDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "destinationOrderDetailStylesheetId", externalDestinationOrderDetailStylesheetId);
     object destinationOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "destinationOrderStylesheetId", externalDestinationOrderStylesheetId);
     object executionDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "executionDetailStylesheetId", externalExecutionDetailStylesheetId);
     object executionStylesheetId = Stylesheet.FindOptionalKey(configurationId, "executionStylesheetId", externalExecutionStylesheetId);
     object matchStylesheetId = Stylesheet.FindOptionalKey(configurationId, "matchStylesheetId", externalMatchStylesheetId);
     object matchHistoryStylesheetId = Stylesheet.FindOptionalKey(configurationId, "matchHistoryStylesheetId", externalMatchHistoryStylesheetId);
     object partyTypeCode = PartyType.FindOptionalKey(configurationId, "partyTypeCode", externalPartyTypeCode);
     object sourceOrderDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "sourceOrderDetailStylesheetId", externalSourceOrderDetailStylesheetId);
     object sourceOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "sourceOrderStylesheetId", externalSourceOrderStylesheetId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     object workingOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "workingOrderStylesheetId", externalWorkingOrderStylesheetId);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerMarketData.BlotterRow blotterRow = blotterTable.FindByBlotterId(blotterId);
     rowVersion = ((long)(blotterRow[blotterTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Blotter.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, advertisementStylesheetId, blotterId, destinationOrderDetailStylesheetId, destinationOrderStylesheetId, executionDetailStylesheetId, executionStylesheetId, matchStylesheetId, matchHistoryStylesheetId, partyTypeCode, sourceOrderDetailStylesheetId, sourceOrderStylesheetId, typeCode, workingOrderStylesheetId);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
コード例 #3
0
ファイル: Blotter.cs プロジェクト: DonaldAirey/quasar
        /// <summary>ArchiveChildrens a Blotter 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="blotterId">The value for the BlotterId 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 blotterId)
        {
            // Accessor for the Blotter Table.
            ServerMarketData.BlotterDataTable blotterTable = ServerMarketData.Blotter;
            // This record can be used to iterate through all the children.
            ServerMarketData.BlotterRow blotterRow = blotterTable.FindByBlotterId(blotterId);
            // Archive the child records.
            for (int index = 0; (index < blotterRow.GetBranchRows().Length); index = (index + 1))
            {
                ServerMarketData.BranchRow childBranchRow = blotterRow.GetBranchRows()[index];
                Branch.ArchiveChildren(adoTransaction, sqlTransaction, childBranchRow.RowVersion, childBranchRow.BranchId);
            }
            for (int index = 0; (index < blotterRow.GetSourceRows().Length); index = (index + 1))
            {
                ServerMarketData.SourceRow childSourceRow = blotterRow.GetSourceRows()[index];
                Source.ArchiveChildren(adoTransaction, sqlTransaction, childSourceRow.RowVersion, childSourceRow.SourceId);
            }
            for (int index = 0; (index < blotterRow.GetTraderRows().Length); index = (index + 1))
            {
                ServerMarketData.TraderRow childTraderRow = blotterRow.GetTraderRows()[index];
                Trader.ArchiveChildren(adoTransaction, sqlTransaction, childTraderRow.RowVersion, childTraderRow.TraderId);
            }
            for (int index = 0; (index < blotterRow.GetWorkingOrderRows().Length); index = (index + 1))
            {
                ServerMarketData.WorkingOrderRow childWorkingOrderRow = blotterRow.GetWorkingOrderRows()[index];
                WorkingOrder.Archive(adoTransaction, sqlTransaction, childWorkingOrderRow.RowVersion, childWorkingOrderRow.WorkingOrderId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            blotterRow[blotterTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(blotterRow);
            blotterRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Blotter\" set \"IsArchived\" = 1 where \"BlotterId\"=@blotterId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@blotterId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blotterId));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #4
0
ファイル: Blotter.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Archives a Blotter 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="blotterId">The value for the BlotterId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public new static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int blotterId)
        {
            // Accessor for the Blotter Table.
            ServerMarketData.BlotterDataTable blotterTable = ServerMarketData.Blotter;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.BlotterRow blotterRow = blotterTable.FindByBlotterId(blotterId);
            if ((blotterRow == null))
            {
                throw new Exception(string.Format("The Blotter table does not have an element identified by {0}", blotterId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((blotterRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Delete the base class record.  Note that optimistic concurrency is only used
            // by the top level type in the hierarchy, it is bypassed after you pass the first test.
            long baseRowVersion = blotterRow.ObjectRow.RowVersion;

            Object.Archive(adoTransaction, sqlTransaction, baseRowVersion, blotterId);
        }
コード例 #5
0
ファイル: Blotter.cs プロジェクト: DonaldAirey/quasar
 /// <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.
     ServerMarketData.BlotterDataTable blotterTable = ServerMarketData.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.
     ServerMarketData.BlotterRow blotterRow = blotterTable.FindByBlotterId(blotterId);
     rowVersion = ((long)(blotterRow[blotterTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Blotter.Archive(adoTransaction, sqlTransaction, rowVersion, blotterId);
 }
コード例 #6
0
ファイル: Blotter.cs プロジェクト: DonaldAirey/quasar
 /// <summary>Loads a Blotter record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public new static void Load(ParameterList parameters)
 {
     // Accessor for the Blotter Table.
     ServerMarketData.BlotterDataTable blotterTable = ServerMarketData.Blotter;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].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 externalAdvertisementStylesheetId = parameters["advertisementStylesheetId"].Value;
     string externalBlotterId = parameters["blotterId"];
     object externalDestinationOrderDetailStylesheetId = parameters["destinationOrderDetailStylesheetId"].Value;
     object externalDestinationOrderStylesheetId = parameters["destinationOrderStylesheetId"].Value;
     object externalExecutionDetailStylesheetId = parameters["executionDetailStylesheetId"].Value;
     object externalExecutionStylesheetId = parameters["executionStylesheetId"].Value;
     object externalMatchStylesheetId = parameters["matchStylesheetId"].Value;
     object externalMatchHistoryStylesheetId = parameters["matchHistoryStylesheetId"].Value;
     string externalPartyTypeCode = parameters["partyTypeCode"];
     object externalSourceOrderDetailStylesheetId = parameters["sourceOrderDetailStylesheetId"].Value;
     object externalSourceOrderStylesheetId = parameters["sourceOrderStylesheetId"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     object externalWorkingOrderStylesheetId = parameters["workingOrderStylesheetId"].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
     object advertisementStylesheetId = Stylesheet.FindOptionalKey(configurationId, "advertisementStylesheetId", externalAdvertisementStylesheetId);
     int blotterId = Object.FindKey(configurationId, "blotterId", externalBlotterId);
     object destinationOrderDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "destinationOrderDetailStylesheetId", externalDestinationOrderDetailStylesheetId);
     object destinationOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "destinationOrderStylesheetId", externalDestinationOrderStylesheetId);
     object executionDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "executionDetailStylesheetId", externalExecutionDetailStylesheetId);
     object executionStylesheetId = Stylesheet.FindOptionalKey(configurationId, "executionStylesheetId", externalExecutionStylesheetId);
     object matchStylesheetId = Stylesheet.FindOptionalKey(configurationId, "matchStylesheetId", externalMatchStylesheetId);
     object matchHistoryStylesheetId = Stylesheet.FindOptionalKey(configurationId, "matchHistoryStylesheetId", externalMatchHistoryStylesheetId);
     int partyTypeCode = PartyType.FindRequiredKey(configurationId, "partyTypeCode", externalPartyTypeCode);
     object sourceOrderDetailStylesheetId = Stylesheet.FindOptionalKey(configurationId, "sourceOrderDetailStylesheetId", externalSourceOrderDetailStylesheetId);
     object sourceOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "sourceOrderStylesheetId", externalSourceOrderStylesheetId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     object workingOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "workingOrderStylesheetId", externalWorkingOrderStylesheetId);
     ServerMarketData.BlotterRow blotterRow = blotterTable.FindByBlotterId(blotterId);
     // 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 ((blotterRow == null))
     {
         // 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 = Blotter.GetExternalKeyIndex(configurationId, "blotterId");
         object[] externalIdArray = new object[8];
         externalIdArray[externalKeyIndex] = externalBlotterId;
         object externalId0 = externalIdArray[0];
         object externalId1 = externalIdArray[1];
         object externalId2 = externalIdArray[2];
         object externalId3 = externalIdArray[3];
         object externalId4 = externalIdArray[4];
         object externalId5 = externalIdArray[5];
         object externalId6 = externalIdArray[6];
         object externalId7 = externalIdArray[7];
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Blotter.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, advertisementStylesheetId, destinationOrderDetailStylesheetId, destinationOrderStylesheetId, executionDetailStylesheetId, executionStylesheetId, matchStylesheetId, matchHistoryStylesheetId, partyTypeCode, sourceOrderDetailStylesheetId, sourceOrderStylesheetId, typeCode, workingOrderStylesheetId);
     }
     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.
         rowVersion = ((long)(blotterRow[blotterTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Blotter.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, advertisementStylesheetId, blotterId, destinationOrderDetailStylesheetId, destinationOrderStylesheetId, executionDetailStylesheetId, executionStylesheetId, matchStylesheetId, matchHistoryStylesheetId, partyTypeCode, sourceOrderDetailStylesheetId, sourceOrderStylesheetId, typeCode, workingOrderStylesheetId);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
コード例 #7
0
        /// <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();
        }
コード例 #8
0
ファイル: Blotter.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Updates a Blotter record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">The version number of the row</param>
        /// <param name="description">The value for the Description column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="externalId1">The value for the ExternalId1 column.</param>
        /// <param name="externalId2">The value for the ExternalId2 column.</param>
        /// <param name="externalId3">The value for the ExternalId3 column.</param>
        /// <param name="externalId4">The value for the ExternalId4 column.</param>
        /// <param name="externalId5">The value for the ExternalId5 column.</param>
        /// <param name="externalId6">The value for the ExternalId6 column.</param>
        /// <param name="externalId7">The value for the ExternalId7 column.</param>
        /// <param name="groupPermission">The value for the GroupPermission column.</param>
        /// <param name="hidden">The value for the Hidden column.</param>
        /// <param name="name">The value for the Name column.</param>
        /// <param name="owner">The value for the Owner column.</param>
        /// <param name="ownerPermission">The value for the OwnerPermission column.</param>
        /// <param name="readOnly">The value for the ReadOnly column.</param>
        /// <param name="worldPermission">The value for the WorldPermission column.</param>
        /// <param name="advertisementStylesheetId">The value for the AdvertisementStylesheetId column.</param>
        /// <param name="blotterId">The value for the BlotterId column.</param>
        /// <param name="destinationOrderDetailStylesheetId">The value for the DestinationOrderDetailStylesheetId column.</param>
        /// <param name="destinationOrderStylesheetId">The value for the DestinationOrderStylesheetId column.</param>
        /// <param name="executionDetailStylesheetId">The value for the ExecutionDetailStylesheetId column.</param>
        /// <param name="executionStylesheetId">The value for the ExecutionStylesheetId column.</param>
        /// <param name="matchStylesheetId">The value for the MatchStylesheetId column.</param>
        /// <param name="matchHistoryStylesheetId">The value for the MatchHistoryStylesheetId column.</param>
        /// <param name="partyTypeCode">The value for the PartyTypeCode column.</param>
        /// <param name="sourceOrderDetailStylesheetId">The value for the SourceOrderDetailStylesheetId column.</param>
        /// <param name="sourceOrderStylesheetId">The value for the SourceOrderStylesheetId column.</param>
        /// <param name="typeCode">The value for the TypeCode column.</param>
        /// <param name="workingOrderStylesheetId">The value for the WorkingOrderStylesheetId column.</param>
        public static void Update(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object description,
            object externalId0,
            object externalId1,
            object externalId2,
            object externalId3,
            object externalId4,
            object externalId5,
            object externalId6,
            object externalId7,
            object groupPermission,
            object hidden,
            object name,
            object owner,
            object ownerPermission,
            object readOnly,
            object worldPermission,
            object advertisementStylesheetId,
            int blotterId,
            object destinationOrderDetailStylesheetId,
            object destinationOrderStylesheetId,
            object executionDetailStylesheetId,
            object executionStylesheetId,
            object matchStylesheetId,
            object matchHistoryStylesheetId,
            object partyTypeCode,
            object sourceOrderDetailStylesheetId,
            object sourceOrderStylesheetId,
            object typeCode,
            object workingOrderStylesheetId)
        {
            // Accessor for the Blotter Table.
            ServerMarketData.BlotterDataTable blotterTable = ServerMarketData.Blotter;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.BlotterRow blotterRow = blotterTable.FindByBlotterId(blotterId);
            if ((blotterRow == null))
            {
                throw new Exception(string.Format("The Blotter table does not have an element identified by {0}", blotterId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((blotterRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((advertisementStylesheetId == null))
            {
                advertisementStylesheetId = blotterRow[blotterTable.AdvertisementStylesheetIdColumn];
            }
            if ((destinationOrderDetailStylesheetId == null))
            {
                destinationOrderDetailStylesheetId = blotterRow[blotterTable.DestinationOrderDetailStylesheetIdColumn];
            }
            if ((destinationOrderStylesheetId == null))
            {
                destinationOrderStylesheetId = blotterRow[blotterTable.DestinationOrderStylesheetIdColumn];
            }
            if ((executionDetailStylesheetId == null))
            {
                executionDetailStylesheetId = blotterRow[blotterTable.ExecutionDetailStylesheetIdColumn];
            }
            if ((executionStylesheetId == null))
            {
                executionStylesheetId = blotterRow[blotterTable.ExecutionStylesheetIdColumn];
            }
            if ((matchStylesheetId == null))
            {
                matchStylesheetId = blotterRow[blotterTable.MatchStylesheetIdColumn];
            }
            if ((matchHistoryStylesheetId == null))
            {
                matchHistoryStylesheetId = blotterRow[blotterTable.MatchHistoryStylesheetIdColumn];
            }
            if ((partyTypeCode == null))
            {
                partyTypeCode = blotterRow[blotterTable.PartyTypeCodeColumn];
            }
            if ((sourceOrderDetailStylesheetId == null))
            {
                sourceOrderDetailStylesheetId = blotterRow[blotterTable.SourceOrderDetailStylesheetIdColumn];
            }
            if ((sourceOrderStylesheetId == null))
            {
                sourceOrderStylesheetId = blotterRow[blotterTable.SourceOrderStylesheetIdColumn];
            }
            if ((workingOrderStylesheetId == null))
            {
                workingOrderStylesheetId = blotterRow[blotterTable.WorkingOrderStylesheetIdColumn];
            }
            // Insert the base members using the base class.  Note that optimistic concurrency is only used
            // by the top level type in the hierarchy, it is bypassed after you pass the first test.
            long baseRowVersion = blotterRow.ObjectRow.RowVersion;

            Object.Update(adoTransaction, sqlTransaction, ref baseRowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, blotterId, owner, ownerPermission, readOnly, typeCode, worldPermission);
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            blotterRow[blotterTable.RowVersionColumn] = rowVersion;
            blotterRow[blotterTable.AdvertisementStylesheetIdColumn]          = advertisementStylesheetId;
            blotterRow[blotterTable.DestinationOrderDetailStylesheetIdColumn] = destinationOrderDetailStylesheetId;
            blotterRow[blotterTable.DestinationOrderStylesheetIdColumn]       = destinationOrderStylesheetId;
            blotterRow[blotterTable.ExecutionDetailStylesheetIdColumn]        = executionDetailStylesheetId;
            blotterRow[blotterTable.ExecutionStylesheetIdColumn]         = executionStylesheetId;
            blotterRow[blotterTable.MatchStylesheetIdColumn]             = matchStylesheetId;
            blotterRow[blotterTable.MatchHistoryStylesheetIdColumn]      = matchHistoryStylesheetId;
            blotterRow[blotterTable.PartyTypeCodeColumn]                 = partyTypeCode;
            blotterRow[blotterTable.SourceOrderDetailStylesheetIdColumn] = sourceOrderDetailStylesheetId;
            blotterRow[blotterTable.SourceOrderStylesheetIdColumn]       = sourceOrderStylesheetId;
            blotterRow[blotterTable.WorkingOrderStylesheetIdColumn]      = workingOrderStylesheetId;
            adoTransaction.DataRows.Add(blotterRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Blotter"" set ""RowVersion""=@rowVersion,""AdvertisementStylesheetId""=@advertisementStylesheetId,""DestinationOrderDetailStylesheetId""=@destinationOrderDetailStylesheetId,""DestinationOrderStylesheetId""=@destinationOrderStylesheetId,""ExecutionDetailStylesheetId""=@executionDetailStylesheetId,""ExecutionStylesheetId""=@executionStylesheetId,""MatchStylesheetId""=@matchStylesheetId,""MatchHistoryStylesheetId""=@matchHistoryStylesheetId,""PartyTypeCode""=@partyTypeCode,""SourceOrderDetailStylesheetId""=@sourceOrderDetailStylesheetId,""SourceOrderStylesheetId""=@sourceOrderStylesheetId,""WorkingOrderStylesheetId""=@workingOrderStylesheetId where ""BlotterId""=@blotterId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@advertisementStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, advertisementStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@blotterId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blotterId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationOrderDetailStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationOrderDetailStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationOrderStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationOrderStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@executionDetailStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionDetailStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@executionStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@matchStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, matchStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@matchHistoryStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, matchHistoryStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@partyTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, partyTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceOrderDetailStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceOrderDetailStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceOrderStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceOrderStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@workingOrderStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, workingOrderStylesheetId));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
コード例 #9
0
ファイル: Blotter.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Inserts a Blotter record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">The version number of the row.</param>
        /// <param name="description">The value for the Description column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="externalId1">The value for the ExternalId1 column.</param>
        /// <param name="externalId2">The value for the ExternalId2 column.</param>
        /// <param name="externalId3">The value for the ExternalId3 column.</param>
        /// <param name="externalId4">The value for the ExternalId4 column.</param>
        /// <param name="externalId5">The value for the ExternalId5 column.</param>
        /// <param name="externalId6">The value for the ExternalId6 column.</param>
        /// <param name="externalId7">The value for the ExternalId7 column.</param>
        /// <param name="groupPermission">The value for the GroupPermission column.</param>
        /// <param name="hidden">The value for the Hidden column.</param>
        /// <param name="name">The value for the Name column.</param>
        /// <param name="owner">The value for the Owner column.</param>
        /// <param name="ownerPermission">The value for the OwnerPermission column.</param>
        /// <param name="readOnly">The value for the ReadOnly column.</param>
        /// <param name="worldPermission">The value for the WorldPermission column.</param>
        /// <param name="advertisementStylesheetId">The value for the AdvertisementStylesheetId column.</param>
        /// <param name="destinationOrderDetailStylesheetId">The value for the DestinationOrderDetailStylesheetId column.</param>
        /// <param name="destinationOrderStylesheetId">The value for the DestinationOrderStylesheetId column.</param>
        /// <param name="executionDetailStylesheetId">The value for the ExecutionDetailStylesheetId column.</param>
        /// <param name="executionStylesheetId">The value for the ExecutionStylesheetId column.</param>
        /// <param name="matchStylesheetId">The value for the MatchStylesheetId column.</param>
        /// <param name="matchHistoryStylesheetId">The value for the MatchHistoryStylesheetId column.</param>
        /// <param name="partyTypeCode">The value for the PartyTypeCode column.</param>
        /// <param name="sourceOrderDetailStylesheetId">The value for the SourceOrderDetailStylesheetId column.</param>
        /// <param name="sourceOrderStylesheetId">The value for the SourceOrderStylesheetId column.</param>
        /// <param name="typeCode">The value for the TypeCode column.</param>
        /// <param name="workingOrderStylesheetId">The value for the WorkingOrderStylesheetId column.</param>
        public static int Insert(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object description,
            object externalId0,
            object externalId1,
            object externalId2,
            object externalId3,
            object externalId4,
            object externalId5,
            object externalId6,
            object externalId7,
            object groupPermission,
            object hidden,
            string name,
            object owner,
            object ownerPermission,
            object readOnly,
            object worldPermission,
            object advertisementStylesheetId,
            object destinationOrderDetailStylesheetId,
            object destinationOrderStylesheetId,
            object executionDetailStylesheetId,
            object executionStylesheetId,
            object matchStylesheetId,
            object matchHistoryStylesheetId,
            int partyTypeCode,
            object sourceOrderDetailStylesheetId,
            object sourceOrderStylesheetId,
            object typeCode,
            object workingOrderStylesheetId)
        {
            // Accessor for the Blotter Table.
            ServerMarketData.BlotterDataTable blotterTable = ServerMarketData.Blotter;
            // Apply Defaults
            if ((advertisementStylesheetId == null))
            {
                advertisementStylesheetId = System.DBNull.Value;
            }
            if ((destinationOrderDetailStylesheetId == null))
            {
                destinationOrderDetailStylesheetId = System.DBNull.Value;
            }
            if ((destinationOrderStylesheetId == null))
            {
                destinationOrderStylesheetId = System.DBNull.Value;
            }
            if ((executionDetailStylesheetId == null))
            {
                executionDetailStylesheetId = System.DBNull.Value;
            }
            if ((executionStylesheetId == null))
            {
                executionStylesheetId = System.DBNull.Value;
            }
            if ((matchStylesheetId == null))
            {
                matchStylesheetId = System.DBNull.Value;
            }
            if ((matchHistoryStylesheetId == null))
            {
                matchHistoryStylesheetId = System.DBNull.Value;
            }
            if ((sourceOrderDetailStylesheetId == null))
            {
                sourceOrderDetailStylesheetId = System.DBNull.Value;
            }
            if ((sourceOrderStylesheetId == null))
            {
                sourceOrderStylesheetId = System.DBNull.Value;
            }
            if ((typeCode == null))
            {
                typeCode = "Blotter";
            }
            if ((workingOrderStylesheetId == null))
            {
                workingOrderStylesheetId = System.DBNull.Value;
            }
            // Insert the base members using the base class.
            int blotterId = Object.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, typeCode, worldPermission);

            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerMarketData.BlotterRow blotterRow = blotterTable.NewBlotterRow();
            blotterRow[blotterTable.RowVersionColumn] = rowVersion;
            blotterRow[blotterTable.AdvertisementStylesheetIdColumn] = advertisementStylesheetId;
            blotterRow[blotterTable.BlotterIdColumn] = blotterId;
            blotterRow[blotterTable.DestinationOrderDetailStylesheetIdColumn] = destinationOrderDetailStylesheetId;
            blotterRow[blotterTable.DestinationOrderStylesheetIdColumn]       = destinationOrderStylesheetId;
            blotterRow[blotterTable.ExecutionDetailStylesheetIdColumn]        = executionDetailStylesheetId;
            blotterRow[blotterTable.ExecutionStylesheetIdColumn]         = executionStylesheetId;
            blotterRow[blotterTable.MatchStylesheetIdColumn]             = matchStylesheetId;
            blotterRow[blotterTable.MatchHistoryStylesheetIdColumn]      = matchHistoryStylesheetId;
            blotterRow[blotterTable.PartyTypeCodeColumn]                 = partyTypeCode;
            blotterRow[blotterTable.SourceOrderDetailStylesheetIdColumn] = sourceOrderDetailStylesheetId;
            blotterRow[blotterTable.SourceOrderStylesheetIdColumn]       = sourceOrderStylesheetId;
            blotterRow[blotterTable.WorkingOrderStylesheetIdColumn]      = workingOrderStylesheetId;
            blotterTable.AddBlotterRow(blotterRow);
            adoTransaction.DataRows.Add(blotterRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Blotter"" (""rowVersion"",AdvertisementStylesheetId,BlotterId,DestinationOrderDetailStylesheetId,DestinationOrderStylesheetId,ExecutionDetailStylesheetId,ExecutionStylesheetId,MatchStylesheetId,MatchHistoryStylesheetId,PartyTypeCode,SourceOrderDetailStylesheetId,SourceOrderStylesheetId,WorkingOrderStylesheetId) values (@rowVersion,@advertisementStylesheetId,@blotterId,@destinationOrderDetailStylesheetId,@destinationOrderStylesheetId,@executionDetailStylesheetId,@executionStylesheetId,@matchStylesheetId,@matchHistoryStylesheetId,@partyTypeCode,@sourceOrderDetailStylesheetId,@sourceOrderStylesheetId,@workingOrderStylesheetId)");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@advertisementStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, advertisementStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@blotterId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blotterId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationOrderDetailStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationOrderDetailStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationOrderStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationOrderStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@executionDetailStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionDetailStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@executionStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@matchStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, matchStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@matchHistoryStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, matchHistoryStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@partyTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, partyTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceOrderDetailStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceOrderDetailStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceOrderStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceOrderStylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@workingOrderStylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, workingOrderStylesheetId));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(blotterRow.BlotterId);
        }
コード例 #10
0
ファイル: BlockOrder.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Inserts a Order record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="blockOrderId">The value for the BlockOrderId column.</param>
        /// <param name="accountId">The value for the AccountId column.</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="settlementId">The value for the SettlementId column.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="transactionTypeCode">The value for the TransactionTypeCode column.</param>
        /// <param name="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="orderTypeCode">The value for the OrderTypeCode column.</param>
        /// <param name="conditionCode">The value for the ConditionCode column.</param>
        /// <param name="rowVersion">The value for the RowVersion column.</param>
        /// <param name="isAgency">The value for the Agency column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="price1">The value for the Price1 column.</param>
        /// <param name="price2">The value for the Price2 column.</param>
        /// <param name="note">The value for the Note column.</param>
        public static int Open(
            Transaction transaction,
            int blotterId,
            object accountId,
            int securityId,
            int settlementId,
            object brokerId,
            int transactionTypeCode,
            object timeInForceCode,
            object orderTypeCode,
            object conditionCode,
            ref long rowVersion,
            object isAgency,
            object price1,
            object price2)
        {
            // Find the destination blotter for the block order.
            ServerMarketData.BlotterRow blotterRow = ServerMarketData.Blotter.FindByBlotterId(blotterId);
            if (blotterRow == null)
            {
                throw new Exception(String.Format("Blotter {0} has been deleted.", blotterId));
            }

            // See if the blotter has an algorithm associated with it for blocking orders.  If it does, the library will
            // be dynamically loaded and called to see if there's a block order matching the criteria.
            if (!blotterRow.IsAlgorithmIdNull())
            {
                // Find the algorithm row in the data model.
                ServerMarketData.AlgorithmRow algorithmsRow = blotterRow.AlgorithmRow;

                // Load the assembly specified by the algorithm.  This is basically the DLL module where the type and
                // method of the algorithm.
                Assembly assembly = Assembly.Load(blotterRow.AlgorithmRow.Assembly);
                if (assembly == null)
                {
                    throw new Exception(String.Format("Unable to load assembly {0}", blotterRow.AlgorithmRow.Assembly));
                }

                // Get the type information.
                Type type = assembly.GetType(blotterRow.AlgorithmRow.Type);
                if (type == null)
                {
                    throw new Exception(String.Format("Unable to create type {0} in assembly {1}", blotterRow.AlgorithmRow.Type, blotterRow.AlgorithmRow.Assembly));
                }

                // This is the method that actually performs the work.
                MethodInfo methodInfo = type.GetMethod(blotterRow.AlgorithmRow.Method);
                if (methodInfo == null)
                {
                    throw new Exception(String.Format("Unable to find method {0}.{1}", blotterRow.AlgorithmRow.Type, blotterRow.AlgorithmRow.Method));
                }

                // This is the meat of the rebalancing process.  This dynamic function will call the rebalancing algorithm
                // that is specified in the model.  The results are returned in an OrderForm which can be
                // processed by the server.
                return((int)methodInfo.Invoke(null, new object[] { transaction, blotterId, accountId, securityId, settlementId,
                                                                   brokerId, transactionTypeCode,
                                                                   timeInForceCode, orderTypeCode, conditionCode, price1,
                                                                   price2 }));
            }

            DateTime createdTime      = DateTime.Now;
            int      createdLoginId   = ServerMarketData.LoginId;
            int      statusCode       = Shadows.Quasar.Common.Status.New;
            decimal  quantityExecuted = 0.0M;
            decimal  quantityPlaced   = 0.0M;

            // If there is no blocking algorithm associated with this block order, then create a new block for every individual
            // order that hits the desk.
            return(Shadows.WebService.Core.BlockOrder.Insert(transaction, blotterId, accountId, securityId, settlementId, brokerId, statusCode,
                                                             transactionTypeCode, timeInForceCode, orderTypeCode, conditionCode, ref rowVersion, quantityExecuted, quantityPlaced, null, isAgency, price1,
                                                             price2, createdTime, createdLoginId, createdTime, createdLoginId));
        }
コード例 #11
0
        /// <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.
            ServerMarketData.StylesheetDataTable stylesheetTable = ServerMarketData.Stylesheet;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.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.GetBlotterRowsByStylesheetBlotterAdvertisementStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterAdvertisementStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterDestinationOrderDetailStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterDestinationOrderDetailStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterDestinationOrderStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterDestinationOrderStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterExecutionDetailStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterExecutionDetailStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterExecutionStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterExecutionStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterMatchStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterMatchStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterMatchHistoryStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterMatchHistoryStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterSourceOrderDetailStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterSourceOrderDetailStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterSourceOrderStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterSourceOrderStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterWorkingOrderStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterWorkingOrderStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.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();
        }