Beispiel #1
0
        public ActionResult Editar(string id)
        {
            DraftLawBL oBL    = new DraftLawBL();
            int        pIntID = 0;

            int.TryParse(id, out pIntID);
            DraftLawViewModel       pDraftLawViewModel = oBL.Obtener(pIntID);
            SelectorBL              oSelectorBL        = new SelectorBL();
            List <SelectOptionItem> oCommissions       = oSelectorBL.CommissionsSelector();
            List <SelectListItem>   commissions        = Helper.ConstruirDropDownList <SelectOptionItem>(oCommissions, "Value", "Text", "", true, "", "");

            ViewBag.commissions = commissions;
            List <SelectOptionItem> oInterestAreas = oSelectorBL.InterestAreasSelector();
            List <SelectListItem>   interest_areas = Helper.ConstruirDropDownList <SelectOptionItem>(oInterestAreas, "Value", "Text", "", true, "", "");

            ViewBag.interest_areas = interest_areas;
            if (pDraftLawViewModel.date_presentation.HasValue)
            {
                pDraftLawViewModel.date_presentation_text = pDraftLawViewModel.date_presentation.Value.ToString("dd/MM/yyyy");
            }

            pDraftLawViewModel.period_closed = 1;
            if (pDraftLawViewModel.start_date <= DateTime.Today && pDraftLawViewModel.end_date >= DateTime.Today)
            {
                pDraftLawViewModel.period_closed = 0;
            }

            return(View(pDraftLawViewModel));
        }
Beispiel #2
0
        public JsonResult Verificar(int draft_law_id, int draft_law_number)
        {
            DraftLawBL oDraftLawBL = new DraftLawBL();



            var resultado = oDraftLawBL.VerificarDuplicado(draft_law_id, draft_law_number);

            return(Json(new
            {
                // this is what datatables wants sending back
                valido = resultado,
            }));
        }
