Exemple #1
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 Delete(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Delete' operation.
     adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.Status));
     BlockOrder.Archive(adoTransaction);
 }
Exemple #2
0
        /// <summary>Inserts a Issuer record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">The version number of 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="provinceId">The value for the ProvinceId column.</param>
        /// <param name="typeCode">The value for the TypeCode column.</param>
        /// <param name="issuerTypeCode">The value for the IssuerTypeCode column.</param>
        /// <param name="address0">The value for the Address0 column.</param>
        /// <param name="address1">The value for the Address1 column.</param>
        /// <param name="address2">The value for the Address2 column.</param>
        /// <param name="city">The value for the City column.</param>
        /// <param name="postalCode">The value for the PostalCode column.</param>
        /// <param name="rating0">The value for the Rating0 column.</param>
        /// <param name="rating1">The value for the Rating1 column.</param>
        /// <param name="rating2">The value for the Rating2 column.</param>
        /// <param name="rating3">The value for the Rating3 column.</param>
        /// <param name="userData0">The value for the UserData0 column.</param>
        /// <param name="userData1">The value for the UserData1 column.</param>
        /// <param name="userData2">The value for the UserData2 column.</param>
        /// <param name="userData3">The value for the UserData3 column.</param>
        /// <param name="userData4">The value for the UserData4 column.</param>
        /// <param name="userData5">The value for the UserData5 column.</param>
        /// <param name="userData6">The value for the UserData6 column.</param>
        /// <param name="userData7">The value for the UserData7 column.</param>
        public static int Insert(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object description,
            object externalId0,
            object externalId1,
            object externalId2,
            object externalId3,
            object externalId4,
            object externalId5,
            object externalId6,
            object externalId7,
            object groupPermission,
            object hidden,
            string name,
            object owner,
            object ownerPermission,
            object readOnly,
            object worldPermission,
            object countryId,
            object provinceId,
            object typeCode,
            int issuerTypeCode,
            object address0,
            object address1,
            object address2,
            object city,
            object postalCode,
            object rating0,
            object rating1,
            object rating2,
            object rating3,
            object userData0,
            object userData1,
            object userData2,
            object userData3,
            object userData4,
            object userData5,
            object userData6,
            object userData7)
        {
            // Accessor for the Issuer Table.
            ServerDataModel.IssuerDataTable issuerTable = ServerDataModel.Issuer;
            // Apply Defaults
            if ((countryId == null))
            {
                countryId = System.DBNull.Value;
            }
            if ((provinceId == null))
            {
                provinceId = System.DBNull.Value;
            }
            if ((typeCode == null))
            {
                typeCode = "Issuer";
            }
            if ((address0 == null))
            {
                address0 = System.DBNull.Value;
            }
            if ((address1 == null))
            {
                address1 = System.DBNull.Value;
            }
            if ((address2 == null))
            {
                address2 = System.DBNull.Value;
            }
            if ((city == null))
            {
                city = System.DBNull.Value;
            }
            if ((postalCode == null))
            {
                postalCode = System.DBNull.Value;
            }
            if ((rating0 == null))
            {
                rating0 = System.DBNull.Value;
            }
            if ((rating1 == null))
            {
                rating1 = System.DBNull.Value;
            }
            if ((rating2 == null))
            {
                rating2 = System.DBNull.Value;
            }
            if ((rating3 == null))
            {
                rating3 = System.DBNull.Value;
            }
            if ((userData0 == null))
            {
                userData0 = System.DBNull.Value;
            }
            if ((userData1 == null))
            {
                userData1 = System.DBNull.Value;
            }
            if ((userData2 == null))
            {
                userData2 = System.DBNull.Value;
            }
            if ((userData3 == null))
            {
                userData3 = System.DBNull.Value;
            }
            if ((userData4 == null))
            {
                userData4 = System.DBNull.Value;
            }
            if ((userData5 == null))
            {
                userData5 = System.DBNull.Value;
            }
            if ((userData6 == null))
            {
                userData6 = System.DBNull.Value;
            }
            if ((userData7 == null))
            {
                userData7 = System.DBNull.Value;
            }
            // Insert the base members using the base class.
            int issuerId = Object.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, typeCode, worldPermission);

            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.IssuerRow issuerRow = issuerTable.NewIssuerRow();
            issuerRow[issuerTable.RowVersionColumn]     = rowVersion;
            issuerRow[issuerTable.IssuerIdColumn]       = issuerId;
            issuerRow[issuerTable.CountryIdColumn]      = countryId;
            issuerRow[issuerTable.ProvinceIdColumn]     = provinceId;
            issuerRow[issuerTable.IssuerTypeCodeColumn] = issuerTypeCode;
            issuerRow[issuerTable.Address0Column]       = address0;
            issuerRow[issuerTable.Address1Column]       = address1;
            issuerRow[issuerTable.Address2Column]       = address2;
            issuerRow[issuerTable.CityColumn]           = city;
            issuerRow[issuerTable.PostalCodeColumn]     = postalCode;
            issuerRow[issuerTable.Rating0Column]        = rating0;
            issuerRow[issuerTable.Rating1Column]        = rating1;
            issuerRow[issuerTable.Rating2Column]        = rating2;
            issuerRow[issuerTable.Rating3Column]        = rating3;
            issuerRow[issuerTable.UserData0Column]      = userData0;
            issuerRow[issuerTable.UserData1Column]      = userData1;
            issuerRow[issuerTable.UserData2Column]      = userData2;
            issuerRow[issuerTable.UserData3Column]      = userData3;
            issuerRow[issuerTable.UserData4Column]      = userData4;
            issuerRow[issuerTable.UserData5Column]      = userData5;
            issuerRow[issuerTable.UserData6Column]      = userData6;
            issuerRow[issuerTable.UserData7Column]      = userData7;
            issuerTable.AddIssuerRow(issuerRow);
            adoTransaction.DataRows.Add(issuerRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Issuer"" (""rowVersion"",IssuerId,CountryId,ProvinceId,IssuerTypeCode,Address0,Address1,Address2,City,PostalCode,Rating0,Rating1,Rating2,Rating3,UserData0,UserData1,UserData2,UserData3,UserData4,UserData5,UserData6,UserData7) values (@rowVersion,@issuerId,@countryId,@provinceId,@issuerTypeCode,@address0,@address1,@address2,@city,@postalCode,@rating0,@rating1,@rating2,@rating3,@userData0,@userData1,@userData2,@userData3,@userData4,@userData5,@userData6,@userData7)");

            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("@issuerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, issuerId));
            sqlCommand.Parameters.Add(new SqlParameter("@countryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, countryId));
            sqlCommand.Parameters.Add(new SqlParameter("@provinceId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, provinceId));
            sqlCommand.Parameters.Add(new SqlParameter("@issuerTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, issuerTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@address0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, address0));
            sqlCommand.Parameters.Add(new SqlParameter("@address1", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, address1));
            sqlCommand.Parameters.Add(new SqlParameter("@address2", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, address2));
            sqlCommand.Parameters.Add(new SqlParameter("@city", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, city));
            sqlCommand.Parameters.Add(new SqlParameter("@postalCode", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, postalCode));
            sqlCommand.Parameters.Add(new SqlParameter("@rating0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rating0));
            sqlCommand.Parameters.Add(new SqlParameter("@rating1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rating1));
            sqlCommand.Parameters.Add(new SqlParameter("@rating2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rating2));
            sqlCommand.Parameters.Add(new SqlParameter("@rating3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rating3));
            sqlCommand.Parameters.Add(new SqlParameter("@userData0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData0));
            sqlCommand.Parameters.Add(new SqlParameter("@userData1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData1));
            sqlCommand.Parameters.Add(new SqlParameter("@userData2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData2));
            sqlCommand.Parameters.Add(new SqlParameter("@userData3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData3));
            sqlCommand.Parameters.Add(new SqlParameter("@userData4", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData4));
            sqlCommand.Parameters.Add(new SqlParameter("@userData5", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData5));
            sqlCommand.Parameters.Add(new SqlParameter("@userData6", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData6));
            sqlCommand.Parameters.Add(new SqlParameter("@userData7", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData7));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(issuerRow.IssuerId);
        }
Exemple #3
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>
 internal static void DeleteChildren(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Delete' operation.
     adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.Issuer));
     Debt.DeleteChildren(adoTransaction);
 }
Exemple #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 Archive(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Archive' operation.
     adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.Position));
 }
Exemple #5
0
        /// <summary>Updates a Holiday 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="countryId">The value for the CountryId column.</param>
        /// <param name="date">The value for the Date column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="externalId1">The value for the ExternalId1 column.</param>
        /// <param name="holidayId">The value for the HolidayId column.</param>
        /// <param name="holidayTypeCode">The value for the HolidayTypeCode column.</param>
        public static void Update(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, object countryId, object date, object externalId0, object externalId1, int holidayId, object holidayTypeCode)
        {
            // Accessor for the Holiday Table.
            ServerMarketData.HolidayDataTable holidayTable = ServerMarketData.Holiday;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.HolidayRow holidayRow = holidayTable.FindByHolidayId(holidayId);
            if ((holidayRow == null))
            {
                throw new Exception(string.Format("The Holiday table does not have an element identified by {0}", holidayId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((holidayRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((countryId == null))
            {
                countryId = holidayRow[holidayTable.CountryIdColumn];
            }
            if ((date == null))
            {
                date = holidayRow[holidayTable.DateColumn];
            }
            if ((externalId0 == null))
            {
                externalId0 = holidayRow[holidayTable.ExternalId0Column];
            }
            if ((externalId1 == null))
            {
                externalId1 = holidayRow[holidayTable.ExternalId1Column];
            }
            if ((holidayTypeCode == null))
            {
                holidayTypeCode = holidayRow[holidayTable.HolidayTypeCodeColumn];
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            holidayRow[holidayTable.RowVersionColumn]      = rowVersion;
            holidayRow[holidayTable.CountryIdColumn]       = countryId;
            holidayRow[holidayTable.DateColumn]            = date;
            holidayRow[holidayTable.ExternalId0Column]     = externalId0;
            holidayRow[holidayTable.ExternalId1Column]     = externalId1;
            holidayRow[holidayTable.HolidayTypeCodeColumn] = holidayTypeCode;
            adoTransaction.DataRows.Add(holidayRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Holiday\" set \"RowVersion\"=@rowVersion,\"CountryId\"=@countryId,\"Date\"=@date" +
                                                   ",\"ExternalId0\"=@externalId0,\"ExternalId1\"=@externalId1,\"HolidayTypeCode\"=@holida" +
                                                   "yTypeCode where \"HolidayId\"=@holidayId");

            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("@countryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, countryId));
            sqlCommand.Parameters.Add(new SqlParameter("@date", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, date));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId1", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId1));
            sqlCommand.Parameters.Add(new SqlParameter("@holidayId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, holidayId));
            sqlCommand.Parameters.Add(new SqlParameter("@holidayTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, holidayTypeCode));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Exemple #6
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 Archive(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Archive' operation.
     adoTransaction.LockRequests.AddWriterLock(ServerMarketData.ObjectTreeLock);
 }
Exemple #7
0
 /// <summary>Updates a SourceOrder record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Update(ParameterList parameters)
 {
     // Accessor for the SourceOrder Table.
     ServerMarketData.SourceOrderDataTable sourceOrderTable = ServerMarketData.SourceOrder;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object createdTime = parameters["createdTime"].Value;
     object externalCreatedUserId = parameters["createdUserId"].Value;
     object externalDestinationId = parameters["destinationId"].Value;
     object isAdvertised = parameters["isAdvertised"].Value;
     object isAutoExecute = parameters["isAutoExecute"].Value;
     object isCanceled = parameters["isCanceled"].Value;
     object isHeld = parameters["isHeld"].Value;
     object isSteppedIn = parameters["isSteppedIn"].Value;
     object isSubmitted = parameters["isSubmitted"].Value;
     object limitPrice = parameters["limitPrice"].Value;
     object maximumVolatility = parameters["maximumVolatility"].Value;
     object modifiedTime = parameters["modifiedTime"].Value;
     object externalModifiedUserId = parameters["modifiedUserId"].Value;
     object newsFreeTime = parameters["newsFreeTime"].Value;
     object externalOrderTypeCode = parameters["orderTypeCode"].Value;
     object orderedQuantity = parameters["orderedQuantity"].Value;
     object externalPriceTypeCode = parameters["priceTypeCode"].Value;
     object receivedTime = parameters["receivedTime"].Value;
     object externalSecurityId = parameters["securityId"].Value;
     object externalSettlementId = parameters["settlementId"].Value;
     string externalSourceOrderId = ((string)(parameters["sourceOrderId"]));
     object startTime = parameters["startTime"].Value;
     object externalStatusCode = parameters["statusCode"].Value;
     object stopPrice = parameters["stopPrice"].Value;
     object stopTime = parameters["stopTime"].Value;
     object submittedQuantity = parameters["submittedQuantity"].Value;
     object submittedTime = parameters["submittedTime"].Value;
     object targetPrice = parameters["targetPrice"].Value;
     object externalTimeInForceCode = parameters["timeInForceCode"].Value;
     object externalWorkingOrderId = parameters["workingOrderId"].Value;
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     object createdUserId = User.FindOptionalKey(configurationId, "createdUserId", externalCreatedUserId);
     object destinationId = Destination.FindOptionalKey(configurationId, "destinationId", externalDestinationId);
     object modifiedUserId = User.FindOptionalKey(configurationId, "modifiedUserId", externalModifiedUserId);
     object orderTypeCode = OrderType.FindOptionalKey(configurationId, "orderTypeCode", externalOrderTypeCode);
     object priceTypeCode = PriceType.FindOptionalKey(configurationId, "priceTypeCode", externalPriceTypeCode);
     object securityId = Security.FindOptionalKey(configurationId, "securityId", externalSecurityId);
     object settlementId = Security.FindOptionalKey(configurationId, "settlementId", externalSettlementId);
     int sourceOrderId = SourceOrder.FindRequiredKey(configurationId, "sourceOrderId", externalSourceOrderId);
     object statusCode = Status.FindOptionalKey(configurationId, "statusCode", externalStatusCode);
     object timeInForceCode = TimeInForce.FindOptionalKey(configurationId, "timeInForceCode", externalTimeInForceCode);
     object workingOrderId = WorkingOrder.FindOptionalKey(configurationId, "workingOrderId", externalWorkingOrderId);
     // 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.
     ServerMarketData.SourceOrderRow sourceOrderRow = sourceOrderTable.FindBySourceOrderId(sourceOrderId);
     rowVersion = ((long)(sourceOrderRow[sourceOrderTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.SourceOrder.Update(adoTransaction, sqlTransaction, ref rowVersion, createdTime, createdUserId, destinationId, null, isAdvertised, isAutoExecute, isCanceled, isHeld, isSteppedIn, isSubmitted, limitPrice, maximumVolatility, modifiedTime, modifiedUserId, newsFreeTime, orderTypeCode, orderedQuantity, priceTypeCode, receivedTime, securityId, settlementId, sourceOrderId, startTime, statusCode, stopPrice, stopTime, submittedQuantity, submittedTime, targetPrice, timeInForceCode, workingOrderId);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemple #8
0
        /// <summary>Inserts a Execution record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="accruedInterest">The value for the AccruedInterest column.</param>
        /// <param name="brokerAccountId">The value for the BrokerAccountId column.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="commission">The value for the Commission column.</param>
        /// <param name="createdTime">The value for the CreatedTime column.</param>
        /// <param name="createdUserId">The value for the CreatedUserId column.</param>
        /// <param name="destinationOrderId">The value for the DestinationOrderId column.</param>
        /// <param name="destinationStateCode">The value for the DestinationStateCode column.</param>
        /// <param name="executionPrice">The value for the ExecutionPrice column.</param>
        /// <param name="executionQuantity">The value for the ExecutionQuantity column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="fixMessageId">The value for the FixMessageId column.</param>
        /// <param name="isHidden">The value for the IsHidden column.</param>
        /// <param name="modifiedTime">The value for the ModifiedTime column.</param>
        /// <param name="modifiedUserId">The value for the ModifiedUserId column.</param>
        /// <param name="originalDestinationOrderId">The value for the OriginalDestinationOrderId column.</param>
        /// <param name="originalPrice">The value for the OriginalPrice column.</param>
        /// <param name="originalQuantity">The value for the OriginalQuantity column.</param>
        /// <param name="settlementDate">The value for the SettlementDate column.</param>
        /// <param name="sourceExecutionId">The value for the SourceExecutionId column.</param>
        /// <param name="sourceStateCode">The value for the SourceStateCode column.</param>
        /// <param name="tradeDate">The value for the TradeDate column.</param>
        /// <param name="userFee0">The value for the UserFee0 column.</param>
        /// <param name="userFee1">The value for the UserFee1 column.</param>
        /// <param name="userFee2">The value for the UserFee2 column.</param>
        /// <param name="userFee3">The value for the UserFee3 column.</param>
        public static int Insert(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object accruedInterest,
            object brokerAccountId,
            object brokerId,
            object commission,
            object createdTime,
            object createdUserId,
            int destinationOrderId,
            int destinationStateCode,
            decimal executionPrice,
            decimal executionQuantity,
            object externalId0,
            object fixMessageId,
            object isHidden,
            object modifiedTime,
            object modifiedUserId,
            object originalDestinationOrderId,
            object originalPrice,
            object originalQuantity,
            System.DateTime settlementDate,
            object sourceExecutionId,
            int sourceStateCode,
            System.DateTime tradeDate,
            object userFee0,
            object userFee1,
            object userFee2,
            object userFee3)
        {
            // Accessor for the Execution Table.
            ServerMarketData.ExecutionDataTable executionTable = ServerMarketData.Execution;
            // Apply Defaults
            if ((accruedInterest == null))
            {
                accruedInterest = 0.0m;
            }
            if ((brokerAccountId == null))
            {
                brokerAccountId = System.DBNull.Value;
            }
            if ((brokerId == null))
            {
                brokerId = System.DBNull.Value;
            }
            if ((commission == null))
            {
                commission = 0.0m;
            }
            if ((createdTime == null))
            {
                createdTime = System.DBNull.Value;
            }
            if ((createdUserId == null))
            {
                createdUserId = System.DBNull.Value;
            }
            if ((externalId0 == null))
            {
                externalId0 = System.DBNull.Value;
            }
            if ((fixMessageId == null))
            {
                fixMessageId = System.DBNull.Value;
            }
            if ((isHidden == null))
            {
                isHidden = false;
            }
            if ((modifiedTime == null))
            {
                modifiedTime = System.DBNull.Value;
            }
            if ((modifiedUserId == null))
            {
                modifiedUserId = System.DBNull.Value;
            }
            if ((originalDestinationOrderId == null))
            {
                originalDestinationOrderId = System.DBNull.Value;
            }
            if ((originalPrice == null))
            {
                originalPrice = System.DBNull.Value;
            }
            if ((originalQuantity == null))
            {
                originalQuantity = System.DBNull.Value;
            }
            if ((sourceExecutionId == null))
            {
                sourceExecutionId = System.DBNull.Value;
            }
            if ((userFee0 == null))
            {
                userFee0 = 0.0m;
            }
            if ((userFee1 == null))
            {
                userFee1 = 0.0m;
            }
            if ((userFee2 == null))
            {
                userFee2 = 0.0m;
            }
            if ((userFee3 == null))
            {
                userFee3 = 0.0m;
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerMarketData.ExecutionRow executionRow = executionTable.NewExecutionRow();
            executionRow[executionTable.RowVersionColumn]                 = rowVersion;
            executionRow[executionTable.AccruedInterestColumn]            = accruedInterest;
            executionRow[executionTable.BrokerAccountIdColumn]            = brokerAccountId;
            executionRow[executionTable.BrokerIdColumn]                   = brokerId;
            executionRow[executionTable.CommissionColumn]                 = commission;
            executionRow[executionTable.CreatedTimeColumn]                = createdTime;
            executionRow[executionTable.CreatedUserIdColumn]              = createdUserId;
            executionRow[executionTable.DestinationOrderIdColumn]         = destinationOrderId;
            executionRow[executionTable.DestinationStateCodeColumn]       = destinationStateCode;
            executionRow[executionTable.ExecutionPriceColumn]             = executionPrice;
            executionRow[executionTable.ExecutionQuantityColumn]          = executionQuantity;
            executionRow[executionTable.ExternalId0Column]                = externalId0;
            executionRow[executionTable.FixMessageIdColumn]               = fixMessageId;
            executionRow[executionTable.IsHiddenColumn]                   = isHidden;
            executionRow[executionTable.ModifiedTimeColumn]               = modifiedTime;
            executionRow[executionTable.ModifiedUserIdColumn]             = modifiedUserId;
            executionRow[executionTable.OriginalDestinationOrderIdColumn] = originalDestinationOrderId;
            executionRow[executionTable.OriginalPriceColumn]              = originalPrice;
            executionRow[executionTable.OriginalQuantityColumn]           = originalQuantity;
            executionRow[executionTable.SettlementDateColumn]             = settlementDate;
            executionRow[executionTable.SourceExecutionIdColumn]          = sourceExecutionId;
            executionRow[executionTable.SourceStateCodeColumn]            = sourceStateCode;
            executionRow[executionTable.TradeDateColumn]                  = tradeDate;
            executionRow[executionTable.UserFee0Column]                   = userFee0;
            executionRow[executionTable.UserFee1Column]                   = userFee1;
            executionRow[executionTable.UserFee2Column]                   = userFee2;
            executionRow[executionTable.UserFee3Column]                   = userFee3;
            executionTable.AddExecutionRow(executionRow);
            adoTransaction.DataRows.Add(executionRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Execution"" (""rowVersion"",""AccruedInterest"",""BrokerAccountId"",""BrokerId"",""Commission"",""CreatedTime"",""CreatedUserId"",""DestinationOrderId"",""DestinationStateCode"",""ExecutionId"",""ExecutionPrice"",""ExecutionQuantity"",""ExternalId0"",""FixMessageId"",""IsHidden"",""ModifiedTime"",""ModifiedUserId"",""OriginalDestinationOrderId"",""OriginalPrice"",""OriginalQuantity"",""SettlementDate"",""SourceExecutionId"",""SourceStateCode"",""TradeDate"",""UserFee0"",""UserFee1"",""UserFee2"",""UserFee3"") values (@rowVersion,@accruedInterest,@brokerAccountId,@brokerId,@commission,@createdTime,@createdUserId,@destinationOrderId,@destinationStateCode,@executionId,@executionPrice,@executionQuantity,@externalId0,@fixMessageId,@isHidden,@modifiedTime,@modifiedUserId,@originalDestinationOrderId,@originalPrice,@originalQuantity,@settlementDate,@sourceExecutionId,@sourceStateCode,@tradeDate,@userFee0,@userFee1,@userFee2,@userFee3)");

            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("@accruedInterest", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accruedInterest));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerAccountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerAccountId));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.Parameters.Add(new SqlParameter("@commission", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, commission));
            sqlCommand.Parameters.Add(new SqlParameter("@createdTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdTime));
            sqlCommand.Parameters.Add(new SqlParameter("@createdUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdUserId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationStateCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationStateCode));
            sqlCommand.Parameters.Add(new SqlParameter("@executionId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionRow[executionTable.ExecutionIdColumn]));
            sqlCommand.Parameters.Add(new SqlParameter("@executionPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionPrice));
            sqlCommand.Parameters.Add(new SqlParameter("@executionQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@fixMessageId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, fixMessageId));
            sqlCommand.Parameters.Add(new SqlParameter("@isHidden", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isHidden));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedTime));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedUserId));
            sqlCommand.Parameters.Add(new SqlParameter("@originalDestinationOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalDestinationOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@originalPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalPrice));
            sqlCommand.Parameters.Add(new SqlParameter("@originalQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementDate));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceExecutionId", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceExecutionId));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceStateCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceStateCode));
            sqlCommand.Parameters.Add(new SqlParameter("@tradeDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, tradeDate));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee0));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee1));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee2));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee3));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(executionRow.ExecutionId);
        }
Exemple #9
0
        /// <summary>Updates a Execution 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="accruedInterest">The value for the AccruedInterest column.</param>
        /// <param name="brokerAccountId">The value for the BrokerAccountId column.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="commission">The value for the Commission column.</param>
        /// <param name="createdTime">The value for the CreatedTime column.</param>
        /// <param name="createdUserId">The value for the CreatedUserId column.</param>
        /// <param name="destinationOrderId">The value for the DestinationOrderId column.</param>
        /// <param name="destinationStateCode">The value for the DestinationStateCode column.</param>
        /// <param name="executionId">The value for the ExecutionId column.</param>
        /// <param name="executionPrice">The value for the ExecutionPrice column.</param>
        /// <param name="executionQuantity">The value for the ExecutionQuantity column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="fixMessageId">The value for the FixMessageId column.</param>
        /// <param name="isHidden">The value for the IsHidden column.</param>
        /// <param name="modifiedTime">The value for the ModifiedTime column.</param>
        /// <param name="modifiedUserId">The value for the ModifiedUserId column.</param>
        /// <param name="originalDestinationOrderId">The value for the OriginalDestinationOrderId column.</param>
        /// <param name="originalPrice">The value for the OriginalPrice column.</param>
        /// <param name="originalQuantity">The value for the OriginalQuantity column.</param>
        /// <param name="settlementDate">The value for the SettlementDate column.</param>
        /// <param name="sourceExecutionId">The value for the SourceExecutionId column.</param>
        /// <param name="sourceStateCode">The value for the SourceStateCode column.</param>
        /// <param name="tradeDate">The value for the TradeDate column.</param>
        /// <param name="userFee0">The value for the UserFee0 column.</param>
        /// <param name="userFee1">The value for the UserFee1 column.</param>
        /// <param name="userFee2">The value for the UserFee2 column.</param>
        /// <param name="userFee3">The value for the UserFee3 column.</param>
        public static void Update(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object accruedInterest,
            object brokerAccountId,
            object brokerId,
            object commission,
            object createdTime,
            object createdUserId,
            object destinationOrderId,
            object destinationStateCode,
            int executionId,
            object executionPrice,
            object executionQuantity,
            object externalId0,
            object fixMessageId,
            object isHidden,
            object modifiedTime,
            object modifiedUserId,
            object originalDestinationOrderId,
            object originalPrice,
            object originalQuantity,
            object settlementDate,
            object sourceExecutionId,
            object sourceStateCode,
            object tradeDate,
            object userFee0,
            object userFee1,
            object userFee2,
            object userFee3)
        {
            // Accessor for the Execution Table.
            ServerMarketData.ExecutionDataTable executionTable = ServerMarketData.Execution;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.ExecutionRow executionRow = executionTable.FindByExecutionId(executionId);
            if ((executionRow == null))
            {
                throw new Exception(string.Format("The Execution table does not have an element identified by {0}", executionId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((executionRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((accruedInterest == null))
            {
                accruedInterest = executionRow[executionTable.AccruedInterestColumn];
            }
            if ((brokerAccountId == null))
            {
                brokerAccountId = executionRow[executionTable.BrokerAccountIdColumn];
            }
            if ((brokerId == null))
            {
                brokerId = executionRow[executionTable.BrokerIdColumn];
            }
            if ((commission == null))
            {
                commission = executionRow[executionTable.CommissionColumn];
            }
            if ((createdTime == null))
            {
                createdTime = executionRow[executionTable.CreatedTimeColumn];
            }
            if ((createdUserId == null))
            {
                createdUserId = executionRow[executionTable.CreatedUserIdColumn];
            }
            if ((destinationOrderId == null))
            {
                destinationOrderId = executionRow[executionTable.DestinationOrderIdColumn];
            }
            if ((destinationStateCode == null))
            {
                destinationStateCode = executionRow[executionTable.DestinationStateCodeColumn];
            }
            if ((executionPrice == null))
            {
                executionPrice = executionRow[executionTable.ExecutionPriceColumn];
            }
            if ((executionQuantity == null))
            {
                executionQuantity = executionRow[executionTable.ExecutionQuantityColumn];
            }
            if ((externalId0 == null))
            {
                externalId0 = executionRow[executionTable.ExternalId0Column];
            }
            if ((fixMessageId == null))
            {
                fixMessageId = executionRow[executionTable.FixMessageIdColumn];
            }
            if ((isHidden == null))
            {
                isHidden = executionRow[executionTable.IsHiddenColumn];
            }
            if ((modifiedTime == null))
            {
                modifiedTime = executionRow[executionTable.ModifiedTimeColumn];
            }
            if ((modifiedUserId == null))
            {
                modifiedUserId = executionRow[executionTable.ModifiedUserIdColumn];
            }
            if ((originalDestinationOrderId == null))
            {
                originalDestinationOrderId = executionRow[executionTable.OriginalDestinationOrderIdColumn];
            }
            if ((originalPrice == null))
            {
                originalPrice = executionRow[executionTable.OriginalPriceColumn];
            }
            if ((originalQuantity == null))
            {
                originalQuantity = executionRow[executionTable.OriginalQuantityColumn];
            }
            if ((settlementDate == null))
            {
                settlementDate = executionRow[executionTable.SettlementDateColumn];
            }
            if ((sourceExecutionId == null))
            {
                sourceExecutionId = executionRow[executionTable.SourceExecutionIdColumn];
            }
            if ((sourceStateCode == null))
            {
                sourceStateCode = executionRow[executionTable.SourceStateCodeColumn];
            }
            if ((tradeDate == null))
            {
                tradeDate = executionRow[executionTable.TradeDateColumn];
            }
            if ((userFee0 == null))
            {
                userFee0 = executionRow[executionTable.UserFee0Column];
            }
            if ((userFee1 == null))
            {
                userFee1 = executionRow[executionTable.UserFee1Column];
            }
            if ((userFee2 == null))
            {
                userFee2 = executionRow[executionTable.UserFee2Column];
            }
            if ((userFee3 == null))
            {
                userFee3 = executionRow[executionTable.UserFee3Column];
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            executionRow[executionTable.RowVersionColumn]                 = rowVersion;
            executionRow[executionTable.AccruedInterestColumn]            = accruedInterest;
            executionRow[executionTable.BrokerAccountIdColumn]            = brokerAccountId;
            executionRow[executionTable.BrokerIdColumn]                   = brokerId;
            executionRow[executionTable.CommissionColumn]                 = commission;
            executionRow[executionTable.CreatedTimeColumn]                = createdTime;
            executionRow[executionTable.CreatedUserIdColumn]              = createdUserId;
            executionRow[executionTable.DestinationOrderIdColumn]         = destinationOrderId;
            executionRow[executionTable.DestinationStateCodeColumn]       = destinationStateCode;
            executionRow[executionTable.ExecutionPriceColumn]             = executionPrice;
            executionRow[executionTable.ExecutionQuantityColumn]          = executionQuantity;
            executionRow[executionTable.ExternalId0Column]                = externalId0;
            executionRow[executionTable.FixMessageIdColumn]               = fixMessageId;
            executionRow[executionTable.IsHiddenColumn]                   = isHidden;
            executionRow[executionTable.ModifiedTimeColumn]               = modifiedTime;
            executionRow[executionTable.ModifiedUserIdColumn]             = modifiedUserId;
            executionRow[executionTable.OriginalDestinationOrderIdColumn] = originalDestinationOrderId;
            executionRow[executionTable.OriginalPriceColumn]              = originalPrice;
            executionRow[executionTable.OriginalQuantityColumn]           = originalQuantity;
            executionRow[executionTable.SettlementDateColumn]             = settlementDate;
            executionRow[executionTable.SourceExecutionIdColumn]          = sourceExecutionId;
            executionRow[executionTable.SourceStateCodeColumn]            = sourceStateCode;
            executionRow[executionTable.TradeDateColumn]                  = tradeDate;
            executionRow[executionTable.UserFee0Column]                   = userFee0;
            executionRow[executionTable.UserFee1Column]                   = userFee1;
            executionRow[executionTable.UserFee2Column]                   = userFee2;
            executionRow[executionTable.UserFee3Column]                   = userFee3;
            adoTransaction.DataRows.Add(executionRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Execution"" set ""RowVersion""=@rowVersion,""AccruedInterest""=@accruedInterest,""BrokerAccountId""=@brokerAccountId,""BrokerId""=@brokerId,""Commission""=@commission,""CreatedTime""=@createdTime,""CreatedUserId""=@createdUserId,""DestinationOrderId""=@destinationOrderId,""DestinationStateCode""=@destinationStateCode,""ExecutionPrice""=@executionPrice,""ExecutionQuantity""=@executionQuantity,""ExternalId0""=@externalId0,""FixMessageId""=@fixMessageId,""IsHidden""=@isHidden,""ModifiedTime""=@modifiedTime,""ModifiedUserId""=@modifiedUserId,""OriginalDestinationOrderId""=@originalDestinationOrderId,""OriginalPrice""=@originalPrice,""OriginalQuantity""=@originalQuantity,""SettlementDate""=@settlementDate,""SourceExecutionId""=@sourceExecutionId,""SourceStateCode""=@sourceStateCode,""TradeDate""=@tradeDate,""UserFee0""=@userFee0,""UserFee1""=@userFee1,""UserFee2""=@userFee2,""UserFee3""=@userFee3 where ""ExecutionId""=@executionId");

            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("@accruedInterest", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accruedInterest));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerAccountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerAccountId));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.Parameters.Add(new SqlParameter("@commission", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, commission));
            sqlCommand.Parameters.Add(new SqlParameter("@createdTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdTime));
            sqlCommand.Parameters.Add(new SqlParameter("@createdUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdUserId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationStateCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationStateCode));
            sqlCommand.Parameters.Add(new SqlParameter("@executionId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionId));
            sqlCommand.Parameters.Add(new SqlParameter("@executionPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionPrice));
            sqlCommand.Parameters.Add(new SqlParameter("@executionQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@fixMessageId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, fixMessageId));
            sqlCommand.Parameters.Add(new SqlParameter("@isHidden", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isHidden));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedTime));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedUserId));
            sqlCommand.Parameters.Add(new SqlParameter("@originalDestinationOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalDestinationOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@originalPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalPrice));
            sqlCommand.Parameters.Add(new SqlParameter("@originalQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementDate));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceExecutionId", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceExecutionId));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceStateCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceStateCode));
            sqlCommand.Parameters.Add(new SqlParameter("@tradeDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, tradeDate));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee0));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee1));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee2));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee3));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Exemple #10
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 Archive(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Archive' operation.
     adoTransaction.LockRequests.AddWriterLock(ServerMarketData.StylesheetLock);
     Blotter.ArchiveChildren(adoTransaction);
 }
Exemple #11
0
        /// <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.
            ServerMarketData.StylesheetDataTable stylesheetTable = ServerMarketData.Stylesheet;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.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.GetBlotterRowsByStylesheetBlotterAdvertisementStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterAdvertisementStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterDestinationOrderDetailStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterDestinationOrderDetailStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterDestinationOrderStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterDestinationOrderStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterExecutionDetailStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterExecutionDetailStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterExecutionStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterExecutionStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterMatchStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterMatchStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterMatchHistoryStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterMatchHistoryStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterSourceOrderDetailStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterSourceOrderDetailStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterSourceOrderStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterSourceOrderStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < stylesheetRow.GetBlotterRowsByStylesheetBlotterWorkingOrderStylesheetId().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = stylesheetRow.GetBlotterRowsByStylesheetBlotterWorkingOrderStylesheetId()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.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();
        }
Exemple #12
0
        /// <summary>Updates 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 the row</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="externalId1">The value for the ExternalId1 column.</param>
        /// <param name="name">The value for the Name column.</param>
        /// <param name="stylesheetId">The value for the StylesheetId column.</param>
        /// <param name="stylesheetTypeCode">The value for the StylesheetTypeCode column.</param>
        /// <param name="text">The value for the Text column.</param>
        public static void Update(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, object externalId0, object externalId1, object name, int stylesheetId, object stylesheetTypeCode, object text)
        {
            // Accessor for the Stylesheet Table.
            ServerMarketData.StylesheetDataTable stylesheetTable = ServerMarketData.Stylesheet;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.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.");
            }
            // Apply Defaults
            if ((externalId0 == null))
            {
                externalId0 = stylesheetRow[stylesheetTable.ExternalId0Column];
            }
            if ((externalId1 == null))
            {
                externalId1 = stylesheetRow[stylesheetTable.ExternalId1Column];
            }
            if ((name == null))
            {
                name = stylesheetRow[stylesheetTable.NameColumn];
            }
            if ((stylesheetTypeCode == null))
            {
                stylesheetTypeCode = stylesheetRow[stylesheetTable.StylesheetTypeCodeColumn];
            }
            if ((text == null))
            {
                text = stylesheetRow[stylesheetTable.TextColumn];
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            stylesheetRow[stylesheetTable.RowVersionColumn]         = rowVersion;
            stylesheetRow[stylesheetTable.ExternalId0Column]        = externalId0;
            stylesheetRow[stylesheetTable.ExternalId1Column]        = externalId1;
            stylesheetRow[stylesheetTable.NameColumn]               = name;
            stylesheetRow[stylesheetTable.StylesheetTypeCodeColumn] = stylesheetTypeCode;
            stylesheetRow[stylesheetTable.TextColumn]               = text;
            adoTransaction.DataRows.Add(stylesheetRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Stylesheet\" set \"RowVersion\"=@rowVersion,\"ExternalId0\"=@externalId0,\"Exte" +
                                                   "rnalId1\"=@externalId1,\"Name\"=@name,\"StylesheetTypeCode\"=@stylesheetTypeCode,\"Tex" +
                                                   "t\"=@text where \"StylesheetId\"=@stylesheetId");

            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("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId1", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId1));
            sqlCommand.Parameters.Add(new SqlParameter("@name", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, name));
            sqlCommand.Parameters.Add(new SqlParameter("@stylesheetId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, stylesheetId));
            sqlCommand.Parameters.Add(new SqlParameter("@stylesheetTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, stylesheetTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@text", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, text));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Exemple #13
0
        /// <summary>Inserts a Negotiation record using Metadata Parameters.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit.</param>
        /// <param name="remoteMethod">Contains the metadata parameters and exceptions for this command.</param>
        public static void Decline(ParameterList parameters)
        {
            // Accessor for the Match Table.
            ServerMarketData.MatchDataTable matchTable = ServerMarketData.Match;

            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction = parameters["adoTransaction"];
            SqlTransaction sqlTransaction = parameters["sqlTransaction"];
            int            matchId        = parameters["matchId"];

            int  negotiationId = int.MinValue;
            long rowVersion    = long.MinValue;

            ServerMarketData.MatchRow matchRow = matchTable.FindByMatchId(matchId);
            if (matchRow != null)
            {
                // See if there is already a pending offer.
                bool isFound = false;
                foreach (ServerMarketData.NegotiationRow innerNegotiationRow in matchRow.GetNegotiationRows())
                {
                    if (innerNegotiationRow.StatusCode == Status.Declined)
                    {
                        throw new Exception("This offer has previously been declined.");
                    }

                    if (innerNegotiationRow.StatusCode == Status.Pending)
                    {
                        // Call the internal method to complete the operation.
                        rowVersion    = innerNegotiationRow.RowVersion;
                        negotiationId = innerNegotiationRow.NegotiationId;
                        MarkThree.Guardian.Core.Negotiation.Update(adoTransaction, sqlTransaction, ref rowVersion,
                                                                   matchId, null, negotiationId, null, Status.Declined);

                        isFound = true;
                    }
                }

                // Call the internal method to complete the operation.
                if (!isFound)
                {
                    negotiationId = MarkThree.Guardian.Core.Negotiation.Insert(adoTransaction, sqlTransaction, ref rowVersion, null, matchId,
                                                                               0.0m, Status.Declined);
                }

                // If there's a counter offer, then notify the couter part that the offer has been declined.
                // This will find the contra matching record.
                int contraMatchIndex =
                    ServerMarketData.Match.KeyMatchWorkingOrderIdContraOrderId.Find(new object[] { matchRow.ContraOrderId, matchRow.WorkingOrderId });
                if (contraMatchIndex == -1)
                {
                    throw new Exception(string.Format("Corruption: the match record for {0}, {1} can't be found", matchRow.ContraOrderId, matchRow.WorkingOrderId));
                }
                ServerMarketData.MatchRow contraMatchRow =
                    (ServerMarketData.MatchRow)ServerMarketData.Match.KeyMatchWorkingOrderIdContraOrderId[contraMatchIndex].Row;

                // When both sides have agreed to the Negotiation, the Destination Orders are generated.
                foreach (MarketData.NegotiationRow contraNegotiationRow in contraMatchRow.GetNegotiationRows())
                {
                    if (contraNegotiationRow.StatusCode == Status.Pending)
                    {
                        rowVersion = contraNegotiationRow.RowVersion;
                        MarkThree.Guardian.Core.Negotiation.Update(adoTransaction, sqlTransaction, ref rowVersion, null, null, contraNegotiationRow.NegotiationId, null, Status.Declined);
                    }
                }
            }

            // Return values.
            parameters["rowVersion"] = rowVersion;
            parameters.Return        = negotiationId;
        }
Exemple #14
0
        /// <summary>Inserts a Negotiation record using Metadata Parameters.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit.</param>
        /// <param name="remoteMethod">Contains the metadata parameters and exceptions for this command.</param>
        public static void Offer(ParameterList parameters)
        {
            // Accessor for the Match Table.
            ServerMarketData.MatchDataTable matchTable = ServerMarketData.Match;

            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction = parameters["adoTransaction"];
            SqlTransaction sqlTransaction = parameters["sqlTransaction"];
            int            matchId        = parameters["matchId"];
            decimal        quantity       = parameters["quantity"];

            int  negotiationId = int.MinValue;
            long rowVersion    = long.MinValue;

            ServerMarketData.MatchRow matchRow = matchTable.FindByMatchId(matchId);
            if (matchRow != null)
            {
                // Rule #1: Insure that there are no pending offers.
                foreach (ServerMarketData.NegotiationRow innerNegotiationRow in matchRow.GetNegotiationRows())
                {
                    if (innerNegotiationRow.StatusCode == Status.Pending)
                    {
                        throw new Exception("There is already an offer pending.");
                    }

                    if (innerNegotiationRow.StatusCode == Status.Declined)
                    {
                        throw new Exception("This offer has previously been declined.");
                    }
                }

                // Time stamps and user stamps
                int      createdUserId  = ServerMarketData.UserId;
                DateTime createdTime    = DateTime.Now;
                int      modifiedUserId = ServerMarketData.UserId;
                DateTime modifiedTime   = DateTime.Now;

                // This will find the contra matching record.
                int contraMatchIndex =
                    ServerMarketData.Match.KeyMatchWorkingOrderIdContraOrderId.Find(new object[] { matchRow.ContraOrderId, matchRow.WorkingOrderId });
                if (contraMatchIndex == -1)
                {
                    throw new Exception(string.Format("Corruption: the match record for {0}, {1} can't be found", matchRow.ContraOrderId, matchRow.WorkingOrderId));
                }
                ServerMarketData.MatchRow contraMatchRow =
                    (ServerMarketData.MatchRow)ServerMarketData.Match.KeyMatchWorkingOrderIdContraOrderId[contraMatchIndex].Row;

                // When both sides have agreed to the Negotiation, the Destination Orders are generated.
                ServerMarketData.NegotiationRow contraNegotiationRow = null;
                foreach (MarketData.NegotiationRow innerNegotiationRow in contraMatchRow.GetNegotiationRows())
                {
                    if (innerNegotiationRow.StatusCode == Status.Pending)
                    {
                        contraNegotiationRow = innerNegotiationRow;
                        break;
                    }
                }

                // This means that there's an offer on the other side.
                if (contraNegotiationRow == null)
                {
                    // There is no opposite side of this transaction yet.  It will be placed in the negotation table and wait there
                    // until it times out, or the other side accepts the offer.
                    long negotiationRowVersion = long.MinValue;
                    negotiationId = MarkThree.Guardian.Core.Negotiation.Insert(adoTransaction, sqlTransaction, ref negotiationRowVersion,
                                                                               null, matchId, quantity, Status.Pending);
                }
                else
                {
                    // At this point, there is an offer on both sides of the match for a follow-on order.  We'll create orders and
                    // executions for both sides of the trade for the minimum agreed upon quantity.
                    ServerMarketData.WorkingOrderRow workingOrderRow = matchRow.WorkingOrderRow;
                    ServerMarketData.WorkingOrderRow contraOrderRow  = contraNegotiationRow.MatchRow.WorkingOrderRow;

                    // The quantity of this negotiation will be the minimum of the two offers.
                    decimal matchedQuantity = quantity < contraNegotiationRow.Quantity ? quantity : contraNegotiationRow.Quantity;

                    // Create the order on this side of the trade.
                    long rowVersionDestionation = long.MinValue;
                    int  destinationOrderId     = MarkThree.Guardian.Core.DestinationOrder.Insert(adoTransaction, sqlTransaction,
                                                                                                  ref rowVersionDestionation, null, null, createdTime, createdUserId, Negotiation.destinationId, null, null,
                                                                                                  null, workingOrderRow[ServerMarketData.WorkingOrder.LimitPriceColumn], modifiedTime, modifiedUserId,
                                                                                                  workingOrderRow.OrderTypeCode, matchedQuantity, workingOrderRow.PriceTypeCode, State.Acknowledged, Status.New,
                                                                                                  workingOrderRow[ServerMarketData.WorkingOrder.StopPriceColumn], createdUserId, workingOrderRow.TimeInForceCode,
                                                                                                  workingOrderRow.WorkingOrderId);

                    // Create the Execution for this side of the trade.
                    long rowVersionExecution = long.MinValue;
                    int  executionId         = MarkThree.Guardian.Core.Execution.Insert(adoTransaction, sqlTransaction,
                                                                                        ref rowVersionExecution, null, null, createdTime, createdUserId, destinationOrderId, State.Acknowledged,
                                                                                        workingOrderRow.PriceRow.LastPrice, matchedQuantity, null, null, null, modifiedTime, modifiedUserId,
                                                                                        null, null, null, DateTime.Now, null, State.Sent, DateTime.Now, null, null, null, null);

                    // There is no opposite side of this transaction yet.  It will be placed in the negotation table and wait there
                    // until it times out, or the other side accepts the offer.
                    long negotiationRowVersion = long.MinValue;
                    negotiationId = MarkThree.Guardian.Core.Negotiation.Insert(adoTransaction, sqlTransaction, ref negotiationRowVersion,
                                                                               executionId, matchId, quantity, Status.Accepted);

                    // Create an order for the agreed upon quantity.
                    int contraDestinationOrderId = MarkThree.Guardian.Core.DestinationOrder.Insert(adoTransaction, sqlTransaction,
                                                                                                   ref rowVersionDestionation, null, null, createdTime, createdUserId, Negotiation.destinationId, null, null,
                                                                                                   null, contraOrderRow[ServerMarketData.WorkingOrder.LimitPriceColumn], modifiedTime, modifiedUserId,
                                                                                                   contraOrderRow.OrderTypeCode, matchedQuantity, contraOrderRow.PriceTypeCode, State.Acknowledged, Status.New,
                                                                                                   contraOrderRow[ServerMarketData.WorkingOrder.StopPriceColumn], createdUserId, contraOrderRow.TimeInForceCode,
                                                                                                   contraOrderRow.WorkingOrderId);

                    // Create an execution for the agreed upon quantity
                    int contraExecutionId = MarkThree.Guardian.Core.Execution.Insert(adoTransaction, sqlTransaction,
                                                                                     ref rowVersionExecution, null, null, createdTime, createdUserId, contraDestinationOrderId,
                                                                                     State.Acknowledged, contraOrderRow.PriceRow.LastPrice, matchedQuantity, null, null, null, modifiedTime,
                                                                                     modifiedUserId, null, null, null, DateTime.Now, null, State.Sent, DateTime.Now, null, null, null, null);

                    // Update the contra offer.
                    long contraNegotiationRowVersion = contraNegotiationRow.RowVersion;
                    MarkThree.Guardian.Core.Negotiation.Update(adoTransaction, sqlTransaction, ref contraNegotiationRowVersion, contraExecutionId, null,
                                                               contraNegotiationRow.NegotiationId, null, Status.Accepted);
                }
            }

            // Return values.
            parameters["rowVersion"] = rowVersion;
            parameters.Return        = negotiationId;
        }
Exemple #15
0
        /// <summary>Inserts a SourceOrder record using Metadata Parameters.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit.</param>
        /// <param name="remoteMethod">Contains the metadata parameters and exceptions for this command.</param>
        public static void InsertFile(ParameterList parameters)
        {
            // Accessor for the SourceOrder Table.
            ServerMarketData.SourceOrderDataTable sourceOrderTable = ServerMarketData.SourceOrder;
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction        = parameters["adoTransaction"];
            SqlTransaction sqlTransaction        = parameters["sqlTransaction"];
            object         configurationId       = parameters["configurationId"].Value;
            object         externalBlotterId     = parameters["blotterId"].Value;
            object         externalSourceOrderId = parameters["sourceOrderId"].Value;
            object         externalDestinationId = parameters["destinationId"].Value;
            object         externalId0           = parameters["externalId0"].Value;
            object         isAdvertised          = parameters["isAdvertised"].Value;
            object         isCanceled            = parameters["isCanceled"].Value;
            object         isSteppedIn           = parameters["isSteppedIn"].Value;
            object         limitPrice            = parameters["limitPrice"].Value;

            System.Decimal orderedQuantity            = parameters["orderedQuantity"];
            string         externalOrderTypeCode      = parameters["orderTypeCode"];
            string         externalPriceTypeCode      = parameters["priceTypeCode"];
            object         receivedTime               = parameters["receivedTime"].Value;
            string         externalSecurityId         = parameters["securityId"];
            string         externalSettlementId       = parameters["settlementId"];
            object         stopPrice                  = parameters["stopPrice"].Value;
            object         targetPrice                = parameters["targetPrice"].Value;
            object         externalSubmissionTypeCode = parameters["submissionTypeCode"].Value;
            string         externalTimeInForceCode    = parameters["timeInForceCode"];
            object         uploadedTime               = parameters["uploadedTime"].Value;
            object         externalWorkingOrderId     = parameters["workingOrderId"].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 blotterId          = External.Blotter.FindOptionalKey(configurationId, "blotterId", externalBlotterId);
            int    sourceOrderId      = External.SourceOrder.FindKey(configurationId, "sourceOrderId", (string)externalSourceOrderId);
            int    orderTypeCode      = External.OrderType.FindRequiredKey(configurationId, "orderTypeCode", externalOrderTypeCode);
            object destinationId      = External.Destination.FindOptionalKey(configurationId, "destinationId", externalDestinationId);
            int    priceTypeCode      = External.PriceType.FindRequiredKey(configurationId, "priceTypeCode", externalPriceTypeCode);
            int    securityId         = External.Security.FindRequiredKey(configurationId, "securityId", externalSecurityId);
            int    settlementId       = External.Security.FindRequiredKey(configurationId, "settlementId", externalSettlementId);
            int    timeInForceCode    = External.TimeInForce.FindRequiredKey(configurationId, "timeInForceCode", externalTimeInForceCode);
            object submissionTypeCode = External.SubmissionType.FindOptionalKey(configurationId, "submissionTypeCode", externalSubmissionTypeCode);
            object workingOrderId     = External.WorkingOrder.FindOptionalKey(configurationId, "workingOrderId", externalWorkingOrderId);

            // Optional Parameters
            object canceledQuantity = parameters["canceledQuantity"] is MissingParameter ? (object)null :
                                      Convert.ToDecimal(parameters["canceledQuantity"].Value);
            object isAgencyMatch = parameters["isAgencyMatch"] is MissingParameter ? (object)null :
                                   Convert.ToBoolean(parameters["isAgencyMatch"].Value);
            object isBrokerMatch = parameters["isBrokerMatch"] is MissingParameter ? (object)null :
                                   Convert.ToBoolean(parameters["isBrokerMatch"].Value);
            object isHedgeMatch = parameters["isHedgeMatch"] is MissingParameter ? (object)null :
                                  Convert.ToBoolean(parameters["isHedgeMatch"].Value);
            object isHeld = parameters["isHeld"] is MissingParameter ? (object)null :
                            Convert.ToBoolean(parameters["isHeld"].Value);
            object isInstitutionMatch = parameters["isInstitutionMatch"] is MissingParameter ? (object)null :
                                        Convert.ToBoolean(parameters["isInstitutionMatch"].Value);
            object specifiedLimit = parameters["specifiedLimit"] is MissingParameter ? (object)null :
                                    Convert.ToDecimal(parameters["specifiedLimit"].Value);
            object maximumVolatility = parameters["maximumVolatility"] is MissingParameter ? (object)null :
                                       Convert.ToDecimal(parameters["maximumVolatility"].Value);
            object submittedQuantity = parameters["submittedQuantity"] is MissingParameter ? (object)null :
                                       Convert.ToDecimal(parameters["submittedQuantity"].Value);
            object startTime = parameters["startTime"] is MissingParameter ? (object)null :
                               Convert.ToDateTime(parameters["startTime"].Value);
            object stopTime = parameters["stopTime"] is MissingParameter ? (object)null :
                              Convert.ToDateTime(parameters["stopTime"].Value);
            object newsFreeTime = parameters["newsFreeTime"] is MissingParameter ? (object)null :
                                  Convert.ToInt32(parameters["newsFreeTime"].Value);

            // Time stamps and user stamps
            int      createdUserId  = ServerMarketData.UserId;
            DateTime createdTime    = DateTime.Now;
            int      modifiedUserId = ServerMarketData.UserId;
            DateTime modifiedTime   = DateTime.Now;
            int      statusCode     = Status.New;

            // The Trader table contains additional defaults for incoming orders.
            int traderId = ServerMarketData.UserId;

            ServerMarketData.TraderRow traderRow = ServerMarketData.Trader.FindByTraderId(traderId);
            if (isAgencyMatch == null)
            {
                isAgencyMatch = traderRow.IsAgencyMatch;
            }
            if (isBrokerMatch == null)
            {
                isBrokerMatch = traderRow.IsBrokerMatch;
            }
            if (isHedgeMatch == null)
            {
                isHedgeMatch = traderRow.IsHedgeMatch;
            }
            if (isInstitutionMatch == null)
            {
                isInstitutionMatch = traderRow.IsInstitutionMatch;
            }
            if (maximumVolatility == null && !traderRow.IsMaximumVolatilityDefaultNull())
            {
                maximumVolatility = traderRow.MaximumVolatilityDefault;
            }
            if (startTime == null && !traderRow.IsStartTimeDefaultNull())
            {
                startTime = traderRow.StartTimeDefault;
            }
            if (stopTime == null && !traderRow.IsStopTimeDefaultNull())
            {
                stopTime = traderRow.StopTimeDefault;
            }
            if (newsFreeTime == null && !traderRow.IsNewsFreeTimeDefaultNull())
            {
                newsFreeTime = traderRow.NewsFreeTimeDefault;
            }

            // Rule #1 - Blotter must be specified if the working order is not specified.
            if (blotterId == null && workingOrderId == null)
            {
                throw new Exception("Either a blotter or a Working Order must be specified as a location for this Order");
            }

            // If the incoming order specified a submitted quantity, then automatically enter the order into the cross.
            if (submissionTypeCode == null)
            {
                submissionTypeCode = SubmissionType.NeverMatch;
            }

            object submittedTime = null;

            if ((int)submissionTypeCode != SubmissionType.NeverMatch)
            {
                submittedTime = DateTime.Now;
                if (submittedQuantity == null)
                {
                    submittedQuantity = orderedQuantity;
                }
            }

            // Update the rowversion of the object associated with this trade.
            ServerMarketData.SecurityRow securityRow = ServerMarketData.Security.FindBySecurityId(securityId);
            if (securityRow != null)
            {
                foreach (ServerMarketData.EquityRow equityRow in securityRow.GetEquityRowsBySecurityEquityEquityId())
                {
                    long equityRowVersion = equityRow.RowVersion;
                    Core.Equity.Update(adoTransaction, sqlTransaction, ref equityRowVersion, null, null, null, null, null,
                                       null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
                                       null, equityRow.EquityId, null, null, null, null, null, null, null);
                }

                foreach (ServerMarketData.PriceRow priceRow in securityRow.GetPriceRows())
                {
                    long priceRowVersion = priceRow.RowVersion;
                    Core.Price.Update(adoTransaction, sqlTransaction, ref priceRowVersion, null, null, null, null, null, null, null,
                                      null, null, null, null, null, priceRow.SecurityId, null, null);
                }
            }

            ServerMarketData.SecurityRow settlementRow = ServerMarketData.Security.FindBySecurityId(settlementId);
            if (settlementRow != null)
            {
                foreach (ServerMarketData.CurrencyRow currencyRow in settlementRow.GetCurrencyRows())
                {
                    long currencyRowVersion = currencyRow.RowVersion;
                    Core.Currency.Update(adoTransaction, sqlTransaction, ref currencyRowVersion, null, null, null, null, null,
                                         null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
                                         currencyRow.CurrencyId, null, null, null);
                }
            }

            // An order can be automatically associated with a working order if the working order is specified when the order is
            // created.
            if (workingOrderId == null)
            {
                long     timerRowVersion = long.MinValue;
                DateTime currentTime     = DateTime.Now;
                int      timerId         = Core.Timer.Insert(adoTransaction, sqlTransaction, ref timerRowVersion, currentTime, null, false, currentTime, 0);
                workingOrderId = Core.WorkingOrder.Insert(adoTransaction, sqlTransaction, ref rowVersion, null, (int)blotterId,
                                                          createdTime, createdUserId, destinationId, null, isAgencyMatch, null, true, isBrokerMatch, isHedgeMatch,
                                                          isInstitutionMatch, limitPrice, maximumVolatility,
                                                          modifiedTime, modifiedUserId, newsFreeTime, orderTypeCode, priceTypeCode, securityId,
                                                          settlementId, startTime, statusCode, stopPrice, stopTime, (int)submissionTypeCode, submittedQuantity,
                                                          submittedTime, timeInForceCode, timerId, null);
            }

            // 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 (sourceOrderId == int.MinValue)
            {
                // 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 = External.SourceOrder.GetExternalKeyIndex(configurationId, "sourceOrderId");
                object[] externalIdArray  = new object[1];
                externalIdArray[externalKeyIndex] = externalSourceOrderId;
                externalId0 = externalIdArray[0];

                // Call the internal method to complete the operation.
                MarkThree.Guardian.Core.SourceOrder.Insert(adoTransaction, sqlTransaction, ref rowVersion, createdTime, createdUserId,
                                                           destinationId, externalId0, isAdvertised, isHeld, isCanceled, isHeld, isSteppedIn, submissionTypeCode,
                                                           limitPrice, maximumVolatility, modifiedTime, modifiedUserId, newsFreeTime, orderTypeCode,
                                                           orderedQuantity, priceTypeCode, receivedTime, securityId, settlementId, startTime, statusCode,
                                                           stopPrice, stopTime, submittedQuantity, submittedTime, targetPrice, timeInForceCode, (int)workingOrderId);
            }
            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.
                ServerMarketData.SourceOrderRow sourceOrderRow = sourceOrderTable.FindBySourceOrderId((int)sourceOrderId);
                rowVersion = ((long)(sourceOrderRow[sourceOrderTable.RowVersionColumn]));

                // Call the internal method to complete the operation.
                MarkThree.Guardian.Core.SourceOrder.Update(adoTransaction, sqlTransaction, ref rowVersion, createdTime, createdUserId,
                                                           (int)sourceOrderId, destinationId, stopTime, externalId0, isAdvertised, isHeld, isCanceled, isHeld,
                                                           isSteppedIn, submissionTypeCode, limitPrice, maximumVolatility, modifiedTime, modifiedUserId, newsFreeTime,
                                                           orderTypeCode, orderedQuantity, priceTypeCode, receivedTime, securityId, settlementId,
                                                           startTime, statusCode, stopPrice, submittedQuantity, submittedTime, targetPrice, timeInForceCode,
                                                           workingOrderId);
            }

            // Return values.
            parameters["rowVersion"] = rowVersion;
        }
Exemple #16
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 Archive(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Archive' operation.
     adoTransaction.LockRequests.AddWriterLock(ServerMarketData.ExecutionLock);
     Negotiation.Archive(adoTransaction);
 }
Exemple #17
0
        /// <summary>Inserts a SourceOrder record using Metadata Parameters.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit.</param>
        /// <param name="remoteMethod">Contains the metadata parameters and exceptions for this command.</param>
        public static void Insert(ParameterList parameters)
        {
            // Accessor for the SourceOrder Table.
            ServerMarketData.SourceOrderDataTable sourceOrderTable = ServerMarketData.SourceOrder;
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction        = parameters["adoTransaction"];
            SqlTransaction sqlTransaction        = parameters["sqlTransaction"];
            object         blotterId             = parameters["blotterId"].Value;
            object         configurationId       = parameters["configurationId"].Value;
            object         destinationId         = parameters["destinationId"].Value;
            object         externalBlotterId     = parameters["blotterId"].Value;
            object         externalSourceOrderId = parameters["sourceOrderId"].Value;
            object         externalDestinationId = parameters["destinationId"].Value;
            object         externalId0           = parameters["externalId0"].Value;
            object         isAdvertised          = parameters["isAdvertised"].Value;
            object         isAgencyMatch         = parameters["isAgencyMatch"].Value;
            object         isBrokerMatch         = parameters["isBrokerMatch"].Value;
            object         isCanceled            = parameters["isCanceled"].Value;
            object         isSteppedIn           = parameters["isSteppedIn"].Value;
            object         isHedgeMatch          = parameters["isHedgeMatch"].Value;
            object         isHeld             = parameters["isHeld"].Value;
            object         isInstitutionMatch = parameters["isInstitutionMatch"].Value;
            object         limitPrice         = parameters["limitPrice"].Value;
            object         maximumVolatility  = parameters["maximumVolatility"].Value;
            object         newsFreeTime       = parameters["newsFreeTime"].Value;

            System.Decimal orderedQuantity        = parameters["orderedQuantity"];
            int            orderTypeCode          = parameters["orderTypeCode"];
            int            priceTypeCode          = parameters["priceTypeCode"];
            object         receivedTime           = parameters["receivedTime"].Value;
            string         externalSecurityId     = parameters["securityId"];
            string         externalSettlementId   = parameters["settlementId"];
            object         workingOrderId         = parameters["workingOrderId"].Value;
            object         startTime              = parameters["startTime"].Value;
            object         stopTime               = parameters["stopTime"].Value;
            object         stopPrice              = parameters["stopPrice"].Value;
            object         submissionTypeCode     = parameters["submissionTypeCode"].Value;
            object         submittedQuantity      = parameters["submittedQuantity"].Value;
            object         targetPrice            = parameters["targetPrice"].Value;
            int            timeInForceCode        = parameters["timeInForceCode"];
            object         uploadedTime           = parameters["uploadedTime"].Value;
            object         externalWorkingOrderId = parameters["workingOrderId"].Value;

            // Look up the external values.
            int securityId   = External.Security.FindRequiredKey("US TICKER", "securityId", externalSecurityId);
            int settlementId = External.Security.FindRequiredKey("US TICKER", "settlementId", externalSettlementId);

            // This will get the row version of the newly added Source Order.
            long rowVersion = long.MinValue;

            // Time stamps and user stamps
            DateTime currentTime    = DateTime.Now;
            int      createdUserId  = ServerMarketData.UserId;
            DateTime createdTime    = DateTime.Now;
            int      modifiedUserId = ServerMarketData.UserId;
            DateTime modifiedTime   = DateTime.Now;
            int      statusCode     = Status.New;

            // The Trader table contains additional defaults for incoming orders.
            int traderId = ServerMarketData.UserId;

            ServerMarketData.TraderRow traderRow = ServerMarketData.Trader.FindByTraderId(traderId);
            if (isAgencyMatch == null)
            {
                isAgencyMatch = traderRow.IsAgencyMatch;
            }
            if (isBrokerMatch == null)
            {
                isBrokerMatch = traderRow.IsBrokerMatch;
            }
            if (isHedgeMatch == null)
            {
                isHedgeMatch = traderRow.IsHedgeMatch;
            }
            if (isInstitutionMatch == null)
            {
                isInstitutionMatch = traderRow.IsInstitutionMatch;
            }
            if (maximumVolatility == null && !traderRow.IsMaximumVolatilityDefaultNull())
            {
                maximumVolatility = traderRow.MaximumVolatilityDefault;
            }
            if (startTime == null && !traderRow.IsStartTimeDefaultNull())
            {
                startTime = traderRow.StartTimeDefault;
            }
            if (stopTime == null && !traderRow.IsStopTimeDefaultNull())
            {
                stopTime = traderRow.StopTimeDefault;
            }
            if (newsFreeTime == null && !traderRow.IsNewsFreeTimeDefaultNull())
            {
                newsFreeTime = traderRow.NewsFreeTimeDefault;
            }

            // Rule #1 - Blotter must be specified if the working order is not specified.
            if (blotterId == null && workingOrderId == null)
            {
                throw new Exception("Either a blotter or a Working Order must be specified as a location for this Order");
            }

            // If the incoming order specified a submitted quantity, then automatically enter the order into the cross.
            if (submissionTypeCode == null)
            {
                submissionTypeCode = SubmissionType.NeverMatch;
            }

            object submittedTime = null;

            if ((int)submissionTypeCode != SubmissionType.NeverMatch)
            {
                submittedTime = DateTime.Now;
                if (submittedQuantity == null)
                {
                    submittedQuantity = orderedQuantity;
                }
            }

            // Update the rowversion of the object associated with this trade.
            ServerMarketData.SecurityRow securityRow = ServerMarketData.Security.FindBySecurityId(securityId);
            if (securityRow != null)
            {
                foreach (ServerMarketData.EquityRow equityRow in securityRow.GetEquityRowsBySecurityEquityEquityId())
                {
                    long equityRowVersion = equityRow.RowVersion;
                    Core.Equity.Update(adoTransaction, sqlTransaction, ref equityRowVersion, null, null, null, null, null,
                                       null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
                                       equityRow.EquityId, null, null, null, null, null, null, null);
                }

                foreach (ServerMarketData.PriceRow priceRow in securityRow.GetPriceRows())
                {
                    long priceRowVersion = priceRow.RowVersion;
                    Core.Price.Update(adoTransaction, sqlTransaction, ref priceRowVersion, null, null, null, null, null, null, null,
                                      null, null, null, null, null, priceRow.SecurityId, null, null);
                }
            }

            ServerMarketData.SecurityRow settlementRow = ServerMarketData.Security.FindBySecurityId(settlementId);
            if (settlementRow != null)
            {
                foreach (ServerMarketData.CurrencyRow currencyRow in settlementRow.GetCurrencyRows())
                {
                    long currencyRowVersion = currencyRow.RowVersion;
                    Core.Currency.Update(adoTransaction, sqlTransaction, ref currencyRowVersion, null, null, null, null, null,
                                         null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
                                         currencyRow.CurrencyId, null, null, null);
                }
            }

            // An order can be automatically associated with a working order if the working order is specified when the order is
            // created.
            if (workingOrderId == null)
            {
                long timerRowVersion = long.MinValue;
                int  timerId         = Core.Timer.Insert(adoTransaction, sqlTransaction, ref timerRowVersion, currentTime, null, false, currentTime, 0);
                workingOrderId = Core.WorkingOrder.Insert(adoTransaction, sqlTransaction, ref rowVersion, null, (int)blotterId,
                                                          createdTime, createdUserId, destinationId, null, isAgencyMatch, null, true, isBrokerMatch, isHedgeMatch, isInstitutionMatch, limitPrice,
                                                          maximumVolatility, modifiedTime, modifiedUserId, newsFreeTime, orderTypeCode, priceTypeCode, securityId,
                                                          settlementId, startTime, statusCode, stopPrice, stopTime, (int)submissionTypeCode, submittedQuantity, submittedTime,
                                                          timeInForceCode, timerId, null);
            }

            // Call the internal method to complete the operation.
            MarkThree.Guardian.Core.SourceOrder.Insert(adoTransaction, sqlTransaction, ref rowVersion, createdTime, createdUserId,
                                                       destinationId, externalId0, isAdvertised, isHeld, isCanceled, isHeld, isSteppedIn, submissionTypeCode,
                                                       limitPrice, maximumVolatility, modifiedTime, modifiedUserId, newsFreeTime, orderTypeCode,
                                                       orderedQuantity, priceTypeCode, receivedTime, securityId, settlementId, startTime, statusCode,
                                                       stopPrice, stopTime, submittedQuantity, submittedTime, targetPrice, timeInForceCode, (int)workingOrderId);

            // Return values.
            parameters["rowVersion"] = rowVersion;
        }
Exemple #18
0
 /// <summary>Updates a Debt record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public new static void Update(ParameterList parameters)
 {
     // Accessor for the Debt Table.
     ServerDataModel.DebtDataTable debtTable = ServerDataModel.Debt;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].Value;
     object groupPermission = parameters["groupPermission"].Value;
     object hidden = parameters["hidden"].Value;
     object name = parameters["name"].Value;
     object owner = parameters["owner"].Value;
     object ownerPermission = parameters["ownerPermission"].Value;
     object readOnly = parameters["readOnly"].Value;
     object worldPermission = parameters["worldPermission"].Value;
     object externalCountryId = parameters["countryId"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     object symbol = parameters["symbol"].Value;
     string externalDebtId = ((string)(parameters["debtId"]));
     object externalIssuerId = parameters["issuerId"].Value;
     object externalSettlementId = parameters["settlementId"].Value;
     object externalSecurityTypeCode = parameters["securityTypeCode"].Value;
     object externalDebtTypeCode = parameters["debtTypeCode"].Value;
     object priceFactor = parameters["priceFactor"].Value;
     object quantityFactor = parameters["quantityFactor"].Value;
     object faceOutstanding = parameters["faceOutstanding"].Value;
     object coupon = parameters["coupon"].Value;
     object maturityDate = parameters["maturityDate"].Value;
     object datedDate = parameters["datedDate"].Value;
     object firstCoupon = parameters["firstCoupon"].Value;
     object frequency = parameters["frequency"].Value;
     object redemptionValue = parameters["redemptionValue"].Value;
     object incomeTaxRate = parameters["incomeTaxRate"].Value;
     object capitalGainsTaxRate = parameters["capitalGainsTaxRate"].Value;
     object cutoffPeriod = parameters["cutoffPeriod"].Value;
     object issuePrice = parameters["issuePrice"].Value;
     object trueYield = parameters["trueYield"].Value;
     object weekendCode = parameters["weekendCode"].Value;
     object exdividendDays = parameters["exdividendDays"].Value;
     object rating0 = parameters["rating0"].Value;
     object rating1 = parameters["rating1"].Value;
     object rating2 = parameters["rating2"].Value;
     object rating3 = parameters["rating3"].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 debtId = Security.FindRequiredKey(configurationId, "debtId", externalDebtId);
     object issuerId = Issuer.FindOptionalKey(configurationId, "issuerId", externalIssuerId);
     object settlementId = Security.FindOptionalKey(configurationId, "settlementId", externalSettlementId);
     object securityTypeCode = SecurityType.FindOptionalKey(configurationId, "securityTypeCode", externalSecurityTypeCode);
     object debtTypeCode = DebtType.FindOptionalKey(configurationId, "debtTypeCode", externalDebtTypeCode);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerDataModel.DebtRow debtRow = debtTable.FindByDebtId(debtId);
     rowVersion = ((long)(debtRow[debtTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Quasar.Core.Debt.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, countryId, typeCode, symbol, debtId, issuerId, settlementId, securityTypeCode, debtTypeCode, priceFactor, quantityFactor, faceOutstanding, coupon, maturityDate, datedDate, firstCoupon, frequency, redemptionValue, incomeTaxRate, capitalGainsTaxRate, cutoffPeriod, issuePrice, trueYield, weekendCode, exdividendDays, rating0, rating1, rating2, rating3);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemple #19
0
 /// <summary>Loads a SourceOrder record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Load(ParameterList parameters)
 {
     // Accessor for the SourceOrder Table.
     ServerMarketData.SourceOrderDataTable sourceOrderTable = ServerMarketData.SourceOrder;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     System.DateTime createdTime = parameters["createdTime"];
     string externalCreatedUserId = parameters["createdUserId"];
     object externalDestinationId = parameters["destinationId"].Value;
     object externalId0 = parameters["externalId0"].Value;
     object isAdvertised = parameters["isAdvertised"].Value;
     object isAutoExecute = parameters["isAutoExecute"].Value;
     object isCanceled = parameters["isCanceled"].Value;
     object isHeld = parameters["isHeld"].Value;
     object isSteppedIn = parameters["isSteppedIn"].Value;
     object isSubmitted = parameters["isSubmitted"].Value;
     object limitPrice = parameters["limitPrice"].Value;
     object maximumVolatility = parameters["maximumVolatility"].Value;
     System.DateTime modifiedTime = parameters["modifiedTime"];
     string externalModifiedUserId = parameters["modifiedUserId"];
     object newsFreeTime = parameters["newsFreeTime"].Value;
     string externalOrderTypeCode = parameters["orderTypeCode"];
     decimal orderedQuantity = parameters["orderedQuantity"];
     string externalPriceTypeCode = parameters["priceTypeCode"];
     object receivedTime = parameters["receivedTime"].Value;
     string externalSecurityId = parameters["securityId"];
     object externalSettlementId = parameters["settlementId"].Value;
     object externalSourceOrderId = parameters["sourceOrderId"].Value;
     object startTime = parameters["startTime"].Value;
     string externalStatusCode = parameters["statusCode"];
     object stopPrice = parameters["stopPrice"].Value;
     object stopTime = parameters["stopTime"].Value;
     object submittedQuantity = parameters["submittedQuantity"].Value;
     object submittedTime = parameters["submittedTime"].Value;
     object targetPrice = parameters["targetPrice"].Value;
     string externalTimeInForceCode = parameters["timeInForceCode"];
     string externalWorkingOrderId = parameters["workingOrderId"];
     // 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 createdUserId = User.FindRequiredKey(configurationId, "createdUserId", externalCreatedUserId);
     object destinationId = Destination.FindOptionalKey(configurationId, "destinationId", externalDestinationId);
     int modifiedUserId = User.FindRequiredKey(configurationId, "modifiedUserId", externalModifiedUserId);
     int orderTypeCode = OrderType.FindRequiredKey(configurationId, "orderTypeCode", externalOrderTypeCode);
     int priceTypeCode = PriceType.FindRequiredKey(configurationId, "priceTypeCode", externalPriceTypeCode);
     int securityId = Security.FindRequiredKey(configurationId, "securityId", externalSecurityId);
     object settlementId = Security.FindOptionalKey(configurationId, "settlementId", externalSettlementId);
     int sourceOrderId = SourceOrder.FindKey(configurationId, "sourceOrderId", externalSourceOrderId);
     int statusCode = Status.FindRequiredKey(configurationId, "statusCode", externalStatusCode);
     int timeInForceCode = TimeInForce.FindRequiredKey(configurationId, "timeInForceCode", externalTimeInForceCode);
     int workingOrderId = WorkingOrder.FindRequiredKey(configurationId, "workingOrderId", externalWorkingOrderId);
     // 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 ((sourceOrderId == int.MinValue))
     {
         // 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 = SourceOrder.GetExternalKeyIndex(configurationId, "sourceOrderId");
         object[] externalIdArray = new object[1];
         externalIdArray[externalKeyIndex] = externalSourceOrderId;
         externalId0 = externalIdArray[0];
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.SourceOrder.Insert(adoTransaction, sqlTransaction, ref rowVersion, createdTime, createdUserId, destinationId, externalId0, isAdvertised, isAutoExecute, isCanceled, isHeld, isSteppedIn, isSubmitted, limitPrice, maximumVolatility, modifiedTime, modifiedUserId, newsFreeTime, orderTypeCode, orderedQuantity, priceTypeCode, receivedTime, securityId, settlementId, startTime, statusCode, stopPrice, stopTime, submittedQuantity, submittedTime, targetPrice, timeInForceCode, workingOrderId);
     }
     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.
         ServerMarketData.SourceOrderRow sourceOrderRow = sourceOrderTable.FindBySourceOrderId(sourceOrderId);
         rowVersion = ((long)(sourceOrderRow[sourceOrderTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.SourceOrder.Update(adoTransaction, sqlTransaction, ref rowVersion, createdTime, createdUserId, destinationId, externalId0, isAdvertised, isAutoExecute, isCanceled, isHeld, isSteppedIn, isSubmitted, limitPrice, maximumVolatility, modifiedTime, modifiedUserId, newsFreeTime, orderTypeCode, orderedQuantity, priceTypeCode, receivedTime, securityId, settlementId, sourceOrderId, startTime, statusCode, stopPrice, stopTime, submittedQuantity, submittedTime, targetPrice, timeInForceCode, workingOrderId);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemple #20
0
 /// <summary>Loads a Debt record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public new static void Load(ParameterList parameters)
 {
     // Accessor for the Debt Table.
     ServerDataModel.DebtDataTable debtTable = ServerDataModel.Debt;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].Value;
     object groupPermission = parameters["groupPermission"].Value;
     object hidden = parameters["hidden"].Value;
     string name = parameters["name"];
     object owner = parameters["owner"].Value;
     object ownerPermission = parameters["ownerPermission"].Value;
     object readOnly = parameters["readOnly"].Value;
     object worldPermission = parameters["worldPermission"].Value;
     string externalCountryId = parameters["countryId"];
     object externalTypeCode = parameters["typeCode"].Value;
     object symbol = parameters["symbol"].Value;
     string externalDebtId = parameters["debtId"];
     object externalIssuerId = parameters["issuerId"].Value;
     string externalSettlementId = parameters["settlementId"];
     object externalSecurityTypeCode = parameters["securityTypeCode"].Value;
     string externalDebtTypeCode = parameters["debtTypeCode"];
     object priceFactor = parameters["priceFactor"].Value;
     object quantityFactor = parameters["quantityFactor"].Value;
     object faceOutstanding = parameters["faceOutstanding"].Value;
     decimal coupon = parameters["coupon"];
     System.DateTime maturityDate = parameters["maturityDate"];
     object datedDate = parameters["datedDate"].Value;
     object firstCoupon = parameters["firstCoupon"].Value;
     object frequency = parameters["frequency"].Value;
     object redemptionValue = parameters["redemptionValue"].Value;
     object incomeTaxRate = parameters["incomeTaxRate"].Value;
     object capitalGainsTaxRate = parameters["capitalGainsTaxRate"].Value;
     object cutoffPeriod = parameters["cutoffPeriod"].Value;
     object issuePrice = parameters["issuePrice"].Value;
     object trueYield = parameters["trueYield"].Value;
     object weekendCode = parameters["weekendCode"].Value;
     object exdividendDays = parameters["exdividendDays"].Value;
     object rating0 = parameters["rating0"].Value;
     object rating1 = parameters["rating1"].Value;
     object rating2 = parameters["rating2"].Value;
     object rating3 = parameters["rating3"].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 debtId = Security.FindKey(configurationId, "debtId", externalDebtId);
     object issuerId = Issuer.FindOptionalKey(configurationId, "issuerId", externalIssuerId);
     int settlementId = Security.FindRequiredKey(configurationId, "settlementId", externalSettlementId);
     object securityTypeCode = SecurityType.FindOptionalKey(configurationId, "securityTypeCode", externalSecurityTypeCode);
     int debtTypeCode = DebtType.FindRequiredKey(configurationId, "debtTypeCode", externalDebtTypeCode);
     ServerDataModel.DebtRow debtRow = debtTable.FindByDebtId(debtId);
     // The load operation will create a record if it doesn't exist, or update an existing record.  The external
     // identifier is used to determine if a record exists with the same key.
     if ((debtRow == null))
     {
         // Populate the 'externalId' varaibles so that the external identifier can be used to find the row when an
         // external method is called with the same 'configurationId' parameter.
         int externalKeyIndex = Debt.GetExternalKeyIndex(configurationId, "debtId");
         object[] externalIdArray = new object[8];
         externalIdArray[externalKeyIndex] = externalDebtId;
         object externalId0 = externalIdArray[0];
         object externalId1 = externalIdArray[1];
         object externalId2 = externalIdArray[2];
         object externalId3 = externalIdArray[3];
         object externalId4 = externalIdArray[4];
         object externalId5 = externalIdArray[5];
         object externalId6 = externalIdArray[6];
         object externalId7 = externalIdArray[7];
         // Call the internal method to complete the operation.
         MarkThree.Quasar.Core.Debt.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, settlementId, securityTypeCode, debtTypeCode, priceFactor, quantityFactor, faceOutstanding, coupon, maturityDate, datedDate, firstCoupon, frequency, redemptionValue, incomeTaxRate, capitalGainsTaxRate, cutoffPeriod, issuePrice, trueYield, weekendCode, exdividendDays, rating0, rating1, rating2, rating3);
     }
     else
     {
         // While the optimistic concurrency checking is disabled for the external methods, the internal methods
         // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
         // will bypass the coused when the internal method is called.
         rowVersion = ((long)(debtRow[debtTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Quasar.Core.Debt.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, countryId, typeCode, symbol, debtId, issuerId, settlementId, securityTypeCode, debtTypeCode, priceFactor, quantityFactor, faceOutstanding, coupon, maturityDate, datedDate, firstCoupon, frequency, redemptionValue, incomeTaxRate, capitalGainsTaxRate, cutoffPeriod, issuePrice, trueYield, weekendCode, exdividendDays, rating0, rating1, rating2, rating3);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemple #21
0
        /// <summary>Updates a Position 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="accountId">The value for the AccountId column.</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="userData0">The value for the UserData0 column.</param>
        /// <param name="userData1">The value for the UserData1 column.</param>
        /// <param name="userData2">The value for the UserData2 column.</param>
        /// <param name="userData3">The value for the UserData3 column.</param>
        /// <param name="userData4">The value for the UserData4 column.</param>
        /// <param name="userData5">The value for the UserData5 column.</param>
        /// <param name="userData6">The value for the UserData6 column.</param>
        /// <param name="userData7">The value for the UserData7 column.</param>
        public static void Update(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, int accountId, int securityId, int positionTypeCode, object userData0, object userData1, object userData2, object userData3, object userData4, object userData5, object userData6, object userData7)
        {
            // Accessor for the Position Table.
            ServerDataModel.PositionDataTable positionTable = ServerDataModel.Position;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.PositionRow positionRow = positionTable.FindByAccountIdSecurityIdPositionTypeCode(accountId, securityId, positionTypeCode);
            if ((positionRow == null))
            {
                throw new Exception(string.Format("The Position table does not have an element identified by {0}{0}{0}", accountId, securityId, positionTypeCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((positionRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((userData0 == null))
            {
                userData0 = positionRow[positionTable.UserData0Column];
            }
            if ((userData1 == null))
            {
                userData1 = positionRow[positionTable.UserData1Column];
            }
            if ((userData2 == null))
            {
                userData2 = positionRow[positionTable.UserData2Column];
            }
            if ((userData3 == null))
            {
                userData3 = positionRow[positionTable.UserData3Column];
            }
            if ((userData4 == null))
            {
                userData4 = positionRow[positionTable.UserData4Column];
            }
            if ((userData5 == null))
            {
                userData5 = positionRow[positionTable.UserData5Column];
            }
            if ((userData6 == null))
            {
                userData6 = positionRow[positionTable.UserData6Column];
            }
            if ((userData7 == null))
            {
                userData7 = positionRow[positionTable.UserData7Column];
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Update the record in the ADO database.
            positionRow[positionTable.RowVersionColumn] = rowVersion;
            positionRow[positionTable.UserData0Column]  = userData0;
            positionRow[positionTable.UserData1Column]  = userData1;
            positionRow[positionTable.UserData2Column]  = userData2;
            positionRow[positionTable.UserData3Column]  = userData3;
            positionRow[positionTable.UserData4Column]  = userData4;
            positionRow[positionTable.UserData5Column]  = userData5;
            positionRow[positionTable.UserData6Column]  = userData6;
            positionRow[positionTable.UserData7Column]  = userData7;
            adoTransaction.DataRows.Add(positionRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Position"" set ""RowVersion""=@rowVersion,""UserData0""=@userData0,""UserData1""=@userData1,""UserData2""=@userData2,""UserData3""=@userData3,""UserData4""=@userData4,""UserData5""=@userData5,""UserData6""=@userData6,""UserData7""=@userData7 where ""AccountId""=@accountId and ""SecurityId""=@securityId and ""PositionTypeCode""=@positionTypeCode");

            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("@accountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accountId));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.Parameters.Add(new SqlParameter("@positionTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, positionTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@userData0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData0));
            sqlCommand.Parameters.Add(new SqlParameter("@userData1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData1));
            sqlCommand.Parameters.Add(new SqlParameter("@userData2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData2));
            sqlCommand.Parameters.Add(new SqlParameter("@userData3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData3));
            sqlCommand.Parameters.Add(new SqlParameter("@userData4", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData4));
            sqlCommand.Parameters.Add(new SqlParameter("@userData5", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData5));
            sqlCommand.Parameters.Add(new SqlParameter("@userData6", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData6));
            sqlCommand.Parameters.Add(new SqlParameter("@userData7", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData7));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Exemple #22
0
 /// <summary>Loads a Blotter 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 Blotter Table.
     ServerDataModel.BlotterDataTable blotterTable = ServerDataModel.Blotter;
     // 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 externalBlotterId = parameters["blotterId"];
     object externalBlockOrderStylesheetId = parameters["blockOrderStylesheetId"].Value;
     object externalPlacementStylesheetId = parameters["placementStylesheetId"].Value;
     object externalExecutionStylesheetId = parameters["executionStylesheetId"].Value;
     object externalTicketStylesheetId = parameters["ticketStylesheetId"].Value;
     object externalAlgorithmId = parameters["algorithmId"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     string externalBlotterTypeCode = parameters["blotterTypeCode"];
     object defaultBlotter = parameters["defaultBlotter"].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 blotterId = Object.FindKey(configurationId, "blotterId", externalBlotterId);
     object blockOrderStylesheetId = Stylesheet.FindOptionalKey(configurationId, "blockOrderStylesheetId", externalBlockOrderStylesheetId);
     object placementStylesheetId = Stylesheet.FindOptionalKey(configurationId, "placementStylesheetId", externalPlacementStylesheetId);
     object executionStylesheetId = Stylesheet.FindOptionalKey(configurationId, "executionStylesheetId", externalExecutionStylesheetId);
     object ticketStylesheetId = Stylesheet.FindOptionalKey(configurationId, "ticketStylesheetId", externalTicketStylesheetId);
     object algorithmId = Algorithm.FindOptionalKey(configurationId, "algorithmId", externalAlgorithmId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     int blotterTypeCode = BlotterType.FindRequiredKey(configurationId, "blotterTypeCode", externalBlotterTypeCode);
     ServerDataModel.BlotterRow blotterRow = blotterTable.FindByBlotterId(blotterId);
     // 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 ((blotterRow == 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 = Blotter.GetExternalKeyIndex(configurationId, "blotterId");
         object[] externalIdArray = new object[8];
         externalIdArray[externalKeyIndex] = externalBlotterId;
         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.Blotter.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, blockOrderStylesheetId, placementStylesheetId, executionStylesheetId, ticketStylesheetId, algorithmId, typeCode, blotterTypeCode, defaultBlotter);
     }
     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)(blotterRow[blotterTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Quasar.Core.Blotter.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, blotterId, blockOrderStylesheetId, placementStylesheetId, executionStylesheetId, ticketStylesheetId, algorithmId, typeCode, blotterTypeCode, defaultBlotter);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemple #23
0
        /// <summary>Inserts a Position record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="accountId">The value for the AccountId column.</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="userData0">The value for the UserData0 column.</param>
        /// <param name="userData1">The value for the UserData1 column.</param>
        /// <param name="userData2">The value for the UserData2 column.</param>
        /// <param name="userData3">The value for the UserData3 column.</param>
        /// <param name="userData4">The value for the UserData4 column.</param>
        /// <param name="userData5">The value for the UserData5 column.</param>
        /// <param name="userData6">The value for the UserData6 column.</param>
        /// <param name="userData7">The value for the UserData7 column.</param>
        public static void Insert(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, int accountId, int securityId, int positionTypeCode, object userData0, object userData1, object userData2, object userData3, object userData4, object userData5, object userData6, object userData7)
        {
            // Accessor for the Position Table.
            ServerDataModel.PositionDataTable positionTable = ServerDataModel.Position;
            // Apply Defaults
            if ((userData0 == null))
            {
                userData0 = System.DBNull.Value;
            }
            if ((userData1 == null))
            {
                userData1 = System.DBNull.Value;
            }
            if ((userData2 == null))
            {
                userData2 = System.DBNull.Value;
            }
            if ((userData3 == null))
            {
                userData3 = System.DBNull.Value;
            }
            if ((userData4 == null))
            {
                userData4 = System.DBNull.Value;
            }
            if ((userData5 == null))
            {
                userData5 = System.DBNull.Value;
            }
            if ((userData6 == null))
            {
                userData6 = System.DBNull.Value;
            }
            if ((userData7 == null))
            {
                userData7 = System.DBNull.Value;
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.PositionRow positionRow = positionTable.NewPositionRow();
            positionRow[positionTable.RowVersionColumn]       = rowVersion;
            positionRow[positionTable.AccountIdColumn]        = accountId;
            positionRow[positionTable.SecurityIdColumn]       = securityId;
            positionRow[positionTable.PositionTypeCodeColumn] = positionTypeCode;
            positionRow[positionTable.UserData0Column]        = userData0;
            positionRow[positionTable.UserData1Column]        = userData1;
            positionRow[positionTable.UserData2Column]        = userData2;
            positionRow[positionTable.UserData3Column]        = userData3;
            positionRow[positionTable.UserData4Column]        = userData4;
            positionRow[positionTable.UserData5Column]        = userData5;
            positionRow[positionTable.UserData6Column]        = userData6;
            positionRow[positionTable.UserData7Column]        = userData7;
            positionTable.AddPositionRow(positionRow);
            adoTransaction.DataRows.Add(positionRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Position"" (""rowVersion"",""AccountId"",""SecurityId"",""PositionTypeCode"",""UserData0"",""UserData1"",""UserData2"",""UserData3"",""UserData4"",""UserData5"",""UserData6"",""UserData7"") values (@rowVersion,@accountId,@securityId,@positionTypeCode,@userData0,@userData1,@userData2,@userData3,@userData4,@userData5,@userData6,@userData7)");

            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("@accountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accountId));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.Parameters.Add(new SqlParameter("@positionTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, positionTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@userData0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData0));
            sqlCommand.Parameters.Add(new SqlParameter("@userData1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData1));
            sqlCommand.Parameters.Add(new SqlParameter("@userData2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData2));
            sqlCommand.Parameters.Add(new SqlParameter("@userData3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData3));
            sqlCommand.Parameters.Add(new SqlParameter("@userData4", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData4));
            sqlCommand.Parameters.Add(new SqlParameter("@userData5", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData5));
            sqlCommand.Parameters.Add(new SqlParameter("@userData6", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData6));
            sqlCommand.Parameters.Add(new SqlParameter("@userData7", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData7));
            sqlCommand.ExecuteNonQuery();
        }
Exemple #24
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 new static void Delete(AdoTransaction adoTransaction)
 {
     // Lock the tables at the base level of the object hierarchy.
     Security.Delete(adoTransaction);
 }
Exemple #25
0
 /// <summary>Collects the table lock request(s) for an Insert operation</summary>
 /// <param name="adoTransaction">A list of locks required for this operation.</param>
 public static void Insert(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for this operation.
     adoTransaction.LockRequests.AddWriterLock(ServerMarketData.HolidayLock);
 }
Exemple #26
0
        /// <summary>Inserts 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 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="securityTypeCode">The value for the SecurityTypeCode column.</param>
        /// <param name="priceFactor">The value for the PriceFactor column.</param>
        /// <param name="quantityFactor">The value for the QuantityFactor 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 securityTypeCode,
            object priceFactor,
            object quantityFactor)
        {
            // Accessor for the Currency Table.
            ServerDataModel.CurrencyDataTable currencyTable = ServerDataModel.Currency;
            // Apply Defaults
            if ((securityTypeCode == null))
            {
                securityTypeCode = 0;
            }
            if ((priceFactor == null))
            {
                priceFactor = 1.0m;
            }
            if ((quantityFactor == null))
            {
                quantityFactor = 1.0m;
            }
            // Insert the base members using the base class.
            int currencyId = 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.CurrencyRow currencyRow = currencyTable.NewCurrencyRow();
            currencyRow[currencyTable.RowVersionColumn] = rowVersion;
            currencyRow[currencyTable.CurrencyIdColumn] = currencyId;
            currencyTable.AddCurrencyRow(currencyRow);
            adoTransaction.DataRows.Add(currencyRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand("insert \"Currency\" (\"rowVersion\",CurrencyId) values (@rowVersion,@currencyId)");

            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("@currencyId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, currencyId));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(currencyRow.CurrencyId);
        }
Exemple #27
0
        /// <summary>Updates a Issuer record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">The version number of 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="issuerId">The value for the IssuerId column.</param>
        /// <param name="countryId">The value for the CountryId column.</param>
        /// <param name="provinceId">The value for the ProvinceId column.</param>
        /// <param name="typeCode">The value for the TypeCode column.</param>
        /// <param name="issuerTypeCode">The value for the IssuerTypeCode column.</param>
        /// <param name="address0">The value for the Address0 column.</param>
        /// <param name="address1">The value for the Address1 column.</param>
        /// <param name="address2">The value for the Address2 column.</param>
        /// <param name="city">The value for the City column.</param>
        /// <param name="postalCode">The value for the PostalCode column.</param>
        /// <param name="rating0">The value for the Rating0 column.</param>
        /// <param name="rating1">The value for the Rating1 column.</param>
        /// <param name="rating2">The value for the Rating2 column.</param>
        /// <param name="rating3">The value for the Rating3 column.</param>
        /// <param name="userData0">The value for the UserData0 column.</param>
        /// <param name="userData1">The value for the UserData1 column.</param>
        /// <param name="userData2">The value for the UserData2 column.</param>
        /// <param name="userData3">The value for the UserData3 column.</param>
        /// <param name="userData4">The value for the UserData4 column.</param>
        /// <param name="userData5">The value for the UserData5 column.</param>
        /// <param name="userData6">The value for the UserData6 column.</param>
        /// <param name="userData7">The value for the UserData7 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,
            int issuerId,
            object countryId,
            object provinceId,
            object typeCode,
            object issuerTypeCode,
            object address0,
            object address1,
            object address2,
            object city,
            object postalCode,
            object rating0,
            object rating1,
            object rating2,
            object rating3,
            object userData0,
            object userData1,
            object userData2,
            object userData3,
            object userData4,
            object userData5,
            object userData6,
            object userData7)
        {
            // Accessor for the Issuer Table.
            ServerDataModel.IssuerDataTable issuerTable = ServerDataModel.Issuer;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.IssuerRow issuerRow = issuerTable.FindByIssuerId(issuerId);
            if ((issuerRow == null))
            {
                throw new Exception(string.Format("The Issuer table does not have an element identified by {0}", issuerId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((issuerRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((countryId == null))
            {
                countryId = issuerRow[issuerTable.CountryIdColumn];
            }
            if ((provinceId == null))
            {
                provinceId = issuerRow[issuerTable.ProvinceIdColumn];
            }
            if ((issuerTypeCode == null))
            {
                issuerTypeCode = issuerRow[issuerTable.IssuerTypeCodeColumn];
            }
            if ((address0 == null))
            {
                address0 = issuerRow[issuerTable.Address0Column];
            }
            if ((address1 == null))
            {
                address1 = issuerRow[issuerTable.Address1Column];
            }
            if ((address2 == null))
            {
                address2 = issuerRow[issuerTable.Address2Column];
            }
            if ((city == null))
            {
                city = issuerRow[issuerTable.CityColumn];
            }
            if ((postalCode == null))
            {
                postalCode = issuerRow[issuerTable.PostalCodeColumn];
            }
            if ((rating0 == null))
            {
                rating0 = issuerRow[issuerTable.Rating0Column];
            }
            if ((rating1 == null))
            {
                rating1 = issuerRow[issuerTable.Rating1Column];
            }
            if ((rating2 == null))
            {
                rating2 = issuerRow[issuerTable.Rating2Column];
            }
            if ((rating3 == null))
            {
                rating3 = issuerRow[issuerTable.Rating3Column];
            }
            if ((userData0 == null))
            {
                userData0 = issuerRow[issuerTable.UserData0Column];
            }
            if ((userData1 == null))
            {
                userData1 = issuerRow[issuerTable.UserData1Column];
            }
            if ((userData2 == null))
            {
                userData2 = issuerRow[issuerTable.UserData2Column];
            }
            if ((userData3 == null))
            {
                userData3 = issuerRow[issuerTable.UserData3Column];
            }
            if ((userData4 == null))
            {
                userData4 = issuerRow[issuerTable.UserData4Column];
            }
            if ((userData5 == null))
            {
                userData5 = issuerRow[issuerTable.UserData5Column];
            }
            if ((userData6 == null))
            {
                userData6 = issuerRow[issuerTable.UserData6Column];
            }
            if ((userData7 == null))
            {
                userData7 = issuerRow[issuerTable.UserData7Column];
            }
            // 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 = issuerRow.ObjectRow.RowVersion;

            Object.Update(adoTransaction, sqlTransaction, ref baseRowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, issuerId, owner, ownerPermission, readOnly, typeCode, worldPermission);
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Update the record in the ADO database.
            issuerRow[issuerTable.RowVersionColumn]     = rowVersion;
            issuerRow[issuerTable.CountryIdColumn]      = countryId;
            issuerRow[issuerTable.ProvinceIdColumn]     = provinceId;
            issuerRow[issuerTable.IssuerTypeCodeColumn] = issuerTypeCode;
            issuerRow[issuerTable.Address0Column]       = address0;
            issuerRow[issuerTable.Address1Column]       = address1;
            issuerRow[issuerTable.Address2Column]       = address2;
            issuerRow[issuerTable.CityColumn]           = city;
            issuerRow[issuerTable.PostalCodeColumn]     = postalCode;
            issuerRow[issuerTable.Rating0Column]        = rating0;
            issuerRow[issuerTable.Rating1Column]        = rating1;
            issuerRow[issuerTable.Rating2Column]        = rating2;
            issuerRow[issuerTable.Rating3Column]        = rating3;
            issuerRow[issuerTable.UserData0Column]      = userData0;
            issuerRow[issuerTable.UserData1Column]      = userData1;
            issuerRow[issuerTable.UserData2Column]      = userData2;
            issuerRow[issuerTable.UserData3Column]      = userData3;
            issuerRow[issuerTable.UserData4Column]      = userData4;
            issuerRow[issuerTable.UserData5Column]      = userData5;
            issuerRow[issuerTable.UserData6Column]      = userData6;
            issuerRow[issuerTable.UserData7Column]      = userData7;
            adoTransaction.DataRows.Add(issuerRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Issuer"" set ""RowVersion""=@rowVersion,""CountryId""=@countryId,""ProvinceId""=@provinceId,""IssuerTypeCode""=@issuerTypeCode,""Address0""=@address0,""Address1""=@address1,""Address2""=@address2,""City""=@city,""PostalCode""=@postalCode,""Rating0""=@rating0,""Rating1""=@rating1,""Rating2""=@rating2,""Rating3""=@rating3,""UserData0""=@userData0,""UserData1""=@userData1,""UserData2""=@userData2,""UserData3""=@userData3,""UserData4""=@userData4,""UserData5""=@userData5,""UserData6""=@userData6,""UserData7""=@userData7 where ""IssuerId""=@issuerId");

            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("@issuerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, issuerId));
            sqlCommand.Parameters.Add(new SqlParameter("@countryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, countryId));
            sqlCommand.Parameters.Add(new SqlParameter("@provinceId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, provinceId));
            sqlCommand.Parameters.Add(new SqlParameter("@issuerTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, issuerTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@address0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, address0));
            sqlCommand.Parameters.Add(new SqlParameter("@address1", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, address1));
            sqlCommand.Parameters.Add(new SqlParameter("@address2", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, address2));
            sqlCommand.Parameters.Add(new SqlParameter("@city", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, city));
            sqlCommand.Parameters.Add(new SqlParameter("@postalCode", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, postalCode));
            sqlCommand.Parameters.Add(new SqlParameter("@rating0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rating0));
            sqlCommand.Parameters.Add(new SqlParameter("@rating1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rating1));
            sqlCommand.Parameters.Add(new SqlParameter("@rating2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rating2));
            sqlCommand.Parameters.Add(new SqlParameter("@rating3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rating3));
            sqlCommand.Parameters.Add(new SqlParameter("@userData0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData0));
            sqlCommand.Parameters.Add(new SqlParameter("@userData1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData1));
            sqlCommand.Parameters.Add(new SqlParameter("@userData2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData2));
            sqlCommand.Parameters.Add(new SqlParameter("@userData3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData3));
            sqlCommand.Parameters.Add(new SqlParameter("@userData4", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData4));
            sqlCommand.Parameters.Add(new SqlParameter("@userData5", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData5));
            sqlCommand.Parameters.Add(new SqlParameter("@userData6", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData6));
            sqlCommand.Parameters.Add(new SqlParameter("@userData7", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userData7));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Exemple #28
0
 /// <summary>Collects the table lock request(s) for an Insert operation</summary>
 /// <param name="adoTransaction">A list of locks required for this operation.</param>
 public static void Insert(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for this operation.
     adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.Holiday));
 }
Exemple #29
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 new static void Archive(AdoTransaction adoTransaction)
 {
     // Lock the tables at the base level of the object hierarchy.
     Object.Archive(adoTransaction);
 }
Exemple #30
0
        /// <summary>Updates a Status 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="statusCode">The value for the StatusCode column.</param>
        /// <param name="mnemonic">The value for the Mnemonic column.</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>
        public static void Update(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, int statusCode, object mnemonic, object description, object externalId0, object externalId1, object externalId2, object externalId3)
        {
            // Accessor for the Status Table.
            ServerDataModel.StatusDataTable statusTable = ServerDataModel.Status;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.StatusRow statusRow = statusTable.FindByStatusCode(statusCode);
            if ((statusRow == null))
            {
                throw new Exception(string.Format("The Status table does not have an element identified by {0}", statusCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((statusRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((mnemonic == null))
            {
                mnemonic = statusRow[statusTable.MnemonicColumn];
            }
            if ((description == null))
            {
                description = statusRow[statusTable.DescriptionColumn];
            }
            if ((externalId0 == null))
            {
                externalId0 = statusRow[statusTable.ExternalId0Column];
            }
            if ((externalId1 == null))
            {
                externalId1 = statusRow[statusTable.ExternalId1Column];
            }
            if ((externalId2 == null))
            {
                externalId2 = statusRow[statusTable.ExternalId2Column];
            }
            if ((externalId3 == null))
            {
                externalId3 = statusRow[statusTable.ExternalId3Column];
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Update the record in the ADO database.
            statusRow[statusTable.RowVersionColumn]  = rowVersion;
            statusRow[statusTable.MnemonicColumn]    = mnemonic;
            statusRow[statusTable.DescriptionColumn] = description;
            statusRow[statusTable.ExternalId0Column] = externalId0;
            statusRow[statusTable.ExternalId1Column] = externalId1;
            statusRow[statusTable.ExternalId2Column] = externalId2;
            statusRow[statusTable.ExternalId3Column] = externalId3;
            adoTransaction.DataRows.Add(statusRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Status\" set \"RowVersion\"=@rowVersion,\"Mnemonic\"=@mnemonic,\"Description\"=@" +
                                                   "description,\"ExternalId0\"=@externalId0,\"ExternalId1\"=@externalId1,\"ExternalId2\"=" +
                                                   "@externalId2,\"ExternalId3\"=@externalId3 where \"StatusCode\"=@statusCode");

            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("@statusCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, statusCode));
            sqlCommand.Parameters.Add(new SqlParameter("@mnemonic", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, mnemonic));
            sqlCommand.Parameters.Add(new SqlParameter("@description", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, description));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId1", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId1));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId2", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId2));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId3", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId3));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }