Ejemplo n.º 1
0
 /// <summary>Updates a Security 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 Security Table.
     ServerMarketData.SecurityDataTable securityTable = ServerMarketData.Security;
     // 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 averageDailyVolume = parameters["averageDailyVolume"].Value;
     object externalCountryId = parameters["countryId"].Value;
     object minimumQuantity = parameters["minimumQuantity"].Value;
     object marketCapitalization = parameters["marketCapitalization"].Value;
     object priceFactor = parameters["priceFactor"].Value;
     object quantityFactor = parameters["quantityFactor"].Value;
     string externalSecurityId = ((string)(parameters["securityId"]));
     object symbol = parameters["symbol"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     object logo = parameters["logo"].Value;
     object externalVolumeCategoryId = parameters["volumeCategoryId"].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 countryId = Country.FindOptionalKey(configurationId, "countryId", externalCountryId);
     int securityId = Object.FindRequiredKey(configurationId, "securityId", externalSecurityId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     object volumeCategoryId = VolumeCategory.FindOptionalKey(configurationId, "volumeCategoryId", externalVolumeCategoryId);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerMarketData.SecurityRow securityRow = securityTable.FindBySecurityId(securityId);
     rowVersion = ((long)(securityRow[securityTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Security.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, averageDailyVolume, countryId, minimumQuantity, marketCapitalization, priceFactor, quantityFactor, securityId, symbol, typeCode, logo, volumeCategoryId);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Ejemplo n.º 2
0
        /// <summary>Archives a Security 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="securityId">The value for the SecurityId 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 securityId)
        {
            // Accessor for the Security Table.
            ServerMarketData.SecurityDataTable securityTable = ServerMarketData.Security;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.SecurityRow securityRow = securityTable.FindBySecurityId(securityId);
            if ((securityRow == null))
            {
                throw new Exception(string.Format("The Security table does not have an element identified by {0}", securityId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((securityRow.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 = securityRow.ObjectRow.RowVersion;

            Object.Archive(adoTransaction, sqlTransaction, baseRowVersion, securityId);
        }
Ejemplo n.º 3
0
 /// <summary>Archives a Security 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 Security Table.
     ServerMarketData.SecurityDataTable securityTable = ServerMarketData.Security;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalSecurityId = parameters["securityId"];
     // 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 securityId = Security.FindRequiredKey(configurationId, "securityId", externalSecurityId);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerMarketData.SecurityRow securityRow = securityTable.FindBySecurityId(securityId);
     rowVersion = ((long)(securityRow[securityTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Security.Archive(adoTransaction, sqlTransaction, rowVersion, securityId);
 }
Ejemplo n.º 4
0
        /// <summary>ArchiveChildrens a Security 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="securityId">The value for the SecurityId 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 securityId)
        {
            // Accessor for the Security Table.
            ServerMarketData.SecurityDataTable securityTable = ServerMarketData.Security;
            // This record can be used to iterate through all the children.
            ServerMarketData.SecurityRow securityRow = securityTable.FindBySecurityId(securityId);
            // Archive the child records.
            for (int index = 0; (index < securityRow.GetAccountBaseRows().Length); index = (index + 1))
            {
                ServerMarketData.AccountBaseRow childAccountBaseRow = securityRow.GetAccountBaseRows()[index];
                AccountBase.ArchiveChildren(adoTransaction, sqlTransaction, childAccountBaseRow.RowVersion, childAccountBaseRow.AccountBaseId);
            }
            for (int index = 0; (index < securityRow.GetAllocationRowsBySecurityAllocationSecurityId().Length); index = (index + 1))
            {
                ServerMarketData.AllocationRow childAllocationRow = securityRow.GetAllocationRowsBySecurityAllocationSecurityId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < securityRow.GetAllocationRowsBySecurityAllocationSettlementId().Length); index = (index + 1))
            {
                ServerMarketData.AllocationRow childAllocationRow = securityRow.GetAllocationRowsBySecurityAllocationSettlementId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < securityRow.GetCurrencyRows().Length); index = (index + 1))
            {
                ServerMarketData.CurrencyRow childCurrencyRow = securityRow.GetCurrencyRows()[index];
                Currency.ArchiveChildren(adoTransaction, sqlTransaction, childCurrencyRow.RowVersion, childCurrencyRow.CurrencyId);
            }
            for (int index = 0; (index < securityRow.GetDebtRowsBySecurityDebtDebtId().Length); index = (index + 1))
            {
                ServerMarketData.DebtRow childDebtRow = securityRow.GetDebtRowsBySecurityDebtDebtId()[index];
                Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId);
            }
            for (int index = 0; (index < securityRow.GetDebtRowsBySecurityDebtSettlementId().Length); index = (index + 1))
            {
                ServerMarketData.DebtRow childDebtRow = securityRow.GetDebtRowsBySecurityDebtSettlementId()[index];
                Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId);
            }
            for (int index = 0; (index < securityRow.GetEquityRowsBySecurityEquityEquityId().Length); index = (index + 1))
            {
                ServerMarketData.EquityRow childEquityRow = securityRow.GetEquityRowsBySecurityEquityEquityId()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            for (int index = 0; (index < securityRow.GetEquityRowsBySecurityEquitySettlementId().Length); index = (index + 1))
            {
                ServerMarketData.EquityRow childEquityRow = securityRow.GetEquityRowsBySecurityEquitySettlementId()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            for (int index = 0; (index < securityRow.GetPositionRows().Length); index = (index + 1))
            {
                ServerMarketData.PositionRow childPositionRow = securityRow.GetPositionRows()[index];
                Position.Archive(adoTransaction, sqlTransaction, childPositionRow.RowVersion, childPositionRow.AccountId, childPositionRow.SecurityId, childPositionRow.PositionTypeCode);
            }
            for (int index = 0; (index < securityRow.GetPriceRows().Length); index = (index + 1))
            {
                ServerMarketData.PriceRow childPriceRow = securityRow.GetPriceRows()[index];
                Price.Archive(adoTransaction, sqlTransaction, childPriceRow.RowVersion, childPriceRow.SecurityId);
            }
            for (int index = 0; (index < securityRow.GetSourceOrderRowsBySecuritySourceOrderSecurityId().Length); index = (index + 1))
            {
                ServerMarketData.SourceOrderRow childSourceOrderRow = securityRow.GetSourceOrderRowsBySecuritySourceOrderSecurityId()[index];
                SourceOrder.Archive(adoTransaction, sqlTransaction, childSourceOrderRow.RowVersion, childSourceOrderRow.SourceOrderId);
            }
            for (int index = 0; (index < securityRow.GetSourceOrderRowsBySecuritySourceOrderSettlementId().Length); index = (index + 1))
            {
                ServerMarketData.SourceOrderRow childSourceOrderRow = securityRow.GetSourceOrderRowsBySecuritySourceOrderSettlementId()[index];
                SourceOrder.Archive(adoTransaction, sqlTransaction, childSourceOrderRow.RowVersion, childSourceOrderRow.SourceOrderId);
            }
            for (int index = 0; (index < securityRow.GetTaxLotRows().Length); index = (index + 1))
            {
                ServerMarketData.TaxLotRow childTaxLotRow = securityRow.GetTaxLotRows()[index];
                TaxLot.Archive(adoTransaction, sqlTransaction, childTaxLotRow.RowVersion, childTaxLotRow.TaxLotId);
            }
            for (int index = 0; (index < securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSecurityId().Length); index = (index + 1))
            {
                ServerMarketData.WorkingOrderRow childWorkingOrderRow = securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSecurityId()[index];
                WorkingOrder.Archive(adoTransaction, sqlTransaction, childWorkingOrderRow.RowVersion, childWorkingOrderRow.WorkingOrderId);
            }
            for (int index = 0; (index < securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSettlementId().Length); index = (index + 1))
            {
                ServerMarketData.WorkingOrderRow childWorkingOrderRow = securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSettlementId()[index];
                WorkingOrder.Archive(adoTransaction, sqlTransaction, childWorkingOrderRow.RowVersion, childWorkingOrderRow.WorkingOrderId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            securityRow[securityTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(securityRow);
            securityRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Security\" set \"IsArchived\" = 1 where \"SecurityId\"=@securityId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.ExecuteNonQuery();
        }
Ejemplo n.º 5
0
        /// <summary>Updates a Security 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="averageDailyVolume">The value for the AverageDailyVolume column.</param>
        /// <param name="countryId">The value for the CountryId column.</param>
        /// <param name="minimumQuantity">The value for the MinimumQuantity column.</param>
        /// <param name="marketCapitalization">The value for the MarketCapitalization column.</param>
        /// <param name="priceFactor">The value for the PriceFactor column.</param>
        /// <param name="quantityFactor">The value for the QuantityFactor column.</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="symbol">The value for the Symbol column.</param>
        /// <param name="typeCode">The value for the TypeCode column.</param>
        /// <param name="logo">The value for the Logo column.</param>
        /// <param name="volumeCategoryId">The value for the VolumeCategoryId 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 averageDailyVolume,
            object countryId,
            object minimumQuantity,
            object marketCapitalization,
            object priceFactor,
            object quantityFactor,
            int securityId,
            object symbol,
            object typeCode,
            object logo,
            object volumeCategoryId)
        {
            // Accessor for the Security Table.
            ServerMarketData.SecurityDataTable securityTable = ServerMarketData.Security;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.SecurityRow securityRow = securityTable.FindBySecurityId(securityId);
            if ((securityRow == null))
            {
                throw new Exception(string.Format("The Security table does not have an element identified by {0}", securityId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((securityRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((averageDailyVolume == null))
            {
                averageDailyVolume = securityRow[securityTable.AverageDailyVolumeColumn];
            }
            if ((countryId == null))
            {
                countryId = securityRow[securityTable.CountryIdColumn];
            }
            if ((minimumQuantity == null))
            {
                minimumQuantity = securityRow[securityTable.MinimumQuantityColumn];
            }
            if ((marketCapitalization == null))
            {
                marketCapitalization = securityRow[securityTable.MarketCapitalizationColumn];
            }
            if ((priceFactor == null))
            {
                priceFactor = securityRow[securityTable.PriceFactorColumn];
            }
            if ((quantityFactor == null))
            {
                quantityFactor = securityRow[securityTable.QuantityFactorColumn];
            }
            if ((symbol == null))
            {
                symbol = securityRow[securityTable.SymbolColumn];
            }
            if ((logo == null))
            {
                logo = securityRow[securityTable.LogoColumn];
            }
            if ((volumeCategoryId == null))
            {
                volumeCategoryId = securityRow[securityTable.VolumeCategoryIdColumn];
            }
            // 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 = securityRow.ObjectRow.RowVersion;

            Object.Update(adoTransaction, sqlTransaction, ref baseRowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, securityId, owner, ownerPermission, readOnly, typeCode, worldPermission);
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            securityRow[securityTable.RowVersionColumn]           = rowVersion;
            securityRow[securityTable.AverageDailyVolumeColumn]   = averageDailyVolume;
            securityRow[securityTable.CountryIdColumn]            = countryId;
            securityRow[securityTable.MinimumQuantityColumn]      = minimumQuantity;
            securityRow[securityTable.MarketCapitalizationColumn] = marketCapitalization;
            securityRow[securityTable.PriceFactorColumn]          = priceFactor;
            securityRow[securityTable.QuantityFactorColumn]       = quantityFactor;
            securityRow[securityTable.SymbolColumn]           = symbol;
            securityRow[securityTable.LogoColumn]             = logo;
            securityRow[securityTable.VolumeCategoryIdColumn] = volumeCategoryId;
            adoTransaction.DataRows.Add(securityRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Security"" set ""RowVersion""=@rowVersion,""AverageDailyVolume""=@averageDailyVolume,""CountryId""=@countryId,""MinimumQuantity""=@minimumQuantity,""MarketCapitalization""=@marketCapitalization,""PriceFactor""=@priceFactor,""QuantityFactor""=@quantityFactor,""Symbol""=@symbol,""Logo""=@logo,""VolumeCategoryId""=@volumeCategoryId where ""SecurityId""=@securityId");

            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("@averageDailyVolume", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, averageDailyVolume));
            sqlCommand.Parameters.Add(new SqlParameter("@countryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, countryId));
            sqlCommand.Parameters.Add(new SqlParameter("@minimumQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, minimumQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@marketCapitalization", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, marketCapitalization));
            sqlCommand.Parameters.Add(new SqlParameter("@priceFactor", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, priceFactor));
            sqlCommand.Parameters.Add(new SqlParameter("@quantityFactor", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantityFactor));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.Parameters.Add(new SqlParameter("@symbol", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, symbol));
            sqlCommand.Parameters.Add(new SqlParameter("@logo", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, logo));
            sqlCommand.Parameters.Add(new SqlParameter("@volumeCategoryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, volumeCategoryId));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Ejemplo n.º 6
0
        /// <summary>Inserts a Security 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="averageDailyVolume">The value for the AverageDailyVolume column.</param>
        /// <param name="countryId">The value for the CountryId column.</param>
        /// <param name="minimumQuantity">The value for the MinimumQuantity column.</param>
        /// <param name="marketCapitalization">The value for the MarketCapitalization column.</param>
        /// <param name="priceFactor">The value for the PriceFactor column.</param>
        /// <param name="quantityFactor">The value for the QuantityFactor column.</param>
        /// <param name="symbol">The value for the Symbol column.</param>
        /// <param name="typeCode">The value for the TypeCode column.</param>
        /// <param name="logo">The value for the Logo column.</param>
        /// <param name="volumeCategoryId">The value for the VolumeCategoryId 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 averageDailyVolume,
            int countryId,
            object minimumQuantity,
            object marketCapitalization,
            decimal priceFactor,
            decimal quantityFactor,
            object symbol,
            object typeCode,
            object logo,
            object volumeCategoryId)
        {
            // Accessor for the Security Table.
            ServerMarketData.SecurityDataTable securityTable = ServerMarketData.Security;
            // Apply Defaults
            if ((averageDailyVolume == null))
            {
                averageDailyVolume = System.DBNull.Value;
            }
            if ((minimumQuantity == null))
            {
                minimumQuantity = System.DBNull.Value;
            }
            if ((marketCapitalization == null))
            {
                marketCapitalization = System.DBNull.Value;
            }
            if ((symbol == null))
            {
                symbol = System.DBNull.Value;
            }
            if ((typeCode == null))
            {
                typeCode = "Security";
            }
            if ((logo == null))
            {
                logo = System.DBNull.Value;
            }
            if ((volumeCategoryId == null))
            {
                volumeCategoryId = System.DBNull.Value;
            }
            // Insert the base members using the base class.
            int securityId = 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.SecurityRow securityRow = securityTable.NewSecurityRow();
            securityRow[securityTable.RowVersionColumn]           = rowVersion;
            securityRow[securityTable.AverageDailyVolumeColumn]   = averageDailyVolume;
            securityRow[securityTable.CountryIdColumn]            = countryId;
            securityRow[securityTable.MinimumQuantityColumn]      = minimumQuantity;
            securityRow[securityTable.MarketCapitalizationColumn] = marketCapitalization;
            securityRow[securityTable.PriceFactorColumn]          = priceFactor;
            securityRow[securityTable.QuantityFactorColumn]       = quantityFactor;
            securityRow[securityTable.SecurityIdColumn]           = securityId;
            securityRow[securityTable.SymbolColumn]           = symbol;
            securityRow[securityTable.LogoColumn]             = logo;
            securityRow[securityTable.VolumeCategoryIdColumn] = volumeCategoryId;
            securityTable.AddSecurityRow(securityRow);
            adoTransaction.DataRows.Add(securityRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Security"" (""rowVersion"",AverageDailyVolume,CountryId,MinimumQuantity,MarketCapitalization,PriceFactor,QuantityFactor,SecurityId,Symbol,Logo,VolumeCategoryId) values (@rowVersion,@averageDailyVolume,@countryId,@minimumQuantity,@marketCapitalization,@priceFactor,@quantityFactor,@securityId,@symbol,@logo,@volumeCategoryId)");

            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("@averageDailyVolume", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, averageDailyVolume));
            sqlCommand.Parameters.Add(new SqlParameter("@countryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, countryId));
            sqlCommand.Parameters.Add(new SqlParameter("@minimumQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, minimumQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@marketCapitalization", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, marketCapitalization));
            sqlCommand.Parameters.Add(new SqlParameter("@priceFactor", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, priceFactor));
            sqlCommand.Parameters.Add(new SqlParameter("@quantityFactor", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantityFactor));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.Parameters.Add(new SqlParameter("@symbol", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, symbol));
            sqlCommand.Parameters.Add(new SqlParameter("@logo", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, logo));
            sqlCommand.Parameters.Add(new SqlParameter("@volumeCategoryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, volumeCategoryId));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(securityRow.SecurityId);
        }
Ejemplo n.º 7
0
 /// <summary>Loads a Security 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 Security Table.
     ServerMarketData.SecurityDataTable securityTable = ServerMarketData.Security;
     // 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 averageDailyVolume = parameters["averageDailyVolume"].Value;
     string externalCountryId = parameters["countryId"];
     object minimumQuantity = parameters["minimumQuantity"].Value;
     object marketCapitalization = parameters["marketCapitalization"].Value;
     decimal priceFactor = parameters["priceFactor"];
     decimal quantityFactor = parameters["quantityFactor"];
     string externalSecurityId = parameters["securityId"];
     object symbol = parameters["symbol"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     object logo = parameters["logo"].Value;
     object externalVolumeCategoryId = parameters["volumeCategoryId"].Value;
     // The row versioning is largely disabled for external operations.  The value is returned to the caller in the
     // event it's needed for operations within the batch.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     int countryId = Country.FindRequiredKey(configurationId, "countryId", externalCountryId);
     int securityId = Object.FindKey(configurationId, "securityId", externalSecurityId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     object volumeCategoryId = VolumeCategory.FindOptionalKey(configurationId, "volumeCategoryId", externalVolumeCategoryId);
     ServerMarketData.SecurityRow securityRow = securityTable.FindBySecurityId(securityId);
     // 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 ((securityRow == 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 = Security.GetExternalKeyIndex(configurationId, "securityId");
         object[] externalIdArray = new object[8];
         externalIdArray[externalKeyIndex] = externalSecurityId;
         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.Security.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, averageDailyVolume, countryId, minimumQuantity, marketCapitalization, priceFactor, quantityFactor, symbol, typeCode, logo, volumeCategoryId);
     }
     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)(securityRow[securityTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Security.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, averageDailyVolume, countryId, minimumQuantity, marketCapitalization, priceFactor, quantityFactor, securityId, symbol, typeCode, logo, volumeCategoryId);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }