private void insertAABehaveTables(Boolean auto, wp.Paragraph par)
        {
            List<ReportRow> results;
            MediasCompetencia medias;
            wp.Paragraph tempPar = new wp.Paragraph(); ;
            wp.TableRow tRow;
            setupAABehaveTableTemplate();
            int count;
            wp.Table novaTabela = tempTable.Clone() as wp.Table;

            clearParagraphText(par);

            // temos de lidar aqui com o bloco dos derailers
            foreach (FamiliaCompetencias fam in _Modelo.Familias.Values)
                foreach (Competencia comp in fam.Competencias.Values.Where(a => a.Type != "D"))
                {
                    results = repCalcs.getAvaliacaoComportamentosCriticosExtended(comp.CompetenciaID);
                    medias = repCalcs.getMediasCompetencia(comp.CompetenciaID);

                    tRow = tempRowHeader.Clone() as wp.TableRow;
                    setText(repCalcs.getCompetenciaText(comp.CompetenciaID), tRow.Elements<wp.TableCell>().ElementAt(0));

                    setText(medias.mS.ToString("0.00"), tRow.Elements<wp.TableCell>().ElementAt(1));
                    novaTabela.Append(tRow);

                    tRow = tempRowSeparador.Clone() as wp.TableRow; //separador
                    novaTabela.Append(tRow);

                    tRow = tempRowHeader2.Clone() as wp.TableRow; //segundo header
                    novaTabela.Append(tRow);

                    count = 1;
                    results.RemoveAt(0); // para retirara as legendas que aqui naão são utilizadas

                    foreach (ReportRow rr in results)
                    {
                        if (count % 2 == 0)
                        {
                            //par
                            tRow = tempRowPar.Clone() as wp.TableRow;
                        }
                        else
                        {
                            //impar
                            tRow = tempRowImpar.Clone() as wp.TableRow;
                        }

                        setText(rr.dados[0], tRow.Elements<wp.TableCell>().ElementAt(0));
                        if (rr.dados[1] == "0")
                            rr.dados[1] = "";
                        setText(rr.dados[1], tRow.Elements<wp.TableCell>().ElementAt(1));
                        if (rr.dados[6] == "-1.00")
                            rr.dados[6] = "-";
                        setText(rr.dados[6], tRow.Elements<wp.TableCell>().ElementAt(2));
                        novaTabela.Append(tRow);
                        count++;
                    }

                    // colocar um parágrafo

                    novaTabela.Append(tempParagraph.Clone() as wp.Paragraph);

                }

            par.RemoveAllChildren<wp.Text>();
            par.Append(novaTabela);
        }
        private void insertAADerailers(wp.Paragraph par)
        {
            List<ReportRow> results;
            wp.Paragraph tempPar = new wp.Paragraph(); ;
            wp.TableRow tRow;
            setupAADerailersTableTemplate();
            int count;
            wp.Table novaTabela = tempTable.Clone() as wp.Table;
            wp.SymbolChar simbolo;
            float valor;
            clearParagraphText(par);

            // temos de lidar aqui com o bloco dos derailers
            foreach (FamiliaCompetencias fam in _Modelo.Familias.Values)
                foreach (Competencia comp in fam.Competencias.Values.Where(a => a.Type == "D"))
                {
                    results = repCalcs.getAvaliacaoDerailersExtended(comp.CompetenciaID);
                    //medias = repCalcs.getMediasCompetencia(comp.CompetenciaID);

                    tRow = tempRowHeader.Clone() as wp.TableRow;
                    setText(repCalcs.getCompetenciaText(comp.CompetenciaID), tRow.Elements<wp.TableCell>().ElementAt(0));

                    //setText(medias.mS.ToString("0.00"), tRow.Elements<wp.TableCell>().ElementAt(1));
                    novaTabela.Append(tRow);

                    tRow = tempRowSeparador.Clone() as wp.TableRow; //separador
                    novaTabela.Append(tRow);

                    tRow = tempRowHeader2.Clone() as wp.TableRow; //segundo header
                    novaTabela.Append(tRow);

                    count = 1;
                    results.RemoveAt(0); // para retirara as legendas que aqui não são utilizadas

                    foreach (ReportRow rr in results)
                    {
                        if (count % 2 == 0)
                        {
                            //par
                            tRow = tempRowPar.Clone() as wp.TableRow;
                        }
                        else
                        {
                            //impar
                            tRow = tempRowImpar.Clone() as wp.TableRow;
                        }

                        setText(rr.dados[0], tRow.Elements<wp.TableCell>().ElementAt(0));
                        valor = float.Parse(rr.dados[6]);

                        if (valor <= 2)
                        {
                            // on target
                            simbolo = symbTarget.Clone() as wp.SymbolChar;
                        }
                        else if (valor >= 4)
                        {
                            // a desenvolver
                            simbolo = symbDelevop.Clone() as wp.SymbolChar;
                        }
                        else
                        {
                            // neutro
                            simbolo = symbNeutral.Clone() as wp.SymbolChar;
                        }

                        tRow.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().AppendChild<wp.SymbolChar>(simbolo);

                        if (rr.dados[6] == "-1.00")
                            rr.dados[6] = "-";
                        setText(rr.dados[6], tRow.Elements<wp.TableCell>().ElementAt(2));
                        novaTabela.Append(tRow);
                        count++;
                    }

                    // colocar um parágrafo

                    novaTabela.Append(tempParagraph.Clone() as wp.Paragraph);

                }

            par.RemoveAllChildren<wp.Text>();
            par.Append(novaTabela);
        }
        private void insertHABehaveTables(Boolean auto, wp.Paragraph par)
        {
            List<ReportRow> results;
            MediasCompetencia medias;
            wp.Paragraph tempPar = new wp.Paragraph(); ;
            wp.TableRow tRow;
            int count;
            wp.Run rSymbol;

            setupHABehaveTableTemplate();
            wp.Table novaTabela = tempTable.Clone() as wp.Table;

            String vh, va;

            clearParagraphText(par);

            foreach (FamiliaCompetencias fam in _Modelo.Familias.Values)
                foreach (Competencia comp in fam.Competencias.Values.Where(a => a.Type != "D"))
                {
                    if ("Orientação para Resultados" == repCalcs.getCompetenciaText(comp.CompetenciaID))
                        vh = "";

                    results = repCalcs.getAvaliacaoComportamentosCriticosExtendedOne2One(comp.CompetenciaID);
                    medias = repCalcs.getMediasCompetencia(comp.CompetenciaID);

                    tRow = tempRowHeader.Clone() as wp.TableRow;
                    setText(repCalcs.getCompetenciaText(comp.CompetenciaID), tRow.Elements<wp.TableCell>().ElementAt(0));

                    setText(medias.mS.ToString("0.00"), tRow.Elements<wp.TableCell>().ElementAt(2));
                    setText(medias.mT.ToString("0.00"), tRow.Elements<wp.TableCell>().ElementAt(3));

                    tempPar = tRow.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First();
                    rSymbol = tempPar.Elements<wp.Run>().First();

                    if (medias.mS > medias.mT)
                    {
                        rSymbol.Elements<wp.SymbolChar>().First().Char = symbUp.Char;
                    }
                    else if (medias.mS < medias.mT)
                    {
                        rSymbol.Elements<wp.SymbolChar>().First().Char = symbDw.Char;
                    }
                    else
                    {
                        rSymbol.Elements<wp.SymbolChar>().First().Char = symbH.Char;
                    }

                    novaTabela.Append(tRow);

                    tRow = tempRowHeader2.Clone() as wp.TableRow; //segundo header
                    novaTabela.Append(tRow);

                    count = 1;
                    results.RemoveAt(0); // para retirara as legendas que aqui naão são utilizadas

                    foreach (ReportRow rr in results)
                    {
                        vh = "";
                        va = "";

                        if (count % 2 == 0)
                        {
                            //par
                            tRow = tempRowPar.Clone() as wp.TableRow;
                        }
                        else
                        {
                            //impar
                            tRow = tempRowImpar.Clone() as wp.TableRow;
                        }

                        setText(rr.dados[0], tRow.Elements<wp.TableCell>().ElementAt(0));

                        tempPar = tRow.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First();
                        rSymbol = tempPar.Elements<wp.Run>().First();

                        if (rr.dados[6] == "-1,00")
                            vh = "-";
                        else
                            vh = rr.dados[6];

                        if (rr.dados[7] == "-1,00")
                            va = "-";
                        else va = rr.dados[7];

                        setText(vh, tRow.Elements<wp.TableCell>().ElementAt(2));
                        setText(va, tRow.Elements<wp.TableCell>().ElementAt(3));

                        // o dados de 7 e o dados de 6 podem viR A nullo

                        if (va != "-" && vh != "-" && rr.dados[7] != null && rr.dados[6] != null)
                        {
                            if (float.Parse(rr.dados[6].Replace(",", ".")) > float.Parse(rr.dados[7].Replace(",", ".")))
                            {
                                rSymbol.Elements<wp.SymbolChar>().First().Char = symbUp.Char;
                                CountUps++;
                            }
                            else if (float.Parse(rr.dados[6].Replace(",", ".")) < float.Parse(rr.dados[7].Replace(",", ".")))
                            {
                                rSymbol.Elements<wp.SymbolChar>().First().Char = symbDw.Char;
                                CountDown++;
                            }
                            else
                            {
                                rSymbol.Elements<wp.SymbolChar>().First().Char = symbH.Char;
                                CountHoriz++;
                            }
                        }
                        else
                            rSymbol.Elements<wp.SymbolChar>().First().Char = "F09F";

                        novaTabela.Append(tRow);
                        count++;
                    }

                    // colocar um parágrafo
                    novaTabela.Append(tempParagraph.Clone() as wp.Paragraph);
                }

            par.Append(novaTabela);
        }
        //private void insertTable_Ranking(wp.Paragraph par, List<ReportRow> rows, String tipo)
        //{
        //    if (!rankingTables)
        //    {
        //        setupRankingTables();
        //    }
        //    if (rows == null)
        //    {
        //        par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";
        //        return;
        //    }
        //    // Selecionar o template apropriado
        //    wp.TableRow theRow;
        //    wp.Table theTable = (wp.Table)tableRankS.Clone();
        //    wp.Paragraph theHeader = (wp.Paragraph)parHeadingParS.Clone();
        //    switch (tipo)
        //    {
        //        case "T":
        //            theTable = (wp.Table)tableRankT.Clone();
        //            theHeader = (wp.Paragraph)parHeadingParT.Clone();
        //            break;
        //        case "B":
        //            theTable = (wp.Table)tableRankB.Clone();
        //            theHeader = (wp.Paragraph)parHeadingParB.Clone();
        //            break;
        //        case "C":
        //            theTable = (wp.Table)tableRankC.Clone();
        //            theHeader = (wp.Paragraph)parHeadingParC.Clone();
        //            break;
        //        case "P":
        //            theTable = (wp.Table)tableRankP.Clone();
        //            theHeader = (wp.Paragraph)parHeadingParP.Clone();
        //            break;
        //        case "O":
        //            theTable = (wp.Table)tableRankO.Clone();
        //            theHeader = (wp.Paragraph)parHeadingParO.Clone();
        //            break;
        //    }
        //    // criar a tabela
        //    int count = 0;
        //    wp.Paragraph tempPar;
        //    foreach (ReportRow rr in rows)
        //    {
        //        if (count % 2 == 0)
        //            theRow = (wp.TableRow)trRankRowPar.Clone();
        //        else
        //            theRow = (wp.TableRow)trRankRowImpar.Clone();
        //        for (int i = 0; i < rr.dados.Length; i++)
        //        {
        //            tempPar = theRow.Elements<wp.TableCell>().ElementAt(i).Elements<wp.Paragraph>().First();
        //            tempPar.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[i];
        //        }
        //        theTable.Append(theRow);
        //        count++;
        //    }
        //    // INSERE O HEADER
        //    par.Append(theHeader);
        //    // INSERE A TABELA
        //    par.Append(theTable);
        //    // eliminar o texto do marcador
        //    clearParagraphText(par);
        //}
        private void insertTable_Gaps(wp.Paragraph par, List<ReportRow> rows, String tipo)
        {
            int index = 0;
            int counter = 0;

            if (!gapTables)
            {
                setupGapTables();
            }
            if (rows == null)
            {
                par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";
                return;
            }

            foreach (String s in _projecto.GroupsCodes)
            {
                if (s == tipo)
                {
                    index = counter;
                }
                counter++;
            }

            // Selecionar o template apropriado
            wp.TableRow theRow;
            wp.Table theTable = (wp.Table)tablesRank[index].Clone();
            wp.Paragraph theHeader = (wp.Paragraph)parsHeading[index].Clone();

            /*
            switch (tipo)
            {
                case "Co":
                    theTable = (wp.Table)tableRankB.Clone();
                    theHeader = (wp.Paragraph)parHeadingParB.Clone();
                    break;
                case "Me":
                    theTable = (wp.Table)tableRankC.Clone();
                    theHeader = (wp.Paragraph)parHeadingParC.Clone();
                    break;
                case "Mg":
                    theTable = (wp.Table)tableRankP.Clone();
                    theHeader = (wp.Paragraph)parHeadingParP.Clone();
                    break;
                case "Ve":
                    theTable = (wp.Table)tableRankO.Clone();
                    theHeader = (wp.Paragraph)parHeadingParO.Clone();
                    break;
                case "Pa":
                    theTable = (wp.Table)tableRankO.Clone();
                    theHeader = (wp.Paragraph)parHeadingParO.Clone();
                    break;
            }
            */

            // criar a tabela
            int count = 0;
            wp.Paragraph tempPar;

            foreach (ReportRow rr in rows)
            {
                if (count % 2 == 0)
                    theRow = (wp.TableRow)trRankRowPar.Clone();
                else
                    theRow = (wp.TableRow)trRankRowImpar.Clone();

                for (int i = 0; i < rr.dados.Length - 1; i++)
                {
                    tempPar = theRow.Elements<wp.TableCell>().ElementAt(i).Elements<wp.Paragraph>().First();
                    tempPar.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[i];
                }

                //tempPar = theRow.Elements<wp.TableCell>().ElementAt(rr.dados.Length - 1).Elements<wp.Paragraph>().First();
                // wp.Run rSymbol = tempPar.Elements<wp.Run>().First();
                // rSymbol.Elements<wp.SymbolChar>().First().Char = rr.dados[rr.dados.Length - 1];

                if (rr.dados[rr.dados.Length - 1] == "F0F1")
                    theRow.Elements<wp.TableCell>().ElementAt(rr.dados.Length - 1).Elements<wp.Paragraph>().First().Append((wp.Run)UpSign.Clone());
                else if (rr.dados[rr.dados.Length - 1] == "F0F2")
                    theRow.Elements<wp.TableCell>().ElementAt(rr.dados.Length - 1).Elements<wp.Paragraph>().First().Append((wp.Run)EqSign.Clone());
                else
                    theRow.Elements<wp.TableCell>().ElementAt(rr.dados.Length - 1).Elements<wp.Paragraph>().First().Append((wp.Run)LessSign.Clone());

                theTable.Append(theRow);
                count++;
            }

            // INSERE O HEADER
            par.Append(theHeader);

            // INSERE A TABELA
            par.Append(theTable);

            // eliminar o texto do marcador
            clearParagraphText(par);
        }
