Exemplo n.º 1
0
        public void Assignment_Units()
        {
            var taskId      = TaskId.Create();
            var resourceId1 = ResourceId.Create();
            var resourceId2 = ResourceId.Create();

            var project = Project.Create()
                          .WithStart(new DateTime(2018, 2, 5))
                          .AddTask(taskId).Project
                          .AddResource(resourceId1).Project
                          .AddResource(resourceId2).Project
                          .AddAssignment(taskId, resourceId1)
                          .WithWork(ProjectTime.FromHours(40))
                          .WithUnits(.5).Project
                          .AddAssignment(taskId, resourceId2)
                          .WithWork(ProjectTime.FromHours(20)).Project;

            ProjectAssert.For(project)
            .ForTask(0)
            .AssertDuration(ProjectTime.FromDays(10))
            .AssertWork(ProjectTime.FromHours(60))
            .AssertStart(new DateTime(2018, 2, 5, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 16, 17, 0, 0))
            .Project
            .ForAssignment(taskId, resourceId1)
            .AssertWork(ProjectTime.FromHours(40))
            .AssertStart(new DateTime(2018, 2, 5, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 16, 17, 0, 0))
            .Project
            .ForAssignment(taskId, resourceId2)
            .AssertWork(ProjectTime.FromHours(20))
            .AssertStart(new DateTime(2018, 2, 5, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 7, 12, 0, 0));
        }
        public void Calendar_NightShift()
        {
            var taskId1 = TaskId.Create();
            var taskId2 = TaskId.Create();

            var project = Project.Create()
                          .WithStart(new DateTime(2018, 2, 1))
                          .WithCalendar(Calendar.NightShift)
                          .AddTask(taskId1)
                          .WithDuration(ProjectTime.FromDays(10)).Project
                          .AddTask(taskId2)
                          .WithDuration(ProjectTime.FromDays(5))
                          .AddPredecessorLink(taskId1).Project;

            ProjectAssert.For(project)
            .ForTask(0)
            .AssertDuration(ProjectTime.FromDays(10))
            .AssertStart(new DateTime(2018, 2, 1, 0, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 15, 0, 0, 0))
            .AssertWork(ProjectTime.FromDays(0)).Project
            .ForTask(1)
            .AssertDuration(ProjectTime.FromDays(5))
            .AssertStart(new DateTime(2018, 2, 15, 0, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 22, 0, 0, 0))
            .AssertWork(ProjectTime.FromDays(0));
        }
        public void Calendar_SixDayWorkWeek()
        {
            var taskId1 = TaskId.Create();
            var taskId2 = TaskId.Create();

            var workingSaturday = WorkingDay.CreateEightToFive(DayOfWeek.Saturday);
            var sixDayWorkWeek  = WorkingWeek.Default.WithDay(workingSaturday);
            var calendar        = Calendar.Default.WithWorkingWeek(sixDayWorkWeek);

            var project = Project.Create()
                          .WithStart(new DateTime(2018, 1, 29))
                          .WithCalendar(calendar)
                          .AddTask(taskId1)
                          .WithDuration(ProjectTime.FromDays(10)).Project
                          .AddTask(taskId2)
                          .WithDuration(ProjectTime.FromDays(5))
                          .AddPredecessorLink(taskId1).Project;

            ProjectAssert.For(project)
            .ForTask(0)
            .AssertDuration(ProjectTime.FromDays(10))
            .AssertStart(new DateTime(2018, 1, 29, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 8, 17, 0, 0))
            .AssertWork(TimeSpan.Zero).Project
            .ForTask(1)
            .AssertDuration(ProjectTime.FromDays(5))
            .AssertStart(new DateTime(2018, 2, 9, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 14, 17, 0, 0))
            .AssertWork(TimeSpan.Zero);
        }
        public void Calendar_Default()
        {
            var taskId1 = TaskId.Create();
            var taskId2 = TaskId.Create();

            var project = Project.Create()
                          .WithStart(new DateTime(2018, 1, 29))
                          .AddTask(taskId1)
                          .WithDuration(ProjectTime.FromDays(10)).Project
                          .AddTask(taskId2)
                          .WithDuration(ProjectTime.FromDays(5))
                          .AddPredecessorLink(taskId1).Project;

            ProjectAssert.For(project)
            .ForTask(0)
            .AssertDuration(ProjectTime.FromDays(10))
            .AssertStart(new DateTime(2018, 1, 29, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 9, 17, 0, 0))
            .AssertWork(TimeSpan.Zero).Project
            .ForTask(1)
            .AssertDuration(ProjectTime.FromDays(5))
            .AssertStart(new DateTime(2018, 2, 12, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 16, 17, 0, 0))
            .AssertWork(TimeSpan.Zero);
        }
        public void Calendar_TwentyFourSeven()
        {
            var taskId1 = TaskId.Create();
            var taskId2 = TaskId.Create();

            var project = Project.Create()
                          .WithStart(new DateTime(2018, 2, 1))
                          .WithCalendar(Calendar.TwentyFourSeven)
                          .AddTask(taskId1)
                          .WithDuration(ProjectTime.FromDays(10)).Project
                          .AddTask(taskId2)
                          .WithDuration(ProjectTime.FromDays(5))
                          .AddPredecessorLink(taskId1).Project;

            ProjectAssert.For(project)
            .ForTask(0)
            .AssertDuration(ProjectTime.FromDays(10))
            .AssertStart(new DateTime(2018, 2, 1, 0, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 4, 8, 0, 0))
            .AssertWork(TimeSpan.Zero).Project
            .ForTask(1)
            .AssertDuration(ProjectTime.FromDays(5))
            .AssertStart(new DateTime(2018, 2, 4, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 6, 0, 0, 0))
            .AssertWork(TimeSpan.Zero);
        }
        public void TaskLink_FinishToFinish_NegativeSlack_BeforeProjectStart()
        {
            var taskId  = TaskId.Create();
            var project = Project.Create()
                          .WithStart(new DateTime(2018, 2, 26, 8, 0, 0))
                          .AddTask()
                          .WithDuration(ProjectTime.FromDays(5)).Project
                          .AddTask(taskId)
                          .WithDuration(ProjectTime.FromDays(3)).Project
                          .AddTask()
                          .WithDuration(ProjectTime.FromDays(2))
                          .AddPredecessorLink(taskId,
                                              TaskLinkType.FinishToFinish,
                                              ProjectTime.FromDays(-2))
                          .Project;

            ProjectAssert.For(project)
            .ForTask(0)
            .AssertPredecessors(null)
            .AssertStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 3, 2, 17, 0, 0))
            .AssertEarlyStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertEarlyFinish(new DateTime(2018, 3, 2, 17, 0, 0))
            .AssertLateStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertLateFinish(new DateTime(2018, 3, 2, 17, 0, 0))
            .AssertStartSlack(ProjectTime.FromDays(0))
            .AssertFinishSlack(ProjectTime.FromDays(0))
            .AssertTotalSlack(ProjectTime.FromDays(0))
            .AssertFreeSlack(ProjectTime.FromDays(0)).Project
            .ForTask(1)
            .AssertPredecessors(null)
            .AssertStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 28, 17, 0, 0))
            .AssertEarlyStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertEarlyFinish(new DateTime(2018, 2, 28, 17, 0, 0))
            .AssertLateStart(new DateTime(2018, 2, 28, 8, 0, 0))
            .AssertLateFinish(new DateTime(2018, 3, 2, 17, 0, 0))
            .AssertStartSlack(ProjectTime.FromDays(2))
            .AssertFinishSlack(ProjectTime.FromDays(2))
            .AssertTotalSlack(ProjectTime.FromDays(2))
            .AssertFreeSlack(ProjectTime.FromDays(1)).Project
            .ForTask(2)
            .AssertPredecessors("1FF-2 days")
            .AssertStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 27, 17, 0, 0))
            .AssertEarlyStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertEarlyFinish(new DateTime(2018, 2, 27, 17, 0, 0))
            .AssertLateStart(new DateTime(2018, 3, 1, 8, 0, 0))
            .AssertLateFinish(new DateTime(2018, 3, 2, 17, 0, 0))
            .AssertStartSlack(ProjectTime.FromDays(3))
            .AssertFinishSlack(ProjectTime.FromDays(3))
            .AssertTotalSlack(ProjectTime.FromDays(3))
            .AssertFreeSlack(ProjectTime.FromDays(3));
        }
