コード例 #1
0
ファイル: Province.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Archives a Province 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="provinceId">The value for the ProvinceId 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 provinceId)
        {
            // Accessor for the Province Table.
            ServerDataModel.ProvinceDataTable provinceTable = ServerDataModel.Province;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.ProvinceRow provinceRow = provinceTable.FindByProvinceId(provinceId);
            if ((provinceRow == null))
            {
                throw new Exception(string.Format("The Province table does not have an element identified by {0}", provinceId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((provinceRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < provinceRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = provinceRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            provinceRow[provinceTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(provinceRow);
            provinceRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Province\" set \"IsArchived\" = 1 where \"ProvinceId\"=@provinceId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@provinceId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, provinceId));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #2
0
ファイル: Currency.cs プロジェクト: DonaldAirey/quasar
        /// <summary>ArchiveChildrens a Currency 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="currencyId">The value for the CurrencyId 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 currencyId)
        {
            // Accessor for the Currency Table.
            ServerDataModel.CurrencyDataTable currencyTable = ServerDataModel.Currency;
            // This record can be used to iterate through all the children.
            ServerDataModel.CurrencyRow currencyRow = currencyTable.FindByCurrencyId(currencyId);
            // Archive the child records.
            for (int index = 0; (index < currencyRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = currencyRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < currencyRow.GetPriceRows().Length); index = (index + 1))
            {
                ServerDataModel.PriceRow childPriceRow = currencyRow.GetPriceRows()[index];
                Price.Archive(adoTransaction, sqlTransaction, childPriceRow.RowVersion, childPriceRow.SecurityId, childPriceRow.CurrencyId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            currencyRow[currencyTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(currencyRow);
            currencyRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Currency\" set \"IsArchived\" = 1 where \"CurrencyId\"=@currencyId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@currencyId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, currencyId));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #3
0
        /// <summary>ArchiveChildrens a Scheme 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="schemeId">The value for the SchemeId 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 schemeId)
        {
            // Accessor for the Scheme Table.
            ServerDataModel.SchemeDataTable schemeTable = ServerDataModel.Scheme;
            // This record can be used to iterate through all the children.
            ServerDataModel.SchemeRow schemeRow = schemeTable.FindBySchemeId(schemeId);
            // Archive the child records.
            for (int index = 0; (index < schemeRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = schemeRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < schemeRow.GetModelRows().Length); index = (index + 1))
            {
                ServerDataModel.ModelRow childModelRow = schemeRow.GetModelRows()[index];
                Model.ArchiveChildren(adoTransaction, sqlTransaction, childModelRow.RowVersion, childModelRow.ModelId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            schemeRow[schemeTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(schemeRow);
            schemeRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Scheme\" set \"IsArchived\" = 1 where \"SchemeId\"=@schemeId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@schemeId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, schemeId));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #4
0
 /// <summary>Collects the table lock request(s) for an Update operation</summary>
 /// <param name="adoTransaction">A list of locks required for this operation.</param>
 public static void LockInsert(AdoTransaction adoTransaction, object blockOrderId, object accountId, object securityId, object settlementId, object brokerId, object positionTypeCode, object transactionTypeCode, object timeInForceCode, object orderTypeCode, object conditionCode, object createdUserId, object modifiedUserId)
 {
     // Lock the block order record.
     if (blockOrderId != null)
     {
         ServerDataModel.BlockOrderRow blockOrderRow = ServerDataModel.BlockOrder.FindByBlockOrderId((int)blockOrderId);
         if ((blockOrderRow != null))
         {
             adoTransaction.LockRequests.Add(new RowReaderRequest(blockOrderRow));
         }
     }
     // Lock the account record.
     if (accountId != null)
     {
         ServerDataModel.AccountRow accountRow = ServerDataModel.Account.FindByAccountId((int)accountId);
         if ((accountRow != null))
         {
             adoTransaction.LockRequests.Add(new RowReaderRequest(accountRow));
         }
     }
     // Lock the security record.
     if (securityId != null)
     {
         ServerDataModel.SecurityRow securityRow = ServerDataModel.Security.FindBySecurityId((int)securityId);
         if ((securityRow != null))
         {
             adoTransaction.LockRequests.Add(new RowReaderRequest(securityRow));
         }
     }
     // Lock the settlement record.
     if (settlementId != null)
     {
         ServerDataModel.SecurityRow settlementRow = ServerDataModel.Security.FindBySecurityId((int)settlementId);
         if ((settlementRow != null))
         {
             adoTransaction.LockRequests.Add(new RowReaderRequest(settlementRow));
         }
     }
     // Lock the broker record.
     if (brokerId != null)
     {
         ServerDataModel.BrokerRow brokerRow = ServerDataModel.Broker.FindByBrokerId((int)brokerId);
         if ((brokerRow != null))
         {
             adoTransaction.LockRequests.Add(new RowReaderRequest(brokerRow));
         }
     }
     // Lock the positionTypeCode record.
     if (positionTypeCode != null)
     {
         ServerDataModel.PositionTypeRow positionTypeRow = ServerDataModel.PositionType.FindByPositionTypeCode((int)positionTypeCode);
         if ((positionTypeRow != null))
         {
             adoTransaction.LockRequests.Add(new RowReaderRequest(positionTypeRow));
         }
     }
 }
コード例 #5
0
ファイル: Stylesheet.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Archives a Stylesheet record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="RowVersion">The version number of this row.</param>
        /// <param name="stylesheetId">The value for the StylesheetId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int stylesheetId)
        {
            // Accessor for the Stylesheet Table.
            ServerDataModel.StylesheetDataTable stylesheetTable = ServerDataModel.Stylesheet;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.StylesheetRow stylesheetRow = stylesheetTable.FindByStylesheetId(stylesheetId);
            if ((stylesheetRow == null))
            {
                throw new Exception(string.Format("The Stylesheet table does not have an element identified by {0}", stylesheetId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((stylesheetRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < stylesheetRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = stylesheetRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByFKStylesheetBlotterBlockOrderStylesheetId().Length); index = (index + 1))
            {
                ServerDataModel.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByFKStylesheetBlotterBlockOrderStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByFKStylesheetBlotterPlacementStylesheetId().Length); index = (index + 1))
            {
                ServerDataModel.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByFKStylesheetBlotterPlacementStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByFKStylesheetBlotterExecutionStylesheetId().Length); index = (index + 1))
            {
                ServerDataModel.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByFKStylesheetBlotterExecutionStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByFKStylesheetBlotterTicketStylesheetId().Length); index = (index + 1))
            {
                ServerDataModel.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByFKStylesheetBlotterTicketStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            stylesheetRow[stylesheetTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(stylesheetRow);
            stylesheetRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Stylesheet\" set \"IsArchived\" = 1 where \"StylesheetId\"=@stylesheetId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@stylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, stylesheetId));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #6
0
ファイル: Country.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Deletes a Country 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="countryId">The value for the CountryId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public static void Delete(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int countryId)
        {
            // Accessor for the Country Table.
            ServerDataModel.CountryDataTable countryTable = ServerDataModel.Country;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.CountryRow countryRow = countryTable.FindByCountryId(countryId);
            if ((countryRow == null))
            {
                throw new Exception(string.Format("The Country table does not have an element identified by {0}", countryId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((countryRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Delete the child records.
            for (int index = 0; (index < countryRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = countryRow.GetAccountRows()[index];
                Account.DeleteChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < countryRow.GetSecurityRows().Length); index = (index + 1))
            {
                ServerDataModel.SecurityRow childSecurityRow = countryRow.GetSecurityRows()[index];
                Security.DeleteChildren(adoTransaction, sqlTransaction, childSecurityRow.RowVersion, childSecurityRow.SecurityId);
            }
            for (int index = 0; (index < countryRow.GetHolidayRows().Length); index = (index + 1))
            {
                ServerDataModel.HolidayRow childHolidayRow = countryRow.GetHolidayRows()[index];
                Holiday.Delete(adoTransaction, sqlTransaction, childHolidayRow.RowVersion, childHolidayRow.HolidayId);
            }
            for (int index = 0; (index < countryRow.GetProvinceRows().Length); index = (index + 1))
            {
                ServerDataModel.ProvinceRow childProvinceRow = countryRow.GetProvinceRows()[index];
                Province.Delete(adoTransaction, sqlTransaction, childProvinceRow.RowVersion, childProvinceRow.ProvinceId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            countryRow[countryTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(countryRow);
            countryRow.Delete();
            // Delete the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Country\" set \"IsDeleted\" = 1 where \"CountryId\"=@countryId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@countryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, countryId));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #7
0
        /// <summary>Deletes a TimeInForce 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="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public static void Delete(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int timeInForceCode)
        {
            // Accessor for the TimeInForce Table.
            ServerDataModel.TimeInForceDataTable timeInForceTable = ServerDataModel.TimeInForce;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.TimeInForceRow timeInForceRow = timeInForceTable.FindByTimeInForceCode(timeInForceCode);
            if ((timeInForceRow == null))
            {
                throw new Exception(string.Format("The TimeInForce table does not have an element identified by {0}", timeInForceCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((timeInForceRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Delete the child records.
            for (int index = 0; (index < timeInForceRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = timeInForceRow.GetAccountRows()[index];
                Account.DeleteChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < timeInForceRow.GetOrderRows().Length); index = (index + 1))
            {
                ServerDataModel.OrderRow childOrderRow = timeInForceRow.GetOrderRows()[index];
                Order.Delete(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId);
            }
            for (int index = 0; (index < timeInForceRow.GetPlacementRows().Length); index = (index + 1))
            {
                ServerDataModel.PlacementRow childPlacementRow = timeInForceRow.GetPlacementRows()[index];
                Placement.Delete(adoTransaction, sqlTransaction, childPlacementRow.RowVersion, childPlacementRow.PlacementId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            timeInForceRow[timeInForceTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(timeInForceRow);
            timeInForceRow.Delete();
            // Delete the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"TimeInForce\" set \"IsDeleted\" = 1 where \"TimeInForceCode\"=@timeInForceCode" +
                                                   "");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@timeInForceCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, timeInForceCode));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #8
0
ファイル: Account.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Archives a Account 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 Account Table.
            ServerDataModel.AccountDataTable accountTable = ServerDataModel.Account;
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction    = parameters["adoTransaction"];
            SqlTransaction sqlTransaction    = parameters["sqlTransaction"];
            object         configurationId   = parameters["configurationId"].Value;
            string         externalAccountId = parameters["accountId"];
            // 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 accountId = Account.FindRequiredKey(configurationId, "accountId", externalAccountId);

            // This disables the concurrency checking logic by finding the current row version and passing it to the
            // internal method.
            ServerDataModel.AccountRow accountRow = accountTable.FindByAccountId(accountId);
            rowVersion = ((long)(accountRow[accountTable.RowVersionColumn]));
            // Call the internal method to complete the operation.
            MarkThree.Quasar.Core.Account.Archive(adoTransaction, sqlTransaction, rowVersion, accountId);
        }
コード例 #9
0
ファイル: Blotter.cs プロジェクト: DonaldAirey/quasar
        /// <summary>ArchiveChildrens a Blotter record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">the version number of this row.</param>
        /// <param name="blotterId">The value for the BlotterId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int blotterId)
        {
            // Accessor for the Blotter Table.
            ServerDataModel.BlotterDataTable blotterTable = ServerDataModel.Blotter;
            // This record can be used to iterate through all the children.
            ServerDataModel.BlotterRow blotterRow = blotterTable.FindByBlotterId(blotterId);
            // Archive the child records.
            for (int index = 0; (index < blotterRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = blotterRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < blotterRow.GetBlotterMapRows().Length); index = (index + 1))
            {
                ServerDataModel.BlotterMapRow childBlotterMapRow = blotterRow.GetBlotterMapRows()[index];
                BlotterMap.Archive(adoTransaction, sqlTransaction, childBlotterMapRow.RowVersion, childBlotterMapRow.BlotterMapId);
            }
            for (int index = 0; (index < blotterRow.GetBlockOrderRows().Length); index = (index + 1))
            {
                ServerDataModel.BlockOrderRow childBlockOrderRow = blotterRow.GetBlockOrderRows()[index];
                BlockOrder.Archive(adoTransaction, sqlTransaction, childBlockOrderRow.RowVersion, childBlockOrderRow.BlockOrderId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            blotterRow[blotterTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(blotterRow);
            blotterRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Blotter\" set \"IsArchived\" = 1 where \"BlotterId\"=@blotterId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@blotterId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blotterId));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #10
0
        /// <summary>ArchiveChildrens a Model 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="modelId">The value for the ModelId 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 modelId)
        {
            // Accessor for the Model Table.
            ServerDataModel.ModelDataTable modelTable = ServerDataModel.Model;
            // This record can be used to iterate through all the children.
            ServerDataModel.ModelRow modelRow = modelTable.FindByModelId(modelId);
            // Archive the child records.
            for (int index = 0; (index < modelRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = modelRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < modelRow.GetPositionTargetRows().Length); index = (index + 1))
            {
                ServerDataModel.PositionTargetRow childPositionTargetRow = modelRow.GetPositionTargetRows()[index];
                PositionTarget.Archive(adoTransaction, sqlTransaction, childPositionTargetRow.RowVersion, childPositionTargetRow.ModelId, childPositionTargetRow.SecurityId, childPositionTargetRow.PositionTypeCode);
            }
            for (int index = 0; (index < modelRow.GetSectorTargetRows().Length); index = (index + 1))
            {
                ServerDataModel.SectorTargetRow childSectorTargetRow = modelRow.GetSectorTargetRows()[index];
                SectorTarget.Archive(adoTransaction, sqlTransaction, childSectorTargetRow.RowVersion, childSectorTargetRow.ModelId, childSectorTargetRow.SectorId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            modelRow[modelTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(modelRow);
            modelRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Model\" set \"IsArchived\" = 1 where \"ModelId\"=@modelId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@modelId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modelId));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #11
0
ファイル: Object.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Archives a Object record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="RowVersion">The version number of this row.</param>
        /// <param name="objectId">The value for the ObjectId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int objectId)
        {
            // Accessor for the Object Table.
            ServerDataModel.ObjectDataTable objectTable = ServerDataModel.Object;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.ObjectRow objectRow = objectTable.FindByObjectId(objectId);
            if ((objectRow == null))
            {
                throw new Exception(string.Format("The Object table does not have an element identified by {0}", objectId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((objectRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < objectRow.GetFolderRows().Length); index = (index + 1))
            {
                ServerDataModel.FolderRow childFolderRow = objectRow.GetFolderRows()[index];
                Folder.ArchiveChildren(adoTransaction, sqlTransaction, childFolderRow.RowVersion, childFolderRow.FolderId);
            }
            for (int index = 0; (index < objectRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = objectRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < objectRow.GetBlotterRows().Length); index = (index + 1))
            {
                ServerDataModel.BlotterRow childBlotterRow = objectRow.GetBlotterRows()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < objectRow.GetBrokerRows().Length); index = (index + 1))
            {
                ServerDataModel.BrokerRow childBrokerRow = objectRow.GetBrokerRows()[index];
                Broker.ArchiveChildren(adoTransaction, sqlTransaction, childBrokerRow.RowVersion, childBrokerRow.BrokerId);
            }
            for (int index = 0; (index < objectRow.GetIssuerRows().Length); index = (index + 1))
            {
                ServerDataModel.IssuerRow childIssuerRow = objectRow.GetIssuerRows()[index];
                Issuer.ArchiveChildren(adoTransaction, sqlTransaction, childIssuerRow.RowVersion, childIssuerRow.IssuerId);
            }
            for (int index = 0; (index < objectRow.GetUserRows().Length); index = (index + 1))
            {
                ServerDataModel.UserRow childUserRow = objectRow.GetUserRows()[index];
                User.ArchiveChildren(adoTransaction, sqlTransaction, childUserRow.RowVersion, childUserRow.UserId);
            }
            for (int index = 0; (index < objectRow.GetModelRows().Length); index = (index + 1))
            {
                ServerDataModel.ModelRow childModelRow = objectRow.GetModelRows()[index];
                Model.ArchiveChildren(adoTransaction, sqlTransaction, childModelRow.RowVersion, childModelRow.ModelId);
            }
            for (int index = 0; (index < objectRow.GetObjectTreeRowsByFKObjectObjectTreeChildId().Length); index = (index + 1))
            {
                ServerDataModel.ObjectTreeRow childObjectTreeRow = objectRow.GetObjectTreeRowsByFKObjectObjectTreeChildId()[index];
                ObjectTree.Archive(adoTransaction, sqlTransaction, childObjectTreeRow.RowVersion, childObjectTreeRow.ParentId, childObjectTreeRow.ChildId);
            }
            for (int index = 0; (index < objectRow.GetObjectTreeRowsByFKObjectObjectTreeParentId().Length); index = (index + 1))
            {
                ServerDataModel.ObjectTreeRow childObjectTreeRow = objectRow.GetObjectTreeRowsByFKObjectObjectTreeParentId()[index];
                ObjectTree.Archive(adoTransaction, sqlTransaction, childObjectTreeRow.RowVersion, childObjectTreeRow.ParentId, childObjectTreeRow.ChildId);
            }
            for (int index = 0; (index < objectRow.GetSchemeRows().Length); index = (index + 1))
            {
                ServerDataModel.SchemeRow childSchemeRow = objectRow.GetSchemeRows()[index];
                Scheme.ArchiveChildren(adoTransaction, sqlTransaction, childSchemeRow.RowVersion, childSchemeRow.SchemeId);
            }
            for (int index = 0; (index < objectRow.GetSectorRows().Length); index = (index + 1))
            {
                ServerDataModel.SectorRow childSectorRow = objectRow.GetSectorRows()[index];
                Sector.ArchiveChildren(adoTransaction, sqlTransaction, childSectorRow.RowVersion, childSectorRow.SectorId);
            }
            for (int index = 0; (index < objectRow.GetSecurityRows().Length); index = (index + 1))
            {
                ServerDataModel.SecurityRow childSecurityRow = objectRow.GetSecurityRows()[index];
                Security.ArchiveChildren(adoTransaction, sqlTransaction, childSecurityRow.RowVersion, childSecurityRow.SecurityId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            objectRow[objectTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(objectRow);
            objectRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Object\" set \"IsArchived\" = 1 where \"ObjectId\"=@objectId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@objectId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, objectId));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #12
0
ファイル: Account.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Loads a Account 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 Account Table.
            ServerDataModel.AccountDataTable accountTable = ServerDataModel.Account;
            // 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         externalAccountId       = parameters["accountId"];
            string         externalCurrencyId      = parameters["currencyId"];
            object         externalSchemeId        = parameters["schemeId"].Value;
            object         externalModelId         = parameters["modelId"].Value;
            object         externalBlotterId       = parameters["blotterId"].Value;
            string         externalStylesheetId    = parameters["stylesheetId"];
            object         externalCountryId       = parameters["countryId"].Value;
            object         externalProvinceId      = parameters["provinceId"].Value;
            object         externalTypeCode        = parameters["typeCode"].Value;
            string         externalAccountTypeCode = parameters["accountTypeCode"];
            object         externalLotHandlingCode = parameters["lotHandlingCode"].Value;
            object         externalTimeInForceCode = parameters["timeInForceCode"].Value;
            object         mnemonic                = parameters["mnemonic"].Value;
            object         address0                = parameters["address0"].Value;
            object         address1                = parameters["address1"].Value;
            object         address2                = parameters["address2"].Value;
            object         city                    = parameters["city"].Value;
            object         postalCode              = parameters["postalCode"].Value;
            object         userData0               = parameters["userData0"].Value;
            object         userData1               = parameters["userData1"].Value;
            object         userData2               = parameters["userData2"].Value;
            object         userData3               = parameters["userData3"].Value;
            object         userData4               = parameters["userData4"].Value;
            object         userData5               = parameters["userData5"].Value;
            object         userData6               = parameters["userData6"].Value;
            object         userData7               = parameters["userData7"].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    accountId       = Object.FindKey(configurationId, "accountId", externalAccountId);
            int    currencyId      = Security.FindRequiredKey(configurationId, "currencyId", externalCurrencyId);
            object schemeId        = Scheme.FindOptionalKey(configurationId, "schemeId", externalSchemeId);
            object modelId         = Model.FindOptionalKey(configurationId, "modelId", externalModelId);
            object blotterId       = Blotter.FindOptionalKey(configurationId, "blotterId", externalBlotterId);
            int    stylesheetId    = Stylesheet.FindRequiredKey(configurationId, "stylesheetId", externalStylesheetId);
            object countryId       = Country.FindOptionalKey(configurationId, "countryId", externalCountryId);
            object provinceId      = Province.FindOptionalKey(configurationId, "provinceId", externalProvinceId);
            object typeCode        = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
            int    accountTypeCode = AccountType.FindRequiredKey(configurationId, "accountTypeCode", externalAccountTypeCode);
            object lotHandlingCode = LotHandling.FindOptionalKey(configurationId, "lotHandlingCode", externalLotHandlingCode);
            object timeInForceCode = TimeInForce.FindOptionalKey(configurationId, "timeInForceCode", externalTimeInForceCode);

            ServerDataModel.AccountRow accountRow = accountTable.FindByAccountId(accountId);
            // 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 ((accountRow == 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 = Account.GetExternalKeyIndex(configurationId, "accountId");
                object[] externalIdArray  = new object[8];
                externalIdArray[externalKeyIndex] = externalAccountId;
                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.Account.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, currencyId, schemeId, modelId, blotterId, stylesheetId, countryId, provinceId, typeCode, accountTypeCode, lotHandlingCode, timeInForceCode, mnemonic, address0, address1, address2, city, postalCode, userData0, userData1, userData2, userData3, userData4, userData5, userData6, userData7);
            }
            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)(accountRow[accountTable.RowVersionColumn]));
                // Call the internal method to complete the operation.
                MarkThree.Quasar.Core.Account.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, accountId, currencyId, schemeId, modelId, blotterId, stylesheetId, countryId, provinceId, typeCode, accountTypeCode, lotHandlingCode, timeInForceCode, mnemonic, address0, address1, address2, city, postalCode, userData0, userData1, userData2, userData3, userData4, userData5, userData6, userData7);
            }
            // Return values.
            parameters["rowVersion"] = rowVersion;
        }
コード例 #13
0
ファイル: Account.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Updates a Account 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 Account Table.
            ServerDataModel.AccountDataTable accountTable = ServerDataModel.Account;
            // 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;
            string         externalAccountId       = ((string)(parameters["accountId"]));
            object         externalCurrencyId      = parameters["currencyId"].Value;
            object         externalSchemeId        = parameters["schemeId"].Value;
            object         externalModelId         = parameters["modelId"].Value;
            object         externalBlotterId       = parameters["blotterId"].Value;
            object         externalStylesheetId    = parameters["stylesheetId"].Value;
            object         externalCountryId       = parameters["countryId"].Value;
            object         externalProvinceId      = parameters["provinceId"].Value;
            object         externalTypeCode        = parameters["typeCode"].Value;
            object         externalAccountTypeCode = parameters["accountTypeCode"].Value;
            object         externalLotHandlingCode = parameters["lotHandlingCode"].Value;
            object         externalTimeInForceCode = parameters["timeInForceCode"].Value;
            object         mnemonic                = parameters["mnemonic"].Value;
            object         address0                = parameters["address0"].Value;
            object         address1                = parameters["address1"].Value;
            object         address2                = parameters["address2"].Value;
            object         city                    = parameters["city"].Value;
            object         postalCode              = parameters["postalCode"].Value;
            object         userData0               = parameters["userData0"].Value;
            object         userData1               = parameters["userData1"].Value;
            object         userData2               = parameters["userData2"].Value;
            object         userData3               = parameters["userData3"].Value;
            object         userData4               = parameters["userData4"].Value;
            object         userData5               = parameters["userData5"].Value;
            object         userData6               = parameters["userData6"].Value;
            object         userData7               = parameters["userData7"].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    accountId       = Object.FindRequiredKey(configurationId, "accountId", externalAccountId);
            object currencyId      = Security.FindOptionalKey(configurationId, "currencyId", externalCurrencyId);
            object schemeId        = Scheme.FindOptionalKey(configurationId, "schemeId", externalSchemeId);
            object modelId         = Model.FindOptionalKey(configurationId, "modelId", externalModelId);
            object blotterId       = Blotter.FindOptionalKey(configurationId, "blotterId", externalBlotterId);
            object stylesheetId    = Stylesheet.FindOptionalKey(configurationId, "stylesheetId", externalStylesheetId);
            object countryId       = Country.FindOptionalKey(configurationId, "countryId", externalCountryId);
            object provinceId      = Province.FindOptionalKey(configurationId, "provinceId", externalProvinceId);
            object typeCode        = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
            object accountTypeCode = AccountType.FindOptionalKey(configurationId, "accountTypeCode", externalAccountTypeCode);
            object lotHandlingCode = LotHandling.FindOptionalKey(configurationId, "lotHandlingCode", externalLotHandlingCode);
            object timeInForceCode = TimeInForce.FindOptionalKey(configurationId, "timeInForceCode", externalTimeInForceCode);

            // This disables the concurrency checking logic by finding the current row version and passing it to the
            // internal method.
            ServerDataModel.AccountRow accountRow = accountTable.FindByAccountId(accountId);
            rowVersion = ((long)(accountRow[accountTable.RowVersionColumn]));
            // Call the internal method to complete the operation.
            MarkThree.Quasar.Core.Account.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, accountId, currencyId, schemeId, modelId, blotterId, stylesheetId, countryId, provinceId, typeCode, accountTypeCode, lotHandlingCode, timeInForceCode, mnemonic, address0, address1, address2, city, postalCode, userData0, userData1, userData2, userData3, userData4, userData5, userData6, userData7);
            // Return values.
            parameters["rowVersion"] = rowVersion;
        }
コード例 #14
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();
        }