/// <summary> /// Duplicate button click handler. /// </summary> private void _DuplicateTemplate_Click(object sender, RoutedEventArgs e) { try { ReportInfo selectedInfo = _GetSelectedInfo(); if (null != selectedInfo) { ReportsGenerator generator = App.Current.ReportGenerator; // generate new name string dir = Path.GetDirectoryName(selectedInfo.TemplatePath); // create sub reports List <SubReportInfo> subReports = new List <SubReportInfo>(); foreach (SubReportInfo subReport in selectedInfo.SubReports) { string subNameNew = _GetNameForDublicate(subReport.Name); string subTemplatePath = ReportsGenerator.GetNewTemplatePath(subNameNew, subReport.TemplatePath); SubReportInfo newSubReport = new SubReportInfo(subNameNew, subTemplatePath, subReport.Description, subReport.IsDefault, subReport.GroupId, subReport.IsVisible); // copy template file for subreport template _DuplicateReportFile(subReport.TemplatePath, newSubReport.TemplatePath); subReports.Add(newSubReport); } // create new info string nameNew = _GetNameForDublicate(selectedInfo.Name); string templatePath = ReportsGenerator.GetNewTemplatePath(nameNew, selectedInfo.TemplatePath); ReportInfo newInfo = new ReportInfo(nameNew, selectedInfo.Context, templatePath, selectedInfo.Description, false, subReports); // copy template file for template _DuplicateReportFile(selectedInfo.TemplatePath, newInfo.TemplatePath); generator.AddReportInfo(newInfo); _itemToSelection = newInfo.Name; } } catch (Exception ex) { Logger.Error(ex); App.Current.Messenger.AddError(ex.Message); } _InitReportTable(); }