/// <summary>
        ///
        /// </summary>
        void _currencyService_ConversionRateCompleted(object sender, ConversionRateCompletedEventArgs e)
        {
            Currency[] state = (Currency[])e.UserState;
            double     value = e.Result;

            if (value == 0)
            {
                SystemMonitor.Warning("Value 0 not accepted from service.");
                return;
            }

            ConversionEntry entry = null;

            lock (this)
            {
                if (_entries.ContainsKey(state[0].ToString()) &&
                    _entries[state[0].ToString()].ContainsKey(state[1].ToString()))
                {
                    entry = _entries[state[0].ToString()][state[1].ToString()];
                    entry.Update(value);
                }
            }

            if (EntryUpdateEvent != null && entry != null)
            {
                EntryUpdateEvent(this, entry);
            }
        }
Пример #2
0
 private void service_ConversionRateCompleted(object sender, ConversionRateCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         // try to resort to local data or issue error
         // for now local error
         Result.Text = "Error Calling Service";
     }
     else
     {
         // save result to local storage in case of going offline - save date in case of emergency
         Result.Text = (double.Parse(SourceCurrencyValue.Text) * e.Result) + " " + lpkTargetCurrency.SelectedItem;
     }
 }
 private void syncClient_ConversionRateCompleted(object sender, ConversionRateCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         double result = e.Result;
         ConversionRateHelper.UpdateRate(this.fromOne, this.onGoingOne, System.Convert.ToDecimal(result));
         if (this.nextCurrencyIndex == 15)
         {
             this.nextCurrencyIndex++;
         }
         if (this.stepIndex == 15)
         {
             this.stepIndex++;
             this.nextCurrencyIndex = 0;
         }
         if (this.nextCurrencyIndex == ConversionRateHelper.SupportCurrencyCount)
         {
             this.stepIndex++;
             this.nextCurrencyIndex = 0;
         }
         if (this.stepIndex == ConversionRateHelper.SupportCurrencyCount)
         {
             this.StopSyncing(true);
         }
         else
         {
             this.SyncStep(this.stepIndex, this.nextCurrencyIndex);
             this.nextCurrencyIndex++;
         }
     }
     else
     {
         this.IsStopByUser = true;
         this.Status = 2;
         this.ExceptionWhenSyncing = e.Error;
         this.StopSyncing();
     }
 }