Exemple #1
0
        /// <summary>ArchiveChildrens a Issuer 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="issuerId">The value for the IssuerId 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 issuerId)
        {
            // Accessor for the Issuer Table.
            ServerMarketData.IssuerDataTable issuerTable = ServerMarketData.Issuer;
            // This record can be used to iterate through all the children.
            ServerMarketData.IssuerRow issuerRow = issuerTable.FindByIssuerId(issuerId);
            // Archive the child records.
            for (int index = 0; (index < issuerRow.GetDebtRows().Length); index = (index + 1))
            {
                ServerMarketData.DebtRow childDebtRow = issuerRow.GetDebtRows()[index];
                Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            issuerRow[issuerTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(issuerRow);
            issuerRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Issuer\" set \"IsArchived\" = 1 where \"IssuerId\"=@issuerId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@issuerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, issuerId));
            sqlCommand.ExecuteNonQuery();
        }
        /// <summary>
        /// Authorizes a Debt to be returned to the client.
        /// </summary>
        /// <param name="userDataRow">Identifies the current user.</param>
        /// <param name="debtDataRow">The record to be tested for authorization.</param>
        /// <returns>true if the record belongs in the user's hierarchy.</returns>
        public static bool FilterDebt(DataRow userDataRow, DataRow debtDataRow)
        {
            // This will test the record and return true if it belongs to the hierarchies this user is authorized to view.  False
            // if the record should not be included in the user's data model.
            ServerMarketData.UserRow userRow = (ServerMarketData.UserRow)userDataRow;
            ServerMarketData.DebtRow debtRow = (ServerMarketData.DebtRow)debtDataRow;

            foreach (ServerMarketData.SourceOrderRow sourceOrderRow in debtRow.SecurityRowBySecurityDebtDebtId.GetSourceOrderRowsBySecuritySourceOrderSecurityId())
            {
                if (Hierarchy.IsDescendant(userRow.SystemFolderRow.FolderRow.ObjectRow, sourceOrderRow.WorkingOrderRow.BlotterRow.ObjectRow))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #3
0
 /// <summary>Archives a Debt 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 Debt Table.
     ServerMarketData.DebtDataTable debtTable = ServerMarketData.Debt;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalDebtId = parameters["debtId"];
     // 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 debtId = Debt.FindRequiredKey(configurationId, "debtId", externalDebtId);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerMarketData.DebtRow debtRow = debtTable.FindByDebtId(debtId);
     rowVersion = ((long)(debtRow[debtTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Debt.Archive(adoTransaction, sqlTransaction, rowVersion, debtId);
 }
Exemple #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();
        }
Exemple #5
0
 /// <summary>Loads a Debt 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 Debt Table.
     ServerMarketData.DebtDataTable debtTable = ServerMarketData.Debt;
     // 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;
     object symbol = parameters["symbol"].Value;
     object logo = parameters["logo"].Value;
     object externalVolumeCategoryId = parameters["volumeCategoryId"].Value;
     object capitalGainsTaxRate = parameters["capitalGainsTaxRate"].Value;
     decimal coupon = parameters["coupon"];
     object cutoffPeriod = parameters["cutoffPeriod"].Value;
     object datedDate = parameters["datedDate"].Value;
     string externalDebtId = parameters["debtId"];
     object exdividendDays = parameters["exdividendDays"].Value;
     object faceOutstanding = parameters["faceOutstanding"].Value;
     object firstCoupon = parameters["firstCoupon"].Value;
     object frequency = parameters["frequency"].Value;
     object incomeTaxRate = parameters["incomeTaxRate"].Value;
     object issuePrice = parameters["issuePrice"].Value;
     object externalIssuerId = parameters["issuerId"].Value;
     System.DateTime maturityDate = parameters["maturityDate"];
     object priceFactor = parameters["priceFactor"].Value;
     object quantityFactor = parameters["quantityFactor"].Value;
     object rating0 = parameters["rating0"].Value;
     object rating1 = parameters["rating1"].Value;
     object rating2 = parameters["rating2"].Value;
     object rating3 = parameters["rating3"].Value;
     object redemptionValue = parameters["redemptionValue"].Value;
     string externalSettlementId = parameters["settlementId"];
     object trueYield = parameters["trueYield"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     object weekendCode = parameters["weekendCode"].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);
     object volumeCategoryId = VolumeCategory.FindOptionalKey(configurationId, "volumeCategoryId", externalVolumeCategoryId);
     int debtId = Security.FindKey(configurationId, "debtId", externalDebtId);
     object issuerId = Issuer.FindOptionalKey(configurationId, "issuerId", externalIssuerId);
     int settlementId = Security.FindRequiredKey(configurationId, "settlementId", externalSettlementId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     ServerMarketData.DebtRow debtRow = debtTable.FindByDebtId(debtId);
     // 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 ((debtRow == 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 = Debt.GetExternalKeyIndex(configurationId, "debtId");
         object[] externalIdArray = new object[8];
         externalIdArray[externalKeyIndex] = externalDebtId;
         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.Debt.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, symbol, logo, volumeCategoryId, capitalGainsTaxRate, coupon, cutoffPeriod, datedDate, exdividendDays, faceOutstanding, firstCoupon, frequency, incomeTaxRate, issuePrice, issuerId, maturityDate, priceFactor, quantityFactor, rating0, rating1, rating2, rating3, redemptionValue, settlementId, trueYield, typeCode, weekendCode);
     }
     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)(debtRow[debtTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Debt.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, symbol, logo, volumeCategoryId, capitalGainsTaxRate, coupon, cutoffPeriod, datedDate, debtId, exdividendDays, faceOutstanding, firstCoupon, frequency, incomeTaxRate, issuePrice, issuerId, maturityDate, priceFactor, quantityFactor, rating0, rating1, rating2, rating3, redemptionValue, settlementId, trueYield, typeCode, weekendCode);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemple #6
0
 /// <summary>Updates a Debt 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 Debt Table.
     ServerMarketData.DebtDataTable debtTable = ServerMarketData.Debt;
     // 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 symbol = parameters["symbol"].Value;
     object logo = parameters["logo"].Value;
     object externalVolumeCategoryId = parameters["volumeCategoryId"].Value;
     object capitalGainsTaxRate = parameters["capitalGainsTaxRate"].Value;
     object coupon = parameters["coupon"].Value;
     object cutoffPeriod = parameters["cutoffPeriod"].Value;
     object datedDate = parameters["datedDate"].Value;
     string externalDebtId = ((string)(parameters["debtId"]));
     object exdividendDays = parameters["exdividendDays"].Value;
     object faceOutstanding = parameters["faceOutstanding"].Value;
     object firstCoupon = parameters["firstCoupon"].Value;
     object frequency = parameters["frequency"].Value;
     object incomeTaxRate = parameters["incomeTaxRate"].Value;
     object issuePrice = parameters["issuePrice"].Value;
     object externalIssuerId = parameters["issuerId"].Value;
     object maturityDate = parameters["maturityDate"].Value;
     object priceFactor = parameters["priceFactor"].Value;
     object quantityFactor = parameters["quantityFactor"].Value;
     object rating0 = parameters["rating0"].Value;
     object rating1 = parameters["rating1"].Value;
     object rating2 = parameters["rating2"].Value;
     object rating3 = parameters["rating3"].Value;
     object redemptionValue = parameters["redemptionValue"].Value;
     object externalSettlementId = parameters["settlementId"].Value;
     object trueYield = parameters["trueYield"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     object weekendCode = parameters["weekendCode"].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);
     object volumeCategoryId = VolumeCategory.FindOptionalKey(configurationId, "volumeCategoryId", externalVolumeCategoryId);
     int debtId = Security.FindRequiredKey(configurationId, "debtId", externalDebtId);
     object issuerId = Issuer.FindOptionalKey(configurationId, "issuerId", externalIssuerId);
     object settlementId = Security.FindOptionalKey(configurationId, "settlementId", externalSettlementId);
     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.DebtRow debtRow = debtTable.FindByDebtId(debtId);
     rowVersion = ((long)(debtRow[debtTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Debt.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, symbol, logo, volumeCategoryId, capitalGainsTaxRate, coupon, cutoffPeriod, datedDate, debtId, exdividendDays, faceOutstanding, firstCoupon, frequency, incomeTaxRate, issuePrice, issuerId, maturityDate, priceFactor, quantityFactor, rating0, rating1, rating2, rating3, redemptionValue, settlementId, trueYield, typeCode, weekendCode);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }