Skip to content

Commit c71c5fd

Browse files
committed
Improved installer to avoid picking up older DLL versions referenced by tests
Added explicit method to call to report project progress. Included advances in completed stages in project progress analytics
1 parent 016fab7 commit c71c5fd

File tree

5 files changed

+66
-16
lines changed

5 files changed

+66
-16
lines changed

src/Installer/Installer.wxs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<!--Don't even think of EVER changing this, despite the counter-intuitive name. What it is: "a shared identifier that represents multiple versions of an application" -->
77
<?define Property_UpgradeCode = "{CBCDEE93-B8EF-445e-98A9-B8CAF9502F0D}" ?>
88

9-
<?define OutputDir = "..\..\output\x64\$(var.Configuration)\net48\" ?>
9+
<?define OutputDir = "..\..\src\SayMore\bin\x64\$(var.Configuration)\net48\" ?>
10+
<?define NativeAssetsDir = "..\..\output\x64\$(var.Configuration)\net48\lib\win-x64\" ?>
1011

1112
<!-- good intro to the component vs. file thing, and why each file here is a separate component:
1213
http://blogs.msdn.com/robmen/archive/2003/10/04/56479.aspx -->
@@ -345,22 +346,22 @@ are trying to support, you're better off using non-advertised shortcuts. "-->
345346
</Component>
346347

347348
<Component Id="icudt59.x64" Guid="{F0CAECD1-8D7E-4D4F-9147-A4E8ED2B741B}" Win64="yes">
348-
<File Id="icudt59.x64" Name="icudt59.dll" KeyPath="yes" Source="$(var.OutputDir)lib\win-x64\icudt59.dll" />
349+
<File Id="icudt59.x64" Name="icudt59.dll" KeyPath="yes" Source="$(var.NativeAssetsDir)icudt59.dll" />
349350
</Component>
350351
<Component Id="icuin59.x64" Guid="{F0CAECD1-8D7E-4D4F-9147-A4E8ED2B741C}" Win64="yes">
351-
<File Id="icuin59.x64" Name="icuin59.dll" KeyPath="yes" Source="$(var.OutputDir)lib\win-x64\icuin59.dll" />
352+
<File Id="icuin59.x64" Name="icuin59.dll" KeyPath="yes" Source="$(var.NativeAssetsDir)icuin59.dll" />
352353
</Component>
353354
<Component Id="icuuc59.x64" Guid="{F0CAECD1-8D7E-4D4F-9147-A4E8ED2B741D}" Win64="yes">
354-
<File Id="icuuc59.x64" Name="icuuc59.dll" KeyPath="yes" Source="$(var.OutputDir)lib\win-x64\icuuc59.dll" />
355+
<File Id="icuuc59.x64" Name="icuuc59.dll" KeyPath="yes" Source="$(var.NativeAssetsDir)icuuc59.dll" />
355356
</Component>
356357
<Component Id="ikpFlac.x64" Guid="{F0CAECD1-8D7E-4D4F-9147-A4E8ED2B741E}" Win64="yes">
357-
<File Id="ikpFlac.x64" Name="ikpFlac.dll" KeyPath="yes" Source="$(var.OutputDir)lib\win-x64\ikpFlac.dll" />
358+
<File Id="ikpFlac.x64" Name="ikpFlac.dll" KeyPath="yes" Source="$(var.NativeAssetsDir)ikpFlac.dll" />
358359
</Component>
359360
<Component Id="ikpMP3.x64" Guid="{F0CAECD1-8D7E-4D4F-9147-A4E8ED2B742A}" Win64="yes">
360-
<File Id="ikpMP3.x64" Name="ikpMP3.dll" KeyPath="yes" Source="$(var.OutputDir)lib\win-x64\ikpMP3.dll" />
361+
<File Id="ikpMP3.x64" Name="ikpMP3.dll" KeyPath="yes" Source="$(var.NativeAssetsDir)ikpMP3.dll" />
361362
</Component>
362363
<Component Id="irrKlang.NET4.x64" Guid="{F0CAECD1-8D7E-4D4F-9147-A4E8ED2B742B}" Win64="yes">
363-
<File Id="irrKlang.NET4.x64" Name="irrKlang.NET4.dll" KeyPath="yes" Source="$(var.OutputDir)lib\win-x64\irrKlang.NET4.dll" />
364+
<File Id="irrKlang.NET4.x64" Name="irrKlang.NET4.dll" KeyPath="yes" Source="$(var.NativeAssetsDir)irrKlang.NET4.dll" />
364365
</Component>
365366
</Directory>
366367
</Directory>

src/SayMore/Model/Files/DataGathering/BackgroundFileProcessor.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,7 @@ protected virtual void ProcessAllFiles(string topLevelFolder, bool searchSubFold
388388

389389
Status = kUpToDataStatus;
390390

391-
if (FinishedProcessingAllFiles != null)
392-
FinishedProcessingAllFiles(this, EventArgs.Empty);
391+
FinishedProcessingAllFiles?.Invoke(this, EventArgs.Empty);
393392
}
394393

395394
private static List<string> WalkDirectoryTree(string topLevelFolder, SearchOption searchOption)
@@ -418,7 +417,7 @@ private static List<string> WalkDirectoryTree(string topLevelFolder, SearchOptio
418417
Debug.Print("Directory not found: " + topLevelFolder);
419418
}
420419

