Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TimePhaseDataGetter"/> class.
 /// </summary>
 public TimePhaseDataGetter(TimePhasedDataType.TimePhaseType type, TimePhasedDataType.TimePhaseUnit maxGroupUnit,
                            TimePhasedDataType.TimePhaseUnit minGroupUnit, AssignmentBaseFunctor <double> functor)
 {
     _type         = type;
     _functor      = functor;
     _minGroupUnit = minGroupUnit;
     _maxGroupUnit = maxGroupUnit;
     _value        = new List <TimePhasedDataType>();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the time phase data.
        /// </summary>
        /// <param name="assignment">The assignment.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public static IEnumerable <TimePhasedDataType> GetTimePhaseData(Assignment.Assignment assignment, TimePhasedDataType.TimePhaseType type)
        {
            if (assignment == null)
            {
                throw new ArgumentException("assignment");
            }

            //определяем величину дискретизации для генератора интервалов.
            //Если ее определить слишком маленькую то будет много TimePhases елементов
            //Для плоского распределения трудозатрат использовать ДЕНЬ для нелинейных функций использовать ЧАС
            long groupIntervalValue = assignment.CurrentContour.ContourType == ContourTypes.Flat ? CalendarHelper.MilisPerDay() : CalendarHelper.MilisPerHour();

            long             start = type == TimePhasedDataType.TimePhaseType.AssignmentActualWork ? assignment.Start : assignment.Stop;
            long             stop  = type == TimePhasedDataType.TimePhaseType.AssignmentActualWork ? assignment.Stop : assignment.End;
            Query <Interval> query = new Query <Interval>();
            AssignmentBaseFunctor <double> workFunctor = assignment.GetWorkFunctor();

            GroupingIntervalGenerator groupGen = new GroupingIntervalGenerator(start, stop, groupIntervalValue,
                                                                               workFunctor.CountourGenerator);
            TimePhaseDataGetter timePhaseGetter = new TimePhaseDataGetter(type, TimePhasedDataType.TimePhaseUnit.Day,
                                                                          TimePhasedDataType.TimePhaseUnit.Minute, workFunctor);
            WhereInRangePredicate whereInRange = new WhereInRangePredicate(start, stop);

            query.Select(timePhaseGetter).From(groupGen).Where(whereInRange.Evaluate).Execute();

            return(timePhaseGetter.Value);
        }