Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString.Count > 0)
            {
                string json                       = "";
                JavaScriptSerializer js           = new JavaScriptSerializer();
                ReporteBE            objInteresBE = new ReporteBE();

                string urlReporte = ConfigurationSettings.AppSettings["URL_REPORTE"].ToString();
                lblMensaje.Visible = false;

                try
                {
                    string id         = Request.QueryString["id"].ToString();
                    string token      = Request.QueryString["token"].ToString();
                    string urljson    = ConfigurationManager.AppSettings["URL_JSON"].ToString();
                    string url        = urljson + id + "?token=" + token;
                    var    syncClient = new WebClient();
                    json = syncClient.DownloadString(url);
                }
                catch (Exception ex)
                {
                    redirect("Interes.aspx", "Error al descargar los datos del id ó token");
                    //throw;
                }

                if (json.Length > 20)
                {
                    wsInteres.wsInteres objInteres = new wsInteres.wsInteres();

                    string nombrePDF = "";
                    try
                    {
                        objInteresBE = js.Deserialize <ReporteBE>(json);
                        nombrePDF    = objInteres.CalcularReporteIntereses(objInteresBE);
                        string filePath = urlReporte + nombrePDF;

                        WebClient User       = new WebClient();
                        Byte[]    FileBuffer = User.DownloadData(filePath);
                        if (FileBuffer != null)
                        {
                            Response.ContentType = "application/pdf";
                            Response.AddHeader("content-length", FileBuffer.Length.ToString());
                            Response.BinaryWrite(FileBuffer);
                        }
                    }
                    catch (Exception ex)
                    {
                        redirect("Interes.aspx", "Ocurrio un error al obtener el Id y Token.");
                        //throw;
                    }
                }
            }
        }
    }
Пример #2
0
    public void ReporteUsoUsuarioEmpresa(int IdEmpresa)
    {
        VisitaBL  bl      = new VisitaBL();
        ReporteBE reporte = new ReporteBE();

        reporte = bl.ReporteUsoUsuarioEmpresa(connstring, IdEmpresa);

        // Return JSON data
        JavaScriptSerializer js = new JavaScriptSerializer();
        string strJSON          = js.Serialize(reporte);

        Context.Response.Clear();
        Context.Response.ContentType = "application/json";
        Context.Response.Flush();
        Context.Response.Write(strJSON);
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString.Count > 0)
            {
                string id = "";
                string jsonTemperamentos = "";
                string jsonInteres       = "";
                JavaScriptSerializer  js = new JavaScriptSerializer();
                ReporteTemperamentoBE objTemperamentoBE = new ReporteTemperamentoBE();
                ReporteBE             objInteresBE      = new ReporteBE();
                string urlReporte = ConfigurationSettings.AppSettings["URL_REPORTE"].ToString();
                lblMensaje.Visible = false;

                try
                {
                    id = Request.QueryString["id"].ToString();
                    string token           = Request.QueryString["token"].ToString();
                    string url_jsonInteres = ConfigurationManager.AppSettings["URL_JSON"].ToString();
                    string url             = url_jsonInteres + id + "?token=" + token;

                    var syncClient = new WebClient();
                    jsonInteres = syncClient.DownloadString(url);
                }
                catch (Exception ex)
                {
                    redirect("Consolidado.aspx", "Error al descargar los datos del id ó token");
                }

                if (jsonInteres.Length > 20)
                {
                    wsConsolidatedReport.wsConsolidatedReport objReport = new wsConsolidatedReport.wsConsolidatedReport();
                    string nombrePDF = "";
                    try
                    {
                        objInteresBE = js.Deserialize <ReporteBE>(jsonInteres);


                        string url_jsonTemperamentos = ConfigurationManager.AppSettings["URL_JSON_TEMPERAMENTOS"].ToString();
                        string urltemp     = url_jsonTemperamentos + objInteresBE.report.encuesta.id + "?token=" + objInteresBE.report.encuesta.token;
                        var    syncClient2 = new WebClient();
                        jsonTemperamentos = syncClient2.DownloadString(urltemp);

                        objTemperamentoBE = js.Deserialize <ReporteTemperamentoBE>(jsonTemperamentos);


                        nombrePDF = objReport.GenerarReporte(id, objTemperamentoBE, objInteresBE);
                        string filePath = urlReporte + nombrePDF;

                        WebClient User       = new WebClient();
                        Byte[]    FileBuffer = User.DownloadData(filePath);
                        if (FileBuffer != null)
                        {
                            Response.ContentType = "application/pdf";
                            Response.AddHeader("content-length", FileBuffer.Length.ToString());
                            Response.BinaryWrite(FileBuffer);
                        }
                    }
                    catch (Exception ex)
                    {
                        redirect("Consolidado.aspx", "Ocurrio un error al obtener el Id y Token.");
                    }
                }
            }
        }
    }
Пример #4
0
        public ReporteBE ReporteUsoUsuarioEmpresa(string connstring, int IdEmpresa)
        {
            try
            {
                ReporteBE reporte = new ReporteBE();
                reporte.text = ".";


                DBHelper _oDBHelper = new DBHelper(connstring, Providers.SqlServer);
                reporte.children = VisitaDA.Instanse.ReporteUsoUsuGetUsuarios(_oDBHelper, IdEmpresa);
                foreach (ReporteChildBE childUsuario in reporte.children)
                {
                    childUsuario.leaf = false;
                    childUsuario.task = childUsuario.NombreUsuario;

                    _oDBHelper            = new DBHelper(connstring, Providers.SqlServer);
                    childUsuario.children = VisitaDA.Instanse.ReporteUsoUsuGetAnho(_oDBHelper, childUsuario);
                    foreach (ReporteChildBE childAnho in childUsuario.children)
                    {
                        childAnho.leaf = false;
                        childAnho.task = childAnho.anho.ToString();

                        _oDBHelper         = new DBHelper(connstring, Providers.SqlServer);
                        childAnho.children = VisitaDA.Instanse.ReporteUsoUsuGetSemestre(_oDBHelper, childAnho);
                        foreach (ReporteChildBE childSemestre in childAnho.children)
                        {
                            childSemestre.leaf = false;
                            childSemestre.task = "Semestre " + childSemestre.semestre;

                            _oDBHelper             = new DBHelper(connstring, Providers.SqlServer);
                            childSemestre.children = VisitaDA.Instanse.ReporteUsoUsuGetTrimestre(_oDBHelper, childSemestre);
                            foreach (ReporteChildBE childTrimestre in childSemestre.children)
                            {
                                childTrimestre.leaf = false;
                                childTrimestre.task = "Trimestre " + childTrimestre.trimestre;

                                _oDBHelper = new DBHelper(connstring, Providers.SqlServer);
                                childTrimestre.children = VisitaDA.Instanse.ReporteUsoUsuGetMes(_oDBHelper, childTrimestre);
                                foreach (ReporteChildBE childMes in childTrimestre.children)
                                {
                                    childMes.leaf = false;
                                    childMes.task = new DateTime(childMes.anho, childMes.mes, 01).ToString("MMMM");

                                    _oDBHelper        = new DBHelper(connstring, Providers.SqlServer);
                                    childMes.children = VisitaDA.Instanse.ReporteUsoUsuGetDia(_oDBHelper, childMes);

                                    foreach (ReporteChildBE childDia in childMes.children)
                                    {
                                        childDia.leaf = true;
                                        childDia.task = new DateTime(childDia.anho, childDia.mes, childDia.dia).ToString("dd dddd");
                                    }
                                }
                            }
                        }
                    }
                }

                return(reporte);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }