Exemple #1
0
        /// <summary>
        /// Erstellt neue XY-Listen aus den XY-Koordinaten die momentan im Backend gespeichert wurden.
        /// </summary>
        private void Init_XYLists()
        {
            Clear_XYLists();                      // Listen leeren um sie neu zu befüllen.

            for (int i = 0; i < xylist_size; i++) //Liest Koordianten aus SPSController in Tabellen ein
            {
                //Ist
                xis_list.Items.Add(new ListViewItem(String.Format("{0}", SPSController.GetXVal(i)), 0));
                yis_list.Items.Add(new ListViewItem(String.Format("{0}", SPSController.GetYVal(i)), 0));

                //Soll
                xtar_list.Items.Add(new ListViewItem(String.Format("{0}", SPSController.GetXVal(i)), 0));
                ytar_list.Items.Add(new ListViewItem(String.Format("{0}", SPSController.GetYVal(i)), 0));
            }
            cnt_label.Text = "Punkte: " + SPSController.CountXY.ToString();
        }
Exemple #2
0
        /// <summary>
        /// Schreibt ein aktuelles Backup in einem seperaten Ordner auf Höhe der .exe-Datei
        /// </summary>
        private void BackupLists(bool auto = false)
        {
            string filepath = "";

            if (products.Count > 0) //Backup wird nur ausgeführt wenn Produktliste gefüllt
            {
                //------------------Excel-Backup------------------//
                if (this.excel_checkbox.Checked)
                {
                    this.backupprogress.Visible = true;  //Zeige Ladebalken
                    this.selectionBox.Enabled   = false; // Deaktiviere Bedienelemente
                    this.coorBox.Enabled        = false;

                    //Neue Excel Mappe anlegen
                    Microsoft.Office.Interop.Excel.Application excelapp = new Microsoft.Office.Interop.Excel.Application();
                    excelapp.ScreenUpdating = false; //Neuzeichnen deaktivieren
                    Microsoft.Office.Interop.Excel.Workbook  map  = excelapp.Workbooks.Add();
                    Microsoft.Office.Interop.Excel.Worksheet page = map.Worksheets[1];

                    page.Name = "Backupdaten";

                    int index = 0;

                    for (int i = 0; i < products.Count; i++)
                    {
                        index = i * 33;

                        page.Cells[(index) + 1, 1].Value = productlist.Items[i].ToString(); // Produktbezeichner

                        SPSController.ReadDBEntry(i);
                        for (int j = 0; j < xylist_size; j++) // Koordianten
                        {
                            page.Cells[index + j + 2, 1].Value = SPSController.GetXVal(j);
                            page.Cells[index + j + 2, 2].Value = SPSController.GetYVal(j);
                        }
                        this.backupprogress.PerformStep();                //Step Progressbar
                    }
                    SPSController.ReadDBEntry(productlist.SelectedIndex); //Zurücksetzen auf ausgewählten Eintrag

                    filepath = GetFilepathWithDate();
                    map.SaveAs(filepath + ".xlsx");
                    map.Close();
                    excelapp.ScreenUpdating = true; //Neuzeichnen aktivieren
                    excelapp.Quit();

                    FileInfo exfi = new FileInfo(filepath + ".xlsx");
                    exfi.IsReadOnly = true; //Setze Schreibschutz für Datei

                    lastExcelBackupPath       = filepath;
                    this.backupprogress.Value = 0;

                    SendToConsole("Excel-Backupdatei erstellt");
                }

                //------------------XML-Backup------------------//

                this.backupprogress.Visible = true;  //Zeige Ladebalken
                this.selectionBox.Enabled   = false; // Deaktiviere Bedienelemente
                this.coorBox.Enabled        = false;

                XmlDocument xmlDoc       = new XmlDocument();
                XmlNode     produktliste = xmlDoc.CreateElement("Produkte"); // Root-Node
                xmlDoc.AppendChild(produktliste);

                int k = 0;
                foreach (string entry in products)
                {
                    SPSController.ReadDBEntry(k);

                    XmlNode produkt = xmlDoc.CreateElement(entry);
                    produktliste.AppendChild(produkt);

                    for (int l = 0; l < xylist_size; l++) //X-Koordianten schreiben
                    {
                        XmlNode coor = xmlDoc.CreateElement("X" + l.ToString());
                        coor.InnerText = SPSController.GetXVal(l).ToString();
                        produkt.AppendChild(coor);
                    }

                    for (int l = 0; l < xylist_size; l++) //Y-Koordianten schreiben
                    {
                        XmlNode coor = xmlDoc.CreateElement("Y" + l.ToString());
                        coor.InnerText = SPSController.GetYVal(l).ToString();
                        produkt.AppendChild(coor);
                    }

                    k++;
                    this.backupprogress.PerformStep(); //Step Progressbar
                }
                filepath = GetFilepathWithDate(auto);
                xmlDoc.Save(filepath + ".xml");

                FileInfo xmlfi = new FileInfo(filepath + ".xml");
                xmlfi.IsReadOnly = true;                              //Setze Schreibschutz für Datei

                this.backupprogress.Visible = false;                  //Verstecke Ladebalken
                this.backupprogress.Value   = 0;
                this.selectionBox.Enabled   = true;                   // Aktiviere Bedienelemente
                this.coorBox.Enabled        = true;
                SPSController.ReadDBEntry(productlist.SelectedIndex); //Zurücksetzen auf ausgewählten Eintrag

                SendToConsole(auto ? "Automatisches XML-Backup erstellt\n" : "XML-Backup erstellt\n");

                LastBackupDate(); //Aktuelisiert die Anzeige des letzten Backup Datums
            }
            else
            {
                SendToConsole("Backup kann nicht erstellt werden:\n Keine Einträge in Produktliste!\n");
            }
        }