/// <summary> /// Generate the list of Existing Reports that would be modified and the list of new reports /// </summary> private static List <ReportOrViewSpec> FindReportConflicts(DirectoryInfo toolInfDir, string tempToolPath, out List <ReportOrViewSpec> newReports) { var existingReports = new List <ReportOrViewSpec>(); newReports = new List <ReportOrViewSpec>(); foreach (FileInfo file in toolInfDir.GetFiles(@"*" + ReportSpecList.EXT_REPORTS)) { List <ReportOrViewSpec> loadedItems; try { using (var stream = File.OpenRead(file.FullName)) { loadedItems = ReportSharing.DeserializeReportList(stream); } } catch (Exception exception) { DirectoryEx.SafeDelete(tempToolPath); throw new IOException( string.Format(Resources.SerializableSettingsList_ImportFile_Failure_loading__0__, file.FullName), exception); } var externalToolReports = Settings.Default.PersistedViews.GetViewSpecList(PersistedViews.ExternalToolsGroup.Id); Dictionary <string, ViewSpec> allExistingReports = new Dictionary <string, ViewSpec>(); if (externalToolReports != null) { foreach (var viewSpec in externalToolReports.ViewSpecs) { allExistingReports[viewSpec.Name] = viewSpec; } } foreach (var reportOrViewSpec in loadedItems) { ViewSpec existingView; if (allExistingReports.TryGetValue(reportOrViewSpec.GetKey(), out existingView)) { if (!ReportSharing.AreEquivalent(reportOrViewSpec, new ReportOrViewSpec(existingView))) { existingReports.Add(reportOrViewSpec); } else { newReports.Add(reportOrViewSpec); } } else { newReports.Add(reportOrViewSpec); } } // We now have the list of Reports that would have a naming conflict. } return(existingReports); }
/// <summary> /// Generate the list of Existing Reports that would be modified and the list of new reports /// </summary> private static List <ReportOrViewSpec> FindReportConflicts(DirectoryInfo toolInfDir, string tempToolPath, out List <ReportOrViewSpec> newReports) { var existingReports = new List <ReportOrViewSpec>(); newReports = new List <ReportOrViewSpec>(); var externalToolReports = Settings.Default.PersistedViews.GetViewSpecList(PersistedViews.ExternalToolsGroup.Id); Dictionary <string, ViewSpecLayout> allExistingReports = new Dictionary <string, ViewSpecLayout>(); if (externalToolReports != null) { foreach (var viewSpec in externalToolReports.ViewSpecLayouts) { allExistingReports[viewSpec.Name] = viewSpec; } } var loadedItems = GetReportsFromFiles(toolInfDir, tempToolPath); foreach (var reportOrViewSpec in loadedItems) { ViewSpecLayout existingView; if (allExistingReports.TryGetValue(reportOrViewSpec.GetKey(), out existingView)) { if (!ReportSharing.AreEquivalent(reportOrViewSpec, new ReportOrViewSpec(existingView))) { existingReports.Add(reportOrViewSpec); } else { newReports.Add(reportOrViewSpec); } } else { newReports.Add(reportOrViewSpec); } } // We now have the list of Reports that would have a naming conflict. return(existingReports); }