Ejemplo n.º 1
0
        private async Task CreateExpiredMovedDayAssignForBackLog(Guid dayAssignId, IWeekPlanJobModel ticket, Guid departmentId, int weekNumber, Guid?creatorId)
        {
            INewDayAssignModel model = GetNewDayAssignForExpiredTasks(ticket, departmentId, weekNumber, creatorId);

            model.ExpiredDayAssignId = dayAssignId;
            await dayAssignService.CreateDayAssign(model);
        }
Ejemplo n.º 2
0
        public async Task <Guid> ChangeDayAssignDate(INewDayAssignModel model)
        {
            var year = model.Year != default(int) ? model.Year : DateTime.UtcNow.Year;

            if (model.WeekDay.HasValue)
            {
                model.Date = CalendarHelper.GetDateByWeekAndDayNumber(year, model.WeekNumber, model.WeekDay.Value);
            }

            var dayAssign = model.DayAssignId.HasValue ? dayAssignProvider.Get(model.DayAssignId.Value) : null;

            if (dayAssign == null)
            {
                return(await CreateDayAssign(model));
            }
            else
            {
                model.Id = model.DayAssignId.Value;
                await messageBus.Publish(model.Map <ChangeDayAssignDateCommand>());

                if (dayAssign.StatusId == JobStatus.Expired)
                {
                    await jobStatusService.Pending(dayAssign.Id, dayAssign.StatusId);
                }

                return(model.DayAssignId.Value);
            }
        }
Ejemplo n.º 3
0
        public async Task <IChangeStatusModel> AssignsMembersGroup(INewDayAssignModel model)
        {
            IChangeStatusModel moveToStatusResultModel = new ChangeStatusModel();

            DayAssign dayAssign = await CreateOrGetDayAssign(model);

            try
            {
                if (model.IsUnassignedAll)
                {
                    await jobStatusService.Pending(model.DayAssignId.Value, dayAssign.StatusId);
                }
                else if (dayAssign.StatusId != JobStatus.Assigned && model.TeamLeadId.HasValue)
                {
                    await jobStatusService.Assigned(dayAssign.Id, dayAssign.StatusId);
                }
                else if (dayAssign.StatusId != JobStatus.Opened && !model.TeamLeadId.HasValue)
                {
                    await jobStatusService.Opened(dayAssign.Id, dayAssign.StatusId);
                }

                model.Id = dayAssign.Id;
                await messageBus.Publish(model.Map <ChangeDayAssignMembersComand>());

                moveToStatusResultModel.IsSuccessful = true;
            }
            catch (NotImplementedException)
            {
                moveToStatusResultModel.IsSuccessful = false;
            }

            moveToStatusResultModel.DayAssignId = dayAssign.Id;
            return(moveToStatusResultModel);
        }
Ejemplo n.º 4
0
        private async Task <Guid> CreateDayAssignForPreviousWeek(IWeekPlanJobModel ticket, Guid departmentId, int weekNumber, Guid?creatorId)
        {
            int previousWeek         = GetPreviousWeekNumber(weekNumber);
            INewDayAssignModel model = GetNewDayAssignForExpiredTasks(ticket, departmentId, previousWeek, creatorId);
            Guid dayAssignId         = await dayAssignService.CreateDayAssign(model);

            return(dayAssignId);
        }
Ejemplo n.º 5
0
        public async Task <Guid> CancelJob(INewDayAssignModel model)
        {
            if (!model.DayAssignId.HasValue || model.DayAssignId == Guid.Empty)
            {
                model.DayAssignId = await CreateDayAssign(model);
            }

            IDayAssign dayAssign = GetDayAssignById(model.DayAssignId.Value);
            await jobStatusService.Cancel(model.DayAssignId.Value, dayAssign.StatusId, model.CancellationReasonId);

            return(model.DayAssignId.Value);
        }
Ejemplo n.º 6
0
        private async Task <DayAssign> CreateOrGetDayAssign(INewDayAssignModel model)
        {
            DayAssign dayAssign = model.DayAssignId.HasValue ? dayAssignProvider.Get(model.DayAssignId.Value) : null;

            if (dayAssign == null)
            {
                Guid dayAssignId = await CreateDayAssign(model);

                dayAssign = dayAssignProvider.Get(dayAssignId);
            }
            return(dayAssign);
        }
Ejemplo n.º 7
0
        public async Task <Guid> CreateDayAssign(INewDayAssignModel model)
        {
            JobAssign jobAssign = jobAssignProvider.GetAssignByJobIdAndDepartmentId(model.JobId, model.DepartmentId);

            if (jobAssign == null && model.JobAssignId != Guid.Empty)
            {
                jobAssign = jobAssignProvider.GetById(model.JobAssignId);
            }

            var day = jobAssign?.DayPerWeekList.FirstOrDefault(dp => dp.WeekDay == model.CurrentWeekDay);

            model.Id          = Guid.NewGuid();
            model.JobAssignId = jobAssign.Id;

            Guid dayPerWeekId = model.DayPerWeekId ?? day?.Id ?? Guid.Empty;
            var  command      = Mapper.Map(model, new CreateDayAssignCommand(dayPerWeekId));
            await messageBus.Publish(command);

            return(model.Id);
        }
Ejemplo n.º 8
0
        public async Task <Guid> CreateDayAssignWithEstimate(INewDayAssignModel model)
        {
            JobAssign jobAssign = jobAssignProvider.GetAssignByJobIdAndDepartmentId(model.JobId, model.DepartmentId);

            if (jobAssign == null && model.JobAssignId != Guid.Empty)
            {
                jobAssign = jobAssignProvider.GetById(model.JobAssignId);
            }

            var jobResponsible = jobAssign.JobResponsibleList.FirstOrDefault(j => j.JobId == model.JobId && j.HousingDepartmentId == model.DepartmentId);

            if (jobResponsible != null)
            {
                var day = jobAssign?.DayPerWeekList.FirstOrDefault(dp => dp.WeekDay == model.CurrentWeekDay);

                model.Id                   = Guid.NewGuid();
                model.JobAssignId          = jobAssign.Id;
                model.EstimatedMinutes     = (int)jobResponsible?.EstimateInMinutes;
                model.IsAssignedToAllUsers = jobResponsible?.IsAssignedToAllUsers ?? default(bool);
                model.WeekDay              = day.WeekDay;

                if (jobResponsible.GroupId != Guid.Empty)
                {
                    model.GroupId = jobResponsible.GroupId;
                }

                if (jobResponsible.TeamLeadId != Guid.Empty)
                {
                    model.TeamLeadId = jobResponsible.TeamLeadId;
                }

                model.UserIdList = jobResponsible?.UserIdList ?? new List <Guid>();
                Guid dayPerWeekId = model.DayPerWeekId ?? day?.Id ?? Guid.Empty;

                var command = Mapper.Map(model, new CreateDayAssignCommand(dayPerWeekId));
                await messageBus.Publish(command);

                return(model.Id);
            }
            return(Guid.Empty);
        }