Example #5
0
    private void insertComentariosGroup(wp.Paragraph par, List<ReportRow> rows, String GroupID)
    {
        wp.Table tableComents;
        wp.TableRow trComents;
        wp.TableRow trHeader;
        wp.TableRow trComentsSep;
        wp.Paragraph parComentsSeparator;
        wp.Paragraph HeaderPar;

        // vai buscar o template para os comentários
        String templateDoc = _projecto.Template_Mnemonica;

        String filename = templatePath + "\\" + templateDoc + "_COMMENTS_BY_GROUP.docx";
        wp.TableRow tr;

        using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(filename, true))
        {

            HeaderPar = (wp.Paragraph)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().ElementAt(0).Clone();

            tableComents = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(0).Clone();

            trHeader = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(0);
            trComents = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(1);
            trComentsSep = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(2);
            trComentsSep.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().ElementAt(0).Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";

            tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();
            tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();
            tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();

            parComentsSeparator = (wp.Paragraph)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().ElementAt(0);
        }

        // produzir a secção de comentários

        if (rows == null)
        {
            par.Append((wp.Paragraph)parComentsSeparator.Clone());
        }
        else if (rows.Count == 0)
        {
            par.Append((wp.Paragraph)parComentsSeparator.Clone());
        }
        else
        {
            // o início da secção
            wp.Paragraph h = (wp.Paragraph)HeaderPar.Clone();
            h.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = GroupID;
            par.Append(h);

            foreach (ReportRow rr in rows)
            {
                if (rr.dados[0] == "BREAK")
                    tr = trComentsSep.Clone() as wp.TableRow;
                else if (rr.dados[0] != "")
                {
                    tr = trHeader.Clone() as wp.TableRow;
                    tr.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = repCalcs.getCompetenciaText(int.Parse(rr.dados[0]));
                }
                else
                {
                    tr = trComents.Clone() as wp.TableRow;
                    tr.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[1];
                }
                tableComents.Append(tr);
            }
            par.Append(tableComents);
        }

        // eliminar o texto do marcador
        par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";
    }
