/// <summary> /// Handles generic faults. /// </summary> /// <param name="workingOrders">The batch of Working Order updates.</param> /// <param name="batchFault">The generic FaultException.</param> void HandleFaultException(WebService.WorkingOrder[] workingOrders, FaultException faultException) { // This will try to make the generic faults less generic. The same thing could have been accomplished with a 'Catch' clause but then we would have // needed a separate foreground handler for each kind of fault. This will test to see if we had an 'InsufficientClaims' fault which will invoke a // specific message. FaultException <InsufficientClaimsFault> insufficientClaimsFault = faultException as FaultException <InsufficientClaimsFault>; if (insufficientClaimsFault != null) { // The user doesn't have the required permission to execute this method. MessageBox.Show( Properties.Resources.InsufficientClaimsExceptionError, Settings.Default.ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error); } else { // Check to see if the record is busy. FaultException <OptimisticConcurrencyFault> optimisticConcurrencyFault = faultException as FaultException <OptimisticConcurrencyFault>; if (optimisticConcurrencyFault != null) { // This record is busy - please try again later. MessageBox.Show( Properties.Resources.OptimisticConcurrencyExceptionError, Settings.Default.ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error); } else { // If we haven't recognized what kind of fault was generated, then we'll just emit to the user whatever message came with this fault. MessageBox.Show(faultException.Message, Settings.Default.ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error); } } // When the entire batch fails, we'll restore the entire Model View back to it's original state (the one it had before generating the batch). WorkingOrderCollection <EquityWorkingOrder> workingOrderCollection = this.equityWorkingOrderView.WorkingOrders; foreach (WebService.WorkingOrder workingOrder in workingOrders) { DataModel.WorkingOrderRow workingOrderRow = DataModel.WorkingOrder.WorkingOrderKey.Find(workingOrder.WorkingOrderId); Int32 index = workingOrderCollection.Find(workingOrderRow.WorkingOrderId); if (index >= 0) { EquityWorkingOrder equityWorkingOrder = workingOrderCollection[index]; workingOrderCollection.View.EditItem(equityWorkingOrder); equityWorkingOrder.IsBrokerMatch = workingOrderRow.IsBrokerMatch; equityWorkingOrder.IsHedgeMatch = workingOrderRow.IsHedgeMatch; equityWorkingOrder.IsInstitutionMatch = workingOrderRow.IsInstitutionMatch; workingOrderCollection.View.CommitEdit(); } } }
/// <summary> /// Handles a general change to properties of a working order in the collection. /// </summary> /// <param name="equityBlotterPage">An object in the foreground thread that is notified of errors.</param> /// <param name="equityWorkingOrder">A working order that has changed.</param> static void UpdateWorkingOrderProperty(EquityBlotterPage equityBlotterPage, EquityWorkingOrder equityWorkingOrder) { // This will extract the fields of the working order from the View Model and initiate a background task that will call the server to update the record. WebService.WorkingOrder workingOrder = new WebService.WorkingOrder() { IsBrokerMatch = equityWorkingOrder.IsBrokerMatch, IsHedgeMatch = equityWorkingOrder.IsHedgeMatch, IsInstitutionMatch = equityWorkingOrder.IsInstitutionMatch, RowVersion = equityWorkingOrder.RowVersion, SideCode = equityWorkingOrder.SideCode, TimeInForceCode = equityWorkingOrder.TimeInForceCode, WorkingOrderId = equityWorkingOrder.WorkingOrderId }; ThreadPool.QueueUserWorkItem(equityBlotterPage.UpdateWorkingOrderThread, new WebService.WorkingOrder[] { workingOrder }); }
/// <summary> /// Handles a general change to properties of a working order in the collection. /// </summary> /// <param name="equityBlotterPage">An object in the foreground thread that is notified of errors.</param> /// <param name="equityWorkingOrder">A working order that has changed.</param> static void UpdateWorkingOrderProperty(EquityBlotterPage equityBlotterPage, EquityWorkingOrder equityWorkingOrder) { }