示例#1
0
        /// <summary>
        /// Marks a set of record(s) as read.
        /// </summary>
        /// <param name="state">The list to delete.</param>
        private void RegenerateSettlementThread(object state)
        {
            List <BaseRecord>       consumerDebtSettlementRows = state as List <BaseRecord>;
            MethodResponseErrorCode response;

            // Send the regenerate records.
            TradingSupportClient tradingSupportClient = new TradingSupportClient(Guardian.Properties.Settings.Default.TradingSupportEndpoint);

            try
            {
                response = tradingSupportClient.ResetConsumerDebtSettlement(consumerDebtSettlementRows.ToArray());

                if (!response.IsSuccessful)
                {
                    List <BaseRecord> retryRecords = new List <BaseRecord>();

                    foreach (ErrorInfo errorInfo in response.Errors)
                    {
                        EventLog.Error("ResetConsumerDebtSettlement {0} failed with following message: {1}", errorInfo.BulkIndex, errorInfo.Message);
                    }

                    throw new FaultException("Not all the records were reset.  Please see Event Viewer for detailed information about the errors.");
                }
            }
            catch (FaultException faultException)
            {
                EventLog.Error("{0}, {1}", faultException.Message, faultException.StackTrace);

                this.Dispatcher.BeginInvoke(new Action(() =>
                                                       MessageBox.Show(Application.Current.MainWindow, faultException.Message, Application.Current.MainWindow.Title, MessageBoxButton.OK,
                                                                       MessageBoxImage.Error)));
            }
            catch (Exception exception)
            {
                // Any issues trying to communicate to the server are logged or might not have a valid match row cell to bold or unbold.
                EventLog.Error("{0}, {1}", exception.Message, exception.StackTrace);

                this.Dispatcher.BeginInvoke(new Action(() =>
                                                       MessageBox.Show(Application.Current.MainWindow, "Failed to perform Regenerate Settlement operation.", Application.Current.MainWindow.Title)));
            }
            finally
            {
                if (tradingSupportClient != null && tradingSupportClient.State == CommunicationState.Opened)
                {
                    tradingSupportClient.Close();
                }
            }
        }