Example #1
0
 private LogDocumento getLD(int docID)
 {
     for (int i = grupo.logResultados.Count - 1; i >= 0; i--)
     {
         LogDocumento ld = grupo.logResultados[i];
         if (ld.docID == docID)
         {
             return(ld);
         }
     }
     return(null);
 }
Example #2
0
        private string getListaResultados()
        {
            string ret = "#|";

            for (int i = grupo.logResultados.Count - 1; i >= 0; i--)
            {
                LogDocumento ld = grupo.logResultados[i];
                if (ld.modeloID == "Accion")
                {
                    ret += ld.docID + "#" + ld.titulo + " (" + ld.fecha.ToString("dd/MM/yy") + ")|";
                }
            }
            if (ret.EndsWith("|"))
            {
                ret = ret.Substring(0, ret.Length - 1);
            }
            return(ret);
        }
Example #3
0
        public void Executar(
            string acaoLogDocumento,
            int documentoId,
            string observacao)
        {
            var logDocumento = new LogDocumento
            {
                Acao      = acaoLogDocumento,
                Documento = new Documento {
                    Id = documentoId
                },
                Usuario = (Usuario)this.userSession.UsuarioAtual ?? new Usuario {
                    Id = -1
                },
                Observacao = observacao
            };

            this.logDocumentoRepositorio.Salvar(logDocumento);
        }
Example #4
0
        override protected string toHTMLContenido(Propuesta prop, Grupo g, string email, int width)
        {
            string  ret = "";
            Usuario u   = g.getUsuarioHabilitado(email);

            //validaciones de este nivel
            validar(prop);

            //titulo
            ret += "<div class='titulo1'>" + Tools.tr("Evaluacion de comunicado intergrupal", g.idioma) + "</div><br>";

            //fecha
            if (modo == eModo.finalizado)
            {
                ret += "<div class='titulo2'><nobr>" + Tools.tr("Fecha", g.idioma) + ":" + DateTime.Now.ToString("dd/MM/yy") + " " + DateTime.Now.ToShortTimeString() + "</nobr></div>";
            }

            //documento de Accon a evaluar
            string valores = getListaResultados();

            ret += "<div class='titulo3'>" + Tools.tr("Documento de comunicado a evaluar", g.idioma) + "</div>";
            if (getText("s.basadoEnTemaExistente", prop) == "")
            {
                ret += HTMLLista("f.evaluadoID", valores, prop, 450, g.idioma, true);
            }
            ret += "<br>";

            //defino valores internos
            evaluadoID = getValue("f.evaluadoID", prop).ToString();

            //enalce a documento evaluado
            if (evaluadoID != "" && getLD(Convert.ToInt32(evaluadoID)) != null)
            {
                LogDocumento ld = getLD(Convert.ToInt32(evaluadoID));
                ret += "<table class='smalltip' style='margin: 0 auto;background:wheat;width:200px;'>";
                ret += "<tr><td>";
                ret += "<img src='" + ld.icono + "' style='width:32px;height:40px'></td>";
                ret += "<td style='text-align:left;'>";
                ret += ld.fname + "<br>";
                ret += ld.fecha.ToString("dd/MM/yy") + "<br>";
                ret += "<a href='" + ld.URL + "' target='_blank'>" + ld.titulo + "</a></td>";
                ret += "</tr></table>";
            }

            //preguntas
            for (var q = 1; q <= 5; q++)
            {
                ret += "<div class='tema' style='clear:left;float:left;vertical-align:top'><b>" + Tools.tr("alhijo.evaluacion.p" + q, g.idioma) + "</b></div>";
                ret += "<div style='float:right;vertical-align:middle;text-align:right;margin:0.1vw;margin-right:1vw;'>";
                ret += HTMLBarra("f.p" + q, prop, "No", "Si");
                ret += "</div>";

                if (modo != eModo.prevista && Tools.tr("alhijo.evaluacion.tip" + q, g.idioma) != "")
                {
                    ret += "<div class='smalltip' style='float:left;width:-webkit-fill-available;margin: auto'>" + Tools.tr("alhijo.evaluacion.tip" + q, g.idioma) + "</div>";
                }
                //texto
                ret += "<div style='float:left;width:-webkit-fill-available'>" + HTMLArea("s.t" + q, prop, 0, 120, g.idioma) + "</div>";
            }

            //mensajes de error
            if (errores.ContainsKey(1))
            {
                ret += "<div class='error'>" + errores[1] + "</div>";
            }
            return(ret);
        }
