Exemplo n.º 1
0
 /// <summary>Updates a Source 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 Source Table.
     ServerMarketData.SourceDataTable sourceTable = ServerMarketData.Source;
     // 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;
     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 externalWorkingOrderStylesheetId = parameters["workingOrderStylesheetId"].Value;
     object buyMarketValueThreshold = parameters["buyMarketValueThreshold"].Value;
     object buyQuantityThreshold = parameters["buyQuantityThreshold"].Value;
     object sellMarketValueThreshold = parameters["sellMarketValueThreshold"].Value;
     object sellQuantityThreshold = parameters["sellQuantityThreshold"].Value;
     object shortName = parameters["shortName"].Value;
     string externalSourceId = ((string)(parameters["sourceId"]));
     object externalTypeCode = parameters["typeCode"].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);
     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 workingOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "workingOrderStylesheetId", externalWorkingOrderStylesheetId);
     int sourceId = Blotter.FindRequiredKey(configurationId, "sourceId", externalSourceId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerMarketData.SourceRow sourceRow = sourceTable.FindBySourceId(sourceId);
     rowVersion = ((long)(sourceRow[sourceTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Source.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, advertisementStylesheetId, destinationOrderDetailStylesheetId, destinationOrderStylesheetId, executionDetailStylesheetId, executionStylesheetId, matchStylesheetId, matchHistoryStylesheetId, partyTypeCode, sourceOrderDetailStylesheetId, sourceOrderStylesheetId, workingOrderStylesheetId, buyMarketValueThreshold, buyQuantityThreshold, sellMarketValueThreshold, sellQuantityThreshold, shortName, sourceId, typeCode);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemplo n.º 2
0
        /// <summary>ArchiveChildrens a Source 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="sourceId">The value for the SourceId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal new static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int sourceId)
        {
            // Accessor for the Source Table.
            ServerMarketData.SourceDataTable sourceTable = ServerMarketData.Source;
            // This record can be used to iterate through all the children.
            ServerMarketData.SourceRow sourceRow = sourceTable.FindBySourceId(sourceId);
            // Archive the child records.
            for (int index = 0; (index < sourceRow.GetBrokerRows().Length); index = (index + 1))
            {
                ServerMarketData.BrokerRow childBrokerRow = sourceRow.GetBrokerRows()[index];
                Broker.ArchiveChildren(adoTransaction, sqlTransaction, childBrokerRow.RowVersion, childBrokerRow.BrokerId);
            }
            for (int index = 0; (index < sourceRow.GetInstitutionRows().Length); index = (index + 1))
            {
                ServerMarketData.InstitutionRow childInstitutionRow = sourceRow.GetInstitutionRows()[index];
                Institution.ArchiveChildren(adoTransaction, sqlTransaction, childInstitutionRow.RowVersion, childInstitutionRow.InstitutionId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            sourceRow[sourceTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(sourceRow);
            sourceRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Source\" set \"IsArchived\" = 1 where \"SourceId\"=@sourceId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@sourceId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceId));
            sqlCommand.ExecuteNonQuery();
        }
Exemplo n.º 3
0
        /// <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();
        }
Exemplo n.º 4
0
        /// <summary>Archives a Source 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="sourceId">The value for the SourceId 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 sourceId)
        {
            // Accessor for the Source Table.
            ServerMarketData.SourceDataTable sourceTable = ServerMarketData.Source;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.SourceRow sourceRow = sourceTable.FindBySourceId(sourceId);
            if ((sourceRow == null))
            {
                throw new Exception(string.Format("The Source table does not have an element identified by {0}", sourceId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((sourceRow.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 = sourceRow.BlotterRow.RowVersion;

            Blotter.Archive(adoTransaction, sqlTransaction, baseRowVersion, sourceId);
        }
Exemplo n.º 5
0
 /// <summary>Archives a Source 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 Source Table.
     ServerMarketData.SourceDataTable sourceTable = ServerMarketData.Source;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalSourceId = parameters["sourceId"];
     // 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 sourceId = Source.FindRequiredKey(configurationId, "sourceId", externalSourceId);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerMarketData.SourceRow sourceRow = sourceTable.FindBySourceId(sourceId);
     rowVersion = ((long)(sourceRow[sourceTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Source.Archive(adoTransaction, sqlTransaction, rowVersion, sourceId);
 }
Exemplo n.º 6
0
 /// <summary>Loads a Source 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 Source Table.
     ServerMarketData.SourceDataTable sourceTable = ServerMarketData.Source;
     // 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;
     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 externalWorkingOrderStylesheetId = parameters["workingOrderStylesheetId"].Value;
     object buyMarketValueThreshold = parameters["buyMarketValueThreshold"].Value;
     object buyQuantityThreshold = parameters["buyQuantityThreshold"].Value;
     object sellMarketValueThreshold = parameters["sellMarketValueThreshold"].Value;
     object sellQuantityThreshold = parameters["sellQuantityThreshold"].Value;
     string shortName = parameters["shortName"];
     string externalSourceId = parameters["sourceId"];
     object externalTypeCode = parameters["typeCode"].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);
     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 workingOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "workingOrderStylesheetId", externalWorkingOrderStylesheetId);
     int sourceId = Blotter.FindKey(configurationId, "sourceId", externalSourceId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     ServerMarketData.SourceRow sourceRow = sourceTable.FindBySourceId(sourceId);
     // 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 ((sourceRow == 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 = Source.GetExternalKeyIndex(configurationId, "sourceId");
         object[] externalIdArray = new object[8];
         externalIdArray[externalKeyIndex] = externalSourceId;
         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.Source.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, workingOrderStylesheetId, buyMarketValueThreshold, buyQuantityThreshold, sellMarketValueThreshold, sellQuantityThreshold, shortName, typeCode);
     }
     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)(sourceRow[sourceTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Source.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, advertisementStylesheetId, destinationOrderDetailStylesheetId, destinationOrderStylesheetId, executionDetailStylesheetId, executionStylesheetId, matchStylesheetId, matchHistoryStylesheetId, partyTypeCode, sourceOrderDetailStylesheetId, sourceOrderStylesheetId, workingOrderStylesheetId, buyMarketValueThreshold, buyQuantityThreshold, sellMarketValueThreshold, sellQuantityThreshold, shortName, sourceId, typeCode);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemplo n.º 7
0
        /// <summary>Updates a Source 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="workingOrderStylesheetId">The value for the WorkingOrderStylesheetId column.</param>
        /// <param name="buyMarketValueThreshold">The value for the BuyMarketValueThreshold column.</param>
        /// <param name="buyQuantityThreshold">The value for the BuyQuantityThreshold column.</param>
        /// <param name="sellMarketValueThreshold">The value for the SellMarketValueThreshold column.</param>
        /// <param name="sellQuantityThreshold">The value for the SellQuantityThreshold column.</param>
        /// <param name="shortName">The value for the ShortName column.</param>
        /// <param name="sourceId">The value for the SourceId column.</param>
        /// <param name="typeCode">The value for the TypeCode 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,
            object destinationOrderDetailStylesheetId,
            object destinationOrderStylesheetId,
            object executionDetailStylesheetId,
            object executionStylesheetId,
            object matchStylesheetId,
            object matchHistoryStylesheetId,
            object partyTypeCode,
            object sourceOrderDetailStylesheetId,
            object sourceOrderStylesheetId,
            object workingOrderStylesheetId,
            object buyMarketValueThreshold,
            object buyQuantityThreshold,
            object sellMarketValueThreshold,
            object sellQuantityThreshold,
            object shortName,
            int sourceId,
            object typeCode)
        {
            // Accessor for the Source Table.
            ServerMarketData.SourceDataTable sourceTable = ServerMarketData.Source;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.SourceRow sourceRow = sourceTable.FindBySourceId(sourceId);
            if ((sourceRow == null))
            {
                throw new Exception(string.Format("The Source table does not have an element identified by {0}", sourceId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((sourceRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((buyMarketValueThreshold == null))
            {
                buyMarketValueThreshold = sourceRow[sourceTable.BuyMarketValueThresholdColumn];
            }
            if ((buyQuantityThreshold == null))
            {
                buyQuantityThreshold = sourceRow[sourceTable.BuyQuantityThresholdColumn];
            }
            if ((sellMarketValueThreshold == null))
            {
                sellMarketValueThreshold = sourceRow[sourceTable.SellMarketValueThresholdColumn];
            }
            if ((sellQuantityThreshold == null))
            {
                sellQuantityThreshold = sourceRow[sourceTable.SellQuantityThresholdColumn];
            }
            if ((shortName == null))
            {
                shortName = sourceRow[sourceTable.ShortNameColumn];
            }
            // 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 = sourceRow.BlotterRow.RowVersion;

            Blotter.Update(adoTransaction, sqlTransaction, ref baseRowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, advertisementStylesheetId, sourceId, destinationOrderDetailStylesheetId, destinationOrderStylesheetId, executionDetailStylesheetId, executionStylesheetId, matchStylesheetId, matchHistoryStylesheetId, partyTypeCode, sourceOrderDetailStylesheetId, sourceOrderStylesheetId, typeCode, workingOrderStylesheetId);
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            sourceRow[sourceTable.RowVersionColumn] = rowVersion;
            sourceRow[sourceTable.BuyMarketValueThresholdColumn]  = buyMarketValueThreshold;
            sourceRow[sourceTable.BuyQuantityThresholdColumn]     = buyQuantityThreshold;
            sourceRow[sourceTable.SellMarketValueThresholdColumn] = sellMarketValueThreshold;
            sourceRow[sourceTable.SellQuantityThresholdColumn]    = sellQuantityThreshold;
            sourceRow[sourceTable.ShortNameColumn] = shortName;
            adoTransaction.DataRows.Add(sourceRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Source"" set ""RowVersion""=@rowVersion,""BuyMarketValueThreshold""=@buyMarketValueThreshold,""BuyQuantityThreshold""=@buyQuantityThreshold,""SellMarketValueThreshold""=@sellMarketValueThreshold,""SellQuantityThreshold""=@sellQuantityThreshold,""ShortName""=@shortName where ""SourceId""=@sourceId");

            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("@buyMarketValueThreshold", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, buyMarketValueThreshold));
            sqlCommand.Parameters.Add(new SqlParameter("@buyQuantityThreshold", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, buyQuantityThreshold));
            sqlCommand.Parameters.Add(new SqlParameter("@sellMarketValueThreshold", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sellMarketValueThreshold));
            sqlCommand.Parameters.Add(new SqlParameter("@sellQuantityThreshold", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sellQuantityThreshold));
            sqlCommand.Parameters.Add(new SqlParameter("@shortName", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, shortName));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceId));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Exemplo n.º 8
0
        /// <summary>Inserts a Source 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="workingOrderStylesheetId">The value for the WorkingOrderStylesheetId column.</param>
        /// <param name="buyMarketValueThreshold">The value for the BuyMarketValueThreshold column.</param>
        /// <param name="buyQuantityThreshold">The value for the BuyQuantityThreshold column.</param>
        /// <param name="sellMarketValueThreshold">The value for the SellMarketValueThreshold column.</param>
        /// <param name="sellQuantityThreshold">The value for the SellQuantityThreshold column.</param>
        /// <param name="shortName">The value for the ShortName column.</param>
        /// <param name="typeCode">The value for the TypeCode 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 workingOrderStylesheetId,
            object buyMarketValueThreshold,
            object buyQuantityThreshold,
            object sellMarketValueThreshold,
            object sellQuantityThreshold,
            string shortName,
            object typeCode)
        {
            // Accessor for the Source Table.
            ServerMarketData.SourceDataTable sourceTable = ServerMarketData.Source;
            // Apply Defaults
            if ((buyMarketValueThreshold == null))
            {
                buyMarketValueThreshold = System.DBNull.Value;
            }
            if ((buyQuantityThreshold == null))
            {
                buyQuantityThreshold = System.DBNull.Value;
            }
            if ((sellMarketValueThreshold == null))
            {
                sellMarketValueThreshold = System.DBNull.Value;
            }
            if ((sellQuantityThreshold == null))
            {
                sellQuantityThreshold = System.DBNull.Value;
            }
            if ((typeCode == null))
            {
                typeCode = "Source";
            }
            // Insert the base members using the base class.
            int sourceId = 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);

            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerMarketData.SourceRow sourceRow = sourceTable.NewSourceRow();
            sourceRow[sourceTable.RowVersionColumn] = rowVersion;
            sourceRow[sourceTable.BuyMarketValueThresholdColumn]  = buyMarketValueThreshold;
            sourceRow[sourceTable.BuyQuantityThresholdColumn]     = buyQuantityThreshold;
            sourceRow[sourceTable.SellMarketValueThresholdColumn] = sellMarketValueThreshold;
            sourceRow[sourceTable.SellQuantityThresholdColumn]    = sellQuantityThreshold;
            sourceRow[sourceTable.ShortNameColumn] = shortName;
            sourceRow[sourceTable.SourceIdColumn]  = sourceId;
            sourceTable.AddSourceRow(sourceRow);
            adoTransaction.DataRows.Add(sourceRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Source"" (""rowVersion"",BuyMarketValueThreshold,BuyQuantityThreshold,SellMarketValueThreshold,SellQuantityThreshold,ShortName,SourceId) values (@rowVersion,@buyMarketValueThreshold,@buyQuantityThreshold,@sellMarketValueThreshold,@sellQuantityThreshold,@shortName,@sourceId)");

            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("@buyMarketValueThreshold", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, buyMarketValueThreshold));
            sqlCommand.Parameters.Add(new SqlParameter("@buyQuantityThreshold", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, buyQuantityThreshold));
            sqlCommand.Parameters.Add(new SqlParameter("@sellMarketValueThreshold", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sellMarketValueThreshold));
            sqlCommand.Parameters.Add(new SqlParameter("@sellQuantityThreshold", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sellQuantityThreshold));
            sqlCommand.Parameters.Add(new SqlParameter("@shortName", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, shortName));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceId));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(sourceRow.SourceId);
        }