protected override TimeSpan OnProcess() { var source = new TrueFXSource(); if (_settings.UseTemporaryFiles != TempFiles.NotUse) { source.DumpFolder = GetTempPath(); } var allSecurity = this.GetAllSecurity(); // если фильтр по инструментам выключен (выбран инструмент все инструменты) IEnumerable <HydraTaskSecurity> selectedSecurities = (allSecurity != null ? this.ToHydraSecurities(EntityRegistry.Securities.Filter(ExchangeBoard.TrueFX)) : Settings.Securities ).ToArray(); if (selectedSecurities.IsEmpty()) { this.AddWarningLog(LocalizedStrings.Str2289); source.Refresh(EntityRegistry.Securities, new Security(), SaveSecurity, () => !CanProcess(false)); selectedSecurities = this.ToHydraSecurities(EntityRegistry.Securities.Filter(ExchangeBoard.TrueFX)); } if (selectedSecurities.IsEmpty()) { this.AddWarningLog(LocalizedStrings.Str2292); return(TimeSpan.MaxValue); } var startDate = _settings.StartFrom; var endDate = DateTime.Today - TimeSpan.FromDays(_settings.DayOffset); var allDates = startDate.Range(endDate, TimeSpan.FromDays(1)).ToArray(); foreach (var security in selectedSecurities) { if (!CanProcess()) { break; } if ((allSecurity ?? security).IsLevel1Enabled()) { var storage = StorageRegistry.GetLevel1MessageStorage(security.Security, _settings.Drive, _settings.StorageFormat); var emptyDates = allDates.Except(storage.Dates).ToArray(); if (emptyDates.IsEmpty()) { this.AddInfoLog(LocalizedStrings.Str2293Params, security.Security.Id); } else { var secId = security.Security.ToSecurityId(); foreach (var emptyDate in emptyDates) { if (!CanProcess()) { break; } try { this.AddInfoLog(LocalizedStrings.Str2294Params, emptyDate, security.Security.Id); var ticks = source.LoadTickMessages(secId, emptyDate); if (ticks.Any()) { SaveLevel1Changes(security, ticks); } else { this.AddDebugLog(LocalizedStrings.NoData); } if (_settings.UseTemporaryFiles == TempFiles.UseAndDelete) { File.Delete(source.GetDumpFile(security.Security, emptyDate, emptyDate, typeof(Level1ChangeMessage), null)); } } catch (Exception ex) { HandleError(new InvalidOperationException(LocalizedStrings.Str2295Params .Put(emptyDate, security.Security.Id), ex)); } } } } else { this.AddDebugLog(LocalizedStrings.MarketDataNotEnabled, security.Security.Id, typeof(Level1ChangeMessage).Name); } if (!CanProcess()) { break; } } if (CanProcess()) { this.AddInfoLog(LocalizedStrings.Str2300); } return(base.OnProcess()); }
protected override TimeSpan OnProcess() { var source = new TrueFXSource(); if (_settings.UseTemporaryFiles != TempFiles.NotUse) source.DumpFolder = GetTempPath(); var allSecurity = this.GetAllSecurity(); // если фильтр по инструментам выключен (выбран инструмент все инструменты) IEnumerable<HydraTaskSecurity> selectedSecurities = (allSecurity != null ? this.ToHydraSecurities(EntityRegistry.Securities.Filter(ExchangeBoard.TrueFX)) : Settings.Securities ).ToArray(); if (selectedSecurities.IsEmpty()) { this.AddWarningLog(LocalizedStrings.Str2289); source.Refresh(EntityRegistry.Securities, new Security(), SaveSecurity, () => !CanProcess(false)); selectedSecurities = this.ToHydraSecurities(EntityRegistry.Securities.Filter(ExchangeBoard.TrueFX)); } if (selectedSecurities.IsEmpty()) { this.AddWarningLog(LocalizedStrings.Str2292); return TimeSpan.MaxValue; } var startDate = _settings.StartFrom; var endDate = DateTime.Today - TimeSpan.FromDays(_settings.DayOffset); var allDates = startDate.Range(endDate, TimeSpan.FromDays(1)).ToArray(); foreach (var security in selectedSecurities) { if (!CanProcess()) break; if ((allSecurity ?? security).IsLevel1Enabled()) { var storage = StorageRegistry.GetLevel1MessageStorage(security.Security, _settings.Drive, _settings.StorageFormat); var emptyDates = allDates.Except(storage.Dates).ToArray(); if (emptyDates.IsEmpty()) { this.AddInfoLog(LocalizedStrings.Str2293Params, security.Security.Id); } else { var secId = security.Security.ToSecurityId(); foreach (var emptyDate in emptyDates) { if (!CanProcess()) break; try { this.AddInfoLog(LocalizedStrings.Str2294Params, emptyDate, security.Security.Id); var ticks = source.LoadTickMessages(secId, emptyDate); if (ticks.Any()) SaveLevel1Changes(security, ticks); else this.AddDebugLog(LocalizedStrings.NoData); if (_settings.UseTemporaryFiles == TempFiles.UseAndDelete) File.Delete(source.GetDumpFile(security.Security, emptyDate, emptyDate, typeof(Level1ChangeMessage), null)); } catch (Exception ex) { HandleError(new InvalidOperationException(LocalizedStrings.Str2295Params .Put(emptyDate, security.Security.Id), ex)); } } } } else this.AddDebugLog(LocalizedStrings.MarketDataNotEnabled, security.Security.Id, typeof(Level1ChangeMessage).Name); if (!CanProcess()) break; } if (CanProcess()) this.AddInfoLog(LocalizedStrings.Str2300); return base.OnProcess(); }