/// <summary> /// Set a new status from current Callback. On successfull change, service sent a signal to the client /// </summary> /// <param name="paramNewStatus"></param> public void SetStatus(Operador operatorToChange, AvailabiltyStatus paramNewStatus) { lock (syncObject) { try { // gets client from the service Client clientToChange = getClientByOperator(operatorToChange); // Set the status on operator finded clientToChange.Operator.Status = paramNewStatus; // Sent a confirmation signal to the client CurrentCallback.ServiceChangeStatusRequest(paramNewStatus); // if the callback related to operator has change, update client CheckAndUpdateCallbackOperator(clientToChange, CurrentCallback); // Check if the backoffice is logged in and send refresh status if (connectedBackoffice != null) { SentRefreshForConnectedBackoffice(); } // For debug purposses, sent a console message to inform Log.Info(_operatorClassName, string.Format("{0} has changed status to {1}.", operatorToChange, paramNewStatus)); } catch (Exception ex) { Log.Error("Service", "error setting status: " + ex.Message); // If the callback is no related with any operator, forces disconnection CurrentCallback.Mensaje("There is an error getting operator, please contact the administrator. The service connection has been ended."); // Force the client's desconnection from de the service CurrentCallback.ForceDisconnect(); } } }
/// <summary> /// Sent petition to the service for connection. The request is asnyc type /// </summary> private async void connectService() { try { // Implements new Logica Operador object Logica.Operador logOperator = new Logica.Operador(); // Gets operator from application variable Operador opLogged = App.Current.Properties["user"] as Operador; // Gets interface from current Entidades.Service.Interface.IServicioCallback callbackForUI = this as Entidades.Service.Interface.IServicioCallback; // Calls operation method to connect to the service if (await logOperator.ConnectOperatorToService(opLogged, callbackForUI)) { // Shows connection status on the UI currentStatus = AvailabiltyStatus.ReadyToReceive; } else { // If the connection has been rejected, shows on the UI the results currentStatus = AvailabiltyStatus.Disconnected; } } catch (Exception ex) { Util.MsgBox.Error("Ha ocurrido un error al procesar la solicitud de conexión : " + ex.Message); currentStatus = AvailabiltyStatus.Error; } }
/// <summary> /// On service request, the status of UI is modified by petition /// </summary> /// <param name="paramNewStatus"></param> public void ServiceChangeStatusRequest(AvailabiltyStatus paramNewStatus) { Dispatcher.BeginInvoke((Action)(() => { currentStatus = paramNewStatus; })); }
private void loadConnectionStatus() { // Suscribe to updates on Combo configureComboConnectionItemChanged(); // Sets initial value of the status currentStatus = AvailabiltyStatus.Disconnected; // Subscribe Selection Changed event cboConnect.SelectionChanged += cboConnect_SelectionChanged; }
/// <summary> /// Sent a request to service for changing current status on the service /// </summary> /// <param name="pOperator"></param> /// <param name="newStatus"></param> /// <returns></returns> public async Task ChangeCurrentStatus(Entidades.Operador prmOper, AvailabiltyStatus newStatus) { try { // Checks if the proxy is ready await prepareProxy(); // Sent to the service petition to change te current status proxy.SetStatus(prmOper, newStatus); } catch (Exception ex) { throw ex; } }
/// <summary> /// Sent a request to service for change current status /// </summary> /// <param name="newStatus">the new status for setup in service</param> private async void sentChangeStatusRequest(AvailabiltyStatus newStatus) { try { // Create a new Logic Operator object for operation Logica.Operador logicOperator = new Logica.Operador(); // Gets operator from app properties Operador operatorLogged = App.Current.Properties["user"] as Operador; // Call method request launch await logicOperator.ChangeCurrentStatus(operatorLogged, newStatus); } catch (Exception ex) { Util.MsgBox.Error("Error al procesar el cambio de etsado : " + ex.Message); } }
public void ServiceChangeStatusRequest(AvailabiltyStatus paramNewStatus) { if (paramNewStatus == AvailabiltyStatus.Disconnected) { Dispatcher.BeginInvoke((Action)(() => { // Deactivates backoffice panel grdBackofficePanel.Visibility = Visibility.Collapsed; // Shows reconection panel grdReconnectionPanel.Visibility = Visibility.Visible; // Activate reconnection button btnReconnect.IsEnabled = true; })); } }
/// <summary> /// Informa gráficamente el estado de la conexión de proxy para que el usuario pueda saberlo /// </summary> /// <param name="proxyStatus"></param> public void runActionStatus(AvailabiltyStatus availStatus) { // If the new status is the same of current status if (availStatus == currentStatus) { return; } switch (availStatus) { case AvailabiltyStatus.Disconnected: // if the current status is related to connected status if (lstConnectedStatusOnly.Exists((status) => status.Status == currentStatus)) { // Runs disconnection request disconnectService(); } currentStatus = AvailabiltyStatus.Disconnected; break; case AvailabiltyStatus.Connected: // Launch a connection try with async method connectService(); break; case AvailabiltyStatus.ReadyToReceive: case AvailabiltyStatus.Break: case AvailabiltyStatus.Bath: case AvailabiltyStatus.SpecialTask: sentChangeStatusRequest(availStatus); break; case AvailabiltyStatus.Error: break; default: break; } }
void IServicioCallback.ServiceChangeStatusRequest(AvailabiltyStatus paramNewStatus) { callbackInteraction.ServiceChangeStatusRequest(paramNewStatus); }
public StatusUI(AvailabiltyStatus status, string description, bool isDefault = false) { Status = status; Description = description; IsDefault = isDefault; }