Exemple #1
0
        /// <summary>
        /// This is a very important function in Range design.
        ///
        /// [2012-03-11, 2014-08-22]  => [2012-03-11, 2012-12-31], [2013-01-01, 2013-12-31], [2014-01-01, 2014-08-22]
        /// [2014-02-03, 2014-08-22]  => [2014-02-03, 2014-02-28], [2014-03-01, 2014-03-31], ..., [2014-08-01, 2014-08-22]
        /// [2014-08-03 2:00:00, 2014-08-03 4:00:00] => [2014-08-03 2:00:00, 2014-08-03 3:00:00], [2014-08-03 3:00:00, 2014-08-03 4:00:00]
        /// </summary>
        /// <returns></returns>
        public List <QueryRange> GetDividedRanges()
        {
            DateTime rangedStartDate = GetRangedStartDate();
            DateTime rangedEndDate   = GetRangedEndDate();

            TimeSpan span = rangedEndDate - rangedStartDate;

            if (span < new TimeSpan(0, 5, 0))
            {
                return(null);
            }

            double intervalSeconds = span.TotalSeconds / DividRangeFactor;

            List <QueryRange> resultRange = new List <QueryRange>();
            QueryRange        range;

            DateTime previousTimeStamp = rangedStartDate;
            DateTime lastTimeStamp;

            for (int i = 0; i < DividRangeFactor - 1; i++)
            {
                lastTimeStamp = previousTimeStamp.AddSeconds(intervalSeconds);

                range = new QueryRange(previousTimeStamp, lastTimeStamp);
                resultRange.Add(range);

                previousTimeStamp = lastTimeStamp;
            }

            range = new QueryRange(previousTimeStamp, rangedEndDate);
            resultRange.Add(range);

            return(resultRange);
        }
 public QueryFilter()
 {
     QueryRange       = new QueryRange();
     TopCount         = 0;
     SkipCount        = 0;
     ExcludeStartItem = false;
 }