示例#1
0
        /// <summary>Archives a EquityType 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="equityTypeCode">The value for the EquityTypeCode column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int equityTypeCode)
        {
            // Accessor for the EquityType Table.
            ServerDataModel.EquityTypeDataTable equityTypeTable = ServerDataModel.EquityType;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.EquityTypeRow equityTypeRow = equityTypeTable.FindByEquityTypeCode(equityTypeCode);
            if ((equityTypeRow == null))
            {
                throw new Exception(string.Format("The EquityType table does not have an element identified by {0}", equityTypeCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((equityTypeRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < equityTypeRow.GetEquityRows().Length); index = (index + 1))
            {
                ServerDataModel.EquityRow childEquityRow = equityTypeRow.GetEquityRows()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            equityTypeRow[equityTypeTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(equityTypeRow);
            equityTypeRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"EquityType\" set \"IsArchived\" = 1 where \"EquityTypeCode\"=@equityTypeCode");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@equityTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, equityTypeCode));
            sqlCommand.ExecuteNonQuery();
        }
示例#2
0
        /// <summary>
        /// Authorizes a Equity to be returned to the client.
        /// </summary>
        /// <param name="userDataRow">Identifies the current user.</param>
        /// <param name="equityDataRow">The record to be tested for authorization.</param>
        /// <returns>true if the record belongs in the user's hierarchy.</returns>
        public static bool FilterEquity(DataRow userDataRow, DataRow equityDataRow)
        {
            // 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.
            ServerDataModel.UserRow   userRow   = (ServerDataModel.UserRow)userDataRow;
            ServerDataModel.EquityRow equityRow = (ServerDataModel.EquityRow)equityDataRow;

            return(true);
        }
示例#3
0
 /// <summary>Updates a Equity 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 Equity Table.
     ServerDataModel.EquityDataTable equityTable = ServerDataModel.Equity;
     // 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 externalCountryId = parameters["countryId"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     object symbol = parameters["symbol"].Value;
     string externalEquityId = ((string)(parameters["equityId"]));
     object issuerId = parameters["issuerId"].Value;
     object externalExchangeId = parameters["exchangeId"].Value;
     object externalSettlementId = parameters["settlementId"].Value;
     object externalSecurityTypeCode = parameters["securityTypeCode"].Value;
     object externalEquityTypeCode = parameters["equityTypeCode"].Value;
     object priceFactor = parameters["priceFactor"].Value;
     object quantityFactor = parameters["quantityFactor"].Value;
     object sharesOutstanding = parameters["sharesOutstanding"].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 typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     int equityId = Security.FindRequiredKey(configurationId, "equityId", externalEquityId);
     object exchangeId = Exchange.FindOptionalKey(configurationId, "exchangeId", externalExchangeId);
     object settlementId = Security.FindOptionalKey(configurationId, "settlementId", externalSettlementId);
     object securityTypeCode = SecurityType.FindOptionalKey(configurationId, "securityTypeCode", externalSecurityTypeCode);
     object equityTypeCode = EquityType.FindOptionalKey(configurationId, "equityTypeCode", externalEquityTypeCode);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerDataModel.EquityRow equityRow = equityTable.FindByEquityId(equityId);
     rowVersion = ((long)(equityRow[equityTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Quasar.Core.Equity.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, countryId, typeCode, symbol, equityId, issuerId, exchangeId, settlementId, securityTypeCode, equityTypeCode, priceFactor, quantityFactor, sharesOutstanding);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
示例#4
0
 /// <summary>ArchiveChildrens a Equity 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="equityId">The value for the EquityId 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 equityId)
 {
     // Accessor for the Equity Table.
     ServerDataModel.EquityDataTable equityTable = ServerDataModel.Equity;
     // This record can be used to iterate through all the children.
     ServerDataModel.EquityRow equityRow = equityTable.FindByEquityId(equityId);
     // Archive the child records.
     // Increment the row version
     rowVersion = ServerDataModel.RowVersion.Increment();
     // Delete the record in the ADO database.
     equityRow[equityTable.RowVersionColumn] = rowVersion;
     adoTransaction.DataRows.Add(equityRow);
     equityRow.Delete();
     // Archive the record in the SQL database.
     SqlCommand sqlCommand = new SqlCommand("update \"Equity\" set \"IsArchived\" = 1 where \"EquityId\"=@equityId");
     sqlCommand.Connection = sqlTransaction.Connection;
     sqlCommand.Transaction = sqlTransaction;
     sqlCommand.Parameters.Add(new SqlParameter("@equityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, equityId));
     sqlCommand.ExecuteNonQuery();
 }
示例#5
0
 /// <summary>Archives a Equity 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="equityId">The value for the EquityId 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 equityId)
 {
     // Accessor for the Equity Table.
     ServerDataModel.EquityDataTable equityTable = ServerDataModel.Equity;
     // Rule #1: Make sure the record exists before updating it.
     ServerDataModel.EquityRow equityRow = equityTable.FindByEquityId(equityId);
     if ((equityRow == null))
     {
         throw new Exception(string.Format("The Equity table does not have an element identified by {0}", equityId));
     }
     // Rule #2: Optimistic Concurrency Check
     if ((equityRow.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 = equityRow.SecurityRowByFKSecurityEquityEquityId.RowVersion;
     Security.Archive(adoTransaction, sqlTransaction, baseRowVersion, equityId);
 }
示例#6
0
 /// <summary>Archives a Equity 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 Equity Table.
     ServerDataModel.EquityDataTable equityTable = ServerDataModel.Equity;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalEquityId = parameters["equityId"];
     // 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 equityId = Equity.FindRequiredKey(configurationId, "equityId", externalEquityId);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerDataModel.EquityRow equityRow = equityTable.FindByEquityId(equityId);
     rowVersion = ((long)(equityRow[equityTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Quasar.Core.Equity.Archive(adoTransaction, sqlTransaction, rowVersion, equityId);
 }
示例#7
0
 /// <summary>Updates a Equity 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="countryId">The value for the CountryId column.</param>
 /// <param name="typeCode">The value for the TypeCode column.</param>
 /// <param name="symbol">The value for the Symbol column.</param>
 /// <param name="equityId">The value for the EquityId column.</param>
 /// <param name="issuerId">The value for the IssuerId column.</param>
 /// <param name="exchangeId">The value for the ExchangeId column.</param>
 /// <param name="settlementId">The value for the SettlementId column.</param>
 /// <param name="securityTypeCode">The value for the SecurityTypeCode column.</param>
 /// <param name="equityTypeCode">The value for the EquityTypeCode column.</param>
 /// <param name="priceFactor">The value for the PriceFactor column.</param>
 /// <param name="quantityFactor">The value for the QuantityFactor column.</param>
 /// <param name="sharesOutstanding">The value for the SharesOutstanding 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 countryId, 
             object typeCode, 
             object symbol, 
             int equityId, 
             object issuerId, 
             object exchangeId, 
             object settlementId, 
             object securityTypeCode, 
             object equityTypeCode, 
             object priceFactor, 
             object quantityFactor, 
             object sharesOutstanding)
 {
     // Accessor for the Equity Table.
     ServerDataModel.EquityDataTable equityTable = ServerDataModel.Equity;
     // Rule #1: Make sure the record exists before updating it.
     ServerDataModel.EquityRow equityRow = equityTable.FindByEquityId(equityId);
     if ((equityRow == null))
     {
         throw new Exception(string.Format("The Equity table does not have an element identified by {0}", equityId));
     }
     // Rule #2: Optimistic Concurrency Check
     if ((equityRow.RowVersion != rowVersion))
     {
         throw new System.Exception("This record is busy.  Please try again later.");
     }
     // Apply Defaults
     if ((issuerId == null))
     {
         issuerId = equityRow[equityTable.IssuerIdColumn];
     }
     if ((exchangeId == null))
     {
         exchangeId = equityRow[equityTable.ExchangeIdColumn];
     }
     if ((settlementId == null))
     {
         settlementId = equityRow[equityTable.SettlementIdColumn];
     }
     if ((equityTypeCode == null))
     {
         equityTypeCode = equityRow[equityTable.EquityTypeCodeColumn];
     }
     if ((sharesOutstanding == null))
     {
         sharesOutstanding = equityRow[equityTable.SharesOutstandingColumn];
     }
     // 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 = equityRow.SecurityRowByFKSecurityEquityEquityId.RowVersion;
     Security.Update(adoTransaction, sqlTransaction, ref baseRowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, equityId, countryId, typeCode, securityTypeCode, quantityFactor, priceFactor, symbol);
     // Increment the row version
     rowVersion = ServerDataModel.RowVersion.Increment();
     // Update the record in the ADO database.
     equityRow[equityTable.RowVersionColumn] = rowVersion;
     equityRow[equityTable.IssuerIdColumn] = issuerId;
     equityRow[equityTable.ExchangeIdColumn] = exchangeId;
     equityRow[equityTable.SettlementIdColumn] = settlementId;
     equityRow[equityTable.EquityTypeCodeColumn] = equityTypeCode;
     equityRow[equityTable.SharesOutstandingColumn] = sharesOutstanding;
     adoTransaction.DataRows.Add(equityRow);
     // Update the record in the SQL database.
     SqlCommand sqlCommand = new SqlCommand("update \"Equity\" set \"RowVersion\"=@rowVersion,\"IssuerId\"=@issuerId,\"ExchangeId\"=@e" +
             "xchangeId,\"SettlementId\"=@settlementId,\"EquityTypeCode\"=@equityTypeCode,\"SharesO" +
             "utstanding\"=@sharesOutstanding where \"EquityId\"=@equityId");
     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("@equityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, equityId));
     sqlCommand.Parameters.Add(new SqlParameter("@issuerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, issuerId));
     sqlCommand.Parameters.Add(new SqlParameter("@exchangeId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, exchangeId));
     sqlCommand.Parameters.Add(new SqlParameter("@settlementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementId));
     sqlCommand.Parameters.Add(new SqlParameter("@equityTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, equityTypeCode));
     sqlCommand.Parameters.Add(new SqlParameter("@sharesOutstanding", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sharesOutstanding));
     // Update the record in the SQL database.
     sqlCommand.ExecuteNonQuery();
 }
示例#8
0
 /// <summary>Inserts a Equity 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="countryId">The value for the CountryId column.</param>
 /// <param name="typeCode">The value for the TypeCode column.</param>
 /// <param name="symbol">The value for the Symbol column.</param>
 /// <param name="issuerId">The value for the IssuerId column.</param>
 /// <param name="exchangeId">The value for the ExchangeId column.</param>
 /// <param name="settlementId">The value for the SettlementId column.</param>
 /// <param name="securityTypeCode">The value for the SecurityTypeCode column.</param>
 /// <param name="equityTypeCode">The value for the EquityTypeCode column.</param>
 /// <param name="priceFactor">The value for the PriceFactor column.</param>
 /// <param name="quantityFactor">The value for the QuantityFactor column.</param>
 /// <param name="sharesOutstanding">The value for the SharesOutstanding 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, 
             int countryId, 
             object typeCode, 
             object symbol, 
             object issuerId, 
             object exchangeId, 
             int settlementId, 
             object securityTypeCode, 
             int equityTypeCode, 
             object priceFactor, 
             object quantityFactor, 
             object sharesOutstanding)
 {
     // Accessor for the Equity Table.
     ServerDataModel.EquityDataTable equityTable = ServerDataModel.Equity;
     // Apply Defaults
     if ((issuerId == null))
     {
         issuerId = System.DBNull.Value;
     }
     if ((exchangeId == null))
     {
         exchangeId = System.DBNull.Value;
     }
     if ((securityTypeCode == null))
     {
         securityTypeCode = 1;
     }
     if ((priceFactor == null))
     {
         priceFactor = 1.0m;
     }
     if ((quantityFactor == null))
     {
         quantityFactor = 1.0m;
     }
     if ((sharesOutstanding == null))
     {
         sharesOutstanding = System.DBNull.Value;
     }
     // Insert the base members using the base class.
     int equityId = Security.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, countryId, typeCode, ((int)(securityTypeCode)), ((decimal)(quantityFactor)), ((decimal)(priceFactor)), symbol);
     // Increment the row version
     rowVersion = ServerDataModel.RowVersion.Increment();
     // Insert the record into the ADO database.
     ServerDataModel.EquityRow equityRow = equityTable.NewEquityRow();
     equityRow[equityTable.RowVersionColumn] = rowVersion;
     equityRow[equityTable.EquityIdColumn] = equityId;
     equityRow[equityTable.IssuerIdColumn] = issuerId;
     equityRow[equityTable.ExchangeIdColumn] = exchangeId;
     equityRow[equityTable.SettlementIdColumn] = settlementId;
     equityRow[equityTable.EquityTypeCodeColumn] = equityTypeCode;
     equityRow[equityTable.SharesOutstandingColumn] = sharesOutstanding;
     equityTable.AddEquityRow(equityRow);
     adoTransaction.DataRows.Add(equityRow);
     // Insert the record into the SQL database.
     SqlCommand sqlCommand = new SqlCommand("insert \"Equity\" (\"rowVersion\",EquityId,IssuerId,ExchangeId,SettlementId,EquityTyp" +
             "eCode,SharesOutstanding) values (@rowVersion,@equityId,@issuerId,@exchangeId,@se" +
             "ttlementId,@equityTypeCode,@sharesOutstanding)");
     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("@equityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, equityId));
     sqlCommand.Parameters.Add(new SqlParameter("@issuerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, issuerId));
     sqlCommand.Parameters.Add(new SqlParameter("@exchangeId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, exchangeId));
     sqlCommand.Parameters.Add(new SqlParameter("@settlementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementId));
     sqlCommand.Parameters.Add(new SqlParameter("@equityTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, equityTypeCode));
     sqlCommand.Parameters.Add(new SqlParameter("@sharesOutstanding", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sharesOutstanding));
     sqlCommand.ExecuteNonQuery();
     // Return Statements
     return equityRow.EquityId;
 }
示例#9
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.
            ServerDataModel.SecurityDataTable securityTable = ServerDataModel.Security;
            // This record can be used to iterate through all the children.
            ServerDataModel.SecurityRow securityRow = securityTable.FindBySecurityId(securityId);
            // Archive the child records.
            for (int index = 0; (index < securityRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = securityRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < securityRow.GetAllocationRowsByFKSecurityAllocationSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.AllocationRow childAllocationRow = securityRow.GetAllocationRowsByFKSecurityAllocationSecurityId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < securityRow.GetAllocationRowsByFKSecurityAllocationSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.AllocationRow childAllocationRow = securityRow.GetAllocationRowsByFKSecurityAllocationSettlementId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.BlockOrderRow childBlockOrderRow = securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSecurityId()[index];
                BlockOrder.Archive(adoTransaction, sqlTransaction, childBlockOrderRow.RowVersion, childBlockOrderRow.BlockOrderId);
            }
            for (int index = 0; (index < securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.BlockOrderRow childBlockOrderRow = securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSettlementId()[index];
                BlockOrder.Archive(adoTransaction, sqlTransaction, childBlockOrderRow.RowVersion, childBlockOrderRow.BlockOrderId);
            }
            for (int index = 0; (index < securityRow.GetBlotterMapRows().Length); index = (index + 1))
            {
                ServerDataModel.BlotterMapRow childBlotterMapRow = securityRow.GetBlotterMapRows()[index];
                BlotterMap.Archive(adoTransaction, sqlTransaction, childBlotterMapRow.RowVersion, childBlotterMapRow.BlotterMapId);
            }
            for (int index = 0; (index < securityRow.GetDebtRowsByFKSecurityDebtDebtId().Length); index = (index + 1))
            {
                ServerDataModel.DebtRow childDebtRow = securityRow.GetDebtRowsByFKSecurityDebtDebtId()[index];
                Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId);
            }
            for (int index = 0; (index < securityRow.GetDebtRowsByFKSecurityDebtSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.DebtRow childDebtRow = securityRow.GetDebtRowsByFKSecurityDebtSettlementId()[index];
                Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId);
            }
            for (int index = 0; (index < securityRow.GetCurrencyRows().Length); index = (index + 1))
            {
                ServerDataModel.CurrencyRow childCurrencyRow = securityRow.GetCurrencyRows()[index];
                Currency.ArchiveChildren(adoTransaction, sqlTransaction, childCurrencyRow.RowVersion, childCurrencyRow.CurrencyId);
            }
            for (int index = 0; (index < securityRow.GetEquityRowsByFKSecurityEquityEquityId().Length); index = (index + 1))
            {
                ServerDataModel.EquityRow childEquityRow = securityRow.GetEquityRowsByFKSecurityEquityEquityId()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            for (int index = 0; (index < securityRow.GetEquityRowsByFKSecurityEquitySettlementId().Length); index = (index + 1))
            {
                ServerDataModel.EquityRow childEquityRow = securityRow.GetEquityRowsByFKSecurityEquitySettlementId()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            for (int index = 0; (index < securityRow.GetOrderRowsByFKSecurityOrderSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.OrderRow childOrderRow = securityRow.GetOrderRowsByFKSecurityOrderSecurityId()[index];
                Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId);
            }
            for (int index = 0; (index < securityRow.GetOrderRowsByFKSecurityOrderSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.OrderRow childOrderRow = securityRow.GetOrderRowsByFKSecurityOrderSettlementId()[index];
                Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId);
            }
            for (int index = 0; (index < securityRow.GetPositionRows().Length); index = (index + 1))
            {
                ServerDataModel.PositionRow childPositionRow = securityRow.GetPositionRows()[index];
                Position.Archive(adoTransaction, sqlTransaction, childPositionRow.RowVersion, childPositionRow.AccountId, childPositionRow.SecurityId, childPositionRow.PositionTypeCode);
            }
            for (int index = 0; (index < securityRow.GetPositionTargetRows().Length); index = (index + 1))
            {
                ServerDataModel.PositionTargetRow childPositionTargetRow = securityRow.GetPositionTargetRows()[index];
                PositionTarget.Archive(adoTransaction, sqlTransaction, childPositionTargetRow.RowVersion, childPositionTargetRow.ModelId, childPositionTargetRow.SecurityId, childPositionTargetRow.PositionTypeCode);
            }
            for (int index = 0; (index < securityRow.GetPriceRows().Length); index = (index + 1))
            {
                ServerDataModel.PriceRow childPriceRow = securityRow.GetPriceRows()[index];
                Price.Archive(adoTransaction, sqlTransaction, childPriceRow.RowVersion, childPriceRow.SecurityId, childPriceRow.CurrencyId);
            }
            for (int index = 0; (index < securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.ProposedOrderRow childProposedOrderRow = securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSecurityId()[index];
                ProposedOrder.Archive(adoTransaction, sqlTransaction, childProposedOrderRow.RowVersion, childProposedOrderRow.ProposedOrderId);
            }
            for (int index = 0; (index < securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.ProposedOrderRow childProposedOrderRow = securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSettlementId()[index];
                ProposedOrder.Archive(adoTransaction, sqlTransaction, childProposedOrderRow.RowVersion, childProposedOrderRow.ProposedOrderId);
            }
            for (int index = 0; (index < securityRow.GetTaxLotRows().Length); index = (index + 1))
            {
                ServerDataModel.TaxLotRow childTaxLotRow = securityRow.GetTaxLotRows()[index];
                TaxLot.Archive(adoTransaction, sqlTransaction, childTaxLotRow.RowVersion, childTaxLotRow.TaxLotId);
            }
            for (int index = 0; (index < securityRow.GetViolationRows().Length); index = (index + 1))
            {
                ServerDataModel.ViolationRow childViolationRow = securityRow.GetViolationRows()[index];
                Violation.Archive(adoTransaction, sqlTransaction, childViolationRow.RowVersion, childViolationRow.ViolationId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.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();
        }
示例#10
0
 /// <summary>Loads a Equity 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 Equity Table.
     ServerDataModel.EquityDataTable equityTable = ServerDataModel.Equity;
     // 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;
     string externalCountryId = parameters["countryId"];
     object externalTypeCode = parameters["typeCode"].Value;
     object symbol = parameters["symbol"].Value;
     string externalEquityId = parameters["equityId"];
     object issuerId = parameters["issuerId"].Value;
     object externalExchangeId = parameters["exchangeId"].Value;
     string externalSettlementId = parameters["settlementId"];
     object externalSecurityTypeCode = parameters["securityTypeCode"].Value;
     string externalEquityTypeCode = parameters["equityTypeCode"];
     object priceFactor = parameters["priceFactor"].Value;
     object quantityFactor = parameters["quantityFactor"].Value;
     object sharesOutstanding = parameters["sharesOutstanding"].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 typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     int equityId = Security.FindKey(configurationId, "equityId", externalEquityId);
     object exchangeId = Exchange.FindOptionalKey(configurationId, "exchangeId", externalExchangeId);
     int settlementId = Security.FindRequiredKey(configurationId, "settlementId", externalSettlementId);
     object securityTypeCode = SecurityType.FindOptionalKey(configurationId, "securityTypeCode", externalSecurityTypeCode);
     int equityTypeCode = EquityType.FindRequiredKey(configurationId, "equityTypeCode", externalEquityTypeCode);
     ServerDataModel.EquityRow equityRow = equityTable.FindByEquityId(equityId);
     // 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 ((equityRow == 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 = Equity.GetExternalKeyIndex(configurationId, "equityId");
         object[] externalIdArray = new object[8];
         externalIdArray[externalKeyIndex] = externalEquityId;
         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.Quasar.Core.Equity.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, countryId, typeCode, symbol, issuerId, exchangeId, settlementId, securityTypeCode, equityTypeCode, priceFactor, quantityFactor, sharesOutstanding);
     }
     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)(equityRow[equityTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Quasar.Core.Equity.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, countryId, typeCode, symbol, equityId, issuerId, exchangeId, settlementId, securityTypeCode, equityTypeCode, priceFactor, quantityFactor, sharesOutstanding);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }