/// <summary> /// Save to a given file path /// </summary> /// <param name="path"></param> public void SaveToFile(string path) { //Check last modification if (LastModification != DateTime.MinValue && File.Exists(path)) { DateTime lastDateTime = File.GetLastWriteTime(path); if (LastModification != lastDateTime) { throw new Exception("Unable to save the Server Configuration file. The file has been modified by another user."); } } var xmlOverrides = new XmlAttributeOverrides(); XmlAttributes attrs = new XmlAttributes(); attrs.XmlIgnore = true; xmlOverrides.Add(typeof(RootComponent), "Name", attrs); xmlOverrides.Add(typeof(RootComponent), "GUID", attrs); //Pdf & Excel if (PdfConverterEdited) { PdfConfigurations = PdfConverter.GetConfigurations(); } if (DashboardPdfConverterEdited) { DashboardPdfConfigurations = DashboardPdfConverter.GetConfigurations(); } if (ExcelConverterEdited) { ExcelConfigurations = ExcelConverter.GetConfigurations(); } if (DashboardExcelConverterEdited) { DashboardExcelConfigurations = DashboardExcelConverter.GetConfigurations(); } #if !DEBUG && !NETCOREAPP //Set installation path, used by, to define schedules if (Path.GetFileName(Application.ExecutablePath).ToLower() == Repository.SealServerManager.ToLower() || Path.GetFileName(Application.ExecutablePath).ToLower() == Repository.SealReportDesigner.ToLower()) { _installationDirectory = Path.GetDirectoryName(Application.ExecutablePath); } #endif XmlSerializer serializer = new XmlSerializer(typeof(SealServerConfiguration), xmlOverrides); XmlWriterSettings ws = new XmlWriterSettings(); ws.NewLineHandling = NewLineHandling.Entitize; using (XmlWriter xw = XmlWriter.Create(path, ws)) { serializer.Serialize(xw, this); } FilePath = path; LastModification = File.GetLastWriteTime(path); }
public void SetAdvancedConfigurations() { //Pdf & Excel if (AllowPDFConversion && PdfConverterEdited) { _pdfConfigurations = PdfConverter.GetConfigurations(); } if (ExcelConverterEdited) { _excelConfigurations = ExcelConverter.GetConfigurations(); } foreach (var view in Views) { view.SetAdvancedConfigurations(); } }
/// <summary> /// Save to a given file path /// </summary> /// <param name="path"></param> public void SaveToFile(string path) { //Check last modification if (LastModification != DateTime.MinValue && File.Exists(path)) { DateTime lastDateTime = File.GetLastWriteTime(path); if (LastModification != lastDateTime) { throw new Exception("Unable to save the Server Configuration file. The file has been modified by another user."); } } var xmlOverrides = new XmlAttributeOverrides(); XmlAttributes attrs = new XmlAttributes(); attrs.XmlIgnore = true; xmlOverrides.Add(typeof(RootComponent), "Name", attrs); xmlOverrides.Add(typeof(RootComponent), "GUID", attrs); //Pdf & Excel if (PdfConverterEdited) { PdfConfigurations = PdfConverter.GetConfigurations(); } if (ExcelConverterEdited) { ExcelConfigurations = ExcelConverter.GetConfigurations(); } #if !DEBUG //Set installation path, used by, to define schedules var exePath = Assembly.GetExecutingAssembly().Location; if (Path.GetFileName(exePath).ToLower() == Repository.SealServerManager.ToLower() || Path.GetFileName(exePath).ToLower() == Repository.SealReportDesigner.ToLower()) { _installationDirectory = Path.GetDirectoryName(exePath); } #endif XmlSerializer serializer = new XmlSerializer(typeof(SealServerConfiguration), xmlOverrides); using (var tw = new StreamWriter(path)) { serializer.Serialize(tw, this); tw.Close(); } FilePath = path; LastModification = File.GetLastWriteTime(path); }