Example #6
0
 private static void ModifyWordParagraphTextContent(OXW.Paragraph paragraph, string txt)
 {
     if (null != paragraph)
     {
         OXW.Run run = paragraph.Descendants<OXW.Run>().FirstOrDefault();
         if (null != run)
         {
             run = run.CloneNode(true) as OXW.Run;
             paragraph.RemoveAllChildren<OXW.Run>();
         }
         else
         {
             run = new OXW.Run();
         }
             OXW.Text text = run.Descendants<OXW.Text>().FirstOrDefault();
             text = (null == text ? new OXW.Text() : text.CloneNode(true) as OXW.Text);
             run.RemoveAllChildren<OXW.Text>();
             text.Text = txt;
         if (!string.IsNullOrEmpty(txt) && (char.IsWhiteSpace(txt[0]) || char.IsWhiteSpace(txt[txt.Length-1]))) {
             text.Space = SpaceProcessingModeValues.Preserve;
         }
             run.Append(text);
             paragraph.Append(run);
         }
 }
Example #7
0
    private void insertSkillList(wp.Paragraph par)
    {
        String template = templatePath + "\\" + _projecto.Template_Mnemonica + "_SKILS_TABLE" + ".docx";

        wp.Paragraph templatePar;

        using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(template, true))
        {
            wp.Run r;
            wp.Text t;
            wp.Paragraph p;

            templatePar = wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().First();
            foreach (FamiliaCompetencias fam in _Modelo.Familias.Values)
            {
                foreach (Competencia comp in fam.Competencias.Values)
                {
                    if (comp.Type == "C") continue;

                    p = (wp.Paragraph)templatePar.Clone();
                    r = p.Elements<wp.Run>().First();
                    t = r.Elements<wp.Text>().First();

                    t.Text = comp.PublicName;
                    par.Append(p);
                }
            }
        }

        // eliminar o texto do marcador
        clearParagraphText(par);
    }
        private void insertComentarios(wp.Paragraph par, List<ReportRow> rows)
        {
            wp.Table tableComents;
            wp.TableRow trComents;
            wp.TableRow trHeader;
            wp.TableRow trComentsSep;
            wp.Paragraph parComentsSeparator;

            // vai buscar o template para os comentários
            String templateDoc = _projecto.Template_Mnemonica;

            String filename = rootPath + "docTemplates\\" + templateDoc + "_COMENTS.docx";
            wp.TableRow tr;

            using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(filename, true))
            {

                tableComents = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(0).Clone();

                trHeader = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(0);
                trComents = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(1);
                trComentsSep = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(2);
                trComentsSep.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";

                tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();
                tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();
                tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();

                parComentsSeparator = (wp.Paragraph)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().ElementAt(0);
            }

            // produzir a secção de comentários

            if (rows == null)
            {
                par.Append((wp.Paragraph)parComentsSeparator.Clone());
            }
            else
            {
                foreach (ReportRow rr in rows)
                {
                    if (rr.dados[0] == "BREAK")
                        tr = trComentsSep.Clone() as wp.TableRow;
                    else if (rr.dados[0] != "")
                    {
                        tr = trHeader.Clone() as wp.TableRow;
                        tr.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[0];
                    }
                    else
                    {
                        tr = trComents.Clone() as wp.TableRow;
                        tr.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[1];
                    }
                    tableComents.Append(tr);
                }
                par.Append(tableComents);
            }

            // eliminar o texto do marcador
            par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";
        }
Example #9
0
    private void insertHAAADerailers(wp.Paragraph par)
    {
        List<ReportRow> results;
        MediasCompetencia medias;
        wp.Paragraph tempPar = new wp.Paragraph(); ;
        wp.TableRow tRow;
        int count;
        wp.Run rSymbol;

        wp.SymbolChar simbolo;

        setupHAAADerailersTableTemplate();
        wp.Table novaTabela = tempTable.Clone() as wp.Table;

        String vh, va;

        clearParagraphText(par);

        foreach (FamiliaCompetencias fam in _Modelo.Familias.Values)
            foreach (Competencia comp in fam.Competencias.Values.Where(a => a.Type == "D"))
            {

                results = repCalcs.getAvaliacaoDerailersExtendedOne2One(comp.CompetenciaID);
                medias = repCalcs.getMediasDerailer(comp.CompetenciaID);

                tRow = tempRowHeader.Clone() as wp.TableRow;
                setText(repCalcs.getCompetenciaText(comp.CompetenciaID), tRow.Elements<wp.TableCell>().ElementAt(0));

                //setText(medias.mS.ToString("0.00"), tRow.Elements<wp.TableCell>().ElementAt(2));
                //setText(medias.mT.ToString("0.00"), tRow.Elements<wp.TableCell>().ElementAt(3));

                //tempPar = tRow.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First();
                //rSymbol = tempPar.Elements<wp.Run>().First();

                if (medias.mS > medias.mT)
                {

                }
                else if (medias.mS < medias.mT)
                {

                }
                else
                {

                }

                novaTabela.Append(tRow);

                tRow = tempRowSeparador as wp.TableRow; //separador
                novaTabela.Append(tRow);

                tRow = tempRowHeader2 as wp.TableRow; //Segundo Header
                novaTabela.Append(tRow);

                count = 1;
                results.RemoveAt(0); // para retirara as legendas que aqui naão são utilizadas

                foreach (ReportRow rr in results)
                {
                    vh = "";
                    va = "";

                    if (count % 2 == 0)
                    {
                        //par
                        tRow = tempRowPar.Clone() as wp.TableRow;
                    }
                    else
                    {
                        //impar
                        tRow = tempRowImpar.Clone() as wp.TableRow;
                    }

                    setText(rr.dados[0], tRow.Elements<wp.TableCell>().ElementAt(0));

                    tempPar = tRow.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First();
                    //rSymbol = tempPar.Elements<wp.Run>().First();

                    if (rr.dados[6] == "-1,00")
                        vh = "-";
                    else
                        vh = rr.dados[6];

                    if (rr.dados[7] == "-1,00")
                        va = "-";
                    else va = rr.dados[7];

                    setText(vh, tRow.Elements<wp.TableCell>().ElementAt(1));
                    setText(va, tRow.Elements<wp.TableCell>().ElementAt(2));

                    // o dados de 7 e o dados de 6 podem viR A nullo

                    if (va != "-" && vh != "-" && rr.dados[7] != null && rr.dados[6] != null)
                    {
                        if (float.Parse(rr.dados[6].Replace(",", ".")) != float.Parse(rr.dados[7].Replace(",", ".")))
                        {
                            simbolo = symbDelevop.Clone() as wp.SymbolChar;
                            CountUps++;
                        }
                        else if (float.Parse(rr.dados[6].Replace(",", ".")) == float.Parse(rr.dados[7].Replace(",", ".")))
                        {
                            simbolo = symbNeutral.Clone() as wp.SymbolChar;
                            CountDown++;
                        }
                        else
                        {
                            simbolo = symbNeutral.Clone() as wp.SymbolChar;
                            CountHoriz++;
                        }
                    }
                    else
                        simbolo = symbTarget.Clone() as wp.SymbolChar;

                    tRow.Elements<wp.TableCell>().ElementAt(3).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().AppendChild<wp.SymbolChar>(simbolo);

                    novaTabela.Append(tRow);
                    count++;
                }

                // colocar um parágrafo
                novaTabela.Append(tempParagraph.Clone() as wp.Paragraph);
            }

        par.Append(novaTabela);
    }