Example #5
0
        override protected string toHTMLContenido(int nivel, Propuesta prop, Grupo g, string email, int width)
        {
            string  ret         = "";
            Usuario u           = g.getUsuario(email);
            bool    tieneFlores = false;

            if (u != null)
            {
                tieneFlores = u.floresDisponibles().Count > 0;
            }

            bool editar = (prop == null && tieneFlores && modo != eModo.prevista && modo != eModo.consenso) ||
                          (prop != null && prop.esPrevista() && (modo == eModo.revisar || modo == eModo.editar));

            editar = editar && !consensoAlcanzado;
            bool puedeVariante = prop != null && !prop.esPrevista() && modo == eModo.editar && tieneFlores && !consensoAlcanzado;


            //validaciones de este nivel
            validar(prop, g.idioma);

            if (nivel == 1)
            {
                ret += HTMLEncabezado(prop, g, email, width);

                //enseño manifiesto anterior
                LogDocumento anterior = null;
                foreach (LogDocumento ld in g.logDecisiones)
                {
                    if (ld.modeloNombre == this.nombre && ((prop != null && ld.fecha < prop.born) || prop == null))
                    {
                        anterior = ld; //me quedo con el ultimo
                    }
                }
                if (anterior != null)
                {
                    ret += "<table class='smalltip' style='margin: 0 auto;background:wheat;width:200px'><tr>";
                    ret += "<td colspan=2 style='text-align:center;'><b>" + Tools.tr("Este manifiesto reemplaza al anterior", g.idioma) + "</b></td>";
                    ret += "<tr><td>";
                    ret += "<img src='" + anterior.icono + "' style='width:32px;height:40px'></td>";
                    ret += "<td style='text-align:left;'>";
                    ret += anterior.fname + "<br>";
                    ret += anterior.fecha.ToString("dd/MM/yy") + "<br>";
                    ret += "<a href='" + anterior.URL + "' target='_blank'>" + anterior.titulo + "</a></td>";
                    ret += "</tr></table>";
                }

                //fecha
                if (modo == eModo.consenso)
                {
                    ret += "<div class='titulo2'><nobr>" + Tools.tr("Fecha", g.idioma) + ":" + DateTime.Now.ToString("dd/MM/yy") + " " + DateTime.Now.ToShortTimeString() + "</nobr></div>";
                }

                //tema
                ret += "<div class='tema'>" + Tools.tr("manifiesto.vision.titulo", g.idioma) + "</div>";
                if (editar)
                {
                    ret += "<div class='smalltip'>" + Tools.tr("manifiesto.vision.tip", g.idioma) + "</div>";
                }

                ret += HTMLArea("s.vision", prop, width, 290, tieneFlores, g.idioma);

                //variante
                if (puedeVariante)
                {
                    ret += HTMLVariante(prop.nodoID, g);
                }
            }
            else if (nivel == 2)
            {
                //Mision
                ret += "<div class='tema'>" + Tools.tr("manifiesto.mision.titulo", g.idioma) + "</div>";
                if (editar)
                {
                    ret += "<div class='smalltip'>" + Tools.tr("manifiesto.mision.tip", g.idioma) + "</div>";
                }

                ret += HTMLArea("s.mision", prop, width, 290, tieneFlores, g.idioma);

                //variante
                if (puedeVariante)
                {
                    ret += HTMLVariante(prop.nodoID, g);
                }
            }
            else if (nivel == 3)
            {
                //Objetivo
                ret += "<div class='tema'>" + Tools.tr("manifiesto.objetivos.titulo", g.idioma) + "</div>";
                if (editar)
                {
                    ret += "<div class='smalltip'>" + Tools.tr("manifiesto.objetivos.tip", g.idioma) + "</div>";
                }

                ret += HTMLArea("s.objetivo", prop, width, 290, tieneFlores, g.idioma);

                //variante
                if (puedeVariante)
                {
                    ret += HTMLVariante(prop.nodoID, g);
                }
            }
            else if (nivel == 4)
            {
                ret += "<div class='tema'>" + Tools.tr("manifiesto.servicios.titulo", g.idioma) + "</div>";
                if (editar)
                {
                    ret += "<div class='smalltip'>" + Tools.tr("manifiesto.servicios.tip", g.idioma) + "</div>";
                }

                ret += HTMLArea("s.servicios", prop, width, 550, tieneFlores, g.idioma);

                //variante
                if (puedeVariante)
                {
                    ret += HTMLVariante(prop.nodoID, g);
                }
            }
            else
            {
                throw new Exception(Tools.tr("Nivel [%1] no existe en este modelo", nivel.ToString(), g.idioma));
            }

            if (prop != null)
            {
                prop.niveles = niveles;               //esto es importante si cambian los niveles para que se traspase luego al nodo
            }
            //fin nivel
            if (prop != null && prop.nodoID != 0 && modo != eModo.consenso)
            {
                ret += HTMLFlores(g.arbol.getNodo(prop.nodoID), false, g.getUsuario(email));
            }

            //mensajes de error
            if (errores.ContainsKey(nivel))
            {
                ret += "<div class='error'>" + errores[nivel] + "</div>";
            }
            return(ret);
        }
