private SelectServiceButton[] CreateControlsForGroupsAndServices(ServiceGroup[] groups, Service[] services) { var buttons = new List<SelectServiceButton>(); if (groups != null) { foreach (var group in groups.Where(g => g.IsActive)) { buttons.Add(CreateSelectServiceButton(group.Code, group.Name, group.Color, group.FontSize, (s, a) => OnServiceGroupSelected(group))); } } if (services != null) { foreach (var service in services.Where(s => s.IsActive)) { buttons.Add(CreateSelectServiceButton(service.Code, service.Name, service.GetColor(), service.FontSize, (s, a) => SetSelectedService(service) )); } } return buttons.ToArray(); }
private async void addClientRequest(Service service) { using (var channel = ChannelManager.CreateChannel()) { string surname = string.Format("client {0}", random.Next()); try { var client = await channel.Service.EditClient(new Client() { Surname = surname }); var isPriority = random.Next(0, 1) == 1; var clientRequest = await channel.Service.AddLiveClientRequest(client.Id, service.Id, isPriority, new Dictionary<Guid, object>() { }, Subjects); log(string.Format("Добавлен запроса клиента {0}", clientRequest)); } catch (FaultException exception) { log(string.Format("{0} = {1}", service, exception.Reason)); } catch (Exception exception) { log(exception.ToString()); } } }
public async void SetSelectedService(Service service) { logger.Debug("выбрана услуга [{0}]", service); Model.RequestType = null; Model.SelectedService = service; bool liveTerminal = service.LiveRegistrator.HasFlag(ClientRequestRegistrator.Terminal); bool earlyTerminal = service.EarlyRegistrator.HasFlag(ClientRequestRegistrator.Terminal); if (!liveTerminal && !earlyTerminal) { Window.Warning(Translater.Message("ServiceNotAvailableOnTerminal")); return; } if (liveTerminal && !earlyTerminal) { Model.RequestType = ClientRequestType.Live; } else if (!liveTerminal && earlyTerminal) { Model.RequestType = ClientRequestType.Early; } if (Model.RequestType != null) { try { await Model.AdjustMaxSubjects(); } catch { }; } Navigator.NextPage(); }
private void SetSelectedService(Service service) { OnServiceSelected(this, service); }
private void AddServicesToButtons(Service[] services, List<SelectServiceButton> buttons) { foreach (var service in services.Where(s => s.IsActive)) { buttons.Add(CreateSelectServiceButton(service.Code, service.Name, service.GetColor(), service.FontSize, (s, a) => SetSelectedService(service) )); } }
private void servicesTreeView_AfterSelect(object sender, TreeViewEventArgs e) { var selectedNode = servicesTreeView.SelectedNode; selectedService = selectedNode != null && selectedNode.Tag is Service ? (Service)selectedNode.Tag : null; if (selectedService != null) { earlyDatePicker.MaxDate = ServerDateTime.Today.AddDays(selectedService.MaxEarlyDays); } LoadFreeTime(); }
private async void selectServiceControl_ServiceSelected(object sender, EventArgs e) { selectedService = selectServiceControl.SelectedService; if (selectedService != null) { currentSchedulePanel.Enabled = true; using (var channel = ChannelManager.CreateChannel()) { try { currentScheduleControl.Schedule = await taskPool.AddTask(channel.Service.GetServiceExceptionSchedule(selectedService.Id, ServerDateTime.Today)); currentScheduleCheckBox.Checked = true; } catch (OperationCanceledException) { } catch (CommunicationObjectAbortedException) { } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (FaultException<ObjectNotFoundFault>) { currentScheduleCheckBox.Checked = false; currentScheduleControl.Schedule = null; } catch (FaultException exception) { UIHelper.Warning(exception.Reason.ToString()); } catch (Exception exception) { UIHelper.Warning(exception.Message); } } } else { currentSchedulePanel.Enabled = false; } }
private async void EditServiceStepForm_Load(object sender, EventArgs e) { Enabled = false; using (var channel = ChannelManager.CreateChannel()) { try { if (serviceId != Guid.Empty) { service = await taskPool.AddTask(channel.Service.GetService(serviceId)); } ServiceStep = serviceStepId != Guid.Empty ? await taskPool.AddTask(channel.Service.GetServiceStep(serviceStepId)) : new ServiceStep() { Service = service, Name = "Новый этап" }; Enabled = true; } catch (OperationCanceledException) { } catch (CommunicationObjectAbortedException) { } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (FaultException exception) { UIHelper.Warning(exception.Reason.ToString()); } catch (Exception exception) { UIHelper.Warning(exception.Message); } } }
private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { SelectedService = treeView.SelectedNode.Tag as Service; Selected(this, new EventArgs()); }
private async void saveButton_Click(object sender, EventArgs e) { using (var channel = ChannelManager.CreateChannel()) { try { saveButton.Enabled = false; Service = await taskPool.AddTask(channel.Service.EditService(service)); if (Saved != null) { Saved(this, EventArgs.Empty); } } catch (OperationCanceledException) { } catch (CommunicationObjectAbortedException) { } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (FaultException exception) { UIHelper.Warning(exception.Reason.ToString()); } catch (Exception exception) { UIHelper.Warning(exception.Message); } finally { saveButton.Enabled = true; } } }
private async void EditServiceForm_Load(object sender, EventArgs e) { using (var channel = ChannelManager.CreateChannel()) { try { Enabled = false; if (serviceGroupId != Guid.Empty) { serviceGroup = await taskPool.AddTask(channel.Service.GetServiceGroup(serviceGroupId)); } if (serviceId != Guid.Empty) { Service = await taskPool.AddTask(channel.Service.GetService(serviceId)); } else { var all = ClientRequestRegistrator.Terminal | ClientRequestRegistrator.Manager | ClientRequestRegistrator.Portal; Service = new Service() { IsActive = true, ServiceGroup = serviceGroup, Code = "0.0", Name = "Новая услуга", LiveRegistrator = all, EarlyRegistrator = all, TimeIntervalRounding = TimeSpan.FromMinutes(5), MaxSubjects = 5, Color = "#FFFFFF", FontSize = 1 }; } Enabled = true; } catch (OperationCanceledException) { } catch (CommunicationObjectAbortedException) { } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (FaultException exception) { UIHelper.Warning(exception.Reason.ToString()); } catch (Exception exception) { UIHelper.Warning(exception.Message); } } }
private SelectServiceButton CreateServiceButton(Service service, EventHandler onSelected) { var model = new ServiceButtonViewModel() { Code = service.Code, Name = service.Name, FontSize = service.FontSize == 0 ? 1 : service.FontSize, ServiceBrush = service.GetColor().GetBrushForColor() }; model.OnServiceSelected += onSelected; return new SelectServiceButton() { DataContext = model }; }
private void RenderServices(Service[] services) { resultsGrid.Children.Clear(); resultsGrid.RowDefinitions.Clear(); resultsGrid.RowDefinitions.Add(new RowDefinition()); resultsGrid.ColumnDefinitions.Clear(); int row = 0; int col = 0; foreach (var service in services) { var button = CreateServiceButton(service, (s, a) => { Request.SelectedService = service; Navigator.NextPage(); }); if (col >= ResultsColCount) { col = 0; resultsGrid.RowDefinitions.Add(new RowDefinition()); row++; } else { if (col + 1 > resultsGrid.ColumnDefinitions.Count) { resultsGrid.ColumnDefinitions.Add(new ColumnDefinition()); } } button.SetValue(Grid.ColumnProperty, col++); button.SetValue(Grid.RowProperty, row); resultsGrid.Children.Add(button); } }
public ServiceTreeNode(Service service) : base() { Service = service; Text = service.ToString(); }