public Plan(List <UserDto> users, PeriodUnit unit, int time)
 {
     TimeUnit = unit;
     if (time > 0)
     {
         Time = time;
     }
     else
     {
         throw new ArgumentException("Wrong time");
     }
     Users = new List <UserDto>();
     foreach (var user in users)
     {
         if (Users.Contains(user))
         {
             continue;
         }
         else
         {
             Users.Add(user);
         }
     }
     _jobs = new JobDto[Users.Count, Time];
 }
Beispiel #2
0
        private void PeriodUnits_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem comboBoxItem = (ComboBoxItem)e.AddedItems[0];

            switch (comboBoxItem.Content.ToString())
            {
            case "Week(s)":
            {
                Unit = PeriodUnit.Week;
                break;
            }

            case "Month(s)":
            {
                Unit = PeriodUnit.Month;
                break;
            }

            case "Year(s)":
            {
                Unit = PeriodUnit.Year;
                break;
            }

            case "Day(s)":
            {
                Unit = PeriodUnit.Day;
                break;
            }
            }
        }
        public static double Duration(DateTime startDate, DateTime endDate, PeriodUnit unit = PeriodUnit.Day)
        {
            ValidationHelper.DateTimeGreaterInequality(startDate, "startDate", endDate, "endDate");
            TimeSpan _span = endDate - startDate;


            return((int)_span.TotalDays / (int)unit);
        }
 public ProlongationPeriod(int value, PeriodUnit unit)
 {
     if (value == 0)
     {
         throw new InvalidOperationException("Must specify prolongation period value");
     }
     Value = value;
     Unit  = unit;
 }
Beispiel #5
0
        public virtual IList <IDurationReportResult> Duration(PeriodUnit periodUnit)
        {
            EnsureUtil.EnsureNotNull(typeof(NotValidException), "periodUnit", periodUnit);
            DurationPeriodUnit = periodUnit;

            var commandContext = context.Impl.Context.CommandContext;

            if (commandContext == null)
            {
                return(CommandExecutor.Execute(new CommandAnonymousInnerClass3(this, commandContext)));
            }
            return(ExecuteDuration(commandContext));
        }
        // report execution /////////////////////////////////////////////

        public virtual IList <IDurationReportResult> Duration(PeriodUnit periodUnit)
        {
            throw new NotImplementedException();
            EnsureUtil.EnsureNotNull(typeof(NotValidException), "periodUnit", periodUnit);
            DurationPeriodUnit = periodUnit;

            var commandContext = context.Impl.Context.CommandContext;

            if (commandContext == null)
            {
                //return commandExecutor.execute(new CommandAnonymousInnerClass(this, commandContext));
            }
            //return ExecuteDurationReport(commandContext);
        }
Beispiel #7
0
        // report execution /////////////////////////////////////////////

        public virtual IList <DurationReportResult> duration(PeriodUnit periodUnit)
        {
            ensureNotNull(typeof(NotValidException), "periodUnit", periodUnit);
            this.durationPeriodUnit = periodUnit;

            CommandContext commandContext = Context.CommandContext;

            if (commandContext == null)
            {
                return(commandExecutor.execute(new CommandAnonymousInnerClass(this, commandContext)));
            }
            else
            {
                return(executeDurationReport(commandContext));
            }
        }
Beispiel #8
0
        public static int LimitForPeriodUnit(PeriodUnit pu)
        {
            switch (pu)
            {
            case PeriodUnit.Days:
            case PeriodUnit.Tithis:
                return(36500);

            case PeriodUnit.Weeks:
                return(520);

            case PeriodUnit.Months:
            case PeriodUnit.Masas:
                return(1200);

            default:
                return(100);
            }
        }
