/// <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));
                Project         p        = GetSelectedProjectReferenceRS();

                SolutionClass solution = hierItem.Object as SolutionClass;
                if (p != null)
                {
                    return(p.Kind == BIDSProjectKinds.SSRS);
                }
                else if (solution != null)
                {
                    foreach (Project pp in solution.Projects)
                    {
                        if (p.Kind == BIDSProjectKinds.SSRS)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }
            catch
            {
                return(false);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            string        path     = args[0];
            SolutionClass solution = new SolutionClass();

            solution.ListDirectory(path, 0);
        }
Example #3
0
        public void TestSolution_Array()
        {
            var solutionClass = new SolutionClass();

            int[] array = { 147, 483, 647, 100000000 };
            array.ToList().ForEach(x => Assert.IsTrue(x <= solutionClass.Solution(x)));
        }
Example #4
0
        public override bool DisplayCommand(EnvDTE.UIHierarchyItem item)
        {
            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;
                if (hierItem.Object is Project)
                {
                    Project p = (Project)hierItem.Object;
                    if (!(p.Object is Database))
                    {
                        return(false);
                    }
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)p;
                    return(projExt.Kind == BIDSProjectKinds.SSAS);
                }
            }
            catch { }
            return(false);
        }
Example #5
0
 public void MyTest()
 {
     Assert.AreEqual("Even", SolutionClass.EvenOrOdd(2));
     Assert.AreEqual("Odd", SolutionClass.EvenOrOdd(1));
     Assert.AreEqual("Even", SolutionClass.EvenOrOdd(0));
     Assert.AreEqual("Odd", SolutionClass.EvenOrOdd(7));
     Assert.AreEqual("Odd", SolutionClass.EvenOrOdd(-1));
 }
        /// <summary>
        /// Initialize an instance of fragment with not selected text
        /// </summary>
        /// <param name="solution"></param>
        /// <param name="textDocument"></param>
        public NonSelectedReviewingFragment(SolutionClass solution, TextDocument textDocument)
            : base(solution, textDocument)
        {
            var startPoint = TextDocument.Selection.ActivePoint.CreateEditPoint();

            Text = StartOfDocument.GetLines(TextDocument.StartPoint.Line, TextDocument.EndPoint.Line);
            Line = startPoint.Line;
        }
Example #7
0
 protected ReviewingFragmentBase(SolutionClass solution, TextDocument textDocument)
 {
     Solution     = solution;
     TextDocument = textDocument;
     TextDocumentPathInSolution = GetTextDocumentPathInSolution(solution, textDocument);
     StartOfDocument            = textDocument.StartPoint.CreateEditPoint();
     StartOfDocument.StartOfDocument();
 }
Example #8
0
    private static SolutionFolder FindSolutionFolderOrCreate(SolutionClass sln, string folderName)
    {
        foreach (var x in sln.Projects)
        {
            if (x is Project p && p.Name.Equals(folderName, StringComparison.OrdinalIgnoreCase))
            {
                return((SolutionFolder)p.Object);
            }
        }
        var proj = (sln as Solution2).AddSolutionFolder(folderName);

        return((SolutionFolder)proj.Object);
    }
        /// <summary>
        /// Initialize a new instance of a fragment with selected text
        /// </summary>
        /// <param name="solution">Reviewed solution</param>
        /// <param name="textDocument">Reviewed document</param>
        public SelectedReviewingFragment(SolutionClass solution, TextDocument textDocument)
            : base(solution, textDocument)
        {
            var textSelection = TextDocument.Selection;

            StartCharOffset = textSelection.TopPoint.LineCharOffset;
            EndCharOffset   = textSelection.BottomPoint.LineCharOffset;
            TopLine         = StartOfDocument.GetLines(textSelection.TopLine, textSelection.TopLine + 1);
            BottomLine      = StartOfDocument.GetLines(textSelection.BottomLine, textSelection.BottomLine + 1);

            Line = TextDocument.Selection.TopLine;
            Text = textSelection.Text;
        }
        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);
            }
        }
Example #11
0
        private static SolutionFolder FindSolutionFolder(SolutionClass sln, string folderName)
        {
            var solutionFolder =
                sln.Projects
                .OfType <Project>()
                .FirstOrDefault(p => p.Name.Equals(folderName, StringComparison.OrdinalIgnoreCase))
                ?.Object as SolutionFolder;

            if (solutionFolder is null)
            {
                solutionFolder = (sln as Solution2).AddSolutionFolder(folderName).Object as SolutionFolder;
            }

            return(solutionFolder);
        }
