Skip to content

Commit 06530f3

Browse files
committed
Added new read-only warning text to BIML overwrite, and turn off read-only file flag before copy on overwrite. Minor fixes for find references too
1 parent 49c4471 commit 06530f3

8 files changed

Lines changed: 108 additions & 19 deletions

SSIS/Biml/BimlExpandPlugin.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,24 +163,28 @@ private void Expand(List<string> bimlScriptPaths, Project project, string projec
163163

164164

165165
List<string> newProjectFiles = new List<string>();
166-
string[] newPackageFiles = Directory.GetFiles(tempTargetDirectory, "*.dtsx", SearchOption.AllDirectories);
167-
newProjectFiles.AddRange(newPackageFiles);
168-
169166
#if (!YUKON && !KATMAI)
170167
//IF DENALI or later...
171168
// Read packages AND project connection managers
172169
string[] newConnFiles = Directory.GetFiles(tempTargetDirectory, "*.conmgr", SearchOption.AllDirectories);
173170
newProjectFiles.AddRange(newConnFiles);
174171
#endif
172+
173+
string[] newPackageFiles = Directory.GetFiles(tempTargetDirectory, "*.dtsx", SearchOption.AllDirectories);
174+
newProjectFiles.AddRange(newPackageFiles);
175+
175176
var safePackageFilePaths = new List<string>();
176177
var conflictingPackageFilePaths = new List<string>();
178+
var conflictingPackageHighlights = new List<bool>();
177179
foreach (var tempFilePath in newProjectFiles)
178180
{
179181
string tempFileName = Path.GetFileName(tempFilePath);
180182
string projectItemFileName = Path.Combine(projectDirectory, tempFileName);
181183
if (File.Exists(projectItemFileName))
182184
{
183185
conflictingPackageFilePaths.Add(tempFilePath);
186+
bool readOnly = new FileInfo(projectItemFileName).IsReadOnly;
187+
conflictingPackageHighlights.Add(readOnly);
184188
}
185189
else
186190
{
@@ -190,7 +194,7 @@ private void Expand(List<string> bimlScriptPaths, Project project, string projec
190194

191195
if (conflictingPackageFilePaths.Count > 0)
192196
{
193-
var dialog = new MultipleSelectionConfirmationDialog(conflictingPackageFilePaths, projectDirectory, safePackageFilePaths.Count);
197+
var dialog = new MultipleSelectionConfirmationDialog(conflictingPackageFilePaths, conflictingPackageHighlights, projectDirectory, safePackageFilePaths.Count);
194198
if (dialog.ShowDialog() == DialogResult.OK)
195199
{
196200
foreach (var filePath in dialog.SelectedFilePaths)
@@ -337,6 +341,14 @@ private void Expand(List<string> bimlScriptPaths, Project project, string projec
337341
foreach (var tempFilePath in safePackageFilePaths)
338342
{
339343
string projectItemFilePath = Path.Combine(projectDirectory, Path.GetFileName(tempFilePath));
344+
345+
// Check for read-only and try and overwrite
346+
FileAttributes attributes = File.GetAttributes(projectItemFilePath);
347+
if (attributes.HasFlag(FileAttributes.ReadOnly))
348+
{
349+
File.SetAttributes(projectItemFilePath, attributes & ~FileAttributes.ReadOnly);
350+
}
351+
340352
File.Copy(tempFilePath, projectItemFilePath, true);
341353
project.ProjectItems.AddFromFile(projectItemFilePath);
342354
}

SSIS/Biml/MultipleSelectionConfirmationDialog.Designer.cs

Lines changed: 44 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SSIS/Biml/MultipleSelectionConfirmationDialog.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public IEnumerable<string> SelectedFilePaths
1515
get; private set;
1616
}
1717

18-
public MultipleSelectionConfirmationDialog(List<string> itemsSource, string projectDirectory, int safeCount)
18+
public MultipleSelectionConfirmationDialog(List<string> itemsSource, List<bool> highlighted, string projectDirectory, int safeCount)
1919
{
2020
this.itemsSource = itemsSource;
2121
InitializeComponent();
@@ -24,10 +24,14 @@ public MultipleSelectionConfirmationDialog(List<string> itemsSource, string proj
2424
"In addition to {0} new items, the template generated the following items that conflict with existing items. Which of these items would you like to overwrite?",
2525
safeCount);
2626

27+
int index = 0;
2728
foreach (var item in itemsSource)
2829
{
29-
selectionList.AddItem(Path.Combine(projectDirectory, Path.GetFileName(item)), true);
30+
selectionList.AddItem(Path.Combine(projectDirectory, Path.GetFileName(item)), true, highlighted[index]);
31+
index++;
3032
}
33+
34+
panelWarning.Visible = (highlighted.Contains(true));
3135
}
3236

3337
private void helpButton_Click(object sender, EventArgs e)

SSIS/FindVariableReferences.Designer.cs

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SSIS/FindVariables.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,16 +869,29 @@ private void CheckForLoop(IDTSPropertiesProvider forLoop, TreeNode parent)
869869
ScanProperties(forLoop, parent);
870870

871871
DtsProperty property;
872+
object propertyValue;
872873

873874
// Check explicit expression properties as expressions, missed if we are looking for literal variables.
874875
property = forLoop.Properties["AssignExpression"];
875-
PropertyAsExpressionMatch(property, property.GetValue(forLoop).ToString(), parent);
876+
propertyValue = property.GetValue(forLoop);
877+
if (propertyValue != null)
878+
{
879+
PropertyAsExpressionMatch(property, propertyValue.ToString(), parent);
880+
}
876881

877882
property = forLoop.Properties["EvalExpression"];
878-
PropertyAsExpressionMatch(property, property.GetValue(forLoop).ToString(), parent);
883+
propertyValue = property.GetValue(forLoop);
884+
if (propertyValue != null)
885+
{
886+
PropertyAsExpressionMatch(property, propertyValue.ToString(), parent);
887+
}
879888

880889
property = forLoop.Properties["InitExpression"];
881-
PropertyAsExpressionMatch(property, property.GetValue(forLoop).ToString(), parent);
890+
propertyValue = property.GetValue(forLoop);
891+
if (propertyValue != null)
892+
{
893+
PropertyAsExpressionMatch(property, propertyValue.ToString(), parent);
894+
}
882895
}
883896

884897
private void PropertyAsExpressionMatch(DtsProperty property, string expression, TreeNode parent)

SSIS/ParametersWindowPlugin.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ public override void OnWindowActivated(Window GotFocus, Window LostFocus)
6565

6666
// We want the DtsPackageView, an EditorWindow, Microsoft.DataTransformationServices.Design.DtsPackageView
6767
EditorWindow editorWindow = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator));
68+
if (editorWindow == null)
69+
return;
6870

6971
if (editorWindow.Tag == null)
7072
{
7173
ParametersWindowManager manager = new ParametersWindowManager(editorWindow);
7274
}
7375
else
7476
{
75-
// Safety check to see if anyoine else is using the Tag on the DtsPackageView
77+
// Safety check to see if anyone else is using the Tag on the DtsPackageView
7678
ParametersWindowManager manager = editorWindow.Tag as ParametersWindowManager;
7779
if (manager == null)
7880
{
@@ -221,7 +223,7 @@ private void SetupControl()
221223
// Find Unused button
222224
this.findUnusedButton = new ToolBarButton();
223225
this.findUnusedButton.Style = ToolBarButtonStyle.PushButton;
224-
this.findUnusedButton.ToolTipText = "Find Parameter References (BIDS Helper)";
226+
this.findUnusedButton.ToolTipText = "Find Unused Parameters (BIDS Helper)";
225227
toolbar.Buttons.Add(this.findUnusedButton);
226228
toolbar.ImageList.Images.Add(BIDSHelper.Resources.Versioned.VariableFindUnused);
227229
this.findUnusedButton.ImageIndex = toolbar.ImageList.Images.Count - 1;

SSIS/VariablesWindowPlugin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private void HookupVariablesWindow(Window GotFocus)
127127
if (this.moveCopyButton != null && toolbar.Buttons.Contains(this.moveCopyButton)) return;
128128

129129
#if DENALI || SQL2014
130-
// When you clock the edit expression ellipsis button in the variables grid, we want to use our own expression editor, not the MS one.
130+
// When you click the edit expression ellipsis button in the variables grid, we want to use our own expression editor, not the MS one.
131131
// The following section removes their event handler and adds our own
132132
// Get the type of the variables grid, and get the MouseButtonClicked clicked event info
133133
// Then get the private dlgGridControl1_MouseButtonClicked event handler method, and get an instance delegate
@@ -175,7 +175,7 @@ private void HookupVariablesWindow(Window GotFocus)
175175
// Find Unused button
176176
this.findUnusedButton = new ToolBarButton();
177177
this.findUnusedButton.Style = ToolBarButtonStyle.PushButton;
178-
this.findUnusedButton.ToolTipText = "Find Variable References (BIDS Helper)";
178+
this.findUnusedButton.ToolTipText = "Find Unused Variables (BIDS Helper)";
179179
toolbar.Buttons.Add(this.findUnusedButton);
180180
toolbar.ImageList.Images.Add(BIDSHelper.Resources.Versioned.VariableFindUnused);
181181
this.findUnusedButton.ImageIndex = toolbar.ImageList.Images.Count - 1;

core/SelectionList.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,26 @@ private void UpdateSelectAllCheckBox()
121121

122122
public void AddItem(string item)
123123
{
124-
AddItem(item, false);
124+
AddItem(item, false, false);
125125
}
126126

127-
public void AddItem(string item, bool selected)
127+
public void AddItem(string item, bool selected, bool highlighted)
128128
{
129129
if (this.SelectionEnabled)
130130
{
131-
dataGridView.Rows.Add(selected, item);
131+
// Add new row
132+
int index = dataGridView.Rows.Add(selected, item);
133+
134+
// Set text to italic if "highlighted"
135+
if (highlighted)
136+
{
137+
DataGridViewCell cell = dataGridView.Rows[index].Cells[1];
138+
DataGridViewCellStyle style = cell.Style.Clone();
139+
style.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
140+
cell.Style = style;
141+
}
142+
143+
// Update selection checkbox stuff
132144
totalItems++;
133145
checkedItems += (selected ? 1 : 0);
134146
UpdateSelectAllCheckBox();
@@ -143,7 +155,7 @@ public void AddRange(string[] items)
143155
{
144156
foreach (string item in items)
145157
{
146-
AddItem(item, false);
158+
AddItem(item, false, false);
147159
}
148160
}
149161

0 commit comments

Comments
 (0)