Skip to content

Commit 9df7d1e

Browse files
committed
I fixed the ConfirmRemovalCode to not delete the Gateway and some other bugs with RemoveTableCode.
1 parent 084d64c commit 9df7d1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+496
-565
lines changed

DataJuggler.Win.Controls/DataJuggler.Win.Controls.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
</ApplicationIcon>
4848
</PropertyGroup>
4949
<ItemGroup>
50-
<Reference Include="DataJuggler.Core.UltimateHelper, Version=1.7.1.0, Culture=neutral, processorArchitecture=MSIL">
51-
<HintPath>..\packages\DataJuggler.Core.UltimateHelper.1.7.1\lib\net48\DataJuggler.Core.UltimateHelper.dll</HintPath>
50+
<Reference Include="DataJuggler.Core.UltimateHelper, Version=1.9.0.0, Culture=neutral, processorArchitecture=MSIL">
51+
<HintPath>..\packages\DataJuggler.Core.UltimateHelper.1.9.1\lib\net48\DataJuggler.Core.UltimateHelper.dll</HintPath>
5252
</Reference>
5353
<Reference Include="System" />
5454
<Reference Include="System.Core" />
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="DataJuggler.Core.UltimateHelper" version="1.7.1" targetFramework="net48" />
3+
<package id="DataJuggler.Core.UltimateHelper" version="1.9.1" targetFramework="net48" />
44
</packages>

