Ejemplo n.º 1
0
        private void CancelButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("¿Seguro que desea cancelar esta solicitud?",
                                                                "Confirmación", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                RestClient client = new RestClient(urlBase);
                client.Timeout = -1;
                string urlRequest = "requests/" + RequestSent.idRequest;
                var    request    = new RestRequest(urlRequest, Method.PATCH);
                request.AddHeader("Content-type", "application/json");
                foreach (RestResponseCookie cookie in Login.cookies)
                {
                    request.AddCookie(cookie.Name, cookie.Value);
                }
                Models.RequestStatus status = new Models.RequestStatus();
                status.requestStatus = 4;
                var json = JsonConvert.SerializeObject(status);
                request.AddHeader("Token", Login.tokenAccount.token);
                request.AddParameter("application/json", json, ParameterType.RequestBody);
                System.Net.ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return(true); };
                try
                {
                    IRestResponse response = client.Execute(request);
                    if (response.StatusCode == System.Net.HttpStatusCode.Created || response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        status = JsonConvert.DeserializeObject <Models.RequestStatus>(response.Content);
                        MessageBox.Show("Solicitud cancelada exitosamente", "Cancelación Exitosa", MessageBoxButton.OK, MessageBoxImage.Information);
                        RequestsMadeList requestsMadeList = new RequestsMadeList();
                        requestsMadeList.InitializeMenu();
                        requestsMadeList.Show();
                        Close();
                    }
                    else
                    {
                        Models.Error responseError = JsonConvert.DeserializeObject <Models.Error>(response.Content);
                        MessageBox.Show(responseError.error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        if (response.StatusCode == System.Net.HttpStatusCode.Forbidden || response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
                            response.StatusCode == System.Net.HttpStatusCode.RequestTimeout)
                        {
                            Login login = new Login();
                            login.Show();
                            Close();
                        }
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show("No se pudo obtener información de la base de datos. Intente más tarde", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    TelegramBot.SendToTelegram(exception);
                    LogException.Log(this, exception);
                    RequestsMadeList requestsMadeList = new RequestsMadeList();
                    requestsMadeList.InitializeMenu();
                    requestsMadeList.Show();
                    Close();
                }
            }
        }
Ejemplo n.º 2
0
        private void ListViewMenuSelectionChanged(object sender, SelectionChangedEventArgs selectionChangedEventArgs)
        {
            switch (((ListViewItem)((ListView)sender).SelectedItem).Name)
            {
            case "ListViewItemBehind":
                Service service = new Service();
                service.InitializeMenu();
                service.Show();
                Close();
                break;

            case "ListViewItemHome":
                HomeClient home = new HomeClient();
                home.InitializeMenu();
                home.Show();
                Close();
                break;

            case "ListViewItemAccountEdit":
                AccountEdition accountEdition = new AccountEdition();
                accountEdition.InitializeMenu();
                accountEdition.Show();
                Close();
                break;

            case "ListViewItemChat":
                ChatList chatList = new ChatList();
                chatList.InitializeMenu();
                chatList.Show();
                Close();
                break;

            case "ListViewItemRequest":
                RequestsMadeList requestsMadeList = new RequestsMadeList();
                requestsMadeList.InitializeMenu();
                requestsMadeList.Show();
                Close();
                break;

            case "ListViewItemServiceRegistration":
                AccountActivate accountActivate = new AccountActivate();
                accountActivate.InitializeMenu();
                accountActivate.Show();
                Close();
                break;

            case "ListViewItemCommentTracing":
                CommentClient commentClient = new CommentClient();
                commentClient.InitializeMenu();
                commentClient.Show();
                Close();
                break;

            default:
                break;
            }
        }
        private void ListViewMenuSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            switch (((System.Windows.Controls.ListViewItem)((System.Windows.Controls.ListView)sender).SelectedItem).Name)
            {
            case "ListViewItemAccountEdit":
                AccountEdition accountEdition = new AccountEdition();
                accountEdition.InitializeMenu();
                accountEdition.Show();
                Close();
                break;

            case "ListViewItemChat":
                ChatList chatList = new ChatList();
                chatList.InitializeMenu();
                chatList.Show();
                Close();
                break;

            case "ListViewItemRequest":
                RequestsMadeList requestsMadeList = new RequestsMadeList();
                requestsMadeList.InitializeMenu();
                requestsMadeList.Show();
                Close();
                break;

            case "ListViewItemServiceRegistration":
                AccountActivate accountActivate = new AccountActivate();
                accountActivate.InitializeMenu();
                accountActivate.Show();
                Close();
                break;

            case "ListViewItemCommentTracing":
                CommentClient commentClient = new CommentClient();
                commentClient.InitializeMenu();
                commentClient.Show();
                Close();
                break;

            default:
                break;
            }
        }
Ejemplo n.º 4
0
        private void ListViewMenuSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            switch (((ListViewItem)((ListView)sender).SelectedItem).Name)
            {
            case "ListViewItemHome":
                if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.ONE))
                {
                    HomeClient home = new HomeClient();
                    home.InitializeMenu();
                    home.Show();
                    Close();
                }
                else
                {
                    HomeEmployee home = new HomeEmployee();
                    home.InitializeMenu();
                    home.Show();
                    Close();
                }
                break;

            case "ListViewItemChat":
                ChatList chatList = new ChatList();
                chatList.InitializeMenu();
                chatList.Show();
                Close();
                break;

            case "ListViewItemRequest":
                if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.ONE))
                {
                    RequestsMadeList requestsMadeList = new RequestsMadeList();
                    requestsMadeList.InitializeMenu();
                    requestsMadeList.Show();
                    Close();
                }
                else
                {
                    RequestsReceivedList requestReceivedList = new RequestsReceivedList();
                    requestReceivedList.InitializeMenu();
                    requestReceivedList.Show();
                    Close();
                }
                break;

            case "ListViewItemServiceRegistration":
                if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.ONE))
                {
                    AccountActivate accountActivate = new AccountActivate();
                    accountActivate.InitializeMenu();
                    accountActivate.Show();
                    Close();
                }
                else
                {
                    ServiceRegistry serviceRegistry = new ServiceRegistry();
                    serviceRegistry.InitializeMenu();
                    serviceRegistry.Show();
                    Close();
                }
                break;

            case "ListViewItemCommentTracing":
                if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.ONE))
                {
                    CommentClient commentClient = new CommentClient();
                    commentClient.InitializeMenu();
                    commentClient.Show();
                    Close();
                }
                else
                {
                    ReportGeneration reportGeneration = new ReportGeneration();
                    reportGeneration.InitializeMenu();
                    reportGeneration.Show();
                    Close();
                }
                break;

            default:
                break;
            }
        }