Exemplo n.º 7
0
 public async Task SaveProjectTime(ProjectTime projectTime)
 {
     try
     {
         logger.LogInformation($"Saving ProjectTime(ExternalUserId={projectTime.externalUserId}, ExternalTaskId={projectTime.externalTaskId}, Description={projectTime.description}, Start={projectTime.startTime}, End={projectTime.endTime})");
         await timrSync.SaveProjectTimeAsync(new SaveProjectTimeRequest(projectTime)).ConfigureAwait(false);
     }
     catch (FaultException e)
     {
         logger.LogError($"Failed saving ProjectTime(ExternalUserId={projectTime.externalUserId}, ExternalTaskId={projectTime.externalTaskId}, Description={projectTime.description}, Start={projectTime.startTime}, End={projectTime.endTime}): {e.Message}");
     }
     catch (Exception e)
     {
         logger.LogError(e, $"Failed saving ProjectTime(ExternalUserId={projectTime.externalUserId}, ExternalTaskId={projectTime.externalTaskId}, Description={projectTime.description}, Start={projectTime.startTime}, End={projectTime.endTime})");
     }
 }
        public void Project_FinishDate()
        {
            var taskId  = TaskId.Create();
            var project = Project.Create()
                          .WithStart(new DateTime(2018, 2, 5))
                          .AddTask(taskId)
                          .WithDuration(ProjectTime.FromDays(2))
                          .Project
                          .AddTask()
                          .AddPredecessorLink(taskId)
                          .WithDuration(ProjectTime.FromDays(3))
                          .Project;

            ProjectAssert.For(project)
            .AssertFinish(new DateTime(2018, 2, 9, 17, 0, 0));
        }
        public void TaskLink_StartToFinish_PositiveSlack()
        {
            var taskId  = TaskId.Create();
            var project = Project.Create()
                          .WithStart(new DateTime(2018, 2, 26, 8, 0, 0))
                          .AddTask(taskId)
                          .WithDuration(ProjectTime.FromDays(2)).Project
                          .AddTask()
                          .WithDuration(ProjectTime.FromDays(3))
                          .AddPredecessorLink(taskId,
                                              TaskLinkType.StartToFinish,
                                              ProjectTime.FromDays(1))
                          .Project;

            ProjectAssert.For(project)
            .ForTask(0)
            .AssertPredecessors(null)
            .AssertStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 27, 17, 0, 0))
            .AssertEarlyStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertEarlyFinish(new DateTime(2018, 2, 27, 17, 0, 0))
            .AssertLateStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertLateFinish(new DateTime(2018, 2, 27, 17, 0, 0))
            .AssertStartSlack(ProjectTime.FromDays(0))
            .AssertFinishSlack(ProjectTime.FromDays(0))
            .AssertTotalSlack(ProjectTime.FromDays(0))
            .AssertFreeSlack(ProjectTime.FromDays(0)).Project
            .ForTask(1)
            .AssertPredecessors("0SF+1 day")
            .AssertStart(new DateTime(2018, 2, 22, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 26, 17, 0, 0))
            .AssertEarlyStart(new DateTime(2018, 2, 22, 8, 0, 0))
            .AssertEarlyFinish(new DateTime(2018, 2, 26, 17, 0, 0))
            .AssertLateStart(new DateTime(2018, 2, 23, 8, 0, 0))
            .AssertLateFinish(new DateTime(2018, 2, 27, 17, 0, 0))
            .AssertStartSlack(ProjectTime.FromDays(1))
            .AssertFinishSlack(ProjectTime.FromDays(1))
            .AssertTotalSlack(ProjectTime.FromDays(1))
            .AssertFreeSlack(ProjectTime.FromDays(1));
        }