Example #12
0
        static void Main(string[] args)
        {
            var solutionClass = new SolutionClass();

            int[] array = { 147, 483, 647, 100000000, 100000001 };
            array.ToList().ForEach(x => Console.WriteLine(solutionClass.Solution(x)));

            new ConvertAgoraClass().ConvertLog("https://s3.amazonaws.com/uux-itaas-static/minha-cdn-logs/input-01.txt", "./output/minhaCdn1.csv");

            var conteudo = new StringBuilder();

            System.IO.File.ReadAllLines("./output/minhaCdn1.csv").ToList().ForEach(x => conteudo.AppendLine(x));

            Console.WriteLine(conteudo.ToString());

            Console.ReadKey();
        }
Example #13
0
 public MainWindow()
 {
     InitializeComponent();
     #region 初始化布局
     _dllPanel           = AddLayoutAnchorablePane(LeftAnchorableGroup, "Dll文件");
     _functionPanel      = AddLayoutAnchorablePane(LeftAnchorableGroup, "方法");
     _xaributePanel      = AddLayoutAnchorablePane(LeftAnchorableGroup, "字段");
     _solutionPanel      = AddLayoutAnchorablePane(RightAnchorableGroup, "解决方案");
     _valuePanel         = AddLayoutAnchorablePane(RightAnchorableGroup, "属性");
     _outWindows         = outw;
     _outWindows.Content = new RichTextBox();
     #endregion
     #region 初始化信息
     _myProject = new ProjectClass();
     Solution   = new SolutionClass();
     #endregion
 }
        /// <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;
                var             proj     = GetSelectedProjectReference();

                if (proj != null)
                {
                    if (!(proj.Object is Database))
                    {
                        return(false);
                    }
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)proj;
                    return(projExt.Kind == BIDSProjectKinds.SSAS || projExt.Kind == BIDSProjectKinds.SSIS);
                }
                else if (solution != null)
                {
                    foreach (EnvDTE.Project p in solution.Projects)
                    {
                        if (p.Kind != BIDSProjectKinds.SSIS)
                        {
                            return(false);
                        }
                    }
                    return(solution.Projects.Count > 0);
                }
                else
                {
                    string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
                    return(sFileName.EndsWith(".dtsx"));
                }
            }
            catch { }
            return(false);
        }
        /// <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 string FindProject(EnvDTE.UIHierarchyItems h, Project p)
        {
            var xEnumerator = h.GetEnumerator();

            while (xEnumerator.MoveNext())
            {
                UIHierarchyItem xHierarchyItem = (UIHierarchyItem)xEnumerator.Current;
                if (xHierarchyItem.Name == p.Name)
                {
                    dynamic node    = xHierarchyItem.Object;
                    dynamic nodeArg = p.Object; // Cosmos.VS.Package.VSProjectNode

                    try {
                        if (node.Object.Project.ProjectIDGuid == nodeArg.ProjectIDGuid)
                        {
                            return(p.Name);
                        }
                    } catch {
                    }

                    try {
                        if (node.Project.ProjectIDGuid == nodeArg.ProjectIDGuid)
                        {
                            return(p.Name);
                        }
                    } catch {
                    }
                }
                var xPartOfName = FindProject(xHierarchyItem.UIHierarchyItems, p);
                if (xPartOfName.Length > 0)
                {
                    SolutionClass solution = xHierarchyItem.Object as SolutionClass;
                    if (solution != null)
                    {
                        return(xHierarchyItem.Name + "\\" + xPartOfName);
                    }
                    return(xHierarchyItem.Name + "\\" + xPartOfName);
                }
            }
            return(string.Empty);
        }
        /// <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;
                EnvDTE.Project  proj     = GetSelectedProjectReference();

                if (proj != null)
                {
                    if (proj.Object == null || proj.Object.GetType().FullName != "Microsoft.AnalysisServices.Database")
                    {
                        return(false);                                                                                                //this should be a reference to Microsoft.AnalysisServices.AppLocal.dll
                    }
                    //Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)proj;
                    return(proj.Kind == BIDSProjectKinds.SSIS);
                }
                else if (solution != null)
                {
                    foreach (EnvDTE.Project p in solution.Projects)
                    {
                        if (p.Kind != BIDSProjectKinds.SSIS)
                        {
                            return(false);
                        }
                    }
                    return(solution.Projects.Count > 0);
                }
            }
            catch { }
            return(false);
        }
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                SolutionClass   solution    = hierItem.Object as SolutionClass;

                // test if this is a Multi-Dim project
                if (hierItem.Object is EnvDTE.Project)
                {
                    EnvDTE.Project p = (EnvDTE.Project)hierItem.Object;
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = p as Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt;
                    if (p == null)
                    {
                        return(false);
                    }

                    if (projExt.Kind == BIDSProjectKinds.SSAS)
                    {
                        return(true);
                        //Database db = (Database)p.Object;
                        //ScanAnalysisServicesProperties(db);
                    }
                }
                // else test if this is a tabular .bim file
                if (!(hierItem.Object is ProjectItem))
                {
                    return(false);
                }
                string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
                return(sFileName.EndsWith(".bim"));
            }
            catch
            {
                return(false);
            }
        }
