/// <summary> /// Construct a new PersistedViews, migrating over the values from the old ViewSpecList /// and ReportSpecList properties. Views that are in use by an external tool get put in /// the External Tools group, and views that are /// </summary> public PersistedViews(ReportSpecList reportSpecList, ViewSpecList viewSpecList, ToolList toolList) { var viewItems = new List <ViewSpec>(); if (null != viewSpecList) { viewItems.AddRange(viewSpecList.ViewSpecs); } if (null != reportSpecList) { RevisionIndex = reportSpecList.RevisionIndex + 1; foreach (var newView in ReportSharing.ConvertAll(reportSpecList.Select(reportSpec => new ReportOrViewSpec(reportSpec)), new SrmDocument(SrmSettingsList.GetDefault()))) { if (viewItems.Any(viewSpec => viewSpec.Name == newView.Name)) { continue; } viewItems.Add(newView); } } var viewSpecLists = new Dictionary <ViewGroup, Dictionary <string, ViewSpec> >(); foreach (var viewItem in viewItems) { ViewGroup group; if (toolList.Any(tool => tool.ReportTitle == viewItem.Name)) { group = ExternalToolsGroup; } else { group = MainGroup; } Dictionary <string, ViewSpec> list; if (!viewSpecLists.TryGetValue(group, out list)) { list = new Dictionary <string, ViewSpec>(); viewSpecLists.Add(group, list); } if (!list.ContainsKey(viewItem.Name)) { list.Add(viewItem.Name, viewItem); } else { for (int i = 1;; i++) { string name = viewItem.Name + i; if (!list.ContainsKey(name)) { list.Add(name, viewItem.SetName(name)); break; } } } } foreach (var entry in viewSpecLists) { SetViewSpecList(entry.Key.Id, new ViewSpecList(entry.Value.Values)); } AddDefaults(); }
private string GetTitle(string title) { return(ToolList.Any(item => Equals(item.Title, title)) ? ToolInstaller.GetUniqueName(title, value => !ToolList.Any(item => Equals(item.Title, value))) : title); }
/// <summary> /// Construct a new PersistedViews, migrating over the values from the old ViewSpecList /// and ReportSpecList properties. Views that are in use by an external tool get put in /// the External Tools group, and views that are /// </summary> public PersistedViews(ReportSpecList reportSpecList, ViewSpecList viewSpecList, ToolList toolList) { var viewItems = new List<ViewSpec>(); if (null != viewSpecList) { viewItems.AddRange(viewSpecList.ViewSpecs); } if (null != reportSpecList) { RevisionIndex = reportSpecList.RevisionIndex + 1; foreach (var newView in ReportSharing.ConvertAll(reportSpecList.Select(reportSpec => new ReportOrViewSpec(reportSpec)), new SrmDocument(SrmSettingsList.GetDefault()))) { if (viewItems.Any(viewSpec => viewSpec.Name == newView.Name)) { continue; } viewItems.Add(newView); } } var viewSpecLists = new Dictionary<ViewGroup, Dictionary<string, ViewSpec>>(); foreach (var viewItem in viewItems) { ViewGroup group; if (toolList.Any(tool => tool.ReportTitle == viewItem.Name)) { group = ExternalToolsGroup; } else { group = MainGroup; } Dictionary<string, ViewSpec> list; if (!viewSpecLists.TryGetValue(group, out list)) { list = new Dictionary<string, ViewSpec>(); viewSpecLists.Add(group, list); } if (!list.ContainsKey(viewItem.Name)) { list.Add(viewItem.Name, viewItem); } else { for (int i = 1;; i++) { string name = viewItem.Name + i; if (!list.ContainsKey(name)) { list.Add(name, viewItem.SetName(name)); break; } } } } foreach (var entry in viewSpecLists) { SetViewSpecList(entry.Key.Id, new ViewSpecList(entry.Value.Values)); } AddDefaults(); }
/// <summary> /// Return a unique title for a New Tool. (eg. [New Tool1]) /// </summary> private string GetTitle() { return(ToolInstaller.GetUniqueFormat(Resources.ConfigureToolsDlg_GetTitle__New_Tool_0__, value => !ToolList.Any(item => Equals(item.Title, value)))); }