// GET: EnviarCarga
        public ActionResult Index()
        {
            int vPeriodID = int.Parse(Request.Cookies["Periodo"].Value);

            vReportInfo   = LAHelper.setCourses(vReportInfo, vPeriodID);
            vReportInfo   = LAHelper.setProjects(vReportInfo, vPeriodID);
            vReportInfo   = LAHelper.setCommissions(vReportInfo, vPeriodID);
            vAcademicLoad = vReportInfo.todo_profesores.ToArray();

            var Professors = db.Professors.ToList();
            var viewModel  = new ListLoadViewModel();

            viewModel.Items = new List <LoadViewModel>();

            for (int vCont = 0; vCont < Professors.Count(); vCont++)
            {
                Professor vProf = Professors.ElementAt(vCont);
                int       vActiveProfessor = 0;
                bool      vCourses = false, vProjects = false, vComission = false;
                for (int vElement = 0; vElement < vAcademicLoad.Count(); vElement++)
                {
                    if (vAcademicLoad[vElement].Profesor_Nombre == vProf.Name)
                    {
                        vActiveProfessor = 1;
                        if (vAcademicLoad[vElement].Tipo == "Carga docente")
                        {
                            vCourses = true;
                        }
                        if (vAcademicLoad[vElement].Tipo == "Carga Investigación Extensión")
                        {
                            vProjects = true;
                        }
                        if (vAcademicLoad[vElement].Tipo == "Carga Académico Administrativo")
                        {
                            vComission = true;
                        }
                    }
                }
                if (vActiveProfessor == 1)
                {
                    viewModel.Items.Add(
                        new LoadViewModel()
                    {
                        Selected  = true,
                        Name      = vProf.Name,
                        Course    = vCourses,
                        Project   = vProjects,
                        Comission = vComission
                    });
                }
            }
            return(View(viewModel));
        }
        /// <summary>
        /// Sends all academy load from the actual period
        /// </summary>
        /// <author> Cristian Araya Fuentes </author>
        /// <returns></returns>
        public void SendAcademicLoad(ListLoadViewModel pSelectedList)
        {
            var    Professors      = db.Professors.ToList();
            int    vPeriod         = int.Parse(Request.Cookies["Periodo"].Value);
            String vMessageSubject = "Carga Académica";

            vReportInfo   = LAHelper.setCourses(vReportInfo, vPeriod);
            vReportInfo   = LAHelper.setProjects(vReportInfo, vPeriod);
            vReportInfo   = LAHelper.setCommissions(vReportInfo, vPeriod);
            vAcademicLoad = vReportInfo.todo_profesores.ToArray();
            for (int vCont = 0; vCont < Professors.Count(); vCont++)
            {
                Professor vProf        = Professors.ElementAt(vCont);
                String    vMessageBody = "<html> <body>";
                vMessageBody += "<h2> Carga Académica del siguiente periodo lectivo </h2> \n<h3>Profesor: " + vProf.Name + "</h3>\n";
                vMessageBody += "<table rules='all' style='border-color: #666;' cellpadding='10'>";
                vMessageBody += "<tr style='background: #eee;'> <td><strong>Nombre</strong> </td>   <td><strong>Aula</strong></td> <td><strong>Dia</strong></td>  <td><strong>Hora Inicio</strong></td> <td><strong>Hora Fin</strong></td> <td><strong>Grupo</strong></td> <td><strong>Sede</strong></td> <td><strong>Tipo</strong></td></tr>";
                int vActiveProfessor = 0;
                for (int vElement = 0; vElement < vAcademicLoad.Count(); vElement++)
                {
                    if (vAcademicLoad[vElement].Profesor_Nombre == vProf.Name)
                    {
                        if (pSelectedList.Items.Exists(match => match.Name == vProf.Name && match.Selected == true))
                        {
                            vMessageBody += "<tr><td>" + vAcademicLoad[vElement].Nombre + "</td><td>" + vAcademicLoad[vElement].Aula
                                            + "</td><td>" + vAcademicLoad[vElement].Dia + "</td><td>" + vAcademicLoad[vElement].HoraInicio
                                            + "</td><td>" + vAcademicLoad[vElement].HoraFin + "</td><td>" + vAcademicLoad[vElement].Grupo + "</td><td>"
                                            + vAcademicLoad[vElement].Sede + "</td><td>" + vAcademicLoad[vElement].Tipo + "</td></tr>";
                            vActiveProfessor = 1;
                        }
                    }
                }
                vMessageBody += "</table> </body> </html>";
                if ((vProf.Email != null) && (vActiveProfessor == 1))
                {
                    sendEmail(vProf.Email, vMessageSubject, vMessageBody);
                }
            }
        }
        /// <summary>
        /// Download the general report on a csv file
        /// </summary>
        /// <returns></returns>
        public FileResult Download()
        {
            var fi = new FileInfo("myfile.txt");

            byte[] bytes;
            SACAAE.Helpers.LoadAcademicHelper.ReporteInfo vReportInfo = new SACAAE.Helpers.LoadAcademicHelper.ReporteInfo();
            int vPeriodID = int.Parse(Request.Cookies["Periodo"].Value);

            try
            {
                fi.Delete();
            }
            catch (Exception)
            { }

            using (Stream fs = new MemoryStream())
            {
                StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
                sw.WriteLine("Tipo;Grupo;Nombre;Profesor;Dia;Hora Inicio;Hora Fin;Sede;Aula;Plan de Estudio;Carga Estimada;Tipo Hora;Entidad");
                var IdPeriodo = int.Parse(Request.Cookies["Periodo"].Value);

                vReportInfo = LAHelper.setCourses(vReportInfo, vPeriodID);
                vReportInfo = LAHelper.setProjects(vReportInfo, vPeriodID);
                vReportInfo = LAHelper.setCommissions(vReportInfo, vPeriodID);

                SACAAE.Helpers.LoadAcademicHelper.Profesor[] array_profesores =
                    vReportInfo.todo_profesores.OrderBy(c => c.Profesor_Nombre).ToArray();

                string profe_actual = "";
                double vCargaTec = 0, vCargaReconocimiento = 0, vCargaRecargo = 0;

                foreach (SACAAE.Helpers.LoadAcademicHelper.Profesor profe in array_profesores)
                {
                    vCargaTec = 0; vCargaReconocimiento = 0; vCargaRecargo = 0;
                    if (profe_actual.Equals(""))
                    {
                        profe_actual = profe.Profesor_Nombre;
                    }

                    if (profe_actual.Equals(profe.Profesor_Nombre))
                    {
                        sw.WriteLine(profe.toStr());
                    }

                    else
                    {
                        if (vReportInfo.profesores_carga_tec.ContainsKey(profe_actual))
                        {
                            vCargaTec = vReportInfo.profesores_carga_tec[profe_actual];
                            sw.WriteLine("Subtotal Horas TEC;;;" + profe_actual + ";;;;;;;;" + vCargaTec + ";" + vCargaTec * 100 / 40 + " %");
                        }

                        if (vReportInfo.profesores_carga_reconocimiento.ContainsKey(profe_actual))
                        {
                            vCargaReconocimiento = vReportInfo.profesores_carga_reconocimiento[profe_actual];
                            sw.WriteLine("Subtotal Horas Reconocimiento;;;" + profe_actual + ";;;;;;;;" + vCargaReconocimiento);
                        }

                        if (vReportInfo.profesores_carga_recargo.ContainsKey(profe_actual))
                        {
                            vCargaRecargo = vReportInfo.profesores_carga_recargo[profe_actual];
                            sw.WriteLine("Subtotal Horas Recargo;;;" + profe_actual + ";;;;;;;;" + vCargaRecargo);
                        }
                        sw.WriteLine("Total Horas;;;" + profe_actual + ";;;;;;;;" + (vCargaRecargo + vCargaReconocimiento + vCargaTec));
                        sw.WriteLine();

                        profe_actual = profe.Profesor_Nombre;
                        sw.WriteLine(profe.toStr());
                    }
                }

                if (vReportInfo.profesores_carga_tec.ContainsKey(profe_actual))
                {
                    vCargaTec = vReportInfo.profesores_carga_tec[profe_actual];
                    sw.WriteLine("Subtotal Horas TEC;;;" + profe_actual + ";;;;;;;;" + vCargaTec + ";" + vCargaTec * 100 / 40 + " %");
                }

                if (vReportInfo.profesores_carga_reconocimiento.ContainsKey(profe_actual))
                {
                    vCargaReconocimiento = vReportInfo.profesores_carga_reconocimiento[profe_actual];
                    sw.WriteLine("Subtotal Horas Reconocimiento;;;" + profe_actual + ";;;;;;;;" + vCargaReconocimiento);
                }

                if (vReportInfo.profesores_carga_recargo.ContainsKey(profe_actual))
                {
                    vCargaRecargo = vReportInfo.profesores_carga_recargo[profe_actual];
                    sw.WriteLine("Subtotal Horas Recargo;;;" + profe_actual + ";;;;;;;;" + vCargaRecargo);
                }
                sw.WriteLine("Total Horas;;;" + profe_actual + ";;;;;;;;" + (vCargaRecargo + vCargaReconocimiento + vCargaTec));
                sw.WriteLine();

                sw.Flush();
                fs.Flush();
                fs.Position = 0;
                bytes       = new byte[fs.Length];

                fs.Read(bytes, 0, bytes.Length);
                sw.Close();
                sw.Dispose();
            }
            return(File(bytes, System.Net.Mime.MediaTypeNames.Application.Octet, "Reporte.csv"));
        }