Example #19
0
    static int Main(string[] args)
    {
        var cases = GetStdinLines()
                    .Select(JsonConvert.DeserializeObject <ExpandoObject>);

        foreach (IDictionary <string, object> testCase in cases)
        {
            if (testCase.ContainsKey("check"))
            {
                Console.WriteLine(testCase["check"]);
                return(0);
            }

            var argumentsJson = ToJson(testCase["arguments"]);
            var expectedJson  = ToJson(testCase["expected"]);
            var solution      = SolutionClass.Solution((IList <object>)testCase["arguments"]);
            var solutionJson  = ToJson(solution);

            Assert.AreEqual(expectedJson, solutionJson, $"Arguments were {argumentsJson}");
        }

        return(1);
    }
        /// <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));
                Project         p        = GetSelectedProjectReference();

                SolutionClass solution = hierItem.Object as SolutionClass;
                if (p != null)
                {
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)p;
                    return(projExt.Kind == BIDSProjectKinds.SSRS);
                }
                else if (solution != null)
                {
                    foreach (Project pp in solution.Projects)
                    {
                        Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)p;
                        if (projExt.Kind == BIDSProjectKinds.SSRS)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }
            catch
            {
                return(false);
            }
        }
        public static void ScanReports(UIHierarchy solExplorer, bool LookForUnusedDatasets)
        {
            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;

                List <string> lstRdls = new List <string>();
                if (hierItem.Object is Project)
                {
                    Project p = (Project)hierItem.Object;
                    lstRdls.AddRange(GetRdlFilesInProjectItems(p.ProjectItems, true));
                }
                else if (hierItem.Object is ProjectItem)
                {
                    ProjectItem pi = hierItem.Object as ProjectItem;
                    Project     p  = pi.SubProject;
                    lstRdls.AddRange(GetRdlFilesInProjectItems(p.ProjectItems, true));
                }
                else if (solution != null)
                {
                    foreach (Project p in solution.Projects)
                    {
                        lstRdls.AddRange(GetRdlFilesInProjectItems(p.ProjectItems, true));
                    }
                }

                List <UsedRsDataSets.RsDataSetUsage> lstDataSets = new List <UsedRsDataSets.RsDataSetUsage>();
                foreach (string file in lstRdls)
                {
                    sCurrentFile = file;
                    UsedRsDataSets urds = new UsedRsDataSets(file);
                    foreach (UsedRsDataSets.RsDataSet ds in urds.DataSets)
                    {
                        if (LookForUnusedDatasets && ds.Usages.Count == 0)
                        {
                            UsedRsDataSets.RsDataSetUsage u = new UsedRsDataSets.RsDataSetUsage();
                            u.ReportName  = ds.ReportName;
                            u.DataSetName = ds.DataSetName;
                            lstDataSets.Add(u);
                        }
                        else if (!LookForUnusedDatasets && ds.Usages.Count > 0)
                        {
                            foreach (string usage in ds.Usages)
                            {
                                UsedRsDataSets.RsDataSetUsage u = new UsedRsDataSets.RsDataSetUsage();
                                u.ReportName  = ds.ReportName;
                                u.DataSetName = ds.DataSetName;
                                u.Usage       = usage;
                                lstDataSets.Add(u);
                            }
                        }
                    }
                }

                if (lstDataSets.Count == 0)
                {
                    if (LookForUnusedDatasets)
                    {
                        MessageBox.Show("All datasets are in use.", "BIDS Helper Unused Datasets Report");
                    }
                    else
                    {
                        MessageBox.Show("No datasets found.", "BIDS Helper Used Datasets Report");
                    }
                }
                else
                {
                    ReportViewerForm frm = new ReportViewerForm();
                    frm.ReportBindingSource.DataSource = lstDataSets;
                    if (LookForUnusedDatasets)
                    {
                        frm.Report  = "SSRS.UnusedDatasets.rdlc";
                        frm.Caption = "Unused Datasets Report";
                    }
                    else
                    {
                        frm.Report  = "SSRS.UsedDatasets.rdlc";
                        frm.Caption = "Used Datasets Report";
                    }
                    Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                    reportDataSource1.Name  = "BIDSHelper_SSRS_RsDataSetUsage";
                    reportDataSource1.Value = frm.ReportBindingSource;
                    frm.ReportViewerControl.LocalReport.DataSources.Add(reportDataSource1);

                    frm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                    frm.Show();
                }
            }
            catch (System.Exception ex)
            {
                string sError = string.Empty;
                if (!string.IsNullOrEmpty(sCurrentFile))
                {
                    sError += "Error while scanning report: " + sCurrentFile + "\r\n";
                }
                while (ex != null)
                {
                    sError += ex.Message + "\r\n" + ex.StackTrace + "\r\n\r\n";
                    ex      = ex.InnerException;
                }
                MessageBox.Show(sError);
            }
        }