Exemplo n.º 10
0
        public void Assignment_Work_InitializedFrom_Task_Duration()
        {
            var taskId     = TaskId.Create();
            var resourceId = ResourceId.Create();

            var project = Project.Create()
                          .WithStart(new DateTime(2018, 1, 29))
                          .AddTask(taskId)
                          .WithDuration(ProjectTime.FromDays(10)).Project
                          .AddResource(resourceId).Project
                          .AddAssignment(taskId, resourceId).Project;

            ProjectAssert.For(project)
            .ForTask(0)
            .AssertDuration(ProjectTime.FromDays(10))
            .AssertWork(ProjectTime.FromHours(80))
            .AssertStart(new DateTime(2018, 1, 29, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 9, 17, 0, 0)).Project
            .ForAssignment(taskId, resourceId)
            .AssertWork(ProjectTime.FromHours(80))
            .AssertStart(new DateTime(2018, 1, 29, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 9, 17, 0, 0));
        }
        public void TaskLink_FinishToStart_NegativeSlack()
        {
            var taskId  = TaskId.Create();
            var project = Project.Create()
                          .WithStart(new DateTime(2018, 2, 26, 8, 0, 0))
                          .AddTask(taskId)
                          .WithDuration(ProjectTime.FromDays(2)).Project
                          .AddTask()
                          .WithDuration(ProjectTime.FromDays(3))
                          .AddPredecessorLink(taskId, lag: ProjectTime.FromDays(-1)).Project;

            ProjectAssert.For(project)
            .ForTask(0)
            .AssertPredecessors(null)
            .AssertStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 2, 27, 17, 0, 0))
            .AssertEarlyStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertEarlyFinish(new DateTime(2018, 2, 27, 17, 0, 0))
            .AssertLateStart(new DateTime(2018, 2, 26, 8, 0, 0))
            .AssertLateFinish(new DateTime(2018, 2, 27, 17, 0, 0))
            .AssertStartSlack(ProjectTime.FromDays(0))
            .AssertFinishSlack(ProjectTime.FromDays(0))
            .AssertTotalSlack(ProjectTime.FromDays(0))
            .AssertFreeSlack(ProjectTime.FromDays(0)).Project
            .ForTask(1)
            .AssertPredecessors("0FS-1 days")
            .AssertStart(new DateTime(2018, 2, 27, 8, 0, 0))
            .AssertFinish(new DateTime(2018, 3, 1, 17, 0, 0))
            .AssertEarlyStart(new DateTime(2018, 2, 27, 8, 0, 0))
            .AssertEarlyFinish(new DateTime(2018, 3, 1, 17, 0, 0))
            .AssertLateStart(new DateTime(2018, 2, 27, 8, 0, 0))
            .AssertLateFinish(new DateTime(2018, 3, 1, 17, 0, 0))
            .AssertStartSlack(ProjectTime.FromDays(0))
            .AssertFinishSlack(ProjectTime.FromDays(0))
            .AssertTotalSlack(ProjectTime.FromDays(0))
            .AssertFreeSlack(ProjectTime.FromDays(0));
        }
