Esempio n. 1
0
        /// <summary>
        /// Creates one or more destination orders.
        /// </summary>
        /// <param name="destinationOrders"></param>
        internal static void CreateDestinationOrders(DestinationOrderInfo[] destinationOrders)
        {
            // An instance of the shared data model is required to use its methods.
            DataModel dataModel = new DataModel();

            // Business logic: provide the current time and the user identifier for the new destination order.
            DateTime dateTime = DateTime.UtcNow;
            Guid     userId   = TradingSupport.UserId;

            DataModelTransaction dataModelTransaction = DataModelTransaction.Current;

            StatusRow statusNewRow = DataModel.Status.StatusKeyStatusCode.Find(Status.New);

            statusNewRow.AcquireReaderLock(dataModelTransaction);

            StateRow stateIntialRow = DataModel.State.StateKeyStateCode.Find(State.Initial);

            stateIntialRow.AcquireReaderLock(dataModelTransaction);

            // The entire collection of destination orders is added or rejected as a single transaction.
            foreach (DestinationOrderInfo destinationOrderInfo in destinationOrders)
            {
                Guid destinationOrderId = Guid.NewGuid();
                dataModel.CreateDestinationOrder(
                    destinationOrderInfo.BlotterId,
                    0.0M,
                    null,
                    dateTime,
                    userId,
                    destinationOrderInfo.DestinationId,
                    destinationOrderId,
                    null,
                    null,
                    false,
                    false,
                    null,
                    dateTime,
                    userId,
                    destinationOrderInfo.OrderedQuantity,
                    destinationOrderInfo.OrderTypeId,
                    destinationOrderInfo.SecurityId,
                    dateTime,
                    destinationOrderInfo.SettlementId,
                    destinationOrderInfo.SideCodeId,
                    stateIntialRow.StateId,
                    statusNewRow.StatusId,
                    null,
                    destinationOrderInfo.TimeInForceCodeId,
                    dateTime,
                    null,
                    destinationOrderInfo.WorkingOrderId);
            }
        }