Beispiel #3
0
        public ActionResult Editar([Bind(Include = "draft_law_id,draft_law_number,title,author,origin,date_presentation,date_presentation_text,commission_id,debate_speaker,debate_speaker2,debate_speaker3,debate_speaker4,status,status_comment,interest_area_id,initiative,summary,link")] DraftLawViewModel pDraftLawViewModel)
        {
            // TODO: Add insert logic here
            pDraftLawViewModel.date_presentation = DateTime.ParseExact(pDraftLawViewModel.date_presentation_text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            if (pDraftLawViewModel == null)
            {
                return(HttpNotFound());
            }
            DraftLawBL oDraftLawBL = new DraftLawBL();

            pDraftLawViewModel.user_id_modified = AuthorizeUserAttribute.UsuarioLogeado().user_id;
            oDraftLawBL.Modificar(pDraftLawViewModel);
            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        public JsonResult ObtenerLista(DraftLawFiltersViewModel ofilters, [Bind(Include = "period_id")]  GeneralFilterViewModel generalfiltros)//DataTableAjaxPostModel model
        {
            DraftLawBL oDraftLawBL = new DraftLawBL();
            //DraftLawFiltersViewModel ofilters = new DraftLawFiltersViewModel();
            GridModel <DraftLawViewModel> grid = oDraftLawBL.ObtenerLista(ofilters, generalfiltros);

            return(Json(new
            {
                // this is what datatables wants sending back
                draw = ofilters.draw,
                recordsTotal = grid.total,
                recordsFiltered = grid.recordsFiltered,
                data = grid.rows
            }));
        }
        public JsonResult ObtenerLista(DraftLawFiltersViewModel ofilters, [Bind(Include = "period_id")]  GeneralFilterViewModel generalfiltros)//DataTableAjaxPostModel model
        {
            DraftLawBL oDraftLawBL = new DraftLawBL();
            //DraftLawFiltersViewModel ofilters = new DraftLawFiltersViewModel();

            UserBL oUserBL = new UserBL();
            InvestigatorViewModel         oInvestigatorViewModel = oUserBL.ObtenerInvestigator(AuthorizeUserAttribute.UsuarioLogeado().investigator_id);
            GridModel <DraftLawViewModel> grid = oDraftLawBL.ObtenerMisProyectosLey(ofilters, oInvestigatorViewModel.commissions, oInvestigatorViewModel.interest_areas, generalfiltros);

            return(Json(new
            {
                // this is what datatables wants sending back
                draw = ofilters.draw,
                recordsTotal = grid.total,
                recordsFiltered = grid.recordsFiltered,
                data = grid.rows
            }));
        }
Beispiel #6
0
        public IHttpActionResult DraftLawSearch(DraftLawSearchFilterLiteViewModel filter)
        {
            DraftLawBL      oBL       = new DraftLawBL();
            PeriodBL        oPeriodBL = new PeriodBL();
            PeriodViewModel oPeriod   = oPeriodBL.ObtenerVigente();

            filter.period_id = oPeriod.period_id;
            List <DraftLawLiteViewModel> lista = oBL.ObtenerProyectosLeyMovil(filter);



            var result = new
            {
                // this is what datatables wants sending back

                data = lista
            };

            return(Ok(result));
        }
Beispiel #7
0
        public JsonResult Eliminar(int id)
        {
            DraftLawBL        oDraftLawBL        = new DraftLawBL();
            DraftLawViewModel pDraftLawViewModel = oDraftLawBL.Obtener(id);

            var period_closed = 1;

            if (pDraftLawViewModel.start_date <= DateTime.Today && pDraftLawViewModel.end_date >= DateTime.Today)
            {
                period_closed = 0;
            }
            if (period_closed == 0)
            {
                oDraftLawBL.Eliminar(id);
            }

            return(Json(new
            {
                period_closed = period_closed,
                // this is what datatables wants sending back
                status = "1",
            }));
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            try
            {
                new Program();
                logger.Info("Inicio Proceso: Notificacion.Nuevos.Proyectos.Ley");
                DraftLawBL oDraftLawBL        = new DraftLawBL();
                List <DraftLawViewModel> list = oDraftLawBL.ObtenerNotificables();

                logger.Info("Proceso Notificacion.Nuevos.Proyectos.Ley: " + list.Count());

                if (list.Count() > 0)
                {
                    UserBL oUserBL = new UserBL();
                    List <InvestigatorViewModel> investigadores           = oUserBL.ObtenerInvestigadores();
                    SendEmailNotificationBL      oSendEmailNotificationBL = new SendEmailNotificationBL();

                    foreach (InvestigatorViewModel investigador in investigadores)
                    {
                        try
                        {
                            logger.Info("Inicio Investigador: " + investigador.contact_name);


                            List <DraftLawViewModel> proyectos_asociados = list.Where(a => investigador.commissions.Contains(a.commission_id.Value) && investigador.interest_areas.Contains(a.interest_area_id.Value)).ToList();
                            logger.Info("Proyectyso Nuevos: " + proyectos_asociados.Count());
                            if (proyectos_asociados != null && proyectos_asociados.Count > 0)
                            {
                                NotificationDraftLawViewModel oNotification = new NotificationDraftLawViewModel();
                                oNotification.name      = investigador.contact_name;
                                oNotification.url       = ConfigurationManager.AppSettings["site.url"] + "/Investigator/MisProyectosLey";
                                oNotification.to        = investigador.user_email;
                                oNotification.DraftLaws = proyectos_asociados;

                                oNotification.url_home = ConfigurationManager.AppSettings["site.url"];

                                oNotification.url_politicas  = ConfigurationManager.AppSettings["site.url.politicas"];
                                oNotification.url_contacto   = ConfigurationManager.AppSettings["site.url.contacto"];
                                oNotification.url_privacidad = ConfigurationManager.AppSettings["site.url.privacidad"];
                                oSendEmailNotificationBL.EnviarNotificacionInvestigadorProyectosNuevos(oNotification);

                                NotificationBL        oNotificationBL        = new NotificationBL();
                                NotificationViewModel pNotificationViewModel = new NotificationViewModel();
                                pNotificationViewModel.user_id = investigador.user_id;
                                pNotificationViewModel.message = "Se han registrado proyecto(s) de ley de sus áreas de interés";
                                pNotificationViewModel.url     = @"/Investigator/MisProyectosLey";

                                oNotificationBL.Agregar(pNotificationViewModel);
                            }

                            logger.Info("Fin Investigador: " + investigador.contact_name);
                        }
                        catch (Exception ex)
                        {
                            logger.Info("Error en Notificacion.Nuevos.Proyectos.Ley:");
                            logger.Info("Mensaje: " + ex.Message);
                            logger.Info("StackTrace: " + ex.StackTrace);
                            logger.Error("Notificacion.Nuevos.Proyectos.Ley: ", ex);
                        }
                    }

                    oDraftLawBL.ActualizarNotificacion(list);
                }


                logger.Info("Fin de Proceso: Notificacion.Nuevos.Proyectos.Ley");
            }
            catch (Exception ex)
            {
                logger.Info("Error en Notificacion.Nuevos.Proyectos.Ley:");
                logger.Info("Mensaje: " + ex.Message);
                logger.Info("StackTrace: " + ex.StackTrace);
                logger.Error("Notificacion.Nuevos.Proyectos.Ley: ", ex);
            }
        }
Beispiel #9
0
        public JsonResult Crear([Bind(Include = "draft_law_id,draft_law_number,title,author,origin,date_presentation,date_presentation_text,commission_id,debate_speaker,debate_speaker2,debate_speaker3,debate_speaker4,status,status_comment,interest_area_id,initiative,summary,link")] DraftLawViewModel pDraftLawViewModel)
        {
            // TODO: Add insert logic here


            if (pDraftLawViewModel == null)
            {
                // return HttpNotFound();

                return(Json(new
                {
                    message_error = "Datos inavalidos",
                    status = "0",
                }));
            }
            pDraftLawViewModel.date_presentation = DateTime.ParseExact(pDraftLawViewModel.date_presentation_text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            pDraftLawViewModel.draft_law_id      = 0;

            pDraftLawViewModel.user_id_created = AuthorizeUserAttribute.UsuarioLogeado().user_id;

            pDraftLawViewModel.commission    = "";
            pDraftLawViewModel.interest_area = "";
            List <ImportError>       oErrores = null;
            DraftLawBL               oBL      = new DraftLawBL();
            List <DraftLawViewModel> lista    = new List <DraftLawViewModel>();

            lista.Add(pDraftLawViewModel);
            PeriodBL        oPeriodBL = new PeriodBL();
            PeriodViewModel oPeriod   = oPeriodBL.ObtenerVigente();

            oErrores = ValidarPeriodo(oPeriod, oErrores);
            if (oErrores.Count > 0)
            {
                return(Json(new { successfully = 0, errores = oErrores }));
            }

            if (VerificarPonentes(lista, out oErrores))
            {
                DraftLawBL               oDraftLawBL       = new DraftLawBL();
                CommissionBL             oCommissionBL     = new CommissionBL();
                InterestAreaBL           oInterestAreaBL   = new InterestAreaBL();
                DraftLawStatusBL         oDraftLawStatusBL = new DraftLawStatusBL();
                OriginBL                 oOriginBL         = new OriginBL();
                Dictionary <string, int> commisions        = new Dictionary <string, int>();
                Dictionary <string, int> origins           = oOriginBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.origin).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);
                Dictionary <string, int> interest_areas    = new Dictionary <string, int>();
                Dictionary <string, DraftLawStatusViewModel> draftlaw_status = oDraftLawStatusBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.status).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);

                oDraftLawBL.Import(oPeriod, lista, origins, commisions, interest_areas, draftlaw_status, AuthorizeUserAttribute.UsuarioLogeado().user_id);
                // NotificacionNuevoProyectoLey(lista);
            }


            // oBL.Agregar(pDraftLawViewModel);
            if (oErrores.Count == 0)
            {
                return(Json(new { successfully = 1 }));
            }
            else
            {
                return(Json(new { successfully = 0, errores = oErrores }));
            }

            // return RedirectToAction("Index");
        }
