private void LoadReportTemplateButtonClick(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.AddExtension = true; ofd.DefaultExt = "rt"; ofd.Filter = "Report templates (*.rt)|*.rt"; ofd.CheckFileExists = true; ofd.CheckPathExists = true; if (ofd.ShowDialog() != DialogResult.OK) { return; } ReportFileWriterTemplate rt = null; System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(ReportFileWriterTemplate)); using (System.IO.StreamReader sw = new System.IO.StreamReader(ofd.FileName)) { rt = (ReportFileWriterTemplate)serializer.Deserialize(sw.BaseStream); } this.SetReportWriter(rt.ToReportFileWriter(this.reportTriggers, this.dataSources, this.dataAccumulators)); }
private void SaveReportTemplateButtonClick(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.AddExtension = true; sfd.DefaultExt = "rt"; sfd.Filter = "Report templates (*.rt)|*.rt"; sfd.OverwritePrompt = true; if (sfd.ShowDialog() != DialogResult.OK) { return; } ReportFileWriterTemplate rt = ReportFileWriterTemplate .Create(string.Empty) .WithReportTrigger(GetConfiguredReportTrigger()) .WithReportElements(GetConfiguredReportElements()); System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(ReportFileWriterTemplate)); using (System.IO.StreamWriter sw = new System.IO.StreamWriter(sfd.FileName)) { serializer.Serialize(sw, rt); } }