Ejemplo n.º 1
0
        private NewDayAssignModel GetNewDayAssignForExpiredTasks(IWeekPlanJobModel ticket, Guid departmentId, int currentWeekNumber, Guid?creatorId)
        {
            var result = new NewDayAssignModel
            {
                JobId                = ticket.Id,
                DepartmentId         = departmentId,
                GroupId              = null,
                GroupName            = string.Empty,
                UserIdList           = new List <Guid>(),
                WeekNumber           = currentWeekNumber,
                CurrentWeekDay       = ticket.WeekDay,
                IsAssignedToAllUsers = false,
                TeamLeadId           = null,
                ExpiredDayAssignId   = ticket.DayAssignId,
                ExpiredWeekNumber    = ticket.ExpiredDayAssignId != null ? ticket.ExpiredWeekNumber : ticket.WeekNumber,
                JobAssignId          = ticket.JobAssignId,
                DayPerWeekId         = ticket.DayPerWeekId,
                EstimatedMinutes     = ticket.Estimate?.HoursToMinutes() ?? 0,
                CreatorId            = creatorId
            };

            if (ticket.DayAssignId.HasValue)
            {
                var dayAssign = dayAssignService.GetDayAssignById(ticket.DayAssignId.Value);
                result.Comment          = dayAssign.Comment;
                result.ResidentName     = dayAssign.ResidentName;
                result.ResidentPhone    = dayAssign.ResidentPhone;
                result.TenantType       = dayAssign.TenantType;
                result.UploadList       = dayAssign.UploadList;
                result.EstimatedMinutes = dayAssign.EstimatedMinutes ?? 0;
            }

            return(result);
        }
Ejemplo n.º 2
0
        private List <IWeekPlanJobModel> GetVirtualWeekDayTickets(WeekPlanParamsModel query, string departmentName)
        {
            List <IWeekPlanJobModel> virtualTickets = new List <IWeekPlanJobModel>();

            if (!CanCreateVirtualTickets(query))
            {
                return(virtualTickets);
            }

            IEnumerable <DayPerWeekModel> dayPerWeeksWithoutAlreadyAssigned =
                query.JobAssign.DayPerWeekList.Where(
                    d => !query.Job.DayAssigns.Any(da => da.DayPerWeekId == d.Id && da.WeekNumber == query.WeekNumber) && query.Job.JobTypeId == JobTypeEnum.Facility);

            foreach (var dayPerWeek in dayPerWeeksWithoutAlreadyAssigned)
            {
                IWeekPlanJobModel weekDayJob = MapJobsToWeekModel(query, false, departmentName);

                weekDayJob.IsWeekEndJob = dayPerWeek.WeekDay > WorkingDayCount;
                weekDayJob.WeekDay      = dayPerWeek.WeekDay;
                weekDayJob.DayPerWeekId = dayPerWeek.Id;

                virtualTickets.Add(weekDayJob);
            }
            return(virtualTickets);
        }
Ejemplo n.º 3
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.º 4
0
        private bool IsAllowedJobForCurrentTab(IWeekPlanJobModel weekPlanJob, JobStateType jobState)
        {
            switch (jobState)
            {
            case JobStateType.Completed:
            {
                return(weekPlanJob.StatusId == JobStatus.Completed);
            }

            case JobStateType.NotCompleted:
            {
                int currentWeekNumber = DateTime.Now.GetWeekNumber();
                int currentYear       = DateTime.UtcNow.Year;

                return(weekPlanJob.StatusId.In(JobStatus.Canceled, JobStatus.Expired) ||
                       (weekPlanJob.StatusId != JobStatus.Completed &&
                        (weekPlanJob.Year < currentYear || (weekPlanJob.Year == currentYear && weekPlanJob.WeekNumber < currentWeekNumber))));
            }

            default:
            {
                return(weekPlanJob.StatusId != JobStatus.Completed &&
                       weekPlanJob.StatusId != JobStatus.Canceled &&
                       weekPlanJob.StatusId != JobStatus.Expired);
            }
            }
        }
Ejemplo n.º 5
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.º 6
0
        private int?GetWeekDay(IWeekPlanJobModel job)
        {
            if (job.IsVirtualTicket && !job.IsBackLogJob && job.WeekDay.HasValue)
            {
                return(job.WeekDay.Value);
            }
            if (!job.IsVirtualTicket && !job.IsBackLogJob && job.DayAssignDate.HasValue)
            {
                return(job.DayAssignDate.Value.GetWeekDayNumber());
            }

            return(null);
        }
Ejemplo n.º 7
0
        private DateTime?GetJobAssignDate(IWeekPlanJobModel job)
        {
            if (job.IsVirtualTicket && !job.IsBackLogJob)
            {
                return(CalendarHelper.GetDateByWeekAndDayNumber(job.Year, job.WeekNumber, job.WeekDay.Value));
            }
            if (!job.IsVirtualTicket && !job.IsBackLogJob && job.DayAssignDate.HasValue)
            {
                return(job.DayAssignDate.Value);
            }

            return(null);
        }
Ejemplo n.º 8
0
        private List <IWeekPlanJobModel> GetRealWeekDayTickets(WeekPlanParamsModel query, string departmentName)
        {
            List <IWeekPlanJobModel> realTickets = new List <IWeekPlanJobModel>();
            IEnumerable <Guid>       groupIds    = query.Job.DayAssigns.Where(i => i.GroupId.HasValue).Select(i => i.GroupId.Value);
            List <IGroupModel>       groups      = groupService.GetByIds(groupIds).ToList();

            IEnumerable <IDayAssign> dayAssignsWithoutVirtual = query.Job.DayAssigns?.Where(d => IsValidDayAssign(d, query.WeekNumber, query.Year));

            foreach (var dayAssign in dayAssignsWithoutVirtual)
            {
                IWeekPlanJobModel weekDayJob = MapJobsToWeekModel(query, false, departmentName, dayAssign);

                if (dayAssign.GroupId.HasValue)
                {
                    weekDayJob.GroupName = groups.First(i => i.Id == dayAssign.GroupId).Name;
                }

                realTickets.Add(weekDayJob);
            }

            return(realTickets);
        }
Ejemplo n.º 9
0
        private List <IWeekPlanJobModel> GetRealBackLogTickets(WeekPlanParamsModel query, string departmentName)
        {
            List <IWeekPlanJobModel> realBackLogTickets = new List <IWeekPlanJobModel>();

            List <IDayAssign>  realBackLogAssignList = query.Job.DayAssigns.Where(da => da.WeekNumber == query.WeekNumber && !da.WeekDay.HasValue && da.Year == query.Year).ToList();
            IEnumerable <Guid> groupIds  = realBackLogAssignList.Where(i => i.GroupId.HasValue).Select(i => i.GroupId.Value);
            List <IGroupModel> groupList = groupService.GetByIds(groupIds).ToList();

            foreach (var dayAssign in realBackLogAssignList)
            {
                IWeekPlanJobModel weekDayJob = MapJobsToWeekModel(query, true, departmentName, dayAssign);

                if (dayAssign.GroupId.HasValue)
                {
                    weekDayJob.GroupName = groupList.First(i => i.Id == dayAssign.GroupId).Name;
                }

                realBackLogTickets.Add(weekDayJob);
            }

            return(realBackLogTickets);
        }