Exemple #1
0
        /// <summary>
        /// Accept a settlement.
        /// </summary>
        /// <param name="negotiationId"></param>
        private void AcceptSettlement(Guid negotiationId)
        {
            TradingSupportClient tradingSupportClient = new TradingSupportClient(Guardian.Properties.Settings.Default.TradingSupportEndpoint);

            try
            {
                tradingSupportClient.CreateConsumerDebtSettlement(negotiationId);
            }
            catch (FaultException <ArgumentFault> exception)
            {
                EventLog.Information(
                    "Server rejected auto-accept of consumer debt negotiation {0}: {1}: {2}\n {3}",
                    negotiationId,
                    exception.GetType(),
                    exception.Detail.Message,
                    exception.StackTrace);
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(String.Format("Accepting negotiation {0} failed from debt side inexplicably.", negotiationId));
                EventLog.Error(
                    "Failed to auto-settle consumer debt negotiation {0}: {1}: {2}\n {3}",
                    negotiationId,
                    exception.GetType(),
                    exception.Message,
                    exception.StackTrace);
            }
            finally
            {
                if (tradingSupportClient != null && tradingSupportClient.State == CommunicationState.Opened)
                {
                    tradingSupportClient.Close();
                }
            }

            Thread.Sleep(5000);
        }