Inheritance: IdentifiedEntity
示例#1
0
        /// <summary>
        /// Получить параметры обслуживания
        /// </summary>
        public ServiceRendering[] GetServiceRenderings(Schedule schedule, ServiceStep serviceStep, ServiceRenderingMode serviceRenderingMode)
        {
            var key = new ServiceRenderingKey(schedule, serviceStep, serviceRenderingMode);

            if (!serviceRenderings.ContainsKey(key))
            {
                logger.Info("Загрузка параметров оказания услуги для раписания [{0}]", schedule);

                using (var session = SessionProvider.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    serviceRenderings.Add(key, session.CreateCriteria<ServiceRendering>()
                         .Add(Restrictions.Eq("Schedule", schedule))
                         .Add(serviceStep != null ? Restrictions.Eq("ServiceStep", serviceStep) : Restrictions.IsNull("ServiceStep"))
                         .Add(new Disjunction()
                             .Add(Restrictions.Eq("Mode", serviceRenderingMode))
                             .Add(Restrictions.Eq("Mode", ServiceRenderingMode.AllRequests)))
                         .List<ServiceRendering>()
                         .ToArray());

                    transaction.Commit();
                }
            }

            return serviceRenderings[key];
        }
示例#2
0
        public void AddClientRequest(ClientRequest clientRequest, Schedule schedule)
        {
            if (!clientRequest.IsClosed)
            {
                TimeSpan startTime, finishTime;

                var clientInterval = clientRequest.Type == ClientRequestType.Live
                    ? schedule.LiveClientInterval : schedule.EarlyClientInterval;
                clientInterval = TimeSpan.FromTicks(clientInterval.Ticks * clientRequest.Subjects);

                switch (clientRequest.State)
                {
                    case ClientRequestState.Waiting:
                    case ClientRequestState.Redirected:
                    case ClientRequestState.Postponed:
                        startTime = clientRequest.RequestTime;
                        if (startTime < schedule.StartTime)
                        {
                            startTime = schedule.StartTime;
                        }
                        if (startTime < PlanTime)
                        {
                            startTime = PlanTime;
                        }
                        startTime = GetNearTimeInterval(startTime, schedule, clientRequest.Type);
                        finishTime = startTime.Add(clientInterval);
                        break;

                    case ClientRequestState.Calling:
                        startTime = clientRequest.CallingStartTime;
                        finishTime = PlanTime.Add(clientInterval);
                        break;

                    case ClientRequestState.Rendering:
                        startTime = clientRequest.RenderStartTime;
                        finishTime = startTime.Add(clientInterval);
                        if (finishTime < PlanTime)
                        {
                            finishTime = PlanTime;
                        }
                        break;

                    default:
                        throw new Exception(string.Format("Недопустимое состояние для запроса [{0}]", clientRequest));
                }

                ClientRequestPlans.Add(new ClientRequestPlan(clientRequest, startTime, finishTime));
            }
            else if (clientRequest.State == ClientRequestState.Rendered)
            {
                Metrics.DailyWorkload = Metrics.DailyWorkload.Add(clientRequest.RenderFinishTime - clientRequest.RenderStartTime);
            }
        }
 public DefaultExceptionScheduleReportData(Schedule source, DateTime scheduleDate)
 {
     ScheduleDate = scheduleDate;
     IsWorked = source.IsWorked;
     StartTime = source.StartTime;
     FinishTime = source.FinishTime;
     ClientInterval = source.LiveClientInterval;
     Intersection = source.Intersection;
     MaxClientRequests = source.MaxClientRequests;
 }
示例#4
0
        public TimeSpan GetNearTimeInterval(TimeSpan startTime, Schedule schedule,
            ClientRequestType clientRequestType, int subjects = 1)
        {
            // Недоступные интервалы
            var reservedIntervals = new List<TimeInterval>();

            // Перерывы оператора
            reservedIntervals.AddRange(GetIgnoredIntervals(clientRequestType));
            // Запланированные запросы клиентов
            reservedIntervals.AddRange(clientRequestIntervals);

            var clientInterval = TimeSpan.FromTicks(schedule.LiveClientInterval.Ticks * subjects);

            var renderStartTime = startTime;

            foreach (var exception in reservedIntervals
                .Where(i => i.FinishTime >= startTime)
                .OrderBy(i => i.FinishTime))
            {
                var renderFinishTime = exception.StartTime;

                var interval = renderFinishTime - renderStartTime;
                // Найденный интервал обслуживания клиента больше или равен плановому?
                if (interval < clientInterval - schedule.Intersection)
                {
                    renderStartTime = exception.FinishTime;
                }
                else
                {
                    break;
                }
            }

            return renderStartTime;
        }