protected override TimeSpan OnProcess()
		{
			var competition = new Competition();

			var offset = TimeSpan.FromDays(_settings.Offset);

			if (Competition.AllYears.Any(y => y.Year == _settings.StartFrom.Year) && (_settings.StartFrom + offset) < DateTime.Today)
			{
				this.AddInfoLog(LocalizedStrings.Str2306Params, _settings.StartFrom);

				foreach (var year in Competition.AllYears.Where(d => d.Year >= _settings.StartFrom.Year).ToArray())
				{
					if (!CanProcess())
						break;

					this.AddInfoLog(LocalizedStrings.Str2827Params, year);

					var yearCompetition = competition.Get(year);

					foreach (var date in yearCompetition.Days.Where(d => d >= _settings.StartFrom).ToArray())
					{
						if (!CanProcess())
							break;

						if (_settings.IgnoreWeekends && !ExchangeBoard.Forts.IsTradeDate(date.ApplyTimeZone(ExchangeBoard.Forts.TimeZone), true))
						{
							this.AddDebugLog(LocalizedStrings.WeekEndDate, date);
							continue;
						}

						var canUpdateFrom = true;

						foreach (var member in yearCompetition.Members)
						{
							if (!CanProcess())
							{
								canUpdateFrom = false;
								break;
							}

							var trades = yearCompetition.GetTrades(EntityRegistry.Securities, member, date);

							if (trades.Any())
							{
								foreach (var group in trades.GroupBy(i => i.SecurityId))
									SaveOrderLog(GetSecurity(group.Key), group.OrderBy(i => i.ServerTime));	
							}
							else
								this.AddDebugLog(LocalizedStrings.NoData);
						}

						if (canUpdateFrom)
						{
							_settings.StartFrom = date;
							SaveSettings();
						}
					}
				}
			}
			else
			{
				this.AddInfoLog(LocalizedStrings.Str2828Params, _settings.StartFrom);
			}

			return base.OnProcess();
		}
示例#2
0
        protected override TimeSpan OnProcess()
        {
            var competition = new Competition();

            var offset = TimeSpan.FromDays(_settings.Offset);

            if (Competition.AllYears.Any(y => y.Year == _settings.StartFrom.Year) && (_settings.StartFrom + offset) < DateTime.Today)
            {
                this.AddInfoLog(LocalizedStrings.Str2306Params, _settings.StartFrom);

                foreach (var year in Competition.AllYears.Where(d => d.Year >= _settings.StartFrom.Year).ToArray())
                {
                    if (!CanProcess())
                    {
                        break;
                    }

                    this.AddInfoLog(LocalizedStrings.Str2827Params, year);

                    var yearCompetition = competition.Get(year);

                    foreach (var date in yearCompetition.Days.Where(d => d >= _settings.StartFrom).ToArray())
                    {
                        if (!CanProcess())
                        {
                            break;
                        }

                        if (_settings.IgnoreWeekends && !ExchangeBoard.Forts.IsTradeDate(date.ApplyTimeZone(Exchange.Moex.TimeZoneInfo), true))
                        {
                            this.AddDebugLog(LocalizedStrings.WeekEndDate, date);
                            continue;
                        }

                        var canUpdateFrom = true;

                        foreach (var member in yearCompetition.Members)
                        {
                            if (!CanProcess())
                            {
                                canUpdateFrom = false;
                                break;
                            }

                            var trades = yearCompetition.GetTrades(EntityRegistry.Securities, member, date);

                            if (trades.Any())
                            {
                                foreach (var group in trades.GroupBy(i => i.Order.Security))
                                {
                                    SaveOrderLog(group.Key, group.OrderBy(i => i.Order.Time));
                                }
                            }
                            else
                            {
                                this.AddDebugLog(LocalizedStrings.NoData);
                            }
                        }

                        if (canUpdateFrom)
                        {
                            _settings.StartFrom = date;
                            SaveSettings();
                        }
                    }
                }
            }
            else
            {
                this.AddInfoLog(LocalizedStrings.Str2828Params, _settings.StartFrom);
            }

            return(base.OnProcess());
        }