Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="consumerTrust"></param>
        /// <returns></returns>
        public static MethodResponseErrorCode UpdateSecurity(Security security)
        {
            if (security.RowId == Guid.Empty)
            {
                throw new MissingFieldException("RowId is not set");
            }

            lock (DataModel.SyncRoot)
            {
                SecurityRow row = DataModel.Security.SecurityKey.Find(security.RowId);

                if (TradingSupportWebService.ColumnChanged(row, security))
                {
                    return(UpdateSecurity(new Security[] { security }));
                }
                else
                {
                    return(null);
                }
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="consumer"></param>
        public static MethodResponseErrorCode UpdateConsumer(Consumer consumer)
        {
            if (consumer.RowId == Guid.Empty)
            {
                throw new MissingFieldException("RowId is not set");
            }

            lock (DataModel.SyncRoot)
            {
                ConsumerRow row = DataModel.Consumer.ConsumerKey.Find(consumer.RowId);

                if (TradingSupportWebService.ColumnChanged(row, consumer))
                {
                    return(UpdateConsumer(new Consumer[] { consumer }));
                }
                else
                {
                    return(null);
                }
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="consumer"></param>
        public static MethodResponseErrorCode UpdateNegotiaton(Negotiation negotiation)
        {
            if (negotiation.RowId == Guid.Empty)
            {
                throw new MissingFieldException("RowId is not set");
            }

            lock (DataModel.SyncRoot)
            {
                NegotiationRow row = DataModel.Negotiation.NegotiationKey.Find(negotiation.RowId);

                if (TradingSupportWebService.ColumnChanged(row, negotiation))
                {
                    return(UpdateNegotiaton(new Negotiation[] { negotiation }));
                }
                else
                {
                    return(null);
                }
            }
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="workingOders"></param>
        public static MethodResponseErrorCode UpdateWorkingOrder(WorkingOrderRecord workingOrder)
        {
            MethodResponseErrorCode response = null;
            // Update the database.
            TradingSupportClient tradingSupportClient = new TradingSupportClient(Guardian.Properties.Settings.Default.TradingSupportEndpoint);

            try
            {
                lock (DataModel.SyncRoot)
                {
                    WorkingOrderRow row = DataModel.WorkingOrder.WorkingOrderKey.Find(workingOrder.RowId);

                    if (TradingSupportWebService.ColumnChanged(row, workingOrder))
                    {
                        response = tradingSupportClient.UpdateWorkingOrder(new WorkingOrderRecord[] { workingOrder });
                    }
                    else
                    {
                        response = null;
                    }
                }
            }
            catch (Exception exception)
            {
                // Any issues trying to communicate to the server are logged.
                EventLog.Error("{0}, {1}", exception.Message, exception.StackTrace);
            }
            finally
            {
                if (tradingSupportClient != null && tradingSupportClient.State == CommunicationState.Opened)
                {
                    tradingSupportClient.Close();
                }
            }
            return(response);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="textBoxTxt"></param>
        /// <param name="iContent"></param>
        private void TextBoxValueChanged(string textBoxTxt, IContent iContent)
        {
            DataTableCoordinate dataTableCoordiante = iContent.Key as DataTableCoordinate;
            ConsumerRow         workingOrderRow     = dataTableCoordiante.DataRow as ConsumerRow;
            string textBoxString  = textBoxTxt;
            Guid   workingOrderId = dataTableCoordiante.Association;

            if (dataTableCoordiante.DataColumn == DataModel.Consumer.FirstNameColumn)
            {
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumer(new Consumer(workingOrderRow)
                {
                    FirstName = textBoxString, WorkingOrderId = workingOrderId
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.Consumer.LastNameColumn)
            {
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumer(new Consumer(workingOrderRow)
                {
                    LastName = textBoxString, WorkingOrderId = workingOrderId
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.Consumer.SocialSecurityNumberColumn)
            {
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumer(new Consumer(workingOrderRow)
                {
                    SocialSecurityNumber = textBoxString
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.CreditCard.AccountBalanceColumn)
            {
                CreditCardRow creditCardRow = dataTableCoordiante.DataRow as CreditCardRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateCreditCard(new CreditCard(creditCardRow)
                {
                    AccountBalance = textBoxString
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.CreditCard.OriginalAccountNumberColumn)
            {
                CreditCardRow creditCardRow = dataTableCoordiante.DataRow as CreditCardRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateCreditCard(new CreditCard(creditCardRow)
                {
                    OriginalAccountNumber = textBoxString
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.CreditCard.AccountNumberColumn)
            {
                CreditCardRow creditCardRow = dataTableCoordiante.DataRow as CreditCardRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateCreditCard(new CreditCard(creditCardRow)
                {
                    AccountNumber = textBoxString
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.CreditCard.DebtHolderColumn)
            {
                CreditCardRow creditCardRow = dataTableCoordiante.DataRow as CreditCardRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateCreditCard(new CreditCard(creditCardRow)
                {
                    DebtHolder = textBoxString
                })));
            }
        }
        /// <summary>
        /// Handlers for the ComboBox class of controls.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="routedEventArgs">The routed event arguments.</param>
        private void OnSelectorSelectionChanged(object sender, RoutedEventArgs routedEventArgs)
        {
            // The main idea of this handler is to sort out the user generated actions from the machine generated actions.  Once
            // its determined that it was a user action, a background thread is called to change the associated field to the value
            // selected by the ComboBox.
            SelectionChangedEventArgs selectionChangedEventArgs = routedEventArgs as SelectionChangedEventArgs;

            // Handle changes to ComboBox elements.
            if (selectionChangedEventArgs.OriginalSource is ComboBox)
            {
                ComboBox comboBox = selectionChangedEventArgs.OriginalSource as ComboBox;
                IContent iContent = comboBox.DataContext as IContent;

                // This filters all the ComboBox events looking for user initiated actions that are bound to the data model.
                if (InputHelper.IsUserInitiated(comboBox, ComboBox.SelectedValueProperty) &&
                    iContent != null && iContent.Key is DataTableCoordinate)
                {
                    // At this point, a ComboBox was modified by the user and it is connected to a data model field.  This will extract
                    // the coordinates of the field in the table.  That, in turn, drives the decision about how to update the shared
                    // data model.
                    DataTableCoordinate dataTableCoordiante = iContent.Key as DataTableCoordinate;
                    CreditCardRow       creditCardRow       = dataTableCoordiante.DataRow as CreditCardRow;


                    if (dataTableCoordiante.DataColumn == DataModel.CreditCard.DebtRuleIdColumn)
                    {
                        //make sure the value has changed before making a webSvc call
                        object newDebtRuleId = comboBox.SelectedValue;
                        if (newDebtRuleId == null || (Guid)newDebtRuleId == Guid.Empty)
                        {
                            newDebtRuleId = DBNull.Value;
                        }
                        object oldDebtRuleId = DBNull.Value;
                        if (creditCardRow.IsDebtRuleIdNull() == false)
                        {
                            oldDebtRuleId = creditCardRow.DebtRuleId;
                        }

                        if (object.Equals(oldDebtRuleId, newDebtRuleId) == false)
                        {
                            FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                               TradingSupportWebService.UpdateCreditCard(new CreditCard(creditCardRow)
                            {
                                DebtRuleId = newDebtRuleId
                            })));
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Handlers for the Toggle button class of controls.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="routedEventArgs">The routed event arguments.</param>
        private void OnToggleButtonChange(object sender, RoutedEventArgs routedEventArgs)
        {
            // The main idea of this handler is to sort out the user generated actions from the machine generated actions.  Once
            // its determined that it was a user action, a background thread is called to change the associated field to the value
            // selected by the ToggleButton.
            ToggleButton toggleButton = routedEventArgs.OriginalSource as ToggleButton;
            IContent     iContent     = toggleButton.DataContext as IContent;

            // This filters all the ToggleButton events looking for user initiated actions that are bound to the data model.
            if (InputHelper.IsUserInitiated(toggleButton, ToggleButton.IsCheckedProperty) &&
                iContent != null && iContent.Key is DataTableCoordinate)
            {
                bool toggleButtonState = toggleButton.IsChecked.GetValueOrDefault();

                // At this point, a ToggleButton was modified by the user and it is connected to a data model field.  This will
                // extract the coordinates of the field in the table.  That, in turn, drives the decision about how to update the
                // shared data model.
                DataTableCoordinate     dataTableCoordiante = iContent.Key as DataTableCoordinate;
                ConsumerTrustPaymentRow paymentRow          = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                // Update the IsActive column.
                if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.IsActiveColumn)
                {
                    FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                       TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(paymentRow)
                    {
                        IsActive = toggleButtonState
                    })));
                }
                // Update the IsCleared column.
                if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.IsClearedColumn)
                {
                    FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                       TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(paymentRow)
                    {
                        IsCleared = toggleButtonState
                    })));
                }
            }
        }
        /// <summary>
        /// Handle sending data down to the server for a date time picker changed event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="routedEventArgs"></param>
        private void OnDateTimePicker(object sender, RoutedEventArgs routedEventArgs)
        {
            FluidTrade.Actipro.DateTimePicker originalSourceDateTimePicker = routedEventArgs.OriginalSource as FluidTrade.Actipro.DateTimePicker;
            if (originalSourceDateTimePicker != null)
            {
                IContent iContent = originalSourceDateTimePicker.DataContext as IContent;
                FluidTrade.Actipro.DateTimePicker sourceDateTimePicker = routedEventArgs.Source as FluidTrade.Actipro.DateTimePicker;

                if (InputHelper.IsUserInitiated(originalSourceDateTimePicker, FluidTrade.Actipro.DateTimePicker.DateTimeProperty) &&
                    (sourceDateTimePicker != null) &&
                    (iContent != null) &&
                    (iContent.Key is DataTableCoordinate))
                {
                    // At this point, a ComboBox was modified by the user and it is connected to a data model field.  This will
                    // extract the coordinates of the field in the table.  That, in turn, drives the decision about how to update the
                    // shared data model.
                    DataTableCoordinate     dataTableCoordiante = iContent.Key as DataTableCoordinate;
                    ConsumerTrustPaymentRow paymentRow          = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;

                    // Update the Cleared Date column.
                    if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.ClearedDateColumn)
                    {
                        if (sourceDateTimePicker.DateTime != null)
                        {
                            DateTime selectedItem = (DateTime)sourceDateTimePicker.DateTime;
                            FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                               TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(paymentRow)
                            {
                                ClearedDate = selectedItem
                            })));
                        }
                    }

                    // Update the Actual Payment Date column.
                    if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.ActualPaymentDateColumn)
                    {
                        if (sourceDateTimePicker.DateTime != null)
                        {
                            DateTime selectedItem = (DateTime)sourceDateTimePicker.DateTime;
                            FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                               TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(paymentRow)
                            {
                                ActualPaymentDate = selectedItem
                            })));
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Handle sending data down to the server for a combo box changed event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="routedEventArgs"></param>
        private void OnComboBoxChange(object sender, RoutedEventArgs routedEventArgs)
        {
            FluidTrade.Guardian.Windows.Controls.StatusComboBox originalSourceStatusComboBox = routedEventArgs.OriginalSource as FluidTrade.Guardian.Windows.Controls.StatusComboBox;
            if (originalSourceStatusComboBox != null)
            {
                IContent iContent = originalSourceStatusComboBox.DataContext as IContent;
                FluidTrade.Guardian.Windows.Controls.StatusComboBox sourceStatusComboBox = routedEventArgs.Source as FluidTrade.Guardian.Windows.Controls.StatusComboBox;

                if (InputHelper.IsUserInitiated(originalSourceStatusComboBox, FluidTrade.Guardian.Windows.Controls.StatusComboBox.PersistentSelectedValueProperty) &&
                    (sourceStatusComboBox != null) &&
                    (iContent != null) &&
                    (iContent.Key is DataTableCoordinate))
                {
                    // At this point, a ComboBox was modified by the user and it is connected to a data model field.  This will
                    // extract the coordinates of the field in the table.  That, in turn, drives the decision about how to update the
                    // shared data model.
                    DataTableCoordinate     dataTableCoordiante = iContent.Key as DataTableCoordinate;
                    ConsumerTrustPaymentRow paymentRow          = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;

                    // Update the Payment Status (StatusId) column.
                    if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.StatusIdColumn)
                    {
                        Guid selectedItem          = (Guid)sourceStatusComboBox.SelectedValue;
                        Guid persistedSelectedItem = (Guid)sourceStatusComboBox.PersistentSelectedValue;

                        FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                           TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(paymentRow)
                        {
                            StatusId = persistedSelectedItem
                        })));
                    }
                }
            }
        }
        /// <summary>
        /// Handle sending data down to the server for a text box changed event.
        /// </summary>
        /// <param name="textBoxTxt"></param>
        /// <param name="iContent"></param>
        private void TextBoxValueChanged(string textBoxTxt, IContent iContent)
        {
            DataTableCoordinate dataTableCoordiante = iContent.Key as DataTableCoordinate;
            ConsumerRow         workingOrderRow     = dataTableCoordiante.DataRow as ConsumerRow;
            string textBoxString  = textBoxTxt;
            Guid   workingOrderId = dataTableCoordiante.Association;

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.CheckIdColumn)
            {
                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    CheckId = textBoxTxt
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.Fee0Column)
            {
                Decimal result;
                bool    parsed = Decimal.TryParse(textBoxTxt, out result);
                if (!parsed)
                {
                    result = 0.0m;
                }

                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    Fee0 = result
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.ActualPaymentValueColumn)
            {
                Decimal result;
                bool    parsed = Decimal.TryParse(textBoxTxt, out result);
                if (!parsed)
                {
                    result = 0.0m;
                }

                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    ActualPaymentValue = result
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.Memo0Column)
            {
                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    Memo0 = textBoxTxt
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.Memo1Column)
            {
                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    Memo1 = textBoxTxt
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.Memo2Column)
            {
                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    Memo2 = textBoxTxt
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.TrackingNumberColumn)
            {
                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    TrackingNumber = textBoxTxt
                })));
            }
        }
        /// <summary>
        /// Update the Crossing field.
        /// </summary>
        /// <param name="dataModelClient">The client channel to the shared data model.</param>
        /// <param name="workingOrderRow">The record that is to be updated.</param>
        /// <param name="value">The value of the IsInstutitionMatch field.</param>
        private void UpdateCrossing(WorkingOrderRow workingOrderRow, object newValue)
        {
            // Update the Crossing field.
            Crossing    crossing      = (Boolean)newValue ? Crossing.AlwaysMatch : Crossing.NeverMatch;
            Object      submittedTime = crossing == Crossing.AlwaysMatch ? (Object)DateTime.UtcNow : (Object)null;
            CrossingRow crossingRow   = DataModel.Crossing.CrossingKeyCrossingCode.Find(crossing);


            FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                               TradingSupportWebService.UpdateWorkingOrder(new WorkingOrderRecord(workingOrderRow)
            {
                CrossingCode = crossingRow.CrossingId, SubmittedUTCTime = submittedTime
            })));
        }
        /// <summary>
        /// Handlers for the ComboBox class of controls.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="routedEventArgs">The routed event arguments.</param>
        private void OnSelectorSelectionChanged(object sender, RoutedEventArgs routedEventArgs)
        {
            // The main idea of this handler is to sort out the user generated actions from the machine generated actions.  Once
            // its determined that it was a user action, a background thread is called to change the associated field to the value
            // selected by the ComboBox.
            SelectionChangedEventArgs selectionChangedEventArgs = routedEventArgs as SelectionChangedEventArgs;

            // Handle changes to ComboBox elements.
            if (selectionChangedEventArgs.OriginalSource is ComboBox)
            {
                ComboBox comboBox = selectionChangedEventArgs.OriginalSource as ComboBox;
                IContent iContent = comboBox.DataContext as IContent;

                // This filters all the ComboBox events looking for user initiated actions that are bound to the data model.
                if (InputHelper.IsUserInitiated(comboBox, ComboBox.SelectedValueProperty) &&
                    iContent != null && iContent.Key is DataTableCoordinate)
                {
                    // At this point, a ComboBox was modified by the user and it is connected to a data model field.  This will extract
                    // the coordinates of the field in the table.  That, in turn, drives the decision about how to update the shared
                    // data model.
                    DataTableCoordinate dataTableCoordiante = iContent.Key as DataTableCoordinate;
                    WorkingOrderRow     workingOrderRow     = dataTableCoordiante.DataRow as WorkingOrderRow;

                    if (dataTableCoordiante.DataColumn == DataModel.WorkingOrder.TimeInForceIdColumn)
                    {
                        TimeInForceRow timeInForceRow = DataModel.TimeInForce.TimeInForceKeyTimeInForceCode.Find((TimeInForce)comboBox.SelectedValue);
                        FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                           TradingSupportWebService.UpdateWorkingOrder(new WorkingOrderRecord(workingOrderRow)
                        {
                            TimeInForceId = timeInForceRow.TimeInForceId
                        })));
                    }

                    // This will update changes make to the Side field in a background thread.
                    if (dataTableCoordiante.DataColumn == DataModel.WorkingOrder.SideIdColumn)
                    {
                        SideRow sideRow = DataModel.Side.SideKeySideCode.Find((Side)comboBox.SelectedValue);
                        FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                           TradingSupportWebService.UpdateWorkingOrder(new WorkingOrderRecord(workingOrderRow)
                        {
                            SideId = sideRow.SideId
                        })));
                    }
                }
            }
        }