Example #10
0
    private void insertOverviewSkill(wp.Paragraph par, MainDocumentPart mainPart)
    {
        // ir buscar o template
        // cria o documento final base com base no template
        String templateDoc = _projecto.Template_Mnemonica;

        String filename = templatePath + "\\" + templateDoc + "_OVERVIEW_SKILS_DETAILS.docx";

        wp.Paragraph parHeading = null;

        wp.Table tab1 = null;
        wp.TableRow rowTab1Par = null;
        wp.TableRow rowTab1Impar = null;
        wp.TableRow rowTab1Linha3 = null;

        wp.Run red = null;
        wp.Run yellow = null;
        wp.Run green = null;

        wp.Table legendaTab2 = null;
        wp.Paragraph quebraPagina = null;

        using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(filename, true))
        {
            try
            {
                // o primeiro Parágrafo tem o nome do subcapítulo
                parHeading = (wp.Paragraph)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().ElementAt(0);

                // primeira tabela do template
                tab1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(0).Clone();

                rowTab1Impar = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(1).Clone();
                rowTab1Par = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(2).Clone();
                rowTab1Linha3 = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(3).Clone();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();

                // apanha os run + e - (mais e menos)
                green = (wp.Run)rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                red = (wp.Run)rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                yellow = (wp.Run)rowTab1Linha3.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();

                // eliminar o mais e o menos das linhas e o tracinho
                rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Linha3.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();

            }
            catch
            {

            }

            //parágrafo quebra de página
            quebraPagina = new wp.Paragraph(new wp.Run(new wp.Text("")));
            quebraPagina.ParagraphProperties = new wp.ParagraphProperties();
            quebraPagina.ParagraphProperties.PageBreakBefore = new wp.PageBreakBefore();
            quebraPagina.ParagraphProperties.PageBreakBefore.Val = DocumentFormat.OpenXml.OnOffValue.FromBoolean(true);

        }
        // fim da recolha dos elementos template.
        // passamos para a inserção destes elementos para cada competência

        // eliminar o texto do marcador
        par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";

        wp.Paragraph p = null;
        wp.Run r = null;
        wp.Text t = null;
        wp.Table tab1Temp = null;

        wp.TableRow tab1r = null;
        wp.TableCell tab1c = null;

        int count = 0;

        String pergunta;
        //String tempTexto;
        int contaPaginas = 1;

        String gap;

        foreach (FamiliaCompetencias fam in _Modelo.Familias.Values)
            foreach (Competencia comp in fam.Competencias.Values)
            {
                // são duas páginas de detalhes por cada competência
                // header da 1ªpágina

                if (comp.Type == "C") continue; // é uma competência comentário
                if (comp.Type == "D") continue; // é uma zona de derrailers

                // Nome da competência
                p = (wp.Paragraph)parHeading.Clone();
                r = p.Elements<wp.Run>().First();
                t = r.Elements<wp.Text>().First();
                t.Text = repCalcs.getCompetenciaText(comp.CompetenciaID);

                par.Append(p);

                // PREPARA A TABELA COM OS DETALHES
                tab1Temp = (wp.Table)tab1.Clone();
                tab1r = (wp.TableRow)tab1Temp.Elements<wp.TableRow>().ElementAt(0); // header da tabela
                tab1c = tab1r.Elements<wp.TableCell>().ElementAt(0); // c´clula com o local para o texto

                // os valores obtidos em cada comportamento
                // List<ReportRow> dataComportamentos = repCalcs.getAvaliacaoComportamentosCriticos(comp.CompetenciaID);
                List<ReportRow> dataComportamentosFracosFortes = repCalcs.getAvaliacaoComportamentosCriticos_FracosFortes_3Fatores(comp.CompetenciaID);
                count = 0;
                foreach (Pratica prat in comp.Praticas.Values)
                {
                    if (tab1c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text == "#TEXT_PRATICA#")
                    {
                        String plainText;
                        if (Utility.theServer != null)
                            plainText = Regex.Replace(Utility.theServer.HtmlDecode(prat.Description), "<[^>]+?>", "");
                        else
                            plainText = prat.Description;

                        plainText = DBHelper.ParseTextProprio(plainText, new Pessoa(), false);

                        tab1c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = plainText;

                    }
                    foreach (Pergunta perg in prat.Perguntas.Values)
                    {
                        pergunta = repCalcs.getPergunta(perg.PerguntaID);
                        if (count % 2 == 0)
                        {
                            // linha par
                            tab1r = (wp.TableRow)rowTab1Par.Clone();
                        }
                        else
                        {
                            // linha impar
                            tab1r = (wp.TableRow)rowTab1Impar.Clone();
                        }

                        //seleciona a célula do texto
                        tab1c = tab1r.Elements<wp.TableCell>().ElementAt(0);

                        // introduz o texto da pergunta
                        tab1c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentosFracosFortes[count].dados[0];

                        // as cores desta linha (prática)
                        tab1c = tab1r.Elements<wp.TableCell>().ElementAt(2);
                        switch (dataComportamentosFracosFortes[count].dados[1])
                        {
                            case "C":
                                tab1c.Elements<wp.Paragraph>().First().Append((wp.Run)red.Clone());
                                break;
                            case "B":
                                tab1c.Elements<wp.Paragraph>().First().Append((wp.Run)yellow.Clone());
                                break;
                            case "A":
                                tab1c.Elements<wp.Paragraph>().First().Append((wp.Run)green.Clone());
                                break;
                        }

                        // junta às tabelas as linhas
                        tab1Temp.Append(tab1r);
                        count++;
                    }
                }

                // INSERE A TABELA
                par.Append(tab1Temp);
                par.Append((wp.Paragraph)quebraPagina.Clone());

                contaPaginas++;
            }
    }
