Exemplo n.º 1
0
        private void CancelButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            ServiceOffered serviceOffered = new ServiceOffered();

            serviceOffered.InitializeMenu();
            serviceOffered.Show();
            Close();
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 3
0
        private void UpdateService()
        {
            RestClient client = new RestClient(urlBase);

            client.Timeout = -1;
            string urlService = "services/" + Service.idService;
            var    request    = new RestRequest(urlService, Method.PUT);

            foreach (RestResponseCookie cookie in Login.cookies)
            {
                request.AddCookie(cookie.Name, cookie.Value);
            }
            var json = JsonConvert.SerializeObject(Service);

            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)
                {
                    Service         = JsonConvert.DeserializeObject <Models.Service>(response.Content);
                    isUpdateService = true;
                }
                else
                {
                    Models.Error responseError = JsonConvert.DeserializeObject <Models.Error>(response.Content);
                    if (response.StatusCode == System.Net.HttpStatusCode.Forbidden || response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
                        response.StatusCode == System.Net.HttpStatusCode.RequestTimeout)
                    {
                        BehindLogin(responseError.error);
                    }
                    else
                    {
                        MessageBox.Show(responseError.error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        if (response.StatusCode != System.Net.HttpStatusCode.Conflict && response.StatusCode != System.Net.HttpStatusCode.BadRequest)
                        {
                            ServiceOffered serviceOffered = new ServiceOffered();
                            serviceOffered.InitializeMenu();
                            serviceOffered.Show();
                            Close();
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                TelegramBot.SendToTelegram(exception);
                LogException.Log(this, exception);
                MessageBox.Show("No se pudo modificar el servicio. Intente más tarde", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ServiceOffered serviceOffered = new ServiceOffered();
                serviceOffered.InitializeMenu();
                serviceOffered.Show();
                Close();
            }
        }
Exemplo n.º 4
0
 private void UpdateButtonClicked(object sender, RoutedEventArgs routedEventArgs)
 {
     CreateServiceFromInputData();
     if (ValidateDataService())
     {
         UpdateService();
         if (isUpdateService)
         {
             if (isEditImage)
             {
                 if (Resource.routeSave != null)
                 {
                     DeleteResource();
                     if (isDeleteImage)
                     {
                         CreateResourceFromInputData();
                         RegisterResource();
                         if (isRegisterImage)
                         {
                             MessageBox.Show("El servicio se modificó exitosamente", "Modificación exitosa", MessageBoxButton.OK, MessageBoxImage.Information);
                             ServiceOffered serviceOffered = new ServiceOffered();
                             serviceOffered.InitializeMenu();
                             serviceOffered.Show();
                             Close();
                         }
                     }
                 }
                 else
                 {
                     CreateResourceFromInputData();
                     RegisterResource();
                     if (isRegisterImage)
                     {
                         MessageBox.Show("El servicio se modificó exitosamente", "Modificación exitosa", MessageBoxButton.OK, MessageBoxImage.Information);
                         ServiceOffered serviceOffered = new ServiceOffered();
                         serviceOffered.InitializeMenu();
                         serviceOffered.Show();
                         Close();
                     }
                 }
             }
             else
             {
                 MessageBox.Show("El servicio se modificó exitosamente", "Modificación exitosa", MessageBoxButton.OK, MessageBoxImage.Information);
                 ServiceOffered serviceOffered = new ServiceOffered();
                 serviceOffered.InitializeMenu();
                 serviceOffered.Show();
                 Close();
             }
         }
     }
     else
     {
         MessageBox.Show("Por favor, Ingrese datos correctos en los campos marcados en rojo", "Datos invalidos", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Exemplo n.º 5
0
        private void RegisterResource()
        {
            RestClient client = new RestClient(urlBase);

            client.Timeout = -1;
            var request = new RestRequest("resources", Method.POST);

            request.AddParameter("isMainResource", editResource.isMainResource);
            request.AddParameter("name", editResource.name);
            request.AddParameter("idService", editResource.idService);
            request.AddParameter("idMemberATE", editResource.idMemberATE);
            request.AddFile("resourceFile", routeImage);
            request.AddHeader("Token", Login.tokenAccount.token);
            request.AddHeader("Content-Type", "multipart/form-data");
            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)
                {
                    var responseOk = JsonConvert.DeserializeObject <dynamic>(response.Content);
                    isRegisterImage = true;
                }
                else
                {
                    Models.Error responseError = JsonConvert.DeserializeObject <Models.Error>(response.Content);
                    if (response.StatusCode == System.Net.HttpStatusCode.Forbidden || response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
                        response.StatusCode == System.Net.HttpStatusCode.RequestTimeout)
                    {
                        BehindLogin(responseError.error);
                    }
                    else
                    {
                        MessageBox.Show("El servicio se modificó. Pero " + responseError.error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        if (response.StatusCode != System.Net.HttpStatusCode.Conflict && response.StatusCode != System.Net.HttpStatusCode.BadRequest)
                        {
                            ServiceOffered serviceOffered = new ServiceOffered();
                            serviceOffered.InitializeMenu();
                            serviceOffered.Show();
                            Close();
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                TelegramBot.SendToTelegram(exception);
                LogException.Log(this, exception);
                MessageBox.Show("El servicio se modificó. Pero  no se pudo registrar el recurso.Intente más tarde", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ServiceOffered serviceOffered = new ServiceOffered();
                serviceOffered.InitializeMenu();
                serviceOffered.Show();
                Close();
            }
        }
Exemplo n.º 6
0
        private void DeleteResource()
        {
            RestClient client = new RestClient(urlBase);

            client.Timeout = -1;
            string urlResource = "resources/" + Resource.routeSave;
            var    request     = new RestRequest(urlResource, Method.DELETE);

            foreach (RestResponseCookie cookie in Login.cookies)
            {
                request.AddCookie(cookie.Name, cookie.Value);
            }
            request.AddHeader("Token", Login.tokenAccount.token);
            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)
                {
                    var responseOk = JsonConvert.DeserializeObject <dynamic>(response.Content);
                    isDeleteImage = true;
                }
                else
                {
                    Models.Error responseError = JsonConvert.DeserializeObject <Models.Error>(response.Content);
                    if (response.StatusCode == System.Net.HttpStatusCode.Forbidden || response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
                        response.StatusCode == System.Net.HttpStatusCode.RequestTimeout)
                    {
                        BehindLogin(responseError.error);
                    }
                    else
                    {
                        MessageBox.Show("El servicio se modificó. Pero " + responseError.error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        if (response.StatusCode != System.Net.HttpStatusCode.Conflict && response.StatusCode != System.Net.HttpStatusCode.BadRequest)
                        {
                            ServiceOffered serviceOffered = new ServiceOffered();
                            serviceOffered.InitializeMenu();
                            serviceOffered.Show();
                            Close();
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                TelegramBot.SendToTelegram(exception);
                LogException.Log(this, exception);
                MessageBox.Show("El servicio se modificó. Pero  no se pudo registrar el recurso.Intente más tarde", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ServiceOffered serviceOffered = new ServiceOffered();
                serviceOffered.InitializeMenu();
                serviceOffered.Show();
                Close();
            }
        }
Exemplo n.º 7
0
        private void ServiceItemsControlMouseDoubleClicked(object listViewService, MouseButtonEventArgs mouseButtonEventArgs)
        {
            int itemSelect = ((ListView)listViewService).SelectedIndex;

            if (itemSelect >= Number.NumberValue(NumberValues.ZERO) && itemSelect < services.Count)
            {
                Models.Service serviceSelect = services[itemSelect];
                if (!object.ReferenceEquals(null, serviceSelect))
                {
                    ServiceOffered serviceOffered = new ServiceOffered();
                    ServiceOffered.Service = serviceSelect;
                    serviceOffered.InitializeMenu();
                    serviceOffered.Show();
                    Close();
                }
            }
        }