/// <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> /// Get and set operator information from the service /// </summary> private async void LoadServiceVariable(bool isStartPetition = false) { try { // Generate a new Operator Logic object Logica.Operador logOper = new Logica.Operador(); // Create a new list and save all operators on them List <Entidades.Operador> lstOperators = await logOper.GetOperatorWorkingToday(); // Convert to observable collection lstDetailedOperators.ClearListAndConvertFromOperator(lstOperators); // Update next event time left updateNextEventTimeLeft(); // Start timer to check periodically startTimeToNextEvent(); // Puts the observable collection on itemsource dgConnectedUser.ItemsSource = lstDetailedOperators; // Update combobox for operator filtering and hour filtering generateContentAndLoadCboOperatorReportFiltering(); generateContentForHourReportFiltering(); // If is a start petition refresh balance of the day if (isStartPetition) { StartReportBalanceDayConfiguration(); } } catch (Exception ex) { // Shows error details on a message box Util.MsgBox.Error("Ha ocurrido un error al llenar el listado de operadores: " + ex.Message); } }
private async void SendConnectOrder() { try { // Generamos un objeto de logica operador Logica.Operador logOper = new Logica.Operador(); // Disponemos de una entidad operador Entidades.Operador entOper = new Entidades.Operador() { UserName = txtUsername.Text, Password = txtPassword.Password }; // Consultamos a las capas de negocio para validar el ingreso Entidades.Operador operResponse = await logOper.ConnectBackoffice(entOper, App.Current.MainWindow as Entidades.Service.Interface.IServicioCallback); if (operResponse != null) { Operador = operResponse; DialogResult = true; } else { Util.MsgBox.Error("El usuario o la clave es incorrecta."); logInPetition = false; } } catch (Exception ex) { Util.MsgBox.Error(ex.Message); logInPetition = false; } }
private void btnLoguear_Click(object sender, RoutedEventArgs e) { try { // Generamos un objeto de logica operador Logica.Operador logOper = new Logica.Operador(); // Disponemos de una entidad operador Entidades.Operador entOper = new Entidades.Operador() { UserName = txtUsername.Text, Password = txtPassword.Password }; // Consultamos a las capas de negocio para validar el ingreso entOper = logOper.Ingresar(entOper); if (entOper != null) { Operador = entOper; DialogResult = true; } else { Util.MsgBox.Error("El usuario o la clave es incorrecta."); } } catch (Exception ex) { Util.MsgBox.Error(ex.Message); } }
/// <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); } }
/// <summary> /// Sent a request to service for desconnection /// </summary> private async void disconnectService() { try { // Generates a new logic operator object Logica.Operador logOperator = new Logica.Operador(); // Encapsulates the operator from application Operador operatorLogged = App.Current.Properties["user"] as Operador; // Sent request to logic project for desconnect await logOperator.DisconnectFromService(operatorLogged); } catch (Exception ex) { Util.MsgBox.Error("Ha ocurrido un error al procesar la desconexión: " + ex.Message); } }
private async void SentReconnectSignal() { // Generate new logic operator object Logica.Operador logOperator = new Logica.Operador(); // Gets operator entity saved on application properties Operador operatorLogged = App.Current.Properties["user"] as Operador; // if connection is valid if (await logOperator.ConnectBackoffice(operatorLogged, this) != null) { // Loads connection information LoadConnectionInformation(); // Change visibility of panel grdBackofficePanel.Visibility = Visibility.Visible; grdReconnectionPanel.Visibility = Visibility.Collapsed; } else { // if not reactivates the button btnReconnect.IsEnabled = true; } }