public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            report.output_error = null;

            var  ignored = base.OnCreateView(inflater, container, savedInstanceState);
            View self    = inflater.Inflate(Resource.Layout.CommonReportOutput, null);

            if (!report.getFillCommonInfo(self, true, false, ref report.output_error))
            {
                reportErrorGoBack(report.output_error);
                return(self);
            }

            TableLayout table = self.FindViewById <TableLayout>(Resource.Id.tbReporte);

            // Asegura que ningun parametro este vacío
            if (String.IsNullOrEmpty(report.input_oficina))
            {
                reportErrorGoBack("El campo de oficina no puede ser vacío");
                return(self);
            }

            // Consulta
            // Cambiar las fechas al formato admitido por la BD
            string fecha_jornada = report.input_fecha_jornada.ToString("yyyyMMdd");

            string codigoNotificador = "";

            try
            {
                Helpers.SQLiteConeccion dbConeccion;
                dbConeccion = new Helpers.SQLiteConeccion();
                dbConeccion.consultaDatos(
                    "SELECT CodigoNotificador FROM OficialesNotificadores WHERE NombreCompleto = '" + report.input_notificador + "'",
                    this.Context, ref codigoNotificador);
            }
            catch (Exception)
            {
                reportErrorGoBack("No fue posible obtener la información requerida para le reporte (ID)");
                return(self);
            }

            string query = @"https://pjgestionnotificacionmovilservicios.azurewebsites.net/api/Reportes/NotificacionesPendientesJornada" +
                           "?PCodOficina=" + report.input_oficina +
                           "&PCodNotificador=" + codigoNotificador +
                           "&PFechaJornada=" + fecha_jornada;

            // Verificar si la conección a internet esta disponible
            if (!coneccionInternet.verificaConeccion(this.Context))
            {
                ReportUtils.alertNoInternetMessage(this.Context);
            }

            WebRequest request = HttpWebRequest.Create(query);

            request.ContentType = "application/json";
            request.Method      = "GET";
            string content = "";

            Console.Out.WriteLine("--XDEBUG " + query);
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    Console.Out.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode);
                    reportErrorGoBack("No fue posible obtener la información requerida para le reporte");
                    return(self);
                }

                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    content = reader.ReadToEnd();

                    if (string.IsNullOrWhiteSpace(content))
                    {
                        Console.Out.WriteLine("fzeledon -- Response contained empty body...");
                        reportErrorGoBack("Los valores de entrada de la consulta no generaron resultado");
                        return(self);
                    }

                    try
                    {
                        var jsonParsed = JArray.Parse(content);
                        if (jsonParsed.Count <= 0) // Esperamos al menos un resultado
                        {
                            reportErrorGoBack("La información obtenida para le informe no puede ser procesada");
                            return(self);
                        }


                        // Por cada despacho encontrada

                        ReportUtils.agregarFilaATabla(new string[] { "Notificando", "Expediente", "Fecha de resolución", "Justificación" }, Activity, table);

                        int i = 0;
                        for (i = 0; i < jsonParsed.Count; ++i)
                        {
                            string   notificando     = jsonParsed[i].Value <string>("Notificando");
                            string   expediente      = jsonParsed[i].Value <string>("Expediente");
                            string   resolicion      = jsonParsed[i].Value <string>("FechaResolucion");
                            string   justificacion   = "No disponible"; // FIXME no existia el campo en la consulta
                            DateTime date_resolucion = DateTime.Parse(resolicion);
                            resolicion = date_resolucion.ToString("dd-MMM-yyyy");
                            ReportUtils.agregarFilaATabla(new string[] { notificando, expediente, resolicion, justificacion }, Activity, table);
                            // FIXME. Son demasiadas las respuestas, filtrar por pagina o preguntar como proceder
                            if (i > 200)
                            {
                                break;
                            }
                        }

                        ReportUtils.agregarFilaATabla(new string[] { "Total:", i.ToString(), "", "" }, Activity, table);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error descargando datos de usuario: " + ex.ToString());
                        reportErrorGoBack("Error descargando datos de usuario");
                        return(self);
                    }
                }
            }

            Button btnGen = self.FindViewById <Button>(Resource.Id.btnRegresarNotificacionesEnviadas);

            btnGen.Click += (sender, e) => {
                report.output_error = null;
                Fragment frag = report.getInputReportFragment();
                FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, frag).Commit();
            };

            return(self);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            report.output_error = null;

            var  ignored = base.OnCreateView(inflater, container, savedInstanceState);
            View self    = inflater.Inflate(Resource.Layout.CommonReportOutput, null);

            if (!report.getFillCommonInfo(self, true, false, ref report.output_error))
            {
                reportErrorGoBack(report.output_error);
                return(self);
            }

            TableLayout table = self.FindViewById <TableLayout>(Resource.Id.tbReporte);

            // Asegura que ningun parametro este vacío
            if (String.IsNullOrEmpty(report.input_oficina))
            {
                reportErrorGoBack("El campo de oficina no puede ser vacío");
                return(self);
            }

            // Consulta
            // Cambiar las fechas al formato admitido por la BD
            string fecha_inicio = report.input_fecha_inicio.ToString("yyyyMMdd");
            string fecha_fin    = report.input_fecha_fin.ToString("yyyyMMdd");

            string codigoNotificador = "";

            if (report.loggin_supervisor)
            {
                try
                {
                    Helpers.SQLiteConeccion dbConeccion;
                    dbConeccion = new Helpers.SQLiteConeccion();
                    dbConeccion.consultaDatos(
                        "SELECT CodigoNotificador FROM OficialesNotificadores WHERE NombreCompleto = '" + report.input_notificador + "'",
                        this.Context, ref codigoNotificador);
                }
                catch (Exception)
                {
                    reportErrorGoBack("No fue posible obtener la información requerida para le reporte (ID)");
                    return(self);
                }
            }

            string query = @"https://pjgestionnotificacionmovilservicios.azurewebsites.net/api/Reportes/NotificacionesCompletadasPorNotificador" +
                           "?PCodOficina=" + report.input_oficina +
                           "&PCodNotificador=" + (report.loggin_supervisor ? codigoNotificador : report.loggin_usuario) +
                           "&PFecha1=" + fecha_inicio +
                           "&PFecha2=" + fecha_fin;

            // Verificar si la conección a internet esta disponible
            if (!coneccionInternet.verificaConeccion(this.Context))
            {
                ReportUtils.alertNoInternetMessage(this.Context);
            }

            WebRequest request = HttpWebRequest.Create(query);

            request.ContentType = "application/json";
            request.Method      = "GET";
            string content = "";

            Console.Out.WriteLine("--XDEBUG " + query);
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    Console.Out.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode);
                    reportErrorGoBack("No fue posible obtener la información requerida para le reporte");
                    return(self);
                }

                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    content = reader.ReadToEnd();

                    if (string.IsNullOrWhiteSpace(content))
                    {
                        Console.Out.WriteLine("fzeledon -- Response contained empty body...");
                        reportErrorGoBack("Los valores de entrada de la consulta no generaron resultado");
                        return(self);
                    }

                    try
                    {
                        var jsonParsed = JArray.Parse(content);
                        if (jsonParsed.Count != 2) // Esperamos 2 resultados unicamente
                        {
                            reportErrorGoBack("La información obtenida para le informe no puede ser procesada");
                            return(self);
                        }

                        ReportUtils.agregarFilaATabla(new string[] { "Notificador", report.input_notificador, "" }, Activity, table);
                        ReportUtils.agregarFilaATabla(new string[] { "", "Cantidad", "Porcentaje" }, Activity, table);

                        int total_positivas = 0;
                        int total_negativas = 0;
                        int i = 0;
                        for (i = 0; i < jsonParsed.Count; ++i)
                        {
                            int  total_diligencias = jsonParsed[i].Value <int>("Total");
                            bool diligenciada      = jsonParsed[i].Value <bool>("Diligenciada");

                            if (diligenciada)
                            {
                                total_positivas += total_diligencias;
                            }
                            else
                            {
                                total_negativas += total_diligencias;
                            }
                        }
                        int gran_total = total_positivas + total_negativas;

                        ReportUtils.agregarFilaATabla(new string[] { "Positivas:", total_positivas.ToString(), (100.0 * total_positivas / gran_total).ToString("N3") + "%" }, Activity, table);
                        ReportUtils.agregarFilaATabla(new string[] { "Negativas", total_negativas.ToString(), (100.0 * total_negativas / gran_total).ToString("N3") + "%" }, Activity, table);
                        ReportUtils.agregarFilaATabla(new string[] { "Total:", (gran_total).ToString() }, Activity, table);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error descargando datos de usuario: " + ex.ToString());
                        reportErrorGoBack("Error descargando datos de usuario");
                        return(self);
                    }
                }
            }

            Button btnGen = self.FindViewById <Button>(Resource.Id.btnRegresarNotificacionesEnviadas);

            btnGen.Click += (sender, e) => {
                report.output_error = null;
                Fragment frag = report.getInputReportFragment();
                FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, frag).Commit();
            };

            return(self);
        }