#region Copyright (C) 2003-2010 Stimulsoft /* {*******************************************************************} { } { Stimulsoft Reports.SL } { } { } { Copyright (C) 2003-2010 Stimulsoft } { ALL RIGHTS RESERVED } { } { The entire contents of this file is protected by U.S. and } { International Copyright Laws. Unauthorized reproduction, } { reverse-engineering, and distribution of all or any portion of } { the code contained in this file is strictly prohibited and may } { result in severe civil and criminal penalties and will be } { prosecuted to the maximum extent possible under the law. } { } { RESTRICTIONS } { } { THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES } { ARE CONFIDENTIAL AND PROPRIETARY } { TRADE SECRETS OF Stimulsoft } { } { CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON } { ADDITIONAL RESTRICTIONS. } { } {*******************************************************************} */ #endregion Copyright (C) 2003-2010 Stimulsoft using System; using System.Windows.Controls; using Stimulsoft.Report.SaveLoad; using Stimulsoft.Base.Services; using Stimulsoft.Base; using System.IO; namespace Stimulsoft.Report.SLDesign { public sealed class StiSLReportSaveDialog { public static bool SaveReport(StiReport report) { return SaveReport(null, report); } public static bool SaveReport(StiSLDesignerControl designer) { return SaveReport(designer, designer.Report); } private static bool SaveReport(StiSLDesignerControl designer, StiReport report) { bool saveResult = false; try { if (designer != null)designer.Refresh(); bool result = false; if (designer != null)result = StiOptions.Engine.GlobalEvents.InvokeSavingReportInDesigner(designer, true); if (!result) { #region Save File with Help of SaveFileDialog StiXmlReportSLService xmlReportService = new StiXmlReportSLService(); SaveFileDialog sf = new SaveFileDialog(); sf.Filter = xmlReportService.GetFilter(); if (sf.ShowDialog() == true && !string.IsNullOrEmpty(sf.SafeFileName)) { string fileExt = sf.SafeFileName; FileStream stream = sf.OpenFile() as FileStream; report.Save(xmlReportService, stream); stream.Flush(); stream.Close(); saveResult = true; if (designer != null) { designer.ReportNeverSaved = false; designer.ReportFileName = sf.SafeFileName; } report.IsModified = false; } #endregion } else { saveResult = true; } } catch (Exception exc) { saveResult = false; StiLogService.Write(typeof(StiSLReportSaveDialog), "Saving report...ERROR"); StiLogService.Write(typeof(StiSLReportSaveDialog), exc); StiExceptionProvider.Show(exc); } if (saveResult) StiOptions.Engine.GlobalEvents.InvokeSavedReportInDesigner(designer); return saveResult; } private StiSLReportSaveDialog() { } } }