Esempio n. 1
0
        string HTMLPropuesta(int id, string grupo, string email, int width)
        {
            string           ret = "";
            List <Propuesta> l   = new List <Propuesta>();
            Grupo            g   = app.getGrupo(grupo);

            lock (g)
            {
                Arbol a = g.arbol;
                g.ts = DateTime.Now;
                Propuesta p = a.getPropuesta(id);
                if (p != null)
                {
                    Modelo m = g.organizacion.getModeloDocumento(p.modeloID);
                    ret = m.toHTML(p, g, email, width, Modelo.eModo.ver);
                }
            }
            return(ret);
        }
Esempio n. 2
0
        string HTMLDocumento(int id, string modeloID, string grupo, string email, int width)
        {
            string           ret = "";
            List <Propuesta> l   = new List <Propuesta>();
            Grupo            g   = app.getGrupo(grupo);

            lock (g)
            {
                Arbol a = g.arbol;
                g.ts = DateTime.Now;
                foreach (Nodo n in a.getPath(id))
                {
                    Propuesta op = a.getPropuesta(n); //comparo textox con hermanos y resalto palarbas nuevas
                    if (op != null)
                    {
                        l.Add(op);
                    }
                }
                Modelo m = g.organizacion.getModeloDocumento(modeloID);
                ret = m.toHTML(l, g, email, width, Modelo.eModo.editar); //las propuesta debe ir en orden de nivel
            }
            return(ret);
        }
Esempio n. 3
0
        string doRevisar(int id, string modeloID, string grupo, string email, int width)
        {
            string           ret   = "";
            List <Propuesta> props = new List <Propuesta>();
            Grupo            g     = app.getGrupo(grupo);
            Modelo           m     = g.organizacion.getModeloDocumento(modeloID);

            lock (g)
            {
                //preparo propuestas de nodos ancestros
                Arbol       a    = g.arbol;
                List <Nodo> path = a.getPath(id);
                g.ts = DateTime.Now;
                foreach (Nodo n in path)
                {
                    Propuesta op = a.getPropuesta(n); //comparo textox con hermanos y resalto palarbas nuevas
                    if (n.nivel > 0 && op != null)
                    {
                        props.Add(op);
                    }
                }

                //agrego las propuestas de prevista
                Usuario u = g.getUsuario(email);
                if (u.prevista != null)
                {
                    foreach (Propuesta p in u.prevista.propuestas)
                    {
                        props.Add(p);
                    }
                }

                //genro revision
                ret = m.toHTML(props, g, email, width, Modelo.eModo.revisar); //las propuesta debe ir en orden de nivel
            }
            return(ret);
        }
Esempio n. 4
0
        public Nodo simAgregarNodo(Grupo g, Usuario u, Nodo selected, int generacion)
        {
            //agrego nodo
            //creo texto segun nivel y modelo de documento
            Modelo    m    = g.organizacion.getModeloDocumento("nabu.plataforma.modelos.Accion"); //modelo de simulacion (Accion)
            Propuesta prop = new Propuesta();

            prop.email    = u.email;
            prop.modeloID = m.id;
            prop.nivel    = selected.nivel + 1; //esta propuesta es para el hijo que voy a crear
            prop.nodoID   = selected.id;
            prop.niveles  = 5;
            prop.titulo   = Tools.tr("Documento simulado", g.idioma);
            prop.etiqueta = generacion.ToString();

            //lleno datos de prueba
            foreach (Variable v in m.getVariables())
            {
                if (v.id == "s.etiqueta")
                {
                    prop.bag.Add("s.etiqueta", "Sim");
                }
                else if (v.id == "s.titulo")
                {
                    prop.bag.Add("s.titulo", Tools.tr("Documento simulado", g.idioma));
                }
                else
                {
                    prop.bag.Add(v.id, Tools.tr("Simulacion", g.idioma));
                }
            }

            Nodo nuevoNodo = g.arbol.addNodo(selected, prop);

            return(nuevoNodo);
        }
