예제 #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/" + Request.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);
                        RequestsReceivedList requestReceivedList = new RequestsReceivedList();
                        requestReceivedList.InitializeMenu();
                        requestReceivedList.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);
                    RequestsReceivedList requestReceivedList = new RequestsReceivedList();
                    requestReceivedList.InitializeMenu();
                    requestReceivedList.Show();
                    Close();
                }
            }
        }
예제 #2
0
        private void ListViewMenuSelectionChanged(object sender, SelectionChangedEventArgs selectionChangedEventArgs)
        {
            switch (((ListViewItem)((ListView)sender).SelectedItem).Name)
            {
            case "ListViewItemHome":
                HomeEmployee home = new HomeEmployee();
                home.InitializeMenu();
                home.Show();
                Close();
                break;

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

            case "ListViewItemBehind":
                ServiceOffered serviceOffered = new ServiceOffered();
                serviceOffered.InitializeMenu();
                serviceOffered.Show();
                Close();
                break;

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

            case "ListViewItemRequest":
                RequestsReceivedList requestReceivedList = new RequestsReceivedList();
                requestReceivedList.InitializeMenu();
                requestReceivedList.Show();
                Close();
                break;

            case "ListViewItemServiceRegistration":
                ServiceRegistry serviceRegistry = new ServiceRegistry();
                serviceRegistry.InitializeMenu();
                serviceRegistry.Show();
                Close();
                break;

            case "ListViewItemCommentTracing":
                ReportGeneration reportGeneration = new ReportGeneration();
                reportGeneration.InitializeMenu();
                reportGeneration.Show();
                Close();
                break;

            default:
                break;
            }
        }
예제 #3
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;
            }
        }