Example #11
0
    private void insertGroupList(wp.Paragraph par)
    {
        String template = templatePath + "\\" + _projecto.Template_Mnemonica + "_SKILS_TABLE" + ".docx";

        wp.Paragraph templatePar;

        using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(template, true))
        {
            wp.Run r;
            wp.Text t;
            wp.Paragraph p;

            templatePar = wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().First();

            foreach (String s in _projecto.GroupsDescription)
            {
                p = (wp.Paragraph)templatePar.Clone();
                r = p.Elements<wp.Run>().First();
                t = r.Elements<wp.Text>().First();

                t.Text = s;
                par.Append(p);
            }
        }

        // eliminar o texto do marcador
        clearParagraphText(par);
    }
Example #12
0
    private void insertEscalaDesc(wp.Paragraph par, String scaleType)
    {
        String template = templatePath + "\\" + _projecto.Template_Mnemonica + "_SKILS_TABLE" + ".docx";

        wp.Paragraph templatePar;

        using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(template, true))
        {
            wp.Run r;
            wp.Text t;
            wp.Paragraph p;

            String[] Valores;
            String[] Descricoes;

            templatePar = wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().First();
            int count = 0;
            String StrEscala = _projecto.getCurrentConfig(scaleType);
            if (StrEscala == "")
            {
                if (scaleType == "SCALE")
                {
                    Valores = _Modelo.Scale.Split('|');
                    Descricoes = _Modelo.ScaleDesc.Split('|');
                }
                else
                {
                    try
                    {
                        Valores = _Modelo.Familias.First().Value.Competencias.First().Value.CriticalidadeScale.Split('|');
                        Descricoes = _Modelo.Familias.First().Value.Competencias.First().Value.CriticalidadeText.Split('|');
                    }
                    catch
                    {
                        Valores = new string[0];
                        Descricoes = new string[0];
                    }
                }
            }
            else
            {
                String[] Escalas = StrEscala.Split('«');
                Valores = Escalas[0].Split('|');
                Descricoes = Escalas[1].Split('|');
            }
            // o primeiro valor pode ser o NR, ou não
            foreach (String escValue in Valores)
            {
                p = (wp.Paragraph)templatePar.Clone();
                r = p.Elements<wp.Run>().First();
                t = r.Elements<wp.Text>().First();

                t.Text = Valores[count] + " - " + Descricoes[count];
                count++;
                par.Append(p);
            }
        }

        clearParagraphText(par);
    }
