public override void Exec() { string sCurrentFile = string.Empty; try { UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer; UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0)); SolutionClass solution = hierItem.Object as SolutionClass; Project proj = GetSelectedProjectReference(); List <string> lstRdls = new List <string>(); if (proj != null) { lstRdls.AddRange(DatasetScanner.GetRdlFilesInProjectItems(proj.ProjectItems, false)); } else if (solution != null) { foreach (Project p in solution.Projects) { lstRdls.AddRange(DatasetScanner.GetRdlFilesInProjectItems(p.ProjectItems, true)); } } int iDeleted = 0; foreach (string file in lstRdls) { sCurrentFile = file; string sCachePath = file + ".data"; if (System.IO.File.Exists(sCachePath)) { System.IO.File.SetAttributes(sCachePath, System.IO.FileAttributes.Normal); System.IO.File.Delete(sCachePath); iDeleted++; } } MessageBox.Show("Scanned " + lstRdls.Count + " report(s).\r\nDeleted " + iDeleted + " rdl.data file(s).", "BIDS Helper Delete Dataset Cache Files"); } catch (System.Exception ex) { string sError = string.Empty; if (!string.IsNullOrEmpty(sCurrentFile)) { sError += "Error while scanning report: " + sCurrentFile + "\r\n"; } sError += ex.Message + "\r\n" + ex.StackTrace; MessageBox.Show(sError); } }
/// <summary> /// Determines if the command should be displayed or not. /// </summary> /// <param name="item"></param> /// <returns></returns> public override bool ShouldDisplayCommand() { try { UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer; if (((System.Array)solExplorer.SelectedItems).Length != 1) { return(false); } UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0)); SolutionClass solution = hierItem.Object as SolutionClass; Project project = hierItem.Object as Project; if (project == null && hierItem.Object is ProjectItem) { ProjectItem pi = hierItem.Object as ProjectItem; project = pi.SubProject; } if (project != null) { if (DatasetScanner.GetRdlFilesInProjectItems(project.ProjectItems, true).Length > 0) { return(true); } } else if (solution != null) { foreach (Project p in solution.Projects) { if (DatasetScanner.GetRdlFilesInProjectItems(p.ProjectItems, true).Length > 0) { return(true); } } } return(false); } catch { return(false); } }
public override void Exec() { DatasetScanner.ScanReports(this.ApplicationObject.ToolWindows.SolutionExplorer, false); }