示例#1
0
        public async Task RefreshObserverMessagesAsync()
        {
            try
            {
                OnOperationStart?.Invoke(this, 2);
                var new_messages = await Online.GetNewMessagesAsync();

                OnOperationStep?.Invoke(this, null);
                if (new_messages.Any())
                {
                    var ins_codes = new_messages.Where(x => x.RelativeInstances != null).SelectMany(x => x.RelativeInstances);
                    var miss      = ins_codes.Where(x => !WebService.Instruments.Any(y => y.InsCode == x)).Distinct().ToList();
                    if (miss.Any())
                    {
                        await SaveWebServiceInstruments();
                    }

                    await Storage.SaveMessagesAsync(new_messages.Reverse());
                }
                OnOperationStep?.Invoke(this, null);
                OnOperationCompleted?.Invoke(this, EventArgs.Empty);
            }
            catch (Exception exception)
            {
                _logger.Error("RefreshObserverMessages", exception);
                OnOperationCompleted?.Invoke(this, EventArgs.Empty);
            }
        }