Esempio n. 5
0
        private void generarDocumentoHTML(Nodo n, DateTime now, string fname, string docPath, string URL)
        {
            List <Nodo> pathn  = getPath(n.id);
            Modelo      m      = grupo.organizacion.getModeloDocumento(n.modeloID);
            DateTime    inicio = DateTime.MaxValue;

            //junto propuestas
            List <Propuesta> props = new List <Propuesta>();

            foreach (Nodo n1 in pathn)
            {
                Propuesta p = getPropuesta(n1);
                if (p != null) //la raiz
                {
                    props.Add(p);
                    if (p.born < inicio)
                    {
                        inicio = p.born;
                    }
                }
            }
            //firma consenso
            string ret = "";

            ret += "Documento escrito de forma cooperativa.<br>";
            ret += "Grupo: " + this.nombre + "<br>";
            ret += "Documento ID:" + fname + "<br>";
            ret += "Inicio de debate: " + inicio.ToString("dd/MM/yy") + "<br>";
            ret += "Fecha de consenso: " + DateTime.Now.ToString("dd/MM/yy") + " " + DateTime.Now.ToShortTimeString() + "<br>";
            ret += "Ubicaci&oacute;n: <a target='_blank' href='" + URL + "'>" + URL + "</a><br>";
            ret += "Objetivo: " + this.grupo.objetivo + "<br>";
            ret += "Usuarios: " + this.grupo.getUsuariosHabilitados().Count + "<br>";
            ret += "Activos: " + this.grupo.activos + "<br>";
            ret += "Si: (&ge; " + this.minSiPc + "%): " + n.flores + "<br>";
            ret += "No: (&le; " + this.maxNoPc + "%): " + n.negados + "<br>";

            //admin
            if (this.grupo.getAdmin() != null)
            {
                ret += "Coordinador: " + grupo.getAdmin().nombre + "<br>";
            }

            //representates
            ret += "Representantes: ";
            foreach (Usuario rep in this.grupo.getRepresentantes())
            {
                ret += rep.nombre + ",";
            }
            if (ret.EndsWith(","))
            {
                ret = ret.Substring(0, ret.Length - 1);
            }
            ret += "<br>";

            //secretaria
            if (this.grupo.getSecretaria() != null)
            {
                ret += "Secretaria: " + grupo.getSecretaria().nombre + "<br>";
            }

            //facilitador
            if (this.grupo.getFacilitador() != null)
            {
                ret += "Facilitador: " + grupo.getFacilitador().nombre + "<br>";
            }

            //armo HTML
            string html = "";

            try
            {
                m.firmaConsenso = ret;
                html            = m.toHTML(props, this.grupo, "", 1024, Modelo.eModo.consenso);
            }
            catch (Exception ex)
            {
                throw new Exception("generarDocumentoHTML():toHTML():" + m.nombre + ":" + ex.Message + " " + ex.StackTrace);
            }

            //escribo
            System.IO.File.WriteAllText(grupo.path + "\\" + docPath + "\\" + fname + ".html", html, System.Text.Encoding.UTF8);
        }