421-
if ((files != null) && (searchOption == SearchOption.AllDirectories))
420+
if (files != null && searchOption == SearchOption.AllDirectories)
422421
{
423422
// Now find all the subdirectories under this directory.
424423
var dirs = Directory.GetDirectories(topLevelFolder);

src/SayMore/Model/Files/FieldUpdater.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ private void FindAndUpdateFiles(ComponentFile file, string idOfFieldToFind,
7777

7878
var matchingFiles = GetMatchingFiles(file.FileType);
7979

80-
if (_fieldGatherer != null)
81-
_fieldGatherer.SuspendProcessing();
80+
_fieldGatherer?.SuspendProcessing();
8281

8382
foreach (var path in matchingFiles)
8483
{

src/SayMore/Model/Project.cs

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using SIL.Reporting;
3030
using SIL.Windows.Forms;
3131
using static System.IO.Path;
32+
using static SayMore.Model.Files.ComponentRole.MeasurementTypes;
3233

3334
namespace SayMore.Model
3435
{
@@ -77,8 +78,16 @@ private sealed class MediaDurationStats(TimeSpan initial)
7778

7879
public TimeSpan Delta => Current - Initial;
7980
}
80-
81+
private sealed class RoleCountStats(int initial)
82+
{
83+
public int Initial { get; } = initial;
84+
public int Current { get; set; } = initial;
85+
86+
public int Delta => Current - Initial;
87+
}
88+
8189
private Dictionary<string, MediaDurationStats> _mediaDurationStats;
90+
private Dictionary<string, RoleCountStats> _sessionRoleStats;
8291

8392
public delegate Project Factory(string desiredOrExistingFilePath);
8493

@@ -170,7 +179,7 @@ public Project(string desiredOrExistingSettingsFilePath,
170179
}
171180

172181
/// ------------------------------------------------------------------------------------
173-
public void Dispose()
182+
public void ReportProgressIfNeeded()
174183
{
175184
if (_statisticsViewModel != null)
176185
{
@@ -184,7 +193,9 @@ public void Dispose()
184193
sessionDelta > 0 ||
185194
personDelta > 0 ||
186195
_mediaDurationStats != null &&
187-
_mediaDurationStats.Values.Any(s => s.Delta > TimeSpan.Zero);
196+
_mediaDurationStats.Values.Any(s => s.Delta > TimeSpan.Zero) ||
197+
_sessionRoleStats != null &&
198+
_sessionRoleStats.Values.Any(s => s.Delta > 0); ;
188199

189200
if (hasProgress)
190201
{
@@ -208,11 +219,28 @@ public void Dispose()
208219
}
209220
}
210221
}
222+
223+
if (_sessionRoleStats != null)
224+
{
225+
foreach (var kvp in _sessionRoleStats)
226+
{
227+
var delta = kvp.Value.Delta;
228+
if (delta > 0)
229+
{
230+
properties[$"CompletedStages.{kvp.Key}"] =
231+
delta.ToString();
232+
}
233+
}
234+
}
211235

212236
Analytics.Track("ProjectProgress", properties);
213237
}
214238
}
239+
}
215240

241+
/// ------------------------------------------------------------------------------------
242+
public void Dispose()
243+
{
216244
_sessionsRepoFactory = null;
217245
if (_needToDisposeTranscriptionFont)
218246
TranscriptionFont.Dispose();
@@ -890,6 +918,10 @@ private void FinishedGatheringStatistics(object sender, EventArgs e)
890918
s => s.Name,
891919
s => new MediaDurationStats(s.Length));
892920

921+
_sessionRoleStats = _statisticsViewModel.SessionInformant.GetSessionsCategorizedByStage()
922+
.Where(s => s.Key.MeasurementType != Time)
923+
.ToDictionary(s => s.Key.Id, s => new RoleCountStats(s.Value.Count()));
924+
893925
_statisticsViewModel.NewStatisticsAvailable += UpdateStatistics;
894926
}
895927

@@ -911,6 +943,21 @@ private void UpdateStatistics(object sender, EventArgs e)
911943
};
912944
}
913945
}
946+
947+
foreach (var stat in _statisticsViewModel.SessionInformant.GetSessionsCategorizedByStage()
948+
.Where(s => s.Key.MeasurementType != Time))
949+
{
950+
if (_sessionRoleStats.TryGetValue(stat.Key.Id, out var entry))
951+
entry.Current = stat.Value.Count();
952+
else
953+
{
954+
_sessionRoleStats[stat.Key.Id] =
955+
new RoleCountStats(0)
956+
{
957+
Current = stat.Value.Count()
958+
};
959+
}
960+
}
914961
}
915962
}
916963
}

src/SayMore/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ static void Main()
235235
{
236236
Application.Run();
237237
Settings.Default.Save();
238+
_projectContext?.Project.ReportProgressIfNeeded();
239+
Analytics.FlushClient();
238240
Logger.WriteEvent("SayMore shutting down");
239241
if (s_countOfContiguousFirstChanceOutOfMemoryExceptions > 1)
240242
Logger.WriteEvent("Total number of contiguous OutOfMemoryExceptions: {0}", s_countOfContiguousFirstChanceOutOfMemoryExceptions);
@@ -596,8 +598,10 @@ static void ChooseAnotherProject(object sender, EventArgs e)
596598
}
597599

598600
/// ------------------------------------------------------------------------------------
599-
static void HandleProjectWindowClosed(object sender, EventArgs e)
601+
private static void HandleProjectWindowClosed(object sender, EventArgs e)
600602
{
603+
_projectContext?.Project.ReportProgressIfNeeded();
604+
601605
SafelyDisposeProjectContext();
602606
ReleaseMutexForThisProject();
603607

0 commit comments

Comments
 (0)