public void CurrentClientRequestPlanUpdated(ClientRequestPlan clientRequestPlan, Operator queueOperator) { OnCurrentClientRequestPlanUpdated(this, new QueuePlanEventArgs() { ClientRequestPlan = clientRequestPlan, Operator = queueOperator }); }
private async void EditOperatorForm_Load(object sender, EventArgs e) { Enabled = false; try { using (var channel = WorkplaceChannelManager.CreateChannel()) { workplaceControl.Initialize(await taskPool.AddTask(channel.Service.GetWorkplacesLinks())); } if (operatorId != Guid.Empty) { using (var channel = UserChannelManager.CreateChannel()) { Operator = await taskPool.AddTask(channel.Service.GetUser(operatorId)) as QueueOperator; } } else { Operator = new QueueOperator() { Surname = "Новый пользователь", IsActive = true }; } 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 async void saveButton_Click(object sender, EventArgs e) { try { saveButton.Enabled = false; using (var channel = UserChannelManager.CreateChannel()) { Operator = await taskPool.AddTask(channel.Service.EditOperator(queueOperator)); } 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 UpdateCurrentClientRequest(QueueOperator queueOperator) { try { using (var channel = ServerUser.CreateChannel(queueOperator.SessionId)) { await taskPool.AddTask(channel.Service.UserHeartbeat()); } using (var channel = QueuePlanChannelManager.CreateChannel(queueOperator.SessionId)) { var clientRequestPlan = await channel.Service.GetCurrentClientRequestPlan(); if (clientRequestPlan != null) { ClientRequest clientRequest = clientRequestPlan.ClientRequest; var state = ClientRequestState.Calling; switch (clientRequest.State) { case ClientRequestState.Waiting: break; case ClientRequestState.Calling: state = random.Next(1, 10) >= 5 ? ClientRequestState.Rendering : ClientRequestState.Absence; break; case ClientRequestState.Rendering: state = ClientRequestState.Rendered; break; } await channel.Service.UpdateCurrentClientRequest(state); if (state == ClientRequestState.Calling) { await channel.Service.CallCurrentClient(); } log(string.Format("Установлен статус [{0}] для [{1}]", state, clientRequest)); } else { log(string.Format("[{0}] = [нет активных запросов]", queueOperator)); } } } catch (FaultException exception) { log(string.Format("[{0}] = [{1}]", queueOperator, exception.Reason)); } catch (Exception exception) { log(exception.ToString()); } }
private void UpdateOperatorCurrentRequest(Operator op, ClientRequestPlan plan) { var wrapper = CurrentRequests.SingleOrDefault(w => w.Operator.Equals(op)); if ((plan == null) && (wrapper == null)) { return; } if (wrapper != null) { if (IsActiveRequest(plan)) { wrapper.Request = plan.ClientRequest; } else { CurrentRequests.Remove(wrapper); } } else { if (IsActiveRequest(plan)) { CurrentRequests.Add(new ClientRequestWrapper() { Request = plan.ClientRequest, Operator = op }); } } ShowNotification = CurrentRequests.Count > 0; }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); container = new UnityContainer(); container.RegisterInstance(container); ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(container)); configuration = new ConfigurationManager(Product.Operator.AppName, SpecialFolder.ApplicationData); container.RegisterInstance(configuration); loginSettings = configuration.GetSection<LoginSettings>(LoginSettings.SectionKey); container.RegisterInstance(loginSettings); loginFormSettings = configuration.GetSection<LoginFormSettings>(LoginFormSettings.SectionKey); container.RegisterInstance(loginFormSettings); hubSettings = configuration.GetSection<HubSettings>(HubSettings.SectionKey); container.RegisterInstance(hubSettings); ParseOptions(); if (options.AutoLogin) { endpoint = options.Endpoint; try { using (var serverUserService = new UserService(endpoint)) using (var channelManager = serverUserService.CreateChannelManager()) using (var channel = channelManager.CreateChannel()) { sessionId = Guid.Parse(options.SessionId); currentUser = channel.Service.OpenUserSession(sessionId).Result as QueueOperator; } } catch (Exception ex) { MessageBox.Show(ex.InnerException.Message); return; } container.RegisterInstance<User>(currentUser); container.RegisterInstance<QueueOperator>(currentUser); RegisterServices(); Application.Run(new OperatorForm()); } else { while (true) { var loginForm = new LoginForm(UserRole.Operator); if (loginForm.ShowDialog() == DialogResult.OK) { configuration.Save(); endpoint = loginSettings.Endpoint; currentUser = loginForm.CurrentUser as QueueOperator; sessionId = currentUser.SessionId; container.RegisterInstance<User>(currentUser); container.RegisterInstance<QueueOperator>(currentUser); RegisterServices(); loginForm.Dispose(); using (var f = new OperatorForm()) { Application.Run(f); if (f.IsLogout) { ResetSettings(); continue; } } } break; } } }