示例#1
0
        //public IEnumerable<string> GetFilePaths(DateTime? firstDate, DateTime? lastDate)
        //{
        //    IEnumerable<string> paths;
        //    if (firstDate.HasValue && lastDate.HasValue)
        //    {
        //        var lowerBound = firstDate.Value.Ticks;
        //        var upperBound = lastDate.Value.Ticks;
        //        paths = TickFileModels
        //            .Where(file => lowerBound < file.DateForFile.Ticks && file.DateForFile.Ticks < upperBound)
        //            .Select(file => file.File.LongFileName);
        //    }
        //    else
        //    {
        //        paths = new List<string> { };
        //    }
        //    return paths;
        //}

        public List <List <string> > GetGroupedFilePaths(DateTime?firstDate, DateTime?lastDate)
        {
            List <List <string> > groups = new List <List <string> > {
            };

            if (firstDate.HasValue && lastDate.HasValue)
            {
                var lowerBound      = firstDate.Value.Ticks;
                var upperBound      = lastDate.Value.Ticks;
                var selectedSymbols = SymbolModels.Where(s => s.Selected).ToList();
                var fileModels      = TickFileModels
                                      .Where(file => lowerBound <= file.DateForFile.Ticks && file.DateForFile.Ticks <= upperBound);
                var symbolFilteredFileModels = fileModels.Join(
                    selectedSymbols,
                    outerModel => outerModel.Symbol.Symbol,
                    innerModel => innerModel.Symbol,
                    (outerModel, innerModel) => outerModel);
                var distinctDates = fileModels
                                    .Distinct((model1, model2) => model1.DateForFile.Date == model2.DateForFile.Date)
                                    .Select(model => model.DateForFile);
                foreach (var _dateTime in distinctDates)
                {
                    var dateGroup = symbolFilteredFileModels
                                    .Where(model => model.DateForFile.Date == _dateTime.Date)
                                    .Select(model => model.File.LongFileName).ToList();
                    groups.Add(dateGroup);
                }
            }
            return(groups);
        }
示例#2
0
        public void SetDates()
        {
            var selectedSymbols = SymbolModels.Where(s => s.Selected).ToList();
            var displayDates    = TickFileModels.Join(
                selectedSymbols,
                tickFileModel => tickFileModel.Symbol.Symbol,
                symbolModel => symbolModel.Symbol,
                (model, symbolModel) => model.DateForFile).Distinct().ToList();

            // Set min and max dates:
            if (displayDates.Count != 0)
            {
                FirstDate = displayDates.Min();
                LastDate  = displayDates.Max();
            }
            else if (TickFileModels.Count != 0)
            {
                FirstDate = TickFileModels.Select(m => m.DateForFile).Min();
                LastDate  = TickFileModels.Select(m => m.DateForFile).Max();
            }
            AvailableDates = new ObservableCollection <DateTime>(displayDates);
        }