Example #6
0
        public override string doAccion(Grupo g, string email, string accion, HttpRequest req)
        {
            string ret = "";

            lock (this)
            {
                if (accion == "accionAddEstado")
                {
                    int      EID     = int.Parse(req["EID"]);
                    string   estado  = req["estado"];
                    string   avance  = req["avance"];
                    string   luz     = req["luz"];
                    string   inicio  = req["inicio"];
                    string   fin     = req["fin"];
                    string   descrip = Tools.HTMLLinksBR(Tools.HtmlEncode(req.Form["descrip"]));
                    int      favance = 0;
                    DateTime finicio;
                    DateTime ffin;
                    Usuario  usuario = g.getUsuario(email);

                    try { favance = int.Parse(avance); } catch (Exception) { throw new appException("Valor inválido para avance"); }
                    if (favance < 0 || favance > 100)
                    {
                        throw new appException("Valor inválido para avance");
                    }
                    try {
                        string[] p = inicio.Split('/');
                        finicio = new DateTime(Convert.ToInt32(p[2]),
                                               Convert.ToInt32(p[1]),
                                               Convert.ToInt32(p[0]));
                    }
                    catch (Exception) { throw new appException("Valor inválido para inicio"); }
                    try {
                        string[] p = fin.Split('/');
                        ffin = new DateTime(Convert.ToInt32(p[2]),
                                            Convert.ToInt32(p[1]),
                                            Convert.ToInt32(p[0]));
                    }
                    catch (Exception) { throw new appException("Valor inválido para fin"); }
                    if (finicio > ffin)
                    {
                        throw new appException("Plazo inválido");
                    }

                    foreach (nabu.plataforma.Seguimiento a in seguimientos)
                    {
                        if (a.EID == EID)
                        {
                            nabu.plataforma.Seguimiento.Estado e = new plataforma.Seguimiento.Estado();
                            e.EID     = getEID();
                            e.estado  = Tools.HtmlEncode(estado);
                            e.avance  = favance;
                            e.luz     = Tools.HtmlEncode(luz);
                            e.inicio  = finicio;
                            e.fin     = ffin;
                            e.descrip = descrip;
                            e.email   = email;
                            if (usuario != null)
                            {
                                e.nombreUsuario = usuario.nombre;
                            }
                            a.estados.Add(e);

                            //guardo todo el grupo
                            g.save(Tools.server.MapPath("grupos/" + g.nombre));

                            ret = "{\"accion\":\"accionAddEstado\",\"resultado\":\"ok\",\"operativo\":" + getOperativo(g) + "}";
                        }
                    }
                }
                else if (accion == "crearArbolParaGrupo")
                {
                    int     EID           = int.Parse(req["EID"]);
                    string  grupoNombre   = req["grupoNombre"];
                    Usuario usuarioActual = g.getUsuario(email);
                    foreach (nabu.plataforma.GrupoTrabajo gt in gruposTrabajo)
                    {
                        if (gt.EID == EID)
                        {
                            Grupo newg = Grupo.newGrupo(grupoNombre,
                                                        req["organizacion"],
                                                        usuarioActual.nombre,
                                                        usuarioActual.email,
                                                        usuarioActual.clave,
                                                        g.idioma,
                                                        g.URL);

                            //creo los demas usuarios
                            foreach (string gtemail in gt.integrantes)
                            {
                                Usuario u = g.getUsuario(gtemail);
                                if (u != null && gtemail != email)
                                {
                                    Usuario newu = new Usuario(g.arbol.cantidadFlores);
                                    newu.nombre       = u.nombre;
                                    newu.email        = u.email;
                                    newu.clave        = u.clave;
                                    newu.readOnly     = u.readOnly;
                                    newu.isAdmin      = u.isAdmin;
                                    newu.isSecretaria = u.isSecretaria;
                                    newu.habilitado   = u.habilitado;
                                    newg.usuarios.Add(newu);
                                }
                            }

                            //padre
                            newg.padreURL    = g.URL;
                            newg.padreNombre = g.nombre;
                            Hijo h = new Hijo();
                            h.URL    = newg.URL;
                            h.nombre = newg.nombre;
                            g.hijos.Add(h);

                            //apunto datos
                            gt.grupoNombre = newg.nombre;
                            gt.grupoURL    = newg.URL;

                            //guardo ambos grupos
                            newg.save(Tools.server.MapPath("grupos/" + newg.nombre));
                            g.save(Tools.server.MapPath("grupos/" + g.nombre));

                            ret = "{\"accion\":\"crearArbolParaGrupo\",\"resultado\":\"ok\",\"operativo\":" + getOperativo(g) + "}";

                            break;
                        }
                    }
                }
                else if (accion == "borrarEnlace")
                {
                    int EID = int.Parse(req["EID"]);
                    foreach (nabu.plataforma.GrupoTrabajo gt in gruposTrabajo)
                    {
                        if (gt.EID == EID)
                        {
                            gt.grupoNombre = "";
                            gt.grupoURL    = "";

                            //guardo
                            g.save(Tools.server.MapPath("grupos/" + g.nombre));

                            ret = "{\"accion\":\"borrarEnlace\",\"resultado\":\"ok\",\"operativo\":" + getOperativo(g) + "}";

                            break;
                        }
                    }
                }
                else if (accion == "seguimientoFinalizar")
                {
                    int EID = int.Parse(req["EID"]);
                    foreach (nabu.plataforma.Seguimiento a in seguimientos)
                    {
                        if (a.EID == EID)
                        {
                            //creo documento de resultado
                            LogDocumento ld = crearResultado(g, a, email);
                            g.logResultados.Add(ld);

                            //quito accion
                            seguimientos.Remove(a);

                            //alertas
                            foreach (Usuario u in g.getUsuariosHabilitados())
                            {
                                if (u.email != email)
                                {
                                    u.alertas.Add(new Alerta(Tools.tr("Accion finalizada [%1]", a.nombre, g.idioma)));
                                }
                            }
                            //guardo todo el grupo
                            g.save(Tools.server.MapPath("grupos/" + g.nombre));

                            ret = "{\"accion\":\"seguimientoFinalizar\",\"resultado\":\"ok\",\"operativo\":" + getOperativo(g) + "}";
                            break;
                        }
                    }
                }
            }
            return(ret);
        }
