Ejemplo n.º 1
0
        /// <summary>
        /// Initialize the GUI.
        /// </summary>
        /// <param name="parameter"></param>
        protected override void InitializeData(object parameter)
        {
            settlementLetter = null;
            Guid consumerDebtSettlementId = (Guid)parameter;

            if ((consumerDebtSettlementId != null) && (consumerDebtSettlementId != Guid.Empty))
            {
                // Lock the data model to extract information from the settlementRow.
                lock (DataModel.SyncRoot)
                {
                    ConsumerDebtSettlementRow consumerDebtSettlementRow = DataModel.ConsumerDebtSettlement.ConsumerDebtSettlementKey.Find(consumerDebtSettlementId);
                    if (!consumerDebtSettlementRow.IsSettlementLetterNull())
                    {
                        settlementLetter = Convert.FromBase64String(consumerDebtSettlementRow.SettlementLetter);
                    }
                }

                // Dispatch to foreground thread for updating the GUI.
                if (settlementLetter != null)
                {
                    this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new SettlementLetterHandler(UpdateConsole), settlementLetter);
                }

                currentConsumerDebtSettlementId = consumerDebtSettlementId;
            }
            else
            {
                //Clear out when switching between Debt Classes.
                if ((IsLetterLoaded) && (consumerDebtSettlementId == Guid.Empty))
                {
                    // Sending null to clear out the settlement from the viewer.
                    this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new SettlementLetterHandler(UpdateConsole), null);
                    settlementLetter = null;
                }
                else if ((currentConsumerDebtSettlementId != null) && (currentConsumerDebtSettlementId != Guid.Empty))
                {
                    // Lock the data model to extract information from the settlementRow.
                    lock (DataModel.SyncRoot)
                    {
                        ConsumerDebtSettlementRow consumerDebtSettlementRow = DataModel.ConsumerDebtSettlement.ConsumerDebtSettlementKey.Find(currentConsumerDebtSettlementId);
                        if (!consumerDebtSettlementRow.IsSettlementLetterNull())
                        {
                            settlementLetter = Convert.FromBase64String(consumerDebtSettlementRow.SettlementLetter);
                        }
                    }

                    // Dispatch to foreground thread for updating the GUI.
                    if (settlementLetter != null)
                    {
                        this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new SettlementLetterHandler(UpdateConsole), settlementLetter);
                    }
                }
            }
        }