Beispiel #9
0
        static string periodUnitToString(PeriodUnit unit)
        {
            switch (unit)
            {
            case PeriodUnit.Day:
                return("day");

            case PeriodUnit.Week:
                return("week");

            case PeriodUnit.Month:
                return("month");

            case PeriodUnit.Year:
                return("year");

            default:
                return("unknown");
            }
        }
        private TimeSpan SetTime(PeriodUnit periodUnit, int numPeriod)
        {
            switch (periodUnit)
            {
            case PeriodUnit.Milliseconds:
                return(TimeSpan.FromMilliseconds(numPeriod));

            case PeriodUnit.Seconds:
                return(TimeSpan.FromSeconds(numPeriod));

            case PeriodUnit.Minutes:
                return(TimeSpan.FromMinutes(numPeriod));

            case PeriodUnit.Hours:
                return(TimeSpan.FromHours(numPeriod));

            case PeriodUnit.Days:
                return(TimeSpan.FromDays(numPeriod));

            default:
                throw new NotImplementedException("This periodUnit not implemented");
            }
        }
        private int GetNumPeriods(TimeSpan time, PeriodUnit unit)
        {
            switch (unit)
            {
            case PeriodUnit.Milliseconds:
                return(time.Milliseconds);

            case PeriodUnit.Seconds:
                return(time.Seconds);

            case PeriodUnit.Minutes:
                return(time.Minutes);

            case PeriodUnit.Hours:
                return(time.Hours);

            case PeriodUnit.Days:
                return(time.Days);

            default:
                throw new NotImplementedException("Schedule for this periodUnit not implemented");
            }
        }
Beispiel #12
0
 public virtual DurationReportScenarioBuilder periodUnit(PeriodUnit periodUnit)
 {
     this.periodUnit_Renamed = periodUnit;
     assertion.PeriodUnit    = periodUnit;
     return(this);
 }
        public Schedule CreateShedule(ProjectDto proj, DateTime timeStart, DateTime timeEnd, PeriodUnit periodUnit)
        {
            if (proj == null)
            {
                throw new ArgumentNullException("Project is null");
            }
            if (timeEnd <= timeStart)
            {
                throw new ArgumentException("EarlyTime more LateTime");
            }

            var employmentWorker = new Dictionary <UserDto, int>();

            foreach (var worker in proj.Workers)
            {
                employmentWorker[worker] = 0;
            }

            var timeSpan   = timeEnd - timeStart;
            int numPeriods = GetNumPeriods(timeSpan, periodUnit);


            //Определяем расписание как график Ганта
            var plan = new Plan(proj.Workers, periodUnit, numPeriods);

            //Строим расписание
            for (int period = 0; HaveNotCompletedJob(proj) && period < numPeriods; period++)
            {
                //Создаем фронт работ в данный момент времени
                List <JobDto> front = GetReadyJobs(proj.Jobs, timeStart + SetTime(periodUnit, period));
                //Назанчаем работы из фронта
                while (front.Count != 0)
                {
                    var nextJob = GetNextJob(front);
                    var worker  = AppointJob(proj, plan, period, nextJob);
                    if (worker == null)
                    {
                        break;
                    }
                    else
                    {
                        nextJob.TimeStart = timeStart + SetTime(periodUnit, period);
                        var timeWork = worker.Qualifications.Where(q => q.JobType == nextJob.JobType).Select(q => q.EffectivePercent).FirstOrDefault() * nextJob.LeadTime;
                        nextJob.TimeEnd           = nextJob.TimeStart + timeWork;
                        employmentWorker[worker] += GetNumPeriods(timeWork, periodUnit);                                                            //Добавляем нагрузку на исполнителя
                    }

                    front = GetReadyJobs(proj.Jobs, timeStart + SetTime(periodUnit, period));
                    //TODO добавить проверку на доступность ресурсов
                }
            }

            return(new Schedule(plan));
        }
Beispiel #14
0
 public virtual DurationReportResultAssertion setPeriodUnit(PeriodUnit periodUnit)
 {
     this.periodUnit = periodUnit;
     return(this);
 }
Beispiel #15
0
 public Period(PeriodUnit u, double v)
 {
     Unit  = u;
     Value = (int)v;
 }
