Ejemplo n.º 1
0
 public void BorderTest()
 {
     Tabelle target = new Tabelle(); // TODO: Initialize to an appropriate value
     bool expected = false; // TODO: Initialize to an appropriate value
     bool actual;
     target.Border = expected;
     actual = target.Border;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 2
0
 public void BgColorTest()
 {
     Tabelle target = new Tabelle(); // TODO: Initialize to an appropriate value
     string expected = "Blue"; // TODO: Initialize to an appropriate value
     string actual;
     target.BgColor = expected;
     actual = target.BgColor;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 3
0
 public void ContentTest()
 {
     Tabelle target = new Tabelle(); // TODO: Initialize to an appropriate value
     DataTable expected = new DataTable(); // TODO: Initialize to an appropriate value
     expected.Columns.Add("Test1", typeof(string));
     expected.Rows.Add("Test");
     DataTable actual;
     target.Content = expected;
     actual = target.Content;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Dient zur Auswertung des Knoten Tabelle
 /// Es wird eine Tabellen Objekt instanziiert und die entsprechenden Eigenschaften übernommen.
 /// Falls eine Exception beim Casten der Werte geworfen wird, wird diese gefangen und weitergeleitet
 /// Bei erfolgreicher Erstellung des Objekts wird der Tabelleninhalt über eine Datenbankanbindung abgefragt.
 /// Falls eine Exception bei der Abfrage geworfen wird, wird diese gefangen und weitergeleitet.
 /// Bei erfolgreicher Abfrage wird die Tabelle im Word Dokument hinzugefügt
 /// </summary>
 /// <param name="xml"></param>
 public void Tabelle(string xml)
 {
     XmlTextReader subReader = new XmlTextReader(new System.IO.StringReader(xml));
     Tabelle table = new Tabelle();
     while (subReader.Read())
     {
         if (subReader.NodeType == XmlNodeType.Element)
         {
             switch (subReader.Name)
             {
                 case "id":
                     table.Id = subReader.ReadElementString();
                     break;
                 case "bold":
                     try
                     {
                         table.Bold = subReader.ReadElementContentAsBoolean();
                     }
                     catch (XmlException e)
                     {
                         subReader.Close();
                         throw new OpenDocumentException(e.Message);
                     }
                     break;
                 case "background":
                     table.BgColor = subReader.ReadElementString();
                     break;
                 case "sql":
                     table.Text = subReader.ReadElementString();
                     break;
                 case "border":
                     try
                     {
                         table.Border = subReader.ReadElementContentAsBoolean();
                     }
                     catch (XmlException e)
                     {
                         subReader.Close();
                         throw new OpenDocumentException(e.Message);
                     }
                     break;
                 case "font":
                     table.Font = subReader.ReadElementString();
                     break;
                 case "size":
                     try
                     {
                         table.Size = subReader.ReadElementContentAsInt();
                     }
                     catch (XmlException e)
                     {
                         subReader.Close();
                         throw new OpenDocumentException(e.Message);
                     }
                     break;
                 case "paragraph":
                     try
                     {
                         table.Paragraph = subReader.ReadElementContentAsInt();
                     }
                     catch (XmlException e)
                     {
                         subReader.Close();
                         throw new OpenDocumentException(e.Message);
                     }
                     break;
             }
         }
     }
     subReader.Close();
     try
     {
         table.getContent(connections);
     }
     catch (MySql.Data.MySqlClient.MySqlException e)
     {
         throw new OpenDocumentException(e.Message);
     }
     catch (System.Data.SqlClient.SqlException e)
     {
         throw new OpenDocumentException(e.Message);
     }
     catch (InvalidCastException)
     {
         throw new OpenDocumentException("Datenbankverbindung " + table.Id + " für Tabelle mit Abfrage " + table.Text + " nicht gefunden");
     }
     catch (Exception e)
     {
         throw new OpenDocumentException(e.Message);
     }
     doc.Table(table);
 }
Ejemplo n.º 5
0
 public void FontTest()
 {
     Tabelle target = new Tabelle(); // TODO: Initialize to an appropriate value
     string expected = "Arial"; // TODO: Initialize to an appropriate value
     string actual;
     target.Font = expected;
     actual = target.Font;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 6
0
 public void SizeTest()
 {
     Tabelle target = new Tabelle(); // TODO: Initialize to an appropriate value
     int expected = 10; // TODO: Initialize to an appropriate value
     int actual;
     target.Size = expected;
     actual = target.Size;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Definiert eine falsche SQL Abfrage
 /// </summary>
 public void InitializeFailSql()
 {
     table = new Tabelle();
     table.Id = "mysql";
     table.Border = true;
     table.BgColor = "White";
     table.Bold = true;
     table.Text = "SELECT ..";
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Definiert eine korrekte SQL Abfrage
 /// </summary>
 public void InitializeSql()
 {
     table = new Tabelle();
     table.Id = "mysql";
     table.Border = true;
     table.BgColor = "White";
     table.Bold = true;
     table.Text = "SELECT * from mitarbeiter where mit_nachname='Stanik'";
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Definiert einen falsche DB Server
 /// </summary>
 public void InitializeFailDBConnection()
 {
     table = new Tabelle();
     table.Id = "tt";
     table.Border = true;
     table.BgColor = "White";
     table.Bold = true;
     table.Text = "SELECT * from mitarbeiter where mit_nachname='Stanik'";
 }
Ejemplo n.º 10
0
 public void IdTest()
 {
     Tabelle target = new Tabelle(); // TODO: Initialize to an appropriate value
     string expected = "test"; // TODO: Initialize to an appropriate value
     string actual;
     target.Id = expected;
     actual = target.Id;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 11
0
 public void getFailDBContentTest()
 {
     table = new Tabelle();// TODO: Initialize to an appropriate value
     InitializeFailDBConnection();
     table.getContent(connections);
 }
Ejemplo n.º 12
0
 public void getContentTest()
 {
     table = new Tabelle();// TODO: Initialize to an appropriate value
     InitializeSql();
     table.getContent(connections);
     Assert.IsTrue(table.Content != null);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Erstellt eine Word-Tabelle mit der gewünschten Formatierung
        /// und fügt sie im Word Dokument ein
        /// </summary>
        /// <param name="dataTable"></param>
        public void Table(Tabelle dataTable)
        {
            Body body = word.MainDocumentPart.Document.Body;
            Table table = new Table();
            TableProperties tableProp = new TableProperties();
            TableRow t = new TableRow();
            foreach (DataColumn column in dataTable.Content.Columns)
            {
                Run run_paragraph = new Run();
                RunProperties rPr = new RunProperties(Font(dataTable.Font));
                rPr.Append(Size(dataTable.Size));
                if (dataTable.Bold == true)
                {
                    rPr.Append(new Bold());
                }
                Paragraph para = new Paragraph(ParagraphSpacingAfter(0));
                TableCellProperties headerProp = new TableCellProperties(TableBackground(dataTable.BgColor));
                if (dataTable.Border == true)
                    headerProp.Append(TableGrid());
                run_paragraph.Append(rPr);
                run_paragraph.Append(InsertText(column.ColumnName));
                para.Append(run_paragraph);
                TableCell tc = new TableCell(para);
                tc.Append(headerProp);
                t.Append(tc);
            }
            table.Append(t);

            foreach (DataRow row in dataTable.Content.Rows)
            {
                TableRow tr = new TableRow();
                foreach (DataColumn column in dataTable.Content.Columns)
                {
                    Paragraph para = new Paragraph(ParagraphSpacingAfter(0));
                    Run run_paragraph = new Run();
                    RunProperties rPr = new RunProperties(Font(dataTable.Font));
                    rPr.Append(Size(dataTable.Size));
                    run_paragraph.Append(rPr);
                    run_paragraph.Append(InsertText(row[column].ToString()));
                    para.Append(run_paragraph);
                    TableCell tc = new TableCell(para);
                    if (dataTable.Border == true)
                        tc.Append(new TableCellProperties(TableGrid()));
                    tr.Append(tc);
                }
                table.Append(tr);
            }
            table.Append(tableProp);
            body.Append(table);
        }