Skip to content

Commit cb920c4

Browse files
committed
Fixing FindVariableReferences form, and project file. Branching fun.
1 parent 5fb966b commit cb920c4

5 files changed

Lines changed: 389 additions & 21 deletions

SQL2012_BIDSHelper.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@
199199
<Reference Include="Microsoft.SqlServer.ExecPackageTaskWrap, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
200200
<SpecificVersion>False</SpecificVersion>
201201
<EmbedInteropTypes>False</EmbedInteropTypes>
202-
<HintPath>..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ExecPackageTaskWrap\v4.0_11.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ExecPackageTaskWrap.dll</HintPath>
203-
<Private>False</Private>
202+
<HintPath>..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ExecPackageTaskWrap\v4.0_11.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ExecPackageTaskWrap.dll</HintPath>
204203
</Reference>
205204
<Reference Include="Microsoft.SqlServer.Graph, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
206205
<SpecificVersion>False</SpecificVersion>
@@ -219,10 +218,9 @@
219218
<SpecificVersion>True</SpecificVersion>
220219
<Private>False</Private>
221220
</Reference>
222-
<Reference Include="Microsoft.SqlServer.SQLTask, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=x86">
221+
<Reference Include="Microsoft.SqlServer.SQLTask, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=x86">
223222
<SpecificVersion>False</SpecificVersion>
224-
<HintPath>..\..\Program Files (x86)\Microsoft SQL Server\110\DTS\Tasks\Microsoft.SqlServer.SQLTask.dll</HintPath>
225-
<Private>False</Private>
223+
<HintPath>..\..\..\Program Files (x86)\Microsoft SQL Server\110\DTS\Tasks\Microsoft.SqlServer.SQLTask.dll</HintPath>
226224
</Reference>
227225
<Reference Include="Microsoft.VisualBasic" />
228226
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

SSIS/AutoSortProjectFilesPlugin.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,32 +94,32 @@ private void SolutionOpened()
9494