Beispiel #10
0
        public ActionResult UploadFiles()
        {
            List <ImportError> oErrores = null;

            // Checking no of files injected in Request object
            if (Request.Files.Count > 0)
            {
                try
                {
                    //  Get all files from Request object
                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/";
                        //string filename = Path.GetFileName(Request.Files[i].FileName);

                        HttpPostedFileBase file  = files[i];
                        string             fname = Guid.NewGuid().ToString() + ".xlsx";

                        fname = Path.Combine(Server.MapPath("~/Uploads/"), fname);
                        file.SaveAs(fname);
                        DataTable       dt        = Util.ReadExcelToDataTable(fname);
                        PeriodBL        oPeriodBL = new PeriodBL();
                        PeriodViewModel oPeriod   = oPeriodBL.ObtenerVigente();

                        oErrores = ValidarPeriodo(oPeriod, oErrores);
                        List <DraftLawViewModel> lista = new List <DraftLawViewModel>();
                        if (oErrores.Count == 0)
                        {
                            lista = ConvertirDatatable(dt, out oErrores);
                        }
                        if (oErrores.Count == 0)
                        {
                            if (VerificarPonentes(lista, out oErrores))
                            {
                                DraftLawBL               oDraftLawBL       = new DraftLawBL();
                                CommissionBL             oCommissionBL     = new CommissionBL();
                                InterestAreaBL           oInterestAreaBL   = new InterestAreaBL();
                                DraftLawStatusBL         oDraftLawStatusBL = new DraftLawStatusBL();
                                OriginBL                 oOriginBL         = new OriginBL();
                                Dictionary <string, int> commisions        = oCommissionBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.commission).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);
                                Dictionary <string, int> origins           = oOriginBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.origin).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);
                                Dictionary <string, int> interest_areas    = oInterestAreaBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.interest_area).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);
                                Dictionary <string, DraftLawStatusViewModel> draftlaw_status = oDraftLawStatusBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.status).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);

                                oDraftLawBL.Import(oPeriod, lista, origins, commisions, interest_areas, draftlaw_status, AuthorizeUserAttribute.UsuarioLogeado().user_id);
                                // NotificacionNuevoProyectoLey(lista);
                            }
                        }
                    }
                    if (oErrores.Count == 0)
                    {
                        return(Json(new { successfully = 1 }));
                    }
                    else
                    {
                        return(Json(new { successfully = 0, errores = oErrores }));
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex);
                    if (ex.Data.Contains("RepositoryMessage"))
                    {
                        logger.Error(ex.Data["RepositoryMessage"].ToString());
                    }
                    return(Json(new { successfully = -1, message = "Ha ocurrido un error. Detalle error: " + ex.Message }));
                }
            }
            else
            {
                return(Json("No files selected."));
            }
        }