Esempio n. 6
0
        private bool comprobarConsenso(Nodo n, string email)
        {
            bool        ret   = false;
            Modelo      m     = grupo.organizacion.getModeloDocumento(n.modeloID);
            List <Nodo> pathn = getPath(n.id);

            if (m != null && n.nivel == n.niveles)
            {
                //es una hoja de documento completo, verifico condicion
                n.negados = getNegados(n);

                //condicion de consenso
                if (!n.consensoAlcanzado &&
                    n.flores >= minSiValue &&
                    n.negados <= maxNoValue)
                {
                    //esta rama ha alcanzado el consenso
                    //genero documento
                    DateTime fdate   = DateTime.Now;
                    int      docID   = lastDocID++;
                    string   fname   = m.nombre + "_" + docID.ToString("0000");
                    string   docPath = "documentos\\" + m.carpeta() + "\\" + docID.ToString("0000");
                    string   URL     = grupo.URL + "/grupos/" + nombre + "/" + docPath.Replace('\\', '/') + "/" + fname + ".html";

                    //creo carpeta se salida
                    //crearCarpeta(docPath);
                    if (!System.IO.Directory.Exists(grupo.path + "\\" + docPath))
                    {
                        System.IO.Directory.CreateDirectory(grupo.path + "\\" + docPath);
                        System.IO.Directory.CreateDirectory(grupo.path + "\\" + docPath + "\\res\\documentos");
                        System.IO.File.Copy(grupo.path + "\\..\\..\\styles.css", grupo.path + "\\" + docPath + "\\styles.css");
                        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(grupo.path + "\\..\\..\\res\\documentos");
                        foreach (System.IO.FileInfo fi in di.GetFiles())
                        {
                            System.IO.File.Copy(fi.FullName, grupo.path + "\\" + docPath + "\\res\\documentos\\" + fi.Name);
                        }
                    }

                    //guardo HTML
                    generarDocumentoHTML(n, fdate, fname, docPath, URL);

                    //guardo documento
                    Documento doc = crearDocumento(n, fdate, fname, docPath, URL);

                    //ejecuto proceso de consenso alcanzado
                    try
                    {
                        doc.grupo = grupo;
                        doc.EjecutarConsenso();
                    }
                    catch (Exception ex)
                    {
                        doc.addLog("EjecutarConsenso: <font color=red>" + ex.Message + "</font>");
                    }

                    //guardo el documento
                    doc.save();

                    //notifico via email a todos los socios
                    if (!simulacion)
                    {
                        foreach (Usuario u in grupo.usuarios)
                        {
                            if (u.email != email)
                            {
                                Tools.encolarMailNuevoConsenso(grupo, u.email, n.flores, n.negados, URL);
                                u.alertas.Add(new Alerta(Tools.tr("Nueva decision [%1]", doc.nombre + ": " + doc.titulo, grupo.idioma)));
                            }
                        }
                    }

                    //cruzo modelo con valores
                    Propuesta        p;
                    List <Propuesta> props = new List <Propuesta>();
                    foreach (Nodo n1 in pathn)
                    {
                        p = getPropuesta(n1);
                        if (p != null) //la raiz
                        {
                            props.Add(p);
                        }
                    }

                    //guardo el log historico en el arbol
                    p = getPropuesta(n.id);  //obtengo el titulo del debate de cualquiera de las propuestas
                    LogDocumento ld = new LogDocumento();
                    ld.fecha  = fdate;
                    ld.titulo = p.titulo;
                    ld.icono  = grupo.organizacion.getModeloDocumento(n.modeloID).icono;
                    if (ld.titulo.Length > 50)
                    {
                        ld.titulo = ld.titulo.Substring(0, 50);
                    }
                    ld.modeloNombre = grupo.organizacion.getModeloDocumento(n.modeloID).nombre;
                    ld.modeloID     = n.modeloID;
                    ld.x            = n.x; if (ld.x == 0)
                    {
                        ld.x = 90;
                    }
                    ld.docID        = docID;
                    ld.fname        = fname;
                    ld.arbol        = nombre;
                    ld.objetivo     = grupo.objetivo;
                    ld.flores       = n.flores;
                    ld.negados      = n.negados;
                    ld.carpeta      = m.carpeta();
                    ld.URL          = URL;
                    ld.revisionDias = m.getRevisionDias(props);
                    grupo.logDecisiones.Add(ld);

                    //marco a todos los nodos del debate y sus propuestas
                    for (int i = 0; i < pathn.Count - 1; i++) //menos la raiz
                    {
                        pathn[i].consensoAlcanzado = true;
                        getPropuesta(pathn[i]).consensoAlcanzado = true;
                        foreach (Nodo n2 in pathn[i].children)
                        {
                            marcarConsenso(n2);
                        }
                    }

                    grupo.save(grupo.path + "\\" + docPath); //guardo copia del arbol

                    ret = true;
                }
            }
            return(ret);
        }