Example #22
0
 public void ReturnsOddOrEven(int number, string expectedResult)
 {
     Assert.Equal(expectedResult, SolutionClass.EvenOrOdd(number));
 }
 /// <summary>
 /// 设置项目类
 /// </summary>
 /// <param name="proClass">项目类的实例</param>
 /// <param name="solution">解决方案的实例</param>
 public void SetProjectClass(ProjectClass proClass, SolutionClass solution)
 {
     _myProject  = proClass;
     _mySolution = solution;
 }
Example #24
0
 public static string GetName(this SolutionClass solution)
 {
     return(solution.Properties.Item(NameItem).Value.ToString());
 }
        public override void Exec()
        {
            ProjectItem piCurrent = null;

            try
            {
                listNonDefaultProperties = new List <NonDefaultProperty>();

                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                SolutionClass   solution    = hierItem.Object as SolutionClass;
                EnvDTE.Project  p           = GetSelectedProjectReference();

                if (p != null)
                {
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)p;
                    if (projExt.Kind == BIDSProjectKinds.SSAS)
                    {
                        Database db = (Database)p.Object;
                        ScanAnalysisServicesProperties(db);
                    }
                    else
                    {
                        this.DatabaseName = "Project: " + p.Name;
                        this.SSASProject  = false;

                        try
                        {
                            using (WaitCursor cursor1 = new WaitCursor())
                            {
                                int iProgress = 0;
                                ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationGeneral);
                                Microsoft.SqlServer.Dts.Runtime.Application app = SSIS.PackageHelper.Application; //sets the proper TargetServerVersion
                                foreach (ProjectItem pi in p.ProjectItems)
                                {
                                    ApplicationObject.StatusBar.Progress(true, "Scanning package " + pi.Name, iProgress++, p.ProjectItems.Count);
                                    string sFileName = pi.Name.ToLower();
                                    if (!sFileName.EndsWith(".dtsx"))
                                    {
                                        continue;
                                    }
                                    piCurrent = pi;
                                    this.PackagePathPrefix = pi.Name;
                                    Package package = GetPackageFromIntegrationServicesProjectItem(pi);
                                    ScanIntegrationServicesProperties(package);
                                }
                            }
                        }
                        finally
                        {
                            try
                            {
                                ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationGeneral);
                                ApplicationObject.StatusBar.Progress(false, "", 1, 1);
                            }
                            catch { }
                        }
                    }
                }
                else if (solution != null)
                {
                    this.DatabaseName = "Solution: " + System.IO.Path.GetFileNameWithoutExtension(solution.FullName);
                    try
                    {
                        this.DatabaseName = "Solution: " + solution.Properties.Item("Name").Value;
                    }
                    catch { }

                    this.SSASProject = false;

                    try
                    {
                        using (WaitCursor cursor1 = new WaitCursor())
                        {
                            ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationGeneral);
                            foreach (EnvDTE.Project proj in solution.Projects)
                            {
                                Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)proj;
                                if (projExt.Kind == BIDSProjectKinds.SSIS)
                                {
                                    int iProgress = 0;
                                    Microsoft.SqlServer.Dts.Runtime.Application app = SSIS.PackageHelper.Application; //sets the proper TargetServerVersion;
                                    foreach (ProjectItem pi in proj.ProjectItems)
                                    {
                                        ApplicationObject.StatusBar.Progress(true, "Scanning project " + proj.Name + " package " + pi.Name, iProgress++, proj.ProjectItems.Count);
                                        string sFileName = pi.Name.ToLower();
                                        if (!sFileName.EndsWith(".dtsx"))
                                        {
                                            continue;
                                        }
                                        piCurrent = pi;
                                        this.PackagePathPrefix = proj.Name + "\\" + pi.Name;
                                        Package package = GetPackageFromIntegrationServicesProjectItem(pi);
                                        ScanIntegrationServicesProperties(package);
                                    }
                                }
                            }
                        }
                    }
                    finally
                    {
                        try
                        {
                            ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationGeneral);
                            ApplicationObject.StatusBar.Progress(false, "", 1, 1);
                        }
                        catch { }
                    }
                }
                else
                {
                    ProjectItem pi = (ProjectItem)hierItem.Object;
                    piCurrent = pi;
                    Package package = GetPackageFromIntegrationServicesProjectItem(pi);

                    this.DatabaseName      = "Package: " + package.Name;
                    this.SSASProject       = false;
                    this.PackagePathPrefix = string.Empty;

                    ScanIntegrationServicesProperties(package);
                }

                //clear the cache
                this.packageDefault = null;
                this.dictCachedDtsObjects.Clear();

                if (listNonDefaultProperties.Count == 0)
                {
                    MessageBox.Show("No properties set to non-default values were found.", "BIDS Helper - Non-Default Properties Report");
                    return;
                }

                //pop up the form to let the user exclude properties from showing on the report
                List <string> listExcludedProperties = new List <string>(this.ExcludedProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                BIDSHelper.SSAS.NonDefaultPropertiesSelectionForm selector = new BIDSHelper.SSAS.NonDefaultPropertiesSelectionForm();
                foreach (NonDefaultProperty prop in listNonDefaultProperties)
                {
                    if (!selector.listProperties.Items.Contains(prop.PropertyName))
                    {
                        bool bChecked = !listExcludedProperties.Contains(prop.PropertyName);
                        selector.listProperties.Items.Add(prop.PropertyName, bChecked);
                    }
                }

                DialogResult selectorResult = selector.ShowDialog();
                if (selectorResult == DialogResult.OK)
                {
                    //remove the the report rows they unchecked
                    for (int i = 0; i < listNonDefaultProperties.Count; i++)
                    {
                        if (!selector.listProperties.CheckedItems.Contains(listNonDefaultProperties[i].PropertyName))
                        {
                            listNonDefaultProperties.RemoveAt(i--);
                        }
                    }

                    //save their prefs... keep previously prefs which haven't been changes (because an excluded property may not show up in the possible properties list each time you run the report)
                    foreach (object item in selector.listProperties.Items)
                    {
                        if (!selector.listProperties.CheckedItems.Contains(item)) //if excluded, then add to the excluded list
                        {
                            if (!listExcludedProperties.Contains(item.ToString()))
                            {
                                listExcludedProperties.Add(item.ToString());
                            }
                        }
                        else //if included, then remove from the excluded list
                        {
                            if (listExcludedProperties.Contains(item.ToString()))
                            {
                                listExcludedProperties.Remove(item.ToString());
                            }
                        }
                    }
                    this.ExcludedProperties = string.Join(",", listExcludedProperties.ToArray());

                    ReportViewerForm frm = new ReportViewerForm();
                    frm.ReportBindingSource.DataSource = this.listNonDefaultProperties;
                    frm.Report = "SSAS.NonDefaultProperties.rdlc";
                    Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                    reportDataSource1.Name  = "BIDSHelper_NonDefaultProperty";
                    reportDataSource1.Value = frm.ReportBindingSource;
                    frm.ReportViewerControl.LocalReport.DataSources.Add(reportDataSource1);
                    frm.ReportViewerControl.LocalReport.ReportEmbeddedResource = frm.Report;

                    frm.Caption     = "Non-Default Properties Report";
                    frm.WindowState = FormWindowState.Maximized;
                    frm.Show();
                }
            }
            catch (DtsRuntimeException ex)
            {
                if (ex.ErrorCode == -1073659849L)
                {
                    MessageBox.Show((piCurrent == null ? "This package" : piCurrent.Name) + " has a package password. Please open the package designer, specify the password when the dialog prompts you, then rerun the Non-Default Properties report.\r\n\r\nDetailed error was:\r\n" + ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Password Not Specified");
                }
                else
                {
                    MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error" + (piCurrent == null ? string.Empty : " scanning " + piCurrent.Name));
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error" + (piCurrent == null ? string.Empty : " scanning " + piCurrent.Name));
            }
        }
        public override void Exec()
        {
            ProjectItem piCurrent = null;

            try
            {
                listPackageProperties = new List <PackageProperties>();

                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                SolutionClass   solution    = hierItem.Object as SolutionClass;
                EnvDTE.Project  proj        = GetSelectedProjectReference();

                if (proj != null)
                {
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)proj;
                    this.DatabaseName = "Project: " + proj.Name;

                    try
                    {
                        using (WaitCursor cursor1 = new WaitCursor())
                        {
                            int iProgress = 0;
                            ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationGeneral);
                            foreach (ProjectItem pi in proj.ProjectItems)
                            {
                                ApplicationObject.StatusBar.Progress(true, "Scanning package " + pi.Name, iProgress++, proj.ProjectItems.Count);
                                string sFileName = pi.Name.ToLower();
                                if (!sFileName.EndsWith(".dtsx"))
                                {
                                    continue;
                                }
                                piCurrent = pi;
                                this.PackagePathPrefix = pi.Name;
                                PackageProperties props = GetPackageProperties(pi);
                                if (props == null)
                                {
                                    continue;
                                }
                                listPackageProperties.Add(props);
                            }
                        }
                    }
                    finally
                    {
                        try
                        {
                            ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationGeneral);
                            ApplicationObject.StatusBar.Progress(false, "", 1, 1);
                        }
                        catch { }
                    }
                }
                else if (solution != null)
                {
                    this.DatabaseName = "Solution: " + System.IO.Path.GetFileNameWithoutExtension(solution.FullName);
                    try
                    {
                        this.DatabaseName = "Solution: " + solution.Properties.Item("Name").Value;
                    }
                    catch { }

                    try
                    {
                        using (WaitCursor cursor1 = new WaitCursor())
                        {
                            ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationGeneral);
                            foreach (EnvDTE.Project p in solution.Projects)
                            {
                                Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)p;
                                if (projExt.Kind == BIDSProjectKinds.SSIS)
                                {
                                    int iProgress = 0;
                                    foreach (ProjectItem pi in p.ProjectItems)
                                    {
                                        ApplicationObject.StatusBar.Progress(true, "Scanning project " + p.Name + " package " + pi.Name, iProgress++, p.ProjectItems.Count);
                                        string sFileName = pi.Name.ToLower();
                                        if (!sFileName.EndsWith(".dtsx"))
                                        {
                                            continue;
                                        }
                                        piCurrent = pi;
                                        this.PackagePathPrefix = p.Name + "\\" + pi.Name;
                                        PackageProperties props = GetPackageProperties(pi);
                                        if (props == null)
                                        {
                                            continue;
                                        }
                                        listPackageProperties.Add(props);
                                    }
                                }
                            }
                        }
                    }
                    finally
                    {
                        try
                        {
                            ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationGeneral);
                            ApplicationObject.StatusBar.Progress(false, "", 1, 1);
                        }
                        catch { }
                    }
                }

                ReportViewerForm frm = new ReportViewerForm();
                frm.ReportBindingSource.DataSource = this.listPackageProperties;
                frm.Report = "SSIS.SortablePackageProperties.rdlc";
                Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                reportDataSource1.Name  = "BIDSHelper_PackageProperties";
                reportDataSource1.Value = frm.ReportBindingSource;
                frm.ReportViewerControl.LocalReport.DataSources.Add(reportDataSource1);
                frm.ReportViewerControl.LocalReport.ReportEmbeddedResource = frm.Report;

                frm.Caption     = "Sortable Package Properties Report";
                frm.WindowState = FormWindowState.Maximized;
                frm.Show();
            }
            catch (DtsRuntimeException ex)
            {
                if (ex.ErrorCode == -1073659849L)
                {
                    MessageBox.Show((piCurrent == null ? "This package" : piCurrent.Name) + " has a package password. Please open the package designer, specify the password when the dialog prompts you, then rerun the Sortable Package Properties report.\r\n\r\nDetailed error was:\r\n" + ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Password Not Specified");
                }
                else
                {
                    MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error" + (piCurrent == null ? string.Empty : " scanning " + piCurrent.Name));
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error" + (piCurrent == null ? string.Empty : " scanning " + piCurrent.Name));
            }
        }