Example #7
0
        public LogDocumento crearResultado(Grupo gr, nabu.plataforma.Seguimiento ac, string email)
        {
            int docID = 0;

            lock (gr.arbol)
            {
                docID = gr.arbol.lastDocID++;
            }
            string fname   = "Resultado_" + docID.ToString("0000");
            string docPath = "resultados\\" + docID.ToString("0000");
            string URL     = gr.URL + "/grupos/" + gr.nombre + "/" + docPath.Replace('\\', '/') + "/" + fname + ".html";

            //creo carpeta
            if (!System.IO.Directory.Exists(gr.path + "\\" + docPath))
            {
                System.IO.Directory.CreateDirectory(gr.path + "\\" + docPath);
            }

            //creo documento json
            Documento doc = new Documento();

            doc.fecha    = DateTime.Now;
            doc.nombre   = ac.nombre;
            doc.fname    = fname;
            doc.modeloID = "";
            doc.path     = gr.path + "\\" + docPath + "\\" + fname + ".json";
            doc.URLPath  = URL;
            doc.titulo   = "Resultado de: " + ac.nombre;

            Propuesta prop = new Propuesta();

            prop.bag["fecha"]              = DateTime.Now.ToString("dd/MM/yy") + " " + DateTime.Now.ToShortTimeString();
            prop.bag["Seguimiento"]        = ac.nombre;
            prop.bag["Nacido"]             = ac.born;
            prop.bag["Decision"]           = ac.docURL;
            prop.bag["Objetivo"]           = ac.objetivo;
            prop.bag["Estado final"]       = ac.estado.estado;
            prop.bag["Estado final fecha"] = ac.estado.estadoTs;
            prop.bag["Autor"]              = email;

            int q = 1;

            for (int i = ac.estados.Count - 1; i >= 0; i--)
            {
                nabu.plataforma.Seguimiento.Estado es = ac.estados[i];
                prop.bag["Estado" + i]   = es.estado;
                prop.bag["Email" + i]    = es.email;
                prop.bag["EstadoTs" + i] = es.estadoTs.ToString("dd/MM/yy") + " " + es.estadoTs.ToShortTimeString();
            }
            List <Propuesta> props = new List <Propuesta>();

            props.Add(prop);
            doc.propuestas = props;
            doc.save();

            //HTML
            string html = "<html><head></head>";

            //firma Decision
            html  = "<body>";
            html += "<h1>Resultado de: " + ac.nombre + "</h1>";
            html += "<h2>Fecha: " + DateTime.Now.ToString("dd/MM/yy") + " " + DateTime.Now.ToShortTimeString() + "</h2><br>";
            html += "<b>" + Tools.tr("Accion", gr.idioma) + ":</b> " + ac.nombre + "<br>";
            html += "<b>" + Tools.tr("Nacido", gr.idioma) + ":</b> " + ac.born + "<br>";
            html += "<b>" + Tools.tr("Decision", gr.idioma) + ":</b> <a href='" + ac.docURL + "' target='_blank'>" + Tools.getURLName(ac.docURL) + "</a><br>";

            string HTMLText = Tools.HTMLDecode(Tools.HTMLDecode(ac.objetivo.Replace("\n", "<br>")));

            html += "<b>" + Tools.tr("Objetivo", gr.idioma) + ":</b><br> " + HTMLText + "<br>";
            html += "<b>" + Tools.tr("Estado final", gr.idioma) + ":</b> " + ac.estado.estado + "<br>";
            html += "<b>" + Tools.tr("Estado final fecha", gr.idioma) + ":</b> " + ac.estado.estadoTs + "<br><br>";
            html += "<b>" + Tools.tr("Autor", gr.idioma) + ":</b> " + email + "<br><br>";

            html += "<b>Estados:</b><br>";
            for (int i = ac.estados.Count - 1; i >= 0; i--)
            {
                nabu.plataforma.Seguimiento.Estado es = ac.estados[i];
                html += "<hr>";
                html += "Estado: " + es.estado + " " + es.email + " " + es.estadoTs.ToString("dd/MM/yy") + " " + es.estadoTs.ToShortTimeString() + "<br>";
                html += es.descrip;
            }
            html += "<hr>";
            html += "Documento publicado por: " + email + "<br>";
            html += "Grupo: " + gr.nombre + "<br>";
            html += "Documento ID:" + fname + "<br>";
            html += "Fecha de publicación: " + DateTime.Now.ToString("dd/MM/yy") + " " + DateTime.Now.ToShortTimeString() + "<br>";
            html += "Ubicaci&oacute;n: <a target='_blank' href='" + URL + "'>" + URL + "</a><br>";
            html += "Objetivo: " + gr.objetivo + "<br>";
            html += "Usuarios: " + gr.getUsuariosHabilitados().Count + "<br>";
            html += "Activos: " + gr.activos + "<br>";
            //escribo
            System.IO.File.WriteAllText(gr.path + "\\" + docPath + "\\" + fname + ".html", html, System.Text.Encoding.UTF8);

            //retorno meta data
            LogDocumento ld = new LogDocumento();

            ld.fecha           = DateTime.Now;
            ld.titulo          = "Resultado de: " + ac.nombre;
            ld.documentoNombre = ac.nombre;
            ld.icono           = ac.icono;
            if (ld.titulo.Length > 70)
            {
                ld.titulo = ld.titulo.Substring(0, 70);
            }
            ld.modeloNombre = ac.modeloNombre;
            ld.modeloID     = ac.modeloID;
            ld.x            = 0;
            ld.docID        = docID;
            ld.fname        = fname;
            ld.arbol        = gr.arbol.nombre;
            ld.objetivo     = gr.objetivo;
            ld.flores       = 0;
            ld.negados      = 0;
            ld.carpeta      = "resultados";
            ld.URL          = URL;
            ld.autor        = email;

            return(ld);
        }