Exemplo n.º 12
0
 public async Task <bool> SetProjectTimeStatus(ProjectTime projectTime, ProjectTimeStatus projectTimeStatus)
 {
     return(await SetProjectTimesStatus(new List <long> {
         projectTime.id
     }, projectTimeStatus).ConfigureAwait(false));
 }
Exemplo n.º 13
0
        //打开项目详情统计页面
        public ActionResult ProjectDetailStatistic(Guid projectId)
        {
            StatisticLogic logic       = new StatisticLogic();
            ProjectModel   ProjectInfo = logic.GetProjectDetailById(projectId);
            //return View(ProjectInfo.ToPublicAnonymousType());
            SumHourModel shm = logic.GetTotalValueById(projectId);

            if (shm == null)
            {
                ProjectInfo.TotalValue = 0;
            }
            else
            {
                ProjectInfo.TotalValue = shm.TotalValue;
            }
            ViewBag.ProjectInfo = ProjectInfo;

            //计算折线统计图表中的PloatPlones的值
            List <String> times = logic.GetStatisticTimes(projectId);
            ProjectTime   pt    = logic.GetProjectTime(projectId);

            String planBYM = pt.PBeginTime.Substring(0, 7);
            String planEYM = pt.PEndTime.Substring(0, 7);
            String planBD  = pt.PBeginTime.Substring(8, 2);
            String planED  = pt.PEndTime.Substring(8, 2);

            String realBYM = pt.RBeginTime.Substring(0, 7);
            String realEYM = pt.REndTime.Substring(0, 7);
            String realBD  = pt.RBeginTime.Substring(8, 2);
            String realED  = pt.REndTime.Substring(8, 2);

            int count = times.Count;

            for (int i = 0; i < count; i++)
            {
                if (times[i] == planBYM)
                {
                    ViewBag.PlanBegin = i + (double.Parse(planBD) - getMonthMiddleDay(planBYM)) / getMonthDays(planBYM);
                }
                if (times[i] == planEYM)
                {
                    ViewBag.PlanEnd = i + (double.Parse(planED) - getMonthMiddleDay(planEYM)) / getMonthDays(planEYM);
                }
                if (times[i] == realBYM)
                {
                    ViewBag.RealBegin = i + (double.Parse(realBD) - getMonthMiddleDay(realBYM)) / getMonthDays(realBYM);
                }
                if (times[i] == realEYM)
                {
                    //此种情况为 还未登记 或只登记了一天,在前端统计图渲染时,实际投入的开始时间和结束时间相同,时间区域不会显示,这里故意 +0.008,为了让时间区域显示
                    if (pt.RBeginTime == pt.REndTime)
                    {
                        ViewBag.RealEnd = i + (double.Parse(realED) - getMonthMiddleDay(realEYM)) / getMonthDays(realEYM) + 0.008;
                    }
                    else
                    {
                        ViewBag.RealEnd = i + (double.Parse(realED) - getMonthMiddleDay(realEYM)) / getMonthDays(realEYM);
                    }
                }
            }
            ViewBag.ProjectTime = pt;

            return(View());
        }