Exemple #13
0
        /// <summary>
        /// Handlers for the Toggle button class of controls.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="routedEventArgs">The routed event arguments.</param>
        private void OnToggleButtonChange(object sender, RoutedEventArgs routedEventArgs)
        {
            // The main idea of this handler is to sort out the user generated actions from the machine generated actions.  Once
            // its determined that it was a user action, a background thread is called to change the associated field to the value
            // selected by the ToggleButton.
            ToggleButton toggleButton = routedEventArgs.OriginalSource as ToggleButton;
            IContent     iContent     = toggleButton.DataContext as IContent;

            // This filters all the ToggleButton events looking for user initiated actions that are bound to the data model.
            if (InputHelper.IsUserInitiated(toggleButton, ToggleButton.IsCheckedProperty) &&
                iContent != null && iContent.Key is DataTableCoordinate)
            {
                // At this point, a ToggleButton was modified by the user and it is connected to a data model field.  This will
                // extract the coordinates of the field in the table.  That, in turn, drives the decision about how to update the
                // shared data model.
                DataTableCoordinate dataTableCoordiante = iContent.Key as DataTableCoordinate;
                WorkingOrderRow     workingOrderRow     = dataTableCoordiante.DataRow as WorkingOrderRow;
                bool?selectedValue = toggleButton.IsChecked;

                // Update the Crossing column.
                if (dataTableCoordiante.DataColumn == DataModel.WorkingOrder.CrossingIdColumn)
                {
                    UpdateCrossing(workingOrderRow, toggleButton.IsChecked);
                }

                // Update the IsInstitutionMatch column.
                if (dataTableCoordiante.DataColumn == DataModel.WorkingOrder.IsInstitutionMatchColumn)
                {
                    FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                       TradingSupportWebService.UpdateWorkingOrder(new WorkingOrderRecord(workingOrderRow)
                    {
                        IsInstitutionMatch = selectedValue
                    })));
                }

                // Update the IsBrokerMatch column.
                if (dataTableCoordiante.DataColumn == DataModel.WorkingOrder.IsBrokerMatchColumn)
                {
                    FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                       TradingSupportWebService.UpdateWorkingOrder(new WorkingOrderRecord(workingOrderRow)
                    {
                        IsBrokerMatch = selectedValue
                    })));
                }


                // Update the IsHedgeMatch column.
                if (dataTableCoordiante.DataColumn == DataModel.WorkingOrder.IsHedgeMatchColumn)
                {
                    FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                       TradingSupportWebService.UpdateWorkingOrder(new WorkingOrderRecord(workingOrderRow)
                    {
                        IsHedgeFundMatch = selectedValue
                    })));
                }
            }
        }