/// <summary> /// Mit dieser Methode wird die XML Konfigurationsdatei eingelesen und als Objekt ausgegeben. /// </summary> /// <param name="Pfad">Enthält den Ablageort der Konfigurations-Datei</param> private XmlUarcConfig XmlConfigFileRead(string Pfad) { XmlUarcConfig opcXmlConfig = null; // Einlesen der XML-Datei. opcXmlConfig = OpcUaXmlConfigIO.OpcUaXmlConfigFileRead(Pfad); // Überprüfen der Daten. OpcUaXmlConfigChecker.FormatAndValidate(opcXmlConfig); return(opcXmlConfig); }
public FileResult Download() { //XML-Dokumentname string exampleFileName = "UARCexampleConfig.xml"; //Erzeugen der Beispiel Konfiguration string filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "XML Dateien", exampleFileName); OpcUaXmlConfigIO.OpcUaXmlExampleFileWrite(filePath); //Ausgeben der Beispiel Konfiguration byte[] fileBytes = System.IO.File.ReadAllBytes(filePath); return(File(fileBytes, "application/x-msdownload", exampleFileName)); }
public IActionResult Check(string path) { XmlConfigViewModel configModel = new XmlConfigViewModel(); XmlUarcConfig config = OpcUaXmlConfigIO.OpcUaXmlConfigFileRead(path); try { OpcUaXmlConfigChecker.FormatAndValidate(config); } catch { throw new Exception("Konfigurationsdatei ist nicht korrekt"); } OpcUaXmlConfigIO.OpcUaXmlConfigFileWrite(path, config);; configModel.Path = path; return(View(configModel)); }
public async Task <FileResult> Export() { try { // Erstellen der XmlUarcConfig aus dem Dicitionary vom UarcColletor. XmlUarcConfig xmlUarcConfig = await Program.UarcCollector.ExportXmlConfigAsync(); // Erstellen des Strings mit Datum und Uhrzeit. string dateAndTime = (Convert.ToString(System.DateTime.Now)).Replace(':', '-'); // XML-Dokumentname. string backupFileName = "UARC_Collector Backup, vom: " + dateAndTime + ".xml"; // XML-Ablageort. string filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "XML Dateien", "Backups", backupFileName); // Erzeugen der XML Konfiguration. OpcUaXmlConfigIO.OpcUaXmlConfigFileWrite(filePath, xmlUarcConfig); // Ausgeben der Beispiel Konfiguration. byte[] fileBytes = System.IO.File.ReadAllBytes(filePath); return(File(fileBytes, "application/x-msdownload", backupFileName)); } catch (Exception e) { if (e.Message == null) { e = new Exception("Konfiguration konnte nicht exportiert werden."); throw e; } else { throw e; } } }