Beispiel #4
0
        // GET: /Professor/
        public ActionResult Index()
        {
            var Professors = db.Professors.ToList();
            int vPeriod    = int.Parse(Request.Cookies["Periodo"].Value);
            var viewModel  = new List <ProfesorViewModel>();

            SACAAE.Helpers.LoadAcademicHelper.ReporteInfo vReportInfo = new SACAAE.Helpers.LoadAcademicHelper.ReporteInfo();
            vReportInfo = LAHelper.setCourses(vReportInfo, vPeriod);
            vReportInfo = LAHelper.setProjects(vReportInfo, vPeriod);
            vReportInfo = LAHelper.setCommissions(vReportInfo, vPeriod);

            SACAAE.Helpers.LoadAcademicHelper.Profesor[] array_profesores =
                vReportInfo.todo_profesores.OrderBy(c => c.Profesor_Nombre).ToArray();

            string profe_actual = "";

            List <ProfesorViewModel> vProfList = new List <ProfesorViewModel>();

            foreach (SACAAE.Helpers.LoadAcademicHelper.Profesor profe in array_profesores)
            {
                double vCargaTEC = 0, vReconocimientoHours = 0, vRecargoHours = 0;

                if (profe_actual.Equals(""))
                {
                    profe_actual = profe.Profesor_Nombre;
                }

                if (!profe_actual.Equals(profe.Profesor_Nombre))
                {
                    if (vReportInfo.profesores_carga_tec.ContainsKey(profe_actual))
                    {
                        vCargaTEC = vReportInfo.profesores_carga_tec[profe_actual];
                    }

                    if (vReportInfo.profesores_carga_reconocimiento.ContainsKey(profe_actual))
                    {
                        vReconocimientoHours = vReportInfo.profesores_carga_reconocimiento[profe_actual];
                    }

                    if (vReportInfo.profesores_carga_recargo.ContainsKey(profe_actual))
                    {
                        vRecargoHours = vReportInfo.profesores_carga_recargo[profe_actual];
                    }

                    vProfList.Add(
                        new ProfesorViewModel()
                    {
                        ID                  = 0,
                        Name                = profe_actual,
                        Link                = "",
                        Tel1                = "",
                        Tel2                = "",
                        StateID             = 1,
                        Email               = "",
                        LoadAcademic        = vCargaTEC * 100 / 40,
                        TECHours            = vCargaTEC,
                        ReconocimientoHours = vReconocimientoHours,
                        RecargoHours        = vRecargoHours,
                        TotalHours          = vCargaTEC + vReconocimientoHours + vRecargoHours
                    });
                    profe_actual = profe.Profesor_Nombre;
                }
            }

            for (int vCont = 0; vCont < Professors.Count(); vCont++)
            {
                Professor vProf = Professors.ElementAt(vCont);
                double    vTecHours = 0, vReconocimientoHoursAux = 0, vRecargoHoursAux = 0, vAcademicLoad = 0;
                if ((vProfList.Find(item => item.Name == vProf.Name)) != null)
                {
                    vTecHours = vProfList.Find(item => item.Name == vProf.Name).TECHours;
                    vReconocimientoHoursAux = vProfList.Find(item => item.Name == vProf.Name).ReconocimientoHours;
                    vRecargoHoursAux        = vProfList.Find(item => item.Name == vProf.Name).RecargoHours;
                    vAcademicLoad           = vProfList.Find(item => item.Name == vProf.Name).LoadAcademic;
                }

                viewModel.Add(
                    new ProfesorViewModel()
                {
                    ID                  = vProf.ID,
                    Name                = vProf.Name,
                    Link                = vProf.Link,
                    Tel1                = vProf.Tel1,
                    Tel2                = vProf.Tel2,
                    StateID             = vProf.StateID.GetValueOrDefault(),
                    Email               = vProf.Email,
                    LoadAcademic        = vAcademicLoad,
                    TECHours            = vTecHours,
                    ReconocimientoHours = vReconocimientoHoursAux,
                    RecargoHours        = vRecargoHoursAux,
                    TotalHours          = vReconocimientoHoursAux + vTecHours + vRecargoHoursAux
                });
            }

            return(View(viewModel));
        }
        // GET: /Professor/
        public ActionResult Index()
        {
            var Professors = db.Professors.ToList();
            int vPeriod = int.Parse(Request.Cookies["Periodo"].Value);
            var viewModel = new List<ProfesorViewModel>();

            SACAAE.Helpers.LoadAcademicHelper.ReporteInfo vReportInfo = new SACAAE.Helpers.LoadAcademicHelper.ReporteInfo();
            vReportInfo = LAHelper.setCourses(vReportInfo, vPeriod);
            vReportInfo = LAHelper.setProjects(vReportInfo, vPeriod);
            vReportInfo = LAHelper.setCommissions(vReportInfo, vPeriod);

            SACAAE.Helpers.LoadAcademicHelper.Profesor[] array_profesores =
                vReportInfo.todo_profesores.OrderBy(c => c.Profesor_Nombre).ToArray();

            string profe_actual = "";

            List<ProfesorViewModel> vProfList = new List<ProfesorViewModel>();
            foreach (SACAAE.Helpers.LoadAcademicHelper.Profesor profe in array_profesores)
            {
                double vCargaTEC = 0, vReconocimientoHours = 0, vRecargoHours = 0;

                if (profe_actual.Equals(""))
                {
                    profe_actual = profe.Profesor_Nombre;
                }

                if (!profe_actual.Equals(profe.Profesor_Nombre))
                {
                    if (vReportInfo.profesores_carga_tec.ContainsKey(profe_actual))
                        vCargaTEC = vReportInfo.profesores_carga_tec[profe_actual];

                    if (vReportInfo.profesores_carga_reconocimiento.ContainsKey(profe_actual))
                        vReconocimientoHours = vReportInfo.profesores_carga_reconocimiento[profe_actual];

                    if (vReportInfo.profesores_carga_recargo.ContainsKey(profe_actual))
                        vRecargoHours = vReportInfo.profesores_carga_recargo[profe_actual];

                    vProfList.Add(
                    new ProfesorViewModel()
                    {
                        ID = 0,
                        Name = profe_actual,
                        Link = "",
                        Tel1 = "",
                        Tel2 = "",
                        StateID = 1 ,
                        Email = "" ,
                        LoadAcademic = vCargaTEC * 100 / 40,
                        TECHours = vCargaTEC,
                        ReconocimientoHours = vReconocimientoHours,
                        RecargoHours = vRecargoHours,
                        TotalHours = vCargaTEC + vReconocimientoHours + vRecargoHours
                    });
                    profe_actual = profe.Profesor_Nombre;
                }
            }

            for (int vCont = 0; vCont < Professors.Count(); vCont++)
            {
                Professor vProf = Professors.ElementAt(vCont);
                double vTecHours = 0, vReconocimientoHoursAux = 0, vRecargoHoursAux = 0, vAcademicLoad = 0;
                if ((vProfList.Find(item => item.Name == vProf.Name)) != null)
                {
                    vTecHours = vProfList.Find(item => item.Name == vProf.Name).TECHours;
                    vReconocimientoHoursAux = vProfList.Find(item => item.Name == vProf.Name).ReconocimientoHours;
                    vRecargoHoursAux = vProfList.Find(item => item.Name == vProf.Name).RecargoHours;
                    vAcademicLoad = vProfList.Find(item => item.Name == vProf.Name).LoadAcademic;
                }

                viewModel.Add(
                    new ProfesorViewModel()
                    {
                        ID = vProf.ID,
                        Name = vProf.Name,
                        Link = vProf.Link,
                        Tel1 = vProf.Tel1,
                        Tel2 = vProf.Tel2,
                        StateID = vProf.StateID.GetValueOrDefault(),
                        Email = vProf.Email,
                        LoadAcademic = vAcademicLoad,
                        TECHours = vTecHours,
                        ReconocimientoHours = vReconocimientoHoursAux,
                        RecargoHours = vRecargoHoursAux,
                        TotalHours = vReconocimientoHoursAux + vTecHours + vRecargoHoursAux
                    });
            }

            return View(viewModel);
        }