Skip to content

Commit 945e68c

Browse files
author
Tamim Kadah-Salim
committed
set TIA whitelist registry entry when possible
1 parent 7284658 commit 945e68c

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

TiaGitHandler/Program.cs

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,23 @@ static void Main(string[] args)
9797
Console.WriteLine("Bitte S7 projekt als Parameter angeben!");
9898
return;
9999
}
100+
var version = file.Substring(file.Length - 2, 2) + ".0";
101+
try
102+
{
103+
TiaOpennessWhitelist.EnsureWhitelistEntry(version);
104+
}
105+
catch (InvalidOperationException ex)
106+
{
107+
Console.WriteLine($"Cannot set TIA whitelist registry entry: {ex.Message}");
108+
}
109+
catch (SecurityException ex)
110+
{
111+
Console.WriteLine($"Security exception cannot set TIA whitelist registry entry: {ex.Message}");
112+
}
113+
catch (UnauthorizedAccessException ex)
114+
{
115+
Console.WriteLine($"Unauthorized access exception cannot set TIA whitelist registry entry: {ex.Message}");
116+
}
100117

101118
if (Path.GetExtension(file) == ".ap15_1" || Path.GetExtension(file) == ".ap16")
102119
{
@@ -127,8 +144,25 @@ static void Main(string[] args)
127144
else if (res != null)
128145
{
129146
var ver = ask.Result as string;
130-
prj = Projects.AttachProject(ver);
147+
148+
try
149+
{
150+
TiaOpennessWhitelist.EnsureWhitelistEntry(ver + ".0");
151+
}
152+
catch (InvalidOperationException ex)
153+
{
154+
Console.WriteLine($"Cannot set TIA whitelist registry entry: {ex.Message}");
155+
}
156+
catch (SecurityException ex)
157+
{
158+
Console.WriteLine($"Authorization context to low cannot set TIA whitelist registry entry: {ex.Message}");
159+
}
160+
catch (UnauthorizedAccessException ex)
161+
{
162+
Console.WriteLine($"Unauthorized access exception cannot set TIA whitelist registry entry: {ex.Message}");
163+
}
131164

165+
prj = Projects.AttachProject(ver);
132166
exportPath = Path.GetDirectoryName(prj.ProjectFile);
133167
exportPath = Path.GetFullPath(Path.Combine(exportPath, "..\\out\\Export"));
134168
}
@@ -183,7 +217,7 @@ static void Main(string[] args)
183217
}
184218
}
185219

186-
var version = file.Substring(file.Length - 2, 2);
220+
var version = file.Substring(file.Length - 2, 2) + ".0";
187221

188222
try
189223
{
@@ -193,6 +227,15 @@ static void Main(string[] args)
193227
{
194228
Console.WriteLine($"Cannot set TIA whitelist registry entry: {ex.Message}");
195229
}
230+
catch (SecurityException ex)
231+
{
232+
Console.WriteLine($"Security exception cannot set TIA whitelist registry entry: {ex.Message}");
233+
}
234+
catch (UnauthorizedAccessException ex)
235+
{
236+
Console.WriteLine($"Unauthorized access exception cannot set TIA whitelist registry entry: {ex.Message}");
237+
}
238+
196239

197240
if (attach)
198241
{

0 commit comments

Comments
 (0)