public OperatorPlan(Operator queueOperator, DateTime planDate) { Operator = queueOperator; PlanDate = planDate; Metrics = new OperatorPlanMetrics(queueOperator); ClientRequestPlans = new ObservableCollection<ClientRequestPlan>(); ClientRequestPlans.CollectionChanged += ClientRequestPlans_CollectionChanged; }
/// <summary> /// Получить перерывы оператора /// </summary> public OperatorInterruption[] GetOperatorInterruptions(Operator queueOperator) { if (!operatorInterruptions.ContainsKey(queueOperator)) { logger.Info("Загрузка перерывов оператора [{0}]", queueOperator); using (var session = SessionProvider.OpenSession()) using (var transaction = session.BeginTransaction()) { var interruptions = session.CreateCriteria<OperatorInterruption>() .Add(new Disjunction() .Add(Restrictions.IsNull("Operator")) .Add(Restrictions.Eq("Operator", queueOperator))) .Add(new Disjunction() .Add(new Conjunction() .Add(Restrictions.Eq("Type", OperatorInterruptionType.Weekday)) .Add(Restrictions.Eq("DayOfWeek", PlanDate.DayOfWeek))) .Add(new Conjunction() .Add(Restrictions.Eq("Type", OperatorInterruptionType.TargetDate)) .Add(Restrictions.Eq("TargetDate", PlanDate)))) .List<OperatorInterruption>() .Where(i => (i.WeekFold != 0 ? (i.WeekFold > 0 ? WeekNumber % i.WeekFold == 0 : WeekNumber % Math.Abs(i.WeekFold) != 0) : true)) .ToArray(); operatorInterruptions.Add(queueOperator, interruptions); } } return operatorInterruptions[queueOperator]; }
/// <summary> /// Взять текущий план обслуживания оператора /// </summary> /// <param name="queueOperator"></param> /// <returns></returns> public OperatorPlan GetOperatorPlan(Operator queueOperator) { OperatorPlan operatorPlan = OperatorsPlans .FirstOrDefault(p => p.Operator.Equals(queueOperator)); if (operatorPlan == null) { throw new Exception(string.Format("План обслуживания для оператора [{0}] не найден", queueOperator)); } return operatorPlan; }
public async Task<DTO.Operator> EditOperator(DTO.Operator source) { return await Task.Run(() => { CheckPermission(UserRole.Administrator, AdministratorPermissions.Users); using (var session = SessionProvider.OpenSession()) using (var transaction = session.BeginTransaction()) { Operator queueOperator; if (!source.Empty()) { var operatorId = source.Id; queueOperator = session.Get<Operator>(operatorId); if (queueOperator == null) { throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(operatorId), string.Format("Оператор [{0}] не найден", operatorId)); } } else { queueOperator = new Operator() { SessionId = Guid.NewGuid() }; } queueOperator.Surname = source.Surname; queueOperator.Name = source.Name; queueOperator.Patronymic = source.Patronymic; queueOperator.Email = source.Email; queueOperator.Mobile = source.Mobile; queueOperator.IsActive = source.IsActive; queueOperator.Identity = source.Identity; queueOperator.IsMultisession = source.IsMultisession; if (source.Workplace != null) { Guid workplaceId = source.Workplace.Id; Workplace workplace = session.Get<Workplace>(workplaceId); if (workplace == null) { throw new FaultException<ObjectNotFoundFault>(new ObjectNotFoundFault(workplaceId), string.Format("Рабочее место [{0}] не найдено", workplaceId)); } queueOperator.Workplace = workplace; } else { queueOperator.Workplace = null; } var errors = queueOperator.Validate(); if (errors.Length > 0) { throw new FaultException(errors.First().Message); } session.Save(queueOperator); var todayQueuePlan = QueueInstance.TodayQueuePlan; using (var locker = todayQueuePlan.WriteLock()) { transaction.Commit(); todayQueuePlan.Put(queueOperator); } return Mapper.Map<Operator, DTO.Operator>(queueOperator); } }); }
private void demoDataMenuItem_Click(object sender, EventArgs e) { Log("Загрузка демонстрационных данных"); using (var session = sessionProvider.OpenSession()) using (var transaction = session.BeginTransaction()) { Log("Загрузка рабочих мест"); var w1 = session.CreateCriteria<Workplace>() .Add(Restrictions.Eq("Type", WorkplaceType.Window)) .Add(Restrictions.Eq("Number", 1)) .SetMaxResults(1) .UniqueResult<Workplace>(); if (w1 == null) { w1 = new Workplace(); w1.Type = WorkplaceType.Window; w1.Number = 1; session.Save(w1); } var w2 = session.CreateCriteria<Workplace>() .Add(Restrictions.Eq("Type", WorkplaceType.Cabinet)) .Add(Restrictions.Eq("Number", 10)) .SetMaxResults(1) .UniqueResult<Workplace>(); if (w2 == null) { w2 = new Workplace(); w2.Type = WorkplaceType.Cabinet; w2.Number = 10; session.Save(w2); } var w3 = session.CreateCriteria<Workplace>() .Add(Restrictions.Eq("Type", WorkplaceType.Room)) .Add(Restrictions.Eq("Number", 5)) .SetMaxResults(1) .UniqueResult<Workplace>(); if (w3 == null) { w3 = new Workplace(); w3.Type = WorkplaceType.Room; w3.Number = 5; session.Save(w3); } Log("Загрузка операторов"); var o1 = session.CreateCriteria<Operator>() .Add(Restrictions.Eq("Surname", "Сидоров")) .SetMaxResults(1) .UniqueResult<Operator>(); if (o1 == null) { o1 = new Operator() { IsActive = true, Name = "Денис", Surname = "Сидоров", SessionId = Guid.NewGuid(), Workplace = w1 }; session.Save(o1); } var o2 = session.CreateCriteria<Operator>() .Add(Restrictions.Eq("Surname", "Шитиков")) .SetMaxResults(1) .UniqueResult<Operator>(); if (o2 == null) { o2 = new Operator() { IsActive = true, Name = "Андрей", Surname = "Шитиков", SessionId = Guid.NewGuid(), Workplace = w2 }; session.Save(o2); } var o3 = session.CreateCriteria<Operator>() .Add(Restrictions.Eq("Surname", "Меньшова")) .SetMaxResults(1) .UniqueResult<Operator>(); if (o3 == null) { o3 = new Operator() { IsActive = true, Name = "Ирина", Surname = "Меньшова", SessionId = Guid.NewGuid(), Workplace = w3 }; session.Save(o3); } foreach (var o in new[] { o1, o2, o3 }) { foreach (var d in new[] { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday, DayOfWeek.Sunday }) { var s = session.CreateCriteria<DefaultWeekdaySchedule>() .Add(Restrictions.Eq("DayOfWeek", d)) .UniqueResult<DefaultWeekdaySchedule>(); if (s != null) { session.Save(new ServiceRendering() { Mode = ServiceRenderingMode.AllRequests, Operator = o, Schedule = s }); } } } Log("Загрузка услуг"); var all = ClientRequestRegistrator.Terminal | ClientRequestRegistrator.Manager | ClientRequestRegistrator.Portal; for (int i = 1; i < 10; i++) { var code = string.Format("{0}.0", i); var s = session.CreateCriteria<Service>() .Add(Restrictions.Eq("Code", code)) .SetMaxResults(1) .UniqueResult<Service>(); if (s == null) { session.Save(new Service() { IsActive = true, Code = code, Name = string.Format("Новая услуга {0}", i), LiveRegistrator = all, EarlyRegistrator = all, TimeIntervalRounding = TimeSpan.FromMinutes(5), MaxEarlyDays = 30, MaxClientRecalls = 2, Color = "#0000FF", FontSize = 1, ClientRequire = true, MaxSubjects = 5, SortId = i }); } } Log("Загрузка дополнительных услуг"); foreach (var n in new string[] { "Ксерокопия документа", "Заполнение бланка" }) { var a = session.CreateCriteria<AdditionalService>() .Add(Restrictions.Eq("Name", n)) .SetMaxResults(1) .UniqueResult<AdditionalService>(); if (a == null) { session.Save(new AdditionalService() { Name = n, Price = 500, Measure = "шт" }); } } transaction.Commit(); } Log("Загрузка демонстрационных данных завершена"); }
public OperatorPlanMetrics(Operator queueOperator) { Operator = queueOperator; }
public virtual void Redirect(Operator targetOperator) { Operator = targetOperator; State = ClientRequestState.Redirected; }
public virtual void Calling(Operator queueOperator) { Operator = queueOperator; CallingStartTime = DateTime.Now.TimeOfDay; CallingLastTime = CallingStartTime; State = ClientRequestState.Calling; }