Beispiel #16
0
        public static bool CalcEndDate(GCEarthData m_earth, GregorianDateTime vcStart, out GregorianDateTime vcEnd, PeriodUnit nType, int nCount)
        {
            if (m_earth == null || vcStart == null)
            {
                vcEnd = null;
                return(false);
            }

            GaurabdaDate vaStart = new GaurabdaDate();

            VCTIMEtoVATIME(vcStart, out vaStart, m_earth);
            vcEnd = new GregorianDateTime();
            GaurabdaDate vaEnd = new GaurabdaDate();

            if (nCount > LimitForPeriodUnit(nType))
            {
                nCount = LimitForPeriodUnit(nType);
            }

            switch (nType)
            {
            case PeriodUnit.Days:
                vcEnd.Set(vcStart);
                vcEnd.AddDays(nCount);
                VCTIMEtoVATIME(vcEnd, out vaEnd, m_earth);
                break;

            case PeriodUnit.Weeks:
                vcEnd.Set(vcStart);
                vcEnd.AddDays(nCount * 7);
                VCTIMEtoVATIME(vcEnd, out vaEnd, m_earth);
                break;

            case PeriodUnit.Months:
                vcEnd.Set(vcStart);
                vcEnd.month += nCount;
                while (vcEnd.month > 12)
                {
                    vcEnd.year++;
                    vcEnd.month -= 12;
                }
                VCTIMEtoVATIME(vcEnd, out vaEnd, m_earth);
                break;

            case PeriodUnit.Years:
                vcEnd.Set(vcStart);
                vcEnd.year += nCount;
                VCTIMEtoVATIME(vcEnd, out vaEnd, m_earth);
                break;

            case PeriodUnit.Tithis:
                vaEnd.Set(vaStart);
                vaEnd.tithi += nCount;
                while (vaEnd.tithi >= 30)
                {
                    vaEnd.tithi -= 30;
                    vaEnd.masa++;
                }
                while (vaEnd.masa >= 12)
                {
                    vaEnd.masa -= 12;
                    vaEnd.gyear++;
                }
                VATIMEtoVCTIME(vaEnd, out vcEnd, m_earth);
                break;

            case PeriodUnit.Masas:
                vaEnd.Set(vaStart);
                vaEnd.masa = MasaToComboMasa(vaEnd.masa);
                if (vaEnd.masa == (int)MasaId.ADHIKA_MASA)
                {
                    vcEnd.Set(vcStart);
                    vcEnd.month += nCount;
                    while (vcEnd.month > 12)
                    {
                        vcEnd.year++;
                        vcEnd.month -= 12;
                    }
                    VCTIMEtoVATIME(vcEnd, out vaEnd, m_earth);
                    vaEnd.tithi = vaStart.tithi;
                    VATIMEtoVCTIME(vaEnd, out vcEnd, m_earth);
                }
                else
                {
                    vaEnd.masa += nCount;
                    while (vaEnd.masa >= 12)
                    {
                        vaEnd.masa -= 12;
                        vaEnd.gyear++;
                    }
                    vaEnd.masa = ComboMasaToMasa(vaEnd.masa);
                    VATIMEtoVCTIME(vaEnd, out vcEnd, m_earth);
                }
                break;

            case PeriodUnit.Gaurabda:
                vaEnd.Set(vaStart);
                vaEnd.gyear += nCount;
                VATIMEtoVCTIME(vaEnd, out vcEnd, m_earth);
                break;
            }

            return(true);
        }
Beispiel #17
0
 /// <summary>
 /// Need to check for the culture information.
 /// </summary>
 public Period(DateTime startDateTime, PeriodUnit periodUnit = PeriodUnit.Day)
 {
     this.StartDateTime = startDateTime;
     this.Duration      = (int)periodUnit;
     this.EndDateTime   = this.StartDateTime.AddDays(this.Duration);
 }
Beispiel #18
0
 public virtual DurationReportScenarioBuilder PeriodUnit(PeriodUnit periodUnit)
 {
     PeriodUnitRenamed    = periodUnit;
     Assertion.PeriodUnit = periodUnit;
     return(this);
 }