Example #13
0
    private void insertDetailsSkill(wp.Paragraph par, MainDocumentPart mainPart)
    {
        // na primira fase fazer sem os gráficos

        // ir buscar o template
        // cria o documento final base com base no template
        String templateDoc = _projecto.Template_Mnemonica;

        String filename = templatePath + "\\" + templateDoc + "_SKILS_DETAILS.docx";

        wp.Table tabTitulo1 = null;
        wp.Table tabTitulo2 = null;

        wp.Table tab1 = null;
        wp.TableRow rowTab1Par = null;
        wp.TableRow rowTab1Impar = null;

        wp.Table tab2 = null;
        wp.TableRow rowTab2Par = null;
        wp.TableRow rowTab2Impar = null;

        wp.Run plusSign = null;
        wp.Run minusSign = null;
        wp.Run naSign = null;
        wp.Run eqSign = null;

        wp.Run red = null;
        wp.Run orange = null;
        wp.Run yellow = null;
        wp.Run green = null;
        wp.Paragraph NRs = null;

        wp.Table legendaTab1 = null;
        wp.Table legendaTab2 = null;
        wp.Paragraph quebraPagina = null;

        Boolean inserirChart = true;
        Boolean Pagina1 = true;
        Boolean Pagina2 = true;

        using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(filename, true))
        {
            try
            {
                // primeira tabela do template
                tabTitulo1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(0).Clone();

                // primeira tabela com comportamentos
                tab1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(1).Clone();
                rowTab1Impar = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(1).Clone();
                rowTab1Par = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(2).Clone();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();

                // apanha os run + e - (mais e menos)
                minusSign = (wp.Run)rowTab1Impar.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                naSign = (wp.Run)rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                plusSign = (wp.Run)rowTab1Par.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                try
                {
                    eqSign = (wp.Run)rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                }
                catch
                {
                    eqSign = null;
                }
                // eliminar o mais e o menos das linhas e o tracinho
                rowTab1Impar.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Par.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                if (eqSign != null) rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();

                // depois tenho algures aqui a legenda da tabela
                legendaTab1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(2).Clone();

                // o primeiro parágrafpo tem idiciação de ter ou não o chart
                try
                {
                    wp.Text chartPar = (wp.Text)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().FirstOrDefault().Elements<wp.Run>().FirstOrDefault().Elements<wp.Text>().FirstOrDefault();
                    if (chartPar.Text != "")
                        inserirChart = true;
                    else
                        inserirChart = false;

                }
                catch
                {
                    inserirChart = false;
                }
            }
            catch
            {
                Pagina1 = false;
            }

            //parágrafo quebra de página
            quebraPagina = new wp.Paragraph(new wp.Run(new wp.Text("")));
            quebraPagina.ParagraphProperties = new wp.ParagraphProperties();
            quebraPagina.ParagraphProperties.PageBreakBefore = new wp.PageBreakBefore();
            quebraPagina.ParagraphProperties.PageBreakBefore.Val = DocumentFormat.OpenXml.OnOffValue.FromBoolean(true);

            try
            {
                // segundo header, também uma tabela
                //terá de se analisar o seu interior
                tabTitulo2 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(3).Clone();

                // tsegunda tabela
                tab2 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(4).Clone();
                rowTab2Impar = (wp.TableRow)tab2.Elements<wp.TableRow>().ElementAt(1).Clone();
                rowTab2Par = (wp.TableRow)tab2.Elements<wp.TableRow>().ElementAt(2).Clone();
                tab2.Elements<wp.TableRow>().ElementAt(1).Remove();
                tab2.Elements<wp.TableRow>().ElementAt(1).Remove();

                // agora os paragrafos de cor
                red = (wp.Run)rowTab2Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                orange = (wp.Run)rowTab2Impar.Elements<wp.TableCell>().ElementAt(3).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                yellow = (wp.Run)rowTab2Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                green = (wp.Run)rowTab2Par.Elements<wp.TableCell>().ElementAt(3).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                NRs = (wp.Paragraph)rowTab2Impar.Elements<wp.TableCell>().ElementAt(5).Elements<wp.Paragraph>().First().Clone();

                // eliminar os quadrados do template
                rowTab2Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab2Impar.Elements<wp.TableCell>().ElementAt(3).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab2Impar.Elements<wp.TableCell>().ElementAt(5).Elements<wp.Paragraph>().First().Remove();

                rowTab2Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab2Par.Elements<wp.TableCell>().ElementAt(3).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab2Par.Elements<wp.TableCell>().ElementAt(5).Elements<wp.Paragraph>().First().Remove();

                // legenda tabela 2
                // depois tenho algures aqui a legenda da tabela
                legendaTab2 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(5).Clone();
            }
            catch
            {
                Pagina2 = false;
            }
        }
        // fim da recolha dos elementos template.
        // passamos para a inserção destes elementos para cada competência

        // eliminar o texto do marcador
        par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";

        wp.Paragraph p = null;
        wp.Run r = null;
        wp.Text t = null;
        wp.Table tab = null;
        wp.Table tabTemp = null;
        wp.Table tab1Temp = null;
        wp.Table tab2Temp = null;

        wp.TableRow tab1r = null;
        wp.TableCell tab1c = null;
        wp.TableRow tab2r = null;
        wp.TableCell tab2c = null;

        wp.TableCell tcTemp = null;
        wp.TableRow trTemp = null;
        wp.TableCellProperties tcProps = null;

        int[] critic;
        int count = 0;

        String pergunta;
        //String tempTexto;
        int contaPaginas = 1;
        int ranking;
        String gap;

        foreach (FamiliaCompetencias fam in _Modelo.Familias.Values)
            foreach (Competencia comp in fam.Competencias.Values)
            {
                // são duas páginas de detalhes por cada competência
                // header da 1ªpágina
                if (Pagina1)
                {
                    if (comp.Type == "C") continue; // é uma competência comentário
                    if (comp.Type == "D") continue; // é uma zona de derrailers

                    // Nome da competência
                    tab = (wp.Table)tabTitulo1.Clone();
                    p = tab.Elements<wp.TableRow>().ElementAt(0).Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First();
                    r = p.Elements<wp.Run>().First();
                    t = r.Elements<wp.Text>().First();
                    t.Text = repCalcs.getCompetenciaText(comp.CompetenciaID);

                    // Matriz de criticalidade
                    try
                    {
                        tabTemp = (wp.Table)tab.Elements<wp.TableRow>().First().Elements<wp.TableCell>().ElementAt(1).Elements<wp.Table>().First();

                        // ajustar a cor de cada backgroud destas células
                        critic = repCalcs.getCompetenciaCriticalidadeMatrixPos(comp.CompetenciaID);
                        String porRef = critic[1].ToString() + critic[0].ToString();
                        String pos;
                        for (int x = 0; x < 3; x++)
                        {
                            trTemp = tabTemp.Elements<wp.TableRow>().ElementAt(x);
                            for (int y = 0; y < 3; y++)
                            {
                                pos = x.ToString() + y.ToString();
                                tcTemp = trTemp.Elements<wp.TableCell>().ElementAt(y);
                                tcProps = tcTemp.Elements<wp.TableCellProperties>().First();
                                if (pos != porRef)
                                {
                                    tcProps.Shading.Fill = "C0C0C0";
                                }
                                //if ((critic[0] - x) * 10 + critic[1] - y != 0)

                            }
                        }
                    }
                    catch
                    {

                    }
                    par.Append(tab);

                    // um parágrafo de espaçamento para que as tabelas não colem

                    String spreadsheetTemplate = templatePath + "\\" + templateDoc + "_CHART_BARS.xlsx";
                    // String spreadsheetFileName = rootPath + "generatedFiles\\" + templateDoc + _self.Email + ".xlsx";

                    // GRÁFICO
                    // insert um gráfico com o template definido neste parágrafo 5372100, Cy = 1914525
                    String relID;

                    if (inserirChart)
                    {
                        relID = insertChart(mainPart, par, spreadsheetTemplate, 5372100, 1914525);
                        ChartsToUpdate.Add(relID, repCalcs.DB_getDADOS_GRAFICO(comp.CompetenciaID));
                    }
                }

                // PREPARA AS DUAS TABELAS COM OS DETALHES
                if (Pagina1) tab1Temp = (wp.Table)tab1.Clone();
                if (Pagina2) tab2Temp = (wp.Table)tab2.Clone();

                // os valores obtidos em cada comportamento
                List<ReportRow> dataComportamentos = repCalcs.getAvaliacaoComportamentosCriticos(comp.CompetenciaID);
                List<ReportRow> dataComportamentosFracosFortes = repCalcs.getAvaliacaoComportamentosCriticos_FracosFortes(comp.CompetenciaID);
                count = 0;
                foreach (Pratica prat in comp.Praticas.Values)
                {
                    if (Pagina1)
                    {
                        if (tab1Temp.Elements<wp.TableRow>().First().Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text == "#TEXT_PRATICA#")
                        {
                            String plainText;
                            if (Utility.theServer != null)
                                plainText = Regex.Replace(Utility.theServer.HtmlDecode(prat.Description), "<[^>]+?>", "");
                            else
                                plainText = prat.Description;

                            plainText = DBHelper.ParseTextProprio(plainText, new Pessoa(), false);

                            tab1Temp.Elements<wp.TableRow>().First().Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = plainText;

                        }
                    }
                    if (Pagina2)
                    {
                        if (tab2Temp.Elements<wp.TableRow>().First().Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text == "#TEXT_PRATICA#")
                        {
                            String plainText;
                            if (Utility.theServer != null)
                                plainText = Regex.Replace(Utility.theServer.HtmlDecode(prat.Description), "<[^>]+?>", "");
                            else
                                plainText = prat.Description;

                            plainText = DBHelper.ParseTextProprio(plainText, new Pessoa(), false);

                            tab2Temp.Elements<wp.TableRow>().First().Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = plainText;

                        }
                    }
                    foreach (Pergunta perg in prat.Perguntas.Values)
                    {
                        pergunta = repCalcs.getPergunta(perg.PerguntaID);
                        if (count % 2 == 0)
                        {
                            // linha par
                            if (Pagina1) tab1r = (wp.TableRow)rowTab1Par.Clone();
                            if (Pagina2) tab2r = (wp.TableRow)rowTab2Par.Clone();

                        }
                        else
                        {
                            // linha impar
                            if (Pagina1) tab1r = (wp.TableRow)rowTab1Impar.Clone();
                            if (Pagina2) tab2r = (wp.TableRow)rowTab2Impar.Clone();
                        }

                        if (Pagina1) tab1c = tab1r.Elements<wp.TableCell>().ElementAt(0);
                        if (Pagina2) tab2c = tab2r.Elements<wp.TableCell>().ElementAt(0);

                        if (count + 1 < dataComportamentos.Count)
                        {
                            // introduz o texto da pergunta
                            if (Pagina1) tab1c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentos[count + 1].dados[0];
                            if (Pagina2) tab2c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentos[count + 1].dados[0];
                            // introduz os valores de cada prática
                            if (Pagina1)
                            {
                                for (int i = 1; i <= _projecto.GroupsCodes.Count(); i++)
                                {

                                    tab1c = tab1r.Elements<wp.TableCell>().ElementAt(i);
                                    fillPlusMinus(tab1c, dataComportamentos[count + 1].dados[i], plusSign, minusSign, naSign, eqSign);

                                }
                            }

                        }
                        // as cores desta linha (prática)
                        if (Pagina2)
                        {
                            tab2c = tab2r.Elements<wp.TableCell>().ElementAt(2);
                            switch (dataComportamentosFracosFortes[count].dados[1])
                            {
                                case "C":
                                    tab2c.Elements<wp.Paragraph>().First().Append((wp.Run)red.Clone());
                                    break;
                                case "B":
                                    tab2c.Elements<wp.Paragraph>().First().Append((wp.Run)orange.Clone());
                                    break;
                                case "A":
                                    tab2c.Elements<wp.Paragraph>().First().Append((wp.Run)yellow.Clone());
                                    break;
                            }
                        }

                        if (Pagina2)
                        {
                            tab2c = tab2r.Elements<wp.TableCell>().ElementAt(3);
                            if (dataComportamentosFracosFortes[count].dados[2] == "D")
                                tab2c.Elements<wp.Paragraph>().First().Append((wp.Run)green.Clone());

                            // a percentagem de não respostas
                            tab2c = tab2r.Elements<wp.TableCell>().ElementAt(5);
                            NRs.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentosFracosFortes[count].dados[3] + "%";

                            tab2c.Append((wp.Paragraph)NRs.Clone());
                        }
                        // junta às tabelas as linhas
                        if (Pagina1) tab1Temp.Append(tab1r);
                        if (Pagina2) tab2Temp.Append(tab2r);

                        count++;
                    }
                }

                // INSERE A TABELA 1
                if (Pagina1) par.Append(tab1Temp);
                // LEGENDA 1

                //tempTexto = "";

                //legendaTab1.Elements<wp.TableRow>().ElementAt(1).Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = tempTexto;
                if (Pagina1) par.Append((wp.Table)legendaTab1.Clone());

                // QUEBRA DE PÁGINA 1
                if (Pagina1) par.Append((wp.Paragraph)quebraPagina.Clone());

                // HEADER da 2ªpágina
                if (Pagina2)
                {
                    tab = (wp.Table)tabTitulo2.Clone();
                    p = tab.Elements<wp.TableRow>().ElementAt(1).Elements<wp.TableCell>().ElementAt(0).Elements<wp.Paragraph>().First();
                    r = p.Elements<wp.Run>().First();
                    t = r.Elements<wp.Text>().First();
                    t.Text = repCalcs.getCompetenciaText(comp.CompetenciaID);
                    try
                    {
                        // quadro dos RANKINGS ainda no header2
                        p = tab.Elements<wp.TableRow>().ElementAt(0).Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First();
                        r = p.Elements<wp.Run>().First();
                        t = r.Elements<wp.Text>().First();
                        ranking = repCalcs.getCompetenciaRanking(comp.CompetenciaID, "T");
                        t.Text = ranking == 0 ? "-" : ranking.ToString();

                        for (int i = 1; i < _projecto.GroupsCodes.Count(); i++)
                        {
                            p = tab.Elements<wp.TableRow>().ElementAt(0).Elements<wp.TableCell>().ElementAt(i + 2).Elements<wp.Paragraph>().First();
                            r = p.Elements<wp.Run>().First();
                            t = r.Elements<wp.Text>().First();
                            ranking = repCalcs.getCompetenciaRanking(comp.CompetenciaID, repCalcs.ReportGroupCodes[i]);
                            t.Text = ranking == 0 ? "-" : ranking.ToString();
                        }

                        // quadro dos GAPS ainda no header2
                        p = tab.Elements<wp.TableRow>().ElementAt(1).Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First();
                        r = p.Elements<wp.Run>().First();
                        gap = repCalcs.getCompetenciaGAP(comp.CompetenciaID, "T");
                        r.Elements<wp.SymbolChar>().First().Char = gap;

                        for (int i = 1; i < _projecto.GroupsCodes.Count(); i++)
                        {
                            p = tab.Elements<wp.TableRow>().ElementAt(1).Elements<wp.TableCell>().ElementAt(i + 2).Elements<wp.Paragraph>().First();
                            r = p.Elements<wp.Run>().First();
                            gap = repCalcs.getCompetenciaGAP(comp.CompetenciaID, repCalcs.ReportGroupCodes[i]);
                            r.Elements<wp.SymbolChar>().First().Char = gap;
                        }

                    }
                    catch
                    {

                    }

                    // INSERTE A TABELA DETALHE PAGINA 2
                    par.Append(tab);

                    // um parágrafo de espaçamento para que as tabelas não colem
                    par.Append(new wp.Paragraph());

                    // INSERE A TABELA 2
                    par.Append(tab2Temp);

                    // LEGENDA 2
                    //tempTexto = "";
                    par.Append((wp.Table)legendaTab2.Clone());

                    // QUEBRA DE PÁGINA 2
                    if (contaPaginas < repCalcs.getQuantidadeDeCompetencias())
                        par.Append((wp.Paragraph)quebraPagina.Clone());
                }
                contaPaginas++;
            }
    }
        private void insertAARank(wp.Paragraph par)
        {
            List<ReportRow> results;
            //MediasCompetencia medias;
            wp.Paragraph tempPar = new wp.Paragraph(); ;
            wp.TableRow tRow;
            setupAARankTable();
            wp.Table novaTabela = tempTable.Clone() as wp.Table;

            clearParagraphText(par);

            results = repCalcs.getRankingSELF();

            foreach (ReportRow rr in results)
            {
                tRow = tempRowImpar.Clone() as wp.TableRow;
                setText(rr.dados[0], tRow.Elements<wp.TableCell>().ElementAt(0));
                setText(rr.dados[2], tRow.Elements<wp.TableCell>().ElementAt(1));
                setText(rr.dados[1], tRow.Elements<wp.TableCell>().ElementAt(2));
                novaTabela.Append(tRow);
            }
            par.RemoveAllChildren<wp.Text>();
            par.Append(novaTabela);
        }
