Пример #1
0
        public HttpResponseMessage obtainTicket(int Department_id, string Ticketcol)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);



                using (DenounceService service = new DenounceService())
                {
                    var tike = service.obtainticket(Department_id, Ticketcol);
                    data.result = new { tike };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "tikete");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #2
0
        public HttpResponseMessage Eliminar(string usuario_Id)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (UsuarioService service = new UsuarioService())
                {
                    service.Eliminar(usuario_Id);
                    data.result  = null;
                    data.status  = true;
                    data.message = "El usuario seleccionado se eliminó correctamente";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Eliminar usuario");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #3
0
        public HttpResponseMessage SaveDenounce([FromBody] Department Department)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (DepartmentService service = new DepartmentService())
                {
                    service.saveDepartment(Department);
                    data.result  = null;
                    data.status  = true;
                    data.message = Department.department_Id == -1 ? "Se creó el departamento" : "Se actualizó el departamento";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Hubo un error");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #4
0
        public HttpResponseMessage PostFile(News Noticia)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (NewService service = new NewService())
                {
                    service.NewInsert(Noticia.new_id, Noticia.descripcion, Noticia.fileToUpload, Noticia.titulo, Noticia.expired, Noticia.Active);
                    data.result  = null;
                    data.status  = true;
                    data.message = Noticia.new_id == 0 ? "Se creo la noticia":"Se actualizó corretamenta la noticia";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "hubo un error");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #5
0
        public HttpResponseMessage CardData()
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);



                using (NewService service = new NewService())
                {
                    service.CardData(config.usuario.usuario_Id);
                    data.result = new { service.outstandingcomplaints, service.outstandingdenounces, service.attendedcomplaints, service.attendeddenounces };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Card data");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #6
0
        public HttpResponseMessage ObtenerNoticias()
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);



                using (NewService service = new NewService())
                {
                    var Noticias = service.TodasLasNoticias();
                    data.result = new { Noticias };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Lista de Noticias");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #7
0
        public HttpResponseMessage SaveDenounce(Denounce Denuncia)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (DenounceService service = new DenounceService())
                {
                    service.saveDenounce(Denuncia.Denounces_id, Denuncia.Description, Denuncia.state, Denuncia.person_Id, Denuncia.User_id, Denuncia.Department_Id, Denuncia.Photo, Denuncia.Latitud.ToString(), Denuncia.Longitud.ToString());
                    data.result  = null;
                    data.status  = true;
                    data.message = Denuncia.Denounces_id == 0 ? "Se creó la Denuncia": "Se actualizó la Denuncia";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "hubo un error");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #8
0
        public HttpResponseMessage Guardar([FromBody] Usuario usuario, bool nuevo)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (UsuarioService service = new UsuarioService())
                {
                    service.Guardar(usuario, nuevo);
                    data.result  = null;
                    data.status  = true;
                    data.message = nuevo ? "Se registró correctamente el usuario" : "Se actualizó correctamente el usuario";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Guardar usuario");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #9
0
        public HttpResponseMessage DeleletComplain(int Complain_id)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (ComplainService service = new ComplainService())
                {
                    service.DeleteComplain(Complain_id);
                    data.result  = null;
                    data.status  = true;
                    data.message = "Se ha eliminado la queja";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Eliminar queja");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #10
0
        public HttpResponseMessage addDepartment([FromBody] Departamento department)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (DepartmentService service = new DepartmentService())
                {
                    service.addDepartement(department);
                    data.result  = null;
                    data.status  = true;
                    data.message = "Departamento creado";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Registro de Departamentos");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #11
0
        public HttpResponseMessage ListComplainsbyId(int Id_User)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);



                using (ComplainService service = new ComplainService())
                {
                    var complains = service.ListComplainsbyId(Id_User);
                    data.result = new { complains };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Lista de Quejas");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #12
0
        public HttpResponseMessage UpdateComplain([FromBody] Complain complain)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (ComplainService service = new ComplainService())
                {
                    service.UpdateComplain(complain.Complain_Id, complain.Description, complain.employee, complain.employee_name, complain.department_id, complain.fecha);
                    data.result  = null;
                    data.status  = true;
                    data.message = "Su queja se actualió correctament";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Error actualizando la queja");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #13
0
        public HttpResponseMessage ListaFuncionarios(string depSeleccion)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);



                using (ComplainService service = new ComplainService())
                {
                    var funcionarios = service.TodosFuncionarios(depSeleccion);
                    data.result = new { funcionarios };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Lista de Funcionarios");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #14
0
        public HttpResponseMessage PostFile(Complain queja)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (ComplainService service = new ComplainService())
                {
                    service.GuardarQueja(queja.Description, queja.state, queja.person_Id, queja.User_id, queja.employee_name, queja.employee, queja.department_id, queja.fecha);
                    data.result  = null;
                    data.status  = true;
                    data.message = "Su queja ha sido enviada correctamente";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Error en la creación de la queja");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #15
0
        public HttpResponseMessage UpdateDenouncebyAdmin([FromBody] Denounce Denuncia, string act)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (DenounceService service = new DenounceService())
                {
                    service.UpdateDenouncebyAdmin(Denuncia.Denounces_id, Denuncia.state, Denuncia.Department_Id, Denuncia.Answer, act);
                    data.result  = null;
                    data.status  = true;
                    data.message = act == "R" ? "Se direccionó la denuncia Correctamente" : "Se le ha dado una respuesta a la denuncia correctamente";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "hubo un error");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #16
0
        public HttpResponseMessage Lista()
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (UsuarioService service = new UsuarioService())
                {
                    var usuarios = service.Lista();
                    data.result = new { usuarios, service.cantidad };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Lista de usuarios");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #17
0
        public HttpResponseMessage UpdateComplainbyAdmin(Complain complain)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (ComplainService service = new ComplainService())
                {
                    service.UpdateComplainbyAdmin(complain.Complain_Id, complain.state, complain.Answer);
                    data.result  = null;
                    data.status  = true;
                    data.message = "Se actualizo la queja";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "hubo un error");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #18
0
        public HttpResponseMessage ChangePassword([FromBody] Usuario usuario, string newPassword)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (UsuarioService service = new UsuarioService())
                {
                    service.ChangePassword(usuario.usuario_Id, usuario.password, newPassword);
                    data.result  = null;
                    data.status  = true;
                    data.message = "El cambio de contraseña se completó correctamente";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Cambio de contraseña");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #19
0
        public HttpResponseMessage Guardar([FromBody] Usuario usuario)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                using (UsuarioService service = new UsuarioService())
                {
                    service.Registrarse(usuario);
                    data.result  = null;
                    data.status  = true;
                    data.message = "Registro exitoso";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Registro");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #20
0
        public HttpResponseMessage PersonbyId(int Person_Id)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                using (UsuarioService service = new UsuarioService())
                {
                    var Persona = service.PersonbyId(Person_Id);
                    data.result = new { Persona };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Persona Encontrada");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #21
0
        public DocScanSandboxClientTests()
        {
            _yotiDocScanSandboxClient = SandboxClient.Builder()
                                        .WithApiUri(_someUri)
                                        .WithClientSdkId(_someSdkId)
                                        .WithKeyPair(KeyPair.Get())
                                        .Build();

            _sandboxResponseConfig = new ResponseConfigBuilder().Build();
        }
Пример #22
0
        private static ResponseConfig ParseResponse(JSON json)
        {
            ResponseConfig config = new ResponseConfig(
                json.ToUInt(ID_CRC),
                json.ToString(ID),
                json.ToString(NAME),
                json.ToFloat(TIME),
                json.ToInt(POINTS)
                );

            return(config);
        }
Пример #23
0
    // Solve an incident with a kid
    // If he has vegetable to eat, he starts to eat again
    public bool SolveIncident(uint responseId)
    {
        bool           result   = false;
        ResponseConfig response = GameManager.instance.responseIdToConfig[responseId];

        Debug.Log("Solve incident with: " + response.name);

        if (m_currentIncident != null)
        {
            UnityEngine.Assertions.Assert.IsTrue(response.incidentIdToResult.ContainsKey(m_currentIncident.id), "Can't find result for response " + response.name + " and " + m_currentIncident.name);

            result = response.incidentIdToResult[m_currentIncident.id];

            if (result == false)
            {
                Debug.Log("Wrong response to incident: " + response.name);

                Debug.Log("malus " + response.time);
                // If Malus is more or equal to timeToIncident, we start a new incident
                if (m_currentVegetable.timeToIncident - response.time <= 0)
                {
                    StartIncident();
                    _playerManager.UpdateScore(response.points, false);
                    return(false);
                }
                else
                {
                    timeToIncidentModifier = -response.time;
                }
            }
            else
            {
                Debug.Log("bonus " + response.time);
                timeToIncidentModifier = response.time;
            }

            _childCanvas.DisableFeedback();
            _playerManager.UpdateScore(response.points, result);
        }

        m_currentIncident = null;

        if (m_currentVegetable != null)
        {
            m_isEating                = true;
            m_elapsedTime             = 0f;
            m_Slider_Foreground.color = _playerManager.playerColor;
            _childCanvas.EnableSlider(true);
            _childCanvas.EnableFeedback("Food/food_" + m_currentVegetable.name.ToLower(), true, true);
        }

        return(result);
    }
Пример #24
0
        private static void CalculateResponseToIncident(List <JSON> jsons, ResponseConfig response)
        {
            int count = jsons.Count;

            for (int i = 0; i < count; ++i)
            {
                if (response.id == jsons[i].ToUInt(CALC_RESPONSE_REF))
                {
                    response.incidentIdToResult.Add(jsons[i].ToUInt(CALC_INCIDENT_REF), jsons[i].ToBoolean(CALC_RESULT));
                }
            }
        }
Пример #25
0
        private async Task HandleEchoRequest(DefaultCommandInput <ICoreParseResult> commandInput,
                                             IConsoleManager consoleManager,
                                             HttpState programState,
                                             HttpResponseMessage response,
                                             CancellationToken cancellationToken)
        {
            RequestConfig  requestConfig  = new RequestConfig(_preferences);
            ResponseConfig responseConfig = new ResponseConfig(_preferences);

            string hostString = response.RequestMessage.RequestUri.Scheme + "://" + response.RequestMessage.RequestUri.Host + (!response.RequestMessage.RequestUri.IsDefaultPort ? ":" + response.RequestMessage.RequestUri.Port : "");

            consoleManager.WriteLine($"Request to {hostString}...".SetColor(requestConfig.AddressColor));
            consoleManager.WriteLine();

            string method       = response.RequestMessage.Method.ToString().ToUpperInvariant().SetColor(requestConfig.MethodColor);
            string pathAndQuery = response.RequestMessage.RequestUri.PathAndQuery.SetColor(requestConfig.AddressColor);
            string protocolInfo = $"{"HTTP".SetColor(requestConfig.ProtocolNameColor)}{"/".SetColor(requestConfig.ProtocolSeparatorColor)}{response.Version.ToString().SetColor(requestConfig.ProtocolVersionColor)}";

            consoleManager.WriteLine($"{method} {pathAndQuery} {protocolInfo}");
            IEnumerable <KeyValuePair <string, IEnumerable <string> > > requestHeaders = response.RequestMessage.Headers;

            if (response.RequestMessage.Content != null)
            {
                requestHeaders = requestHeaders.Union(response.RequestMessage.Content.Headers);
            }

            foreach (KeyValuePair <string, IEnumerable <string> > header in requestHeaders.OrderBy(x => x.Key))
            {
                string headerKey   = header.Key.SetColor(requestConfig.HeaderKeyColor);
                string headerSep   = ":".SetColor(requestConfig.HeaderSeparatorColor);
                string headerValue = string.Join(";".SetColor(requestConfig.HeaderValueSeparatorColor), header.Value.Select(x => x.Trim().SetColor(requestConfig.HeaderValueColor)));
                consoleManager.WriteLine($"{headerKey}{headerSep} {headerValue}");
            }

            consoleManager.WriteLine();

            List <string> responseOutput = new List <string>();

            if (response.RequestMessage.Content != null)
            {
                await FormatBodyAsync(commandInput, programState, consoleManager, response.RequestMessage.Content, responseOutput, _preferences, cancellationToken).ConfigureAwait(false);
            }

            consoleManager.WriteLine();
            consoleManager.WriteLine($"Response from {hostString}...".SetColor(requestConfig.AddressColor));
            consoleManager.WriteLine();

            foreach (string responseLine in responseOutput)
            {
                consoleManager.WriteLine(responseLine);
            }
        }
Пример #26
0
        public HttpResponseMessage complaintsFilter(string desde, string hasta, string state, string department)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                if (desde == "_ALL_")
                {
                    desde = "";
                }

                if (hasta == "_ALL_")
                {
                    hasta = "";
                }

                if (state == "_ALL_")
                {
                    state = "";
                }

                if (department == "_ALL_")
                {
                    department = "";
                }


                using (ComplainService service = new ComplainService())
                {
                    var complaints = service.complaintsFilter(desde, hasta, state, department, config.usuario.usuario_Id);
                    data.result = new { complaints };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Lista de quejas");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #27
0
        public HttpResponseMessage AllComplains(string state, string from, string to)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                if (from == "_ALL_")
                {
                    from = "";
                }

                if (to == "_ALL_")
                {
                    to = "";
                }


                if (state == "-1")
                {
                    state = "";
                }


                using (ComplainService service = new ComplainService())
                {
                    var complains = service.AllComplains(state, to, from);
                    data.result = new { complains, service.attendedcomplaints, service.newcomplaints, service.complaintsinprocess };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Lista de Quejas");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #28
0
        public HttpResponseMessage ListDenouncesbyDepartment(int Department_id, string state, string from, string to)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);

                if (from == "_ALL_")
                {
                    from = "";
                }

                if (to == "_ALL_")
                {
                    to = "";
                }


                if (state == "-1")
                {
                    state = "";
                }

                using (DenounceService service = new DenounceService())
                {
                    var Denounces = service.ListDenouncesbyDepartment(Department_id, state, from, to);
                    data.result = new { Denounces, service.newdenounces, service.denouncesinprocess, service.attendeddenounces };
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Lista de Denuncias por Departamento");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #29
0
        public HttpResponseMessage ListDenouncesbyId(int Id_User, string desde, string hasta, string state, string deparment)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            ResponseConfig      config   = VerifyAuthorization(Request.Headers);
            RestResponse        data     = new RestResponse();

            try
            {
                VerifyMessage(config.errorMessage);
                if (desde == "_ALL_")
                {
                    desde = "";
                }
                if (hasta == "_ALL_")
                {
                    hasta = "";
                }
                if (state == "-1")
                {
                    state = "";
                }
                if (deparment == "-1")
                {
                    deparment = "";
                }
                using (DenounceService service = new DenounceService())
                {
                    data.result = service.ListDenouncesbyId(Id_User.ToString(), desde, hasta, state, deparment);
                    data.status = true;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized;
                data.status         = false;
                data.message        = ex.Message;
                data.error          = NewError(ex, "Lista de Quejas");
            }
            finally
            {
                response.Content = CreateContent(data);
            }

            return(response);
        }
Пример #30
0
        public static Dictionary <uint, ResponseConfig> ParseResponses(JSON json)
        {
            Dictionary <uint, ResponseConfig> responses = new Dictionary <uint, ResponseConfig>();
            List <JSON> responseConfigJSONs             = json.ToJSONList(ROOT_DEFINE);
            List <JSON> responseCalcJSONs = json.ToJSONList(ROOT_CALC);
            int         responseCount     = responseConfigJSONs.Count;

            for (int i = 0; i < responseCount; ++i)
            {
                ResponseConfig response = ParseResponse(responseConfigJSONs[i]);

                CalculateResponseToIncident(responseCalcJSONs, response);

                responses.Add(response.id, response);
            }

            return(responses);
        }