DataTier.Net.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DataJuggler", "DataJuggler"
2323
EndProject
2424
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataJuggler.Win.Controls", "DataJuggler.Win.Controls\DataJuggler.Win.Controls.csproj", "{70E97B98-9BE2-4747-A3AF-1C274AE401CE}"
2525
EndProject
26+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataJuggler.Net", "..\DataJuggler.Net\DataJuggler.Net.csproj", "{AF3F5EC6-8494-4CA2-AAC0-B1FA4F752EF5}"
27+
EndProject
2628
Global
2729
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2830
Debug|Any CPU = Debug|Any CPU
@@ -57,6 +59,10 @@ Global
5759
{70E97B98-9BE2-4747-A3AF-1C274AE401CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
5860
{70E97B98-9BE2-4747-A3AF-1C274AE401CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
5961
{70E97B98-9BE2-4747-A3AF-1C274AE401CE}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{AF3F5EC6-8494-4CA2-AAC0-B1FA4F752EF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{AF3F5EC6-8494-4CA2-AAC0-B1FA4F752EF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{AF3F5EC6-8494-4CA2-AAC0-B1FA4F752EF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{AF3F5EC6-8494-4CA2-AAC0-B1FA4F752EF5}.Release|Any CPU.Build.0 = Release|Any CPU
6066
EndGlobalSection
6167
GlobalSection(SolutionProperties) = preSolution
6268
HideSolutionNode = FALSE
@@ -70,6 +76,7 @@ Global
7076
{27171EDA-23EC-4637-BAB3-0FA3F272495B} = {BF88761D-1DEA-4D4B-83DC-570B0BC403B5}
7177
{1F6EF59D-ACCF-4C84-9A99-CC0F27092F17} = {BF88761D-1DEA-4D4B-83DC-570B0BC403B5}
7278
{70E97B98-9BE2-4747-A3AF-1C274AE401CE} = {04AECD9C-6B82-4670-91E4-01CF9962EB0D}
79+
{AF3F5EC6-8494-4CA2-AAC0-B1FA4F752EF5} = {04AECD9C-6B82-4670-91E4-01CF9962EB0D}
7380
EndGlobalSection
7481
GlobalSection(ExtensibilityGlobals) = postSolution
7582
SolutionGuid = {131447C9-774E-4410-AA8D-F03B8B7F974F}

DataTier.Net/Client/ClientUtil/VisualStudioHelper.cs

Lines changed: 120 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private static Type GetObjectType()
195195
Type objectType = null;
196196

197197
// locals
198-
double versionNumber = 17;
198+
double versionNumber = 18;
199199
string programId = "";
200200

201201
do
@@ -309,21 +309,25 @@ private static bool RemoveFileIfFileExistsInProject(EnvDTE.Project project, Proj
309309

310310
// local (Com objects start at 1)
311311
int index = 0;
312-
312+
313313
// iterate project items
314314
foreach(ProjectItem projectItem in projectItems)
315315
{
316-
// Increment the value for tempIndex
316+
// Increment the value for index
317317
index++;
318318

319319
// if the name matches
320320
if(projectItem.Name == projectFile.FileName)
321321
{
322-
// Remove this item
323-
projectItems.Item(index).Remove();
322+
// if this is not the Gateway
323+
if (!projectFile.FileName.Contains("Gateway"))
324+
{
325+
// Remove this item
326+
projectItems.Item(index).Remove();
324327

325-
// Set to true
326-
fileRemoved = true;
328+
// Set to true
329+
fileRemoved = true;
330+
}
327331

328332
// break out of loop
329333
break;
@@ -346,6 +350,62 @@ private static bool RemoveFileIfFileExistsInProject(EnvDTE.Project project, Proj
346350
return fileRemoved;
347351
}
348352
#endregion
353+
354+
#region SafeGetProjectItems(EnvDTE.Project project)
355+
/// <summary>
356+
/// method returns the Get Project Items
357+
/// </summary>
358+
private static EnvDTE.ProjectItems SafeGetProjectItems(EnvDTE.Project project)
359+
{
360+
// initial value
361+
EnvDTE.ProjectItems projectItems = null;
362+
363+
// if the project exists
364+
if (project != null)
365+
{
366+
try
367+
{
368+
projectItems = project.ProjectItems;
369+
}
370+
catch
371+
{
372+
// swallow; COM can throw until fully ready
373+
}
374+
}
375+
376+
// return value
377+
return projectItems;
378+
}
379+
#endregion
380+
381+
#region TryTouchProject(EnvDTE.Project project)
382+
/// <summary>
383+
/// method returns the Touch Project
384+
/// </summary>
385+
private static void TryTouchProject(EnvDTE.Project project)
386+
{
387+
// if the project exists
388+
if (project != null)
389+
{
390+
try
391+
{
392+
// Touching these often triggers load completion
393+
string fullName = project.FullName;
394+
object projectObject = project.Object;
395+
396+
EnvDTE.Properties properties = project.Properties;
397+
if (properties != null)
398+
{
399+
int propertyCount = properties.Count;
400+
}
401+
}
402+
catch
403+
{
404+
// ignore; we're only nudging
405+
}
406+
}
407+
}
408+
#endregion
349409

350410
#region UpdateProject(EnvDTE.Project project, IList<ProjectFile> files, DataManager.ProjectTypeEnum projectType)
351411
/// <summary>
@@ -454,6 +514,9 @@ internal static bool UpdateSolution(VisualStudioSolution visualStudioSolution, s
454514
// each project needs to be updated
455515
foreach (EnvDTE.Project project in solution.Projects)
456516
{
517+
// wait for the projectItems
518+
WaitUntilProjectItemsReady(project, 2000, 100);
519+
457520
// if this project name is the ApplicationLogicComponen project
458521
if (project.Name == visualStudioSolution.ApplicationLogicComponentProjectName)
459522
{
@@ -556,6 +619,56 @@ internal static bool UpdateSolution(VisualStudioSolution visualStudioSolution, s
556619
}
557620
#endregion
558621

622+
#region WaitForProjectItems(EnvDTE.Project project, int timeoutMs, int pollMs)
623+
/// <summary>
624+
/// method returns the For Project Items
625+
/// </summary>
626+
private static bool WaitUntilProjectItemsReady(EnvDTE.Project project, int timeoutMilliseconds, int pollMilliseconds)
627+
{
628+
// initial value
629+
bool ready = false;
630+
631+
// if the project exists
632+
if (project != null)
633+
{
634+
DateTime endTime = DateTime.UtcNow.AddMilliseconds(timeoutMilliseconds);
635+
636+
while (DateTime.UtcNow < endTime)
637+
{
638+
// Nudge project to complete initialization
639+
TryTouchProject(project);
640+
641+
EnvDTE.ProjectItems projectItems = SafeGetProjectItems(project);
642+
643+
// if the projectItems exist
644+
if (projectItems != null)
645+
{
646+
ready = true;
647+
break;
648+
}
649+
650+
System.Windows.Forms.Application.DoEvents();
651+
System.Threading.Thread.Sleep(pollMilliseconds);
652+
}
653+
654+
// final attempt after loop
655+
if (!ready)
656+
{
657+
TryTouchProject(project);
658+
EnvDTE.ProjectItems finalItems = SafeGetProjectItems(project);
659+
660+
if (finalItems != null)
661+
{
662+
ready = true;
663+
}
664+
}
665+
}
666+
667+
// return value
668+
return ready;
669+
}
670+
#endregion
671+
559672
#endregion
560673

561674
}

DataTier.Net/Client/Controls/ConfirmChangesControl.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,9 @@ public void Setup(MethodInfo methodInfo, Project project)
21192119
{
21202120
// Now called Data folder
21212121
customReaderFile = @"DataAccessComponent\Data\Readers\" + MethodInfo.CustomReader.ClassName + ".cs";
2122+
2123+
// Set the dataManager file
2124+
dataManagerFile = @"DataAccessComponent\Data\" + MethodInfo.SelectedTable.ClassName + "Manager.cs";
21222125
}
21232126

21242127
// local used to display the updated Method for the DataManager

DataTier.Net/Client/Controls/ConfirmRemovalControl.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,22 @@ public void Setup(ProjectFileManager projectFileManager, string projectFolder, b
186186
foreach (ProjectFile file in projectFileManager.Files)
187187
{
188188
// if this is the Gateway
189-
if (file.ProjectType == DataManager.ProjectTypeEnum.Gateway)
189+
if ((file.ProjectType == DataManager.ProjectTypeEnum.Gateway) || (file.FileName.Contains("Gateway")))
190190
{
191191
// Do not display or remove the Gateway file, but it is needed to remove the Gateway methods
192192
}
193193
else
194194
{
195-
// Add this item
196-
this.CodeItemsListBox.Items.Add(file.ShortFilePath, true);
195+
if (File.Exists(file.FullFilePath))
196+
{
197+
// Add this item with the ShortFilePath
198+
this.CodeItemsListBox.Items.Add(file.FullFilePath, true);
199+
}
200+
else
201+
{
202+
// Add this item with the ShortFilePath
203+
this.CodeItemsListBox.Items.Add(file.ShortFilePath, true);
204+
}
197205
}
198206
}
199207
}

DataTier.Net/Client/Controls/DataEditorControl.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ private void RemoveTableButton_Click(object sender, EventArgs e)
289289
ProjectFile writerFile = new ProjectFile(writerFileName, DataManager.ProjectTypeEnum.DAC);
290290
ProjectFile writerFileBase = new ProjectFile(writerBaseFileName, DataManager.ProjectTypeEnum.DAC);
291291

292-
// only for .NET8 and V2 Templates
292+
// only V2 Templates
293293
if (Project.TemplateVersion == 2)
294294
{
295295
// replace out
@@ -396,8 +396,12 @@ private void RemoveTableButton_Click(object sender, EventArgs e)
396396
{
397397
if (File.Exists(projectFile.FullFilePath))
398398
{
399-
// Delete this file
400-
File.Delete(projectFile.FullFilePath);
399+
// if this is not the Gateway
400+
if (!projectFile.FileName.Contains("Gateway"))
401+
{
402+
// Delete this file
403+
File.Delete(projectFile.FullFilePath);
404+
}
401405
}
402406
else
403407
{

0 commit comments

Comments
 (0)