Example #15
0
    private void insertTable_Ranking(wp.Paragraph par, List<ReportRow> rows, String tipo)
    {
        if (!rankingTables)
        {
            setupRankingTables();
        }
        if (rows == null)
        {
            par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";
            return;
        }
        // Selecionar o template apropriado por defeito fica o G0
        wp.TableRow theRow;
        wp.Table theTable = (wp.Table)tableRankS.Clone();
        wp.Paragraph theHeader = (wp.Paragraph)parHeadingParS.Clone();

        switch (tipo)
        {
            case "T":
                theTable = (wp.Table)tableRankT.Clone();
                theHeader = (wp.Paragraph)parHeadingParT.Clone();
                break;
            case "G1":
                theTable = (wp.Table)tableRankB.Clone();
                theHeader = (wp.Paragraph)parHeadingParB.Clone();
                break;
            case "G2":
                theTable = (wp.Table)tableRankC.Clone();
                theHeader = (wp.Paragraph)parHeadingParC.Clone();
                break;
            case "G3":
                theTable = (wp.Table)tableRankP.Clone();
                theHeader = (wp.Paragraph)parHeadingParP.Clone();
                break;
            case "G4":
                theTable = (wp.Table)tableRankO.Clone();
                theHeader = (wp.Paragraph)parHeadingParO.Clone();
                break;
        }

        // criar a tabela
        int count = 0;
        wp.Paragraph tempPar;

        foreach (ReportRow rr in rows)
        {
            if (count % 2 == 0)
                theRow = (wp.TableRow)trRankRowPar.Clone();
            else
                theRow = (wp.TableRow)trRankRowImpar.Clone();
            for (int i = 0; i < rr.dados.Length; i++)
            {
                tempPar = theRow.Elements<wp.TableCell>().ElementAt(i).Elements<wp.Paragraph>().First();
                tempPar.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[i];
            }
            theTable.Append(theRow);
            count++;
        }

        // INSERE O HEADER
        par.Append(theHeader);

        // INSERE A TABELA
        par.Append(theTable);

        // eliminar o texto do marcador
        clearParagraphText(par);
    }
        private String insertChart(MainDocumentPart mainPart, wp.Paragraph par, String templateName, int dimx, int dimy)
        {
            String relId;
            // vai buscar o gráfico e coloca-o no local com a dimensão definida HARCODED
            wp.Paragraph chartP = new wp.Paragraph();
            wp.Run chartR = new wp.Run();
            chartP.Append(chartR);
            wp.Drawing drawing = new wp.Drawing();
            chartR.Append(drawing);

            clearParagraphText(par);

            //Open Excel spreadsheet
            using (SpreadsheetDocument mySpreadsheet = SpreadsheetDocument.Open(templateName, true))
            {
                //Get all the appropriate parts

                // assume que há apenas um gráfico por ficheiro template
                // isto deveria evoluir para um ficheiro apenas

                WorkbookPart workbookPart = mySpreadsheet.WorkbookPart;
                WorksheetPart worksheetPart = (WorksheetPart)workbookPart.GetPartById("rId1");
                DrawingsPart drawingPart = worksheetPart.DrawingsPart;
                ChartPart chartPart = (ChartPart)drawingPart.GetPartById("rId1");

                //Clone the chart part and add it to my Word document
                ChartPart importedChartPart = mainPart.AddPart<ChartPart>(chartPart);
                relId = mainPart.GetIdOfPart(importedChartPart);

                //The frame element contains information for the chart
                ssd.GraphicFrame frame = drawingPart.WorksheetDrawing.Descendants<ssd.GraphicFrame>().First();
                string chartName = frame.NonVisualGraphicFrameProperties.NonVisualDrawingProperties.Name;

                //Clone this node so we can add it to my Word document
                Graphic clonedGraphic = (Graphic)frame.Graphic.CloneNode(true);

                // clonedGraphic.GraphicData

                ChartReference c = clonedGraphic.GraphicData.GetFirstChild<ChartReference>();
                c.Id = relId;

                //Give the chart a unique id and name
                wpd.DocProperties docPr = new wpd.DocProperties();
                docPr.Name = chartName;
                docPr.Id = GetMaxDocPrId(mainPart) + 1;

                //add the chart data to the inline drawing object
                // wpd.Inline inline = new wpd.Inline(new wpd.Extent() { Cx = 5372100, Cy = 1914525 });
                wpd.Inline inline;
                if (dimx == 0 && dimy == 0)
                    inline = new wpd.Inline();
                else
                    inline = new wpd.Inline(new wpd.Extent() { Cx = dimx, Cy = dimy });
                inline.Append(docPr, clonedGraphic);
                drawing.Append(inline);
            }

            // JUNTA O GRÁFICO
            par.Append(chartP);

            // retorna o ID do gráfico que necessita update
            return relId;
        }
