示例#1
0
        private IsolatorShiftDetail IsolatorShiftDetail(IsolatorStaffAllocation shift, IList <IntegrationOrderPreperation> shiftOrders)
        {
            var totalOrderReqTime = shiftOrders.Sum(p => p.IntegrationOrder.RequiredPreperationTimeInMins);
            var percent           = shift.IsolatorShift.TotalShiftDurationInMins > 0 ? (shiftOrders.Sum(p => p.IntegrationOrder.RequiredPreperationTimeInMins) * 100 / shift.IsolatorShift.TotalShiftDurationInMins) : 0;

            return(new IsolatorShiftDetail
            {
                IsolatorStaffAllocationId = shift.IsolatorStaffAllocationId,
                ShiftId = shift.IsolatorShift.ShiftId,
                ShiftTitle = string.Format("{2} ({0} - {1})", shift.IsolatorShift.StartTime, shift.IsolatorShift.EndTime, shift.IsolatorShift.ShiftTitle),
                StaffName = shift.Staff.DisplayName(),
                PercentFilled = Math.Round(percent),
                AvailableShiftTimeInMins = shift.IsolatorShift.TotalShiftDurationInMins - totalOrderReqTime,
                IntegrationOrders = shiftOrders.Select(io =>
                                                       new IntegrationOrderDetail()
                {
                    OrderPreperationId = io.IntegrationOrderPreperationId,
                    OrderId = io.IntegrationOrderId,
                    OrderName = io.IntegrationOrder.Name,
                    RequiredDateTime = io.IntegrationOrder.RequiredDate.HasValue ? io.IntegrationOrder.RequiredDate.Value.ToShortDateString() : "",
                    Status = ((OrderProgressEnum)io.IntegrationOrder.OrderLastProgressId).ToString(),
                    RequiredPreperationTimeInMins = io.IntegrationOrder.RequiredPreperationTimeInMins,
                    OrderPriority = ((PriorityEnum)io.IntegrationOrder.PriorityId).ToString(),
                    OrderTimeline = string.Format("{0}", io.CreatedDate.ToString("dd/MM/yyyy HH:mm")),
                    EnableUnschedule = io.IntegrationOrder.OrderLastProgressId == (int)OrderProgressEnum.PreperationScheduled
                }).ToList()
            });
        }
示例#2
0
        private void CreateStaffAllocationRecuring(IsolatorStaffAllocation parent, DateTime recurringDate)
        {
            var child = Mapper.Map <IsolatorStaffAllocation, IsolatorStaffAllocation>(parent);

            child.ParentAllocationId = parent.IsolatorStaffAllocationId;
            child.AllocatedDate      = recurringDate;

            repository.SaveNew(child);
        }
示例#3
0
        public string UpdateIsolatorStaffShift(IsolatorStaffAllocation isolatorStaffAllocation)
        {
            string result = null;

            try
            {
                _repository.SaveExisting <IsolatorStaffAllocation>(isolatorStaffAllocation);
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result);
        }
示例#4
0
        public void CreateRecurringAllocations(IsolatorStaffAllocation parent)
        {
            if (!parent.RecurringEndDate.HasValue)
            {
                return;
            }

            var recurringDate = parent.AllocatedDate;

            do
            {
                recurringDate = recurringDate.AddDays(1);
                var weeklyRecuringDays = !string.IsNullOrEmpty(parent.WeeklyRecurringWeekdays)
                    ? parent.WeeklyRecurringWeekdays.Split('|') : new string[0];

                switch (parent.RecurringTypeId)
                {
                case (int)RecurringTypeEnum.Daily:
                    switch (parent.DailyRecurringTypeId)
                    {
                    case (int)DailyRecurringTypeEnum.Everyday:
                        CreateStaffAllocationRecuring(parent, recurringDate);
                        break;

                    case (int)DailyRecurringTypeEnum.EveryWeekday:
                        if (recurringDate.DayOfWeek == DayOfWeek.Saturday || recurringDate.DayOfWeek == DayOfWeek.Sunday)
                        {
                            continue;
                        }
                        CreateStaffAllocationRecuring(parent, recurringDate);
                        break;
                    }
                    break;

                case (int)RecurringTypeEnum.Weekly:
                    if (weeklyRecuringDays.Any(p => (int)recurringDate.DayOfWeek == Convert.ToInt32(p)))
                    {
                        CreateStaffAllocationRecuring(parent, recurringDate);
                    }
                    break;
                }
            } while (parent.RecurringEndDate.Value.Date > recurringDate.Date);
        }
示例#5
0
 public int CreateIsolatorStaffShift(IsolatorStaffAllocation isolatorStaffAllocation)
 {
     return(_repository.SaveNew <IsolatorStaffAllocation>(isolatorStaffAllocation).IsolatorShiftId);
 }