コード例 #1
0
        [HttpPost]//CREAR HORARIO ACADEMICO
        public JsonResult CrearFileHorarioAcademico(string idTypeFile, string strHorario)
        {
            try
            {
                string   reportPath       = string.Empty;
                string   strNombreReporte = string.Empty;
                string[] strCadenas       = idTypeFile.Split('|');

                if (strHorario.Equals("Clase"))
                {
                    reportPath       = Path.Combine(Server.MapPath("~/Reports"), "rptHorarioClaseDocente.rdlc");
                    strNombreReporte = Language.es_ES.EST_TB_HORARIO_ACADEMICO;
                }
                else
                {
                    reportPath       = Path.Combine(Server.MapPath("~/Reports"), "rptHorarioExamenDocente.rdlc");
                    strNombreReporte = Language.es_ES.EST_TB_HORARIO_EXAMENES;
                }
                if (strCadenas.Length > 1)
                {
                    strHorario = strHorario + "|" + strCadenas[1] + "|" + strCadenas[2] + "|" + strCadenas[3];
                }
                HorarioDocenteModel objHorarioDocente      = new Models.HorarioDocenteModel(strHorario);
                LocalReport         rptHorarioClaseDocente = objHorarioDocente.getReporteHorarios(reportPath);
                string mimeType;
                string encoding;
                string fileNameExtension;
                string deviceInfo = "<DeviceInfo>" +
                                    "   <OutputFormat>" + strCadenas[0] + "</OutputFormat>" +
                                    "</DeviceInfo>";
                Warning[] warnings;
                string[]  streams;
                byte[]    renderedBytes;
                renderedBytes = rptHorarioClaseDocente.Render(strCadenas[0],
                                                              deviceInfo,
                                                              out mimeType,
                                                              out encoding,
                                                              out fileNameExtension,
                                                              out streams,
                                                              out warnings);
                //  Creo el nombre del archivo
                string nameFile = strNombreReporte.Replace(" ", "_") + "_" + objHorarioDocente.UsuarioActual.CarreraActual.Nombre.ToString() + ((strCadenas[0] == "PDF") ? ".pdf" : ".xls");
                //  Direcciono la creacion del archivo a una ubicacion temporal
                string fullPath = Path.Combine(Server.MapPath("~/Temp"), nameFile);
                //  Creo el archivo en la ubicacion temporal
                System.IO.File.WriteAllBytes(fullPath, renderedBytes);
                return(Json(new { fileName = nameFile, errorMessage = "" }));
            }
            catch (Exception ex)
            {
                Errores err = new Errores();
                err.SetError(ex, "createFile");
                return(Json(new { fileName = "none", errorMessage = "Problema al momento de crear el archivo" }));
            }
        }
コード例 #2
0
        public ActionResult HorarioExamenDocente(string strCursoParalelo = "")
        {
            HorarioDocenteModel objHorario = new Models.HorarioDocenteModel();

            return(View("HorarioExamenDocente", objHorario));
        }