9595
private void ProcessHierarchyItem(UIHierarchyItem hierarchyItem)
9696
{
97-
for (var i = 1; i <= hierarchyItem.UIHierarchyItems.Count; i++)
98-
{
99-
// Get the child item in the solution or folder
100-
var projectItem = hierarchyItem.UIHierarchyItems.Item(i);
101-
102-
// Check if it is a Project, skip if not (Solution folders are a type of project too)
103-
var project = projectItem.Object as Project;
104-
if (project == null)
105-
{
106-
continue;
107-
}
97+
System.Diagnostics.Debug.WriteLine(hierarchyItem.Name);
10898

99+
// Check if it is a Project, skip if not (Solution folders are a type of project too)
100+
var project = hierarchyItem.Object as Project;
101+
if (project != null)
102+
{
109103
// Check if it is a SSIS Project, process if it is
110104
if (project.Kind == BIDSProjectKinds.SSIS)
111105
{
112-
ProcessProject(projectItem);
113-
}
114-
else if (project.Kind == BIDSProjectKinds.SolutionFolder)
115-
{
116-
ProcessHierarchyItem(projectItem);
106+
ProcessProject(hierarchyItem);
107+
return;
117108
}
118109
}
110+
111+
// Loop through child items. N.B. Collection index is 1 based, how quaint.
112+
for (var i = 1; i <= hierarchyItem.UIHierarchyItems.Count; i++)
113+
{
114+
var childItem = hierarchyItem.UIHierarchyItems.Item(i);
115+
ProcessHierarchyItem(childItem);
116+
}
119117
}
120118

121119
private void ProcessProject(UIHierarchyItem projectItem)
122120
{
121+
System.Diagnostics.Debug.WriteLine(string.Format("Sorting SSIS Project {0}", projectItem.Name));
122+
123123
for (var i = 1; i <= projectItem.UIHierarchyItems.Count; i++)
124124
{
125125
// Get a project folder, although not all items will be folders, e.g. connections and parameters

SSIS/FindVariableReferences.Designer.cs

Lines changed: 131 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SSIS/FindVariableReferences.cs

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
using BIDSHelper.Core;
2+
using Microsoft.SqlServer.Dts.Runtime;
3+
using System;
4+
using System.ComponentModel;
5+
using System.Drawing;
6+
using System.Windows.Forms;
7+
8+
namespace BIDSHelper.SSIS
9+
{
10+
public partial class FindVariableReferences : Form
11+
{
12+
private BackgroundWorker processPackage = null;
13+
private System.Diagnostics.Stopwatch stopwatch;
14+
private FindVariables finder = new FindVariables();
15+
private Package package;
16+
private Variable variable;
17+
18+
public FindVariableReferences()
19+
{
20+
InitializeComponent();
21+
22+
processPackage = new BackgroundWorker();
23+
processPackage.WorkerReportsProgress = true;
24+
processPackage.WorkerSupportsCancellation = true;
25+
processPackage.DoWork += new DoWorkEventHandler(processPackage_DoWork);
26+
processPackage.RunWorkerCompleted += new RunWorkerCompletedEventHandler(processPackage_RunWorkerCompleted);
27+
28+
this.Icon = BIDSHelper.Resources.Versioned.VariableFindReferences;
29+
}
30+
31+
public void Show(Package package, Variable variable)
32+
{
33+
this.progressBar.Visible = true;
34+
35+
this.package = package;
36+
this.variable = variable;
37+
38+
InitializeTreeView();
39+
40+
stopwatch = new System.Diagnostics.Stopwatch();
41+
processPackage.RunWorkerAsync();
42+
43+
this.Show();
44+
}
45+
46+
public void Show(Package package, Parameter parameter)
47+
{
48+
// Get the Variable object that is the same as the Parameter. A parameter is also an item in the Variables collection.
49+
Variable variable = package.Variables[parameter.ID];
50+
this.Show(package, variable);
51+
}
52+
53+
private void InitializeTreeView()
54+
{
55+
this.treeView.Nodes.Clear();
56+
this.treeView.SuspendLayout();
57+
this.treeView.Enabled = false;
58+
}
59+
60+
private void VariableFound(object sender, VariableFoundEventArgs e)
61+
{
62+
// Report variable found via BackGroundWorker to ensure we are thread safe when accessing the form control later on
63+
this.processPackage.ReportProgress(0, e);
64+
}
65+
66+
private void PruneNodes(TreeNode parent)
67+
{
68+
for (int index = parent.Nodes.Count -1; index >= 0; index--)
69+
{
70+
TreeNode node = parent.Nodes[index];
71+
72+
if (node.IsExpanded || node.Checked)
73+
{
74+
PruneNodes(node);
75+
}
76+
else
77+
{
78+
node.Remove();
79+
}
80+
}
81+
}
82+
83+
#region BackgroundWorker Events
84+
85+
private void processPackage_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
86+
{
87+
TreeNode parent = this.treeView.Nodes[0];
88+
PruneNodes(parent);
89+
90+
stopwatch.Stop();
91+
this.Text += (" " + stopwatch.ElapsedMilliseconds.ToString());
92+
93+
this.treeView.Enabled = true;
94+
this.treeView.ResumeLayout();
95+
96+
this.progressBar.Visible = false;
97+
}
98+
99+
private void processPackage_DoWork(object sender, DoWorkEventArgs e)
100+
{
101+
stopwatch.Start();
102+
finder.FindReferences(this.package, this.variable, this.treeView);
103+
}
104+
#endregion
105+
106+
private void treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
107+
{
108+
SetPropertyGrid(e.Node);
109+
}
110+
111+
private void SetPropertyGrid(TreeNode node)
112+
{
113+
propertyGrid.SelectedObject = node.Tag;
114+
}
115+
}
116+
}

0 commit comments

Comments
 (0)