Example #17
0
 private static void ModifyWordCellTextContent(OXW.TableCell cell, string txt)
 {
     if (null != cell)
     {
         OXW.Paragraph paragraph = cell.Descendants<OXW.Paragraph>().FirstOrDefault();
         if (null != paragraph)
         {
             paragraph = paragraph.CloneNode(true) as OXW.Paragraph;
             ModifyWordParagraphTextContent(paragraph, txt);
             cell.RemoveAllChildren<OXW.Paragraph>();
             cell.Append(paragraph);
         }
     }
 }
        private void insertDetailsSkill(wp.Paragraph par, MainDocumentPart mainPart)
        {
            // na primira fase fazer sem os gráficos

            // ir buscar o template
            // cria o documento final base com base no template
            String templateDoc = _projecto.Template_Mnemonica;

            String filename = rootPath + "docTemplates\\" + templateDoc + "_SKILS_DETAILS.docx";

            wp.Table tabTitulo1;

            wp.Table tab1;
            wp.TableRow rowTab1Par;
            wp.TableRow rowTab1Impar;

            wp.Run plusSign;
            wp.Run minusSign;
            wp.Run naSign;
            wp.Run eqSign;

            wp.Table legendaTab1;
            wp.Paragraph quebraPagina;

            using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(filename, true))
            {
                // primeira tabela do template
                tabTitulo1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(0).Clone();

                // primeira tabela com comportamentos
                tab1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(1).Clone();
                rowTab1Impar = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(1).Clone();
                rowTab1Par = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(2).Clone();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();

                // apanha os run + e - (mais e menos)
                minusSign = (wp.Run)rowTab1Impar.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                naSign = (wp.Run)rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                plusSign = (wp.Run)rowTab1Par.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                eqSign = (wp.Run)rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();

                // eliminar o mais e o menos das linhas e o tracinho
                rowTab1Impar.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Par.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();

                // depois tenho algures aqui a legenda da tabela
                legendaTab1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(2).Clone();

                //parágrafo quebra de página
                quebraPagina = new wp.Paragraph(new wp.Run(new wp.Text("")));
                quebraPagina.ParagraphProperties = new wp.ParagraphProperties();
                quebraPagina.ParagraphProperties.PageBreakBefore = new wp.PageBreakBefore();
                quebraPagina.ParagraphProperties.PageBreakBefore.Val = DocumentFormat.OpenXml.OnOffValue.FromBoolean(true);

            }
            // fim da recolha dos elementos template.
            // passamos para a inserção destes elementos para cada competência

            // eliminar o texto do marcador
            par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";

            wp.Paragraph p;
            wp.Run r;
            wp.Text t;
            wp.Table tab;

            wp.Table tab1Temp;

            wp.TableRow tab1r;
            wp.TableCell tab1c;

            int count = 0;

            String pergunta;
            String tempTexto;
            int contaPaginas = 1;

            foreach (FamiliaCompetencias fam in _Modelo.Familias.Values)
                foreach (Competencia comp in fam.Competencias.Values)
                {
                    // são duas páginas de detalhes por cada competência
                    // header da 1ªpágina

                    if (comp.Type == "C") continue; // é uma competência comentário
                    if (comp.Type == "D") continue; // é uma zona de derrailers

                    // Nome da competência
                    tab = (wp.Table)tabTitulo1.Clone();
                    p = tab.Elements<wp.TableRow>().ElementAt(0).Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First();
                    r = p.Elements<wp.Run>().First();
                    t = r.Elements<wp.Text>().First();
                    t.Text = repCalcs.getCompetenciaText(comp.CompetenciaID);

                    par.Append(tab);// o nome da competência

                    // PREPARA AS DUAS TABELAS COM OS DETALHES
                    tab1Temp = (wp.Table)tab1.Clone();
                    // tab2Temp = (wp.Table)tab2.Clone();

                    // os valores obtidos em cada comportamento
                    List<ReportRow> dataComportamentos = repCalcs.getAvaliacaoComportamentosCriticos(comp.CompetenciaID);
                    List<ReportRow> dataComportamentosFracosFortes = repCalcs.getAvaliacaoComportamentosCriticos_FracosFortes(comp.CompetenciaID);
                    count = 0;
                    foreach (Pratica prat in comp.Praticas.Values)
                        foreach (Pergunta perg in prat.Perguntas.Values)
                        {
                            pergunta = repCalcs.getPergunta(perg.PerguntaID);
                            if (count % 2 == 0)
                            {
                                // linha par
                                tab1r = (wp.TableRow)rowTab1Par.Clone();
                                // tab2r = (wp.TableRow)rowTab2Par.Clone();
                            }
                            else
                            {
                                // linha impar
                                tab1r = (wp.TableRow)rowTab1Impar.Clone();
                                // tab2r = (wp.TableRow)rowTab2Impar.Clone();
                            }

                            tab1c = tab1r.Elements<wp.TableCell>().ElementAt(0);
                            // tab2c = tab2r.Elements<wp.TableCell>().ElementAt(0);

                            if (count + 1 < dataComportamentos.Count)
                            {
                                // introduz o texto da pergunta
                                tab1c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentos[count + 1].dados[0];
                                // tab2c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentos[count + 1].dados[0];
                                // introduz os valores de cada prática

                                // os mais e os menos desta linha (prática), por S;B;P;C;O
                                for (int i = 1; i < dataComportamentos[count + 1].dados.Length; i++ )
                                {
                                    tab1c = tab1r.Elements<wp.TableCell>().ElementAt(i);
                                    fillPlusMinus(tab1c, dataComportamentos[count + 1].dados[i], plusSign, minusSign, naSign, eqSign);
                                }
                            }

                            // junta às tabelas as linhas
                            tab1Temp.Append(tab1r);
                            // tab2Temp.Append(tab2r);

                            count++;
                        }

                    // INSERE A TABELA 1
                    par.Append(tab1Temp);
                    // LEGENDA 1

                    tempTexto = "";

                    //legendaTab1.Elements<wp.TableRow>().ElementAt(1).Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = tempTexto;
                    par.Append((wp.Table)legendaTab1.Clone());

                    // QUEBRA DE PÁGINA 1
                    par.Append((wp.Paragraph)quebraPagina.Clone());

                    // um parágrafo de espaçamento para que as tabelas não colem
                    par.Append(new wp.Paragraph());

                    contaPaginas++;
                }
        }
Example #19
0
    private void insertComentariosGroup(wp.Paragraph par)
    {
        // descrição e nome dos custom groups
        List<ReportRow> rows = null;
        for (int i = 0; i < _projecto.GroupsDescription.Count(); i++)
        {
            rows = repCalcs.getComentarios(langCode, "G" + i.ToString());
            insertComentariosGroup(par, rows, _projecto.GroupsDescription[i]);
            // um parágrafo para separar os headers
            par.Append(new wp.Paragraph(new wp.Run(new wp.Text(""))));

        }
    }