Skip to content

Commit

Permalink
Merged PR 651: V3.3.2 Beta 2
Browse files Browse the repository at this point in the history
## Before submitting this PR for code review, please make sure:
- [X] "Describe the changes being made to the code and why" above has been replaced
- [X] All new files have the standard license headers
- [X] CodeMaid has been run against all new or updated files
- [X] The code builds clean (please check Debug and Setup configurations) without any errors or new warnings
- [X] All NuGet packages have been updated and /README.md updated
- [X] All Unit Tests pass
- [X] You have followed the [Chem4Word Coding Standards](https://chem4word.visualstudio.com/C4W-VNext/_wiki/wikis/C4W-VNext.wiki/2/Coding-Standards)
- [X] You have updated the change history (/src/Chem4Word.V3/Data/Chem4Word-Versions.xml)
- [X] If appropriate you have updated the manual (/docs/Chem4Word-Version3-3-User-Manual.docx)
- [X] The build pipeline is green

Related work items: #1053
  • Loading branch information
MikeWilliams-UK committed Oct 12, 2023
1 parent 319ef36 commit 7f8d418
Show file tree
Hide file tree
Showing 46 changed files with 132 additions and 102 deletions.
12 changes: 6 additions & 6 deletions src/Chem4Word.V3/Chem4WordV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public partial class Chem4WordV3
public bool OptionsReloadRequired = false;

private ConfigWatcher _configWatcher;
private ReferenceKeeper _keeper;

public bool LibraryState;

Expand Down Expand Up @@ -198,8 +199,6 @@ public static void SetGlobalRibbon(CustomRibbon ribbon)
Ribbon = ribbon;
}

private ReferenceKeeper _keeper;

private void C4WAddIn_Startup(object sender, EventArgs e)
{
var module = $"{MethodBase.GetCurrentMethod().Name}()";
Expand All @@ -213,7 +212,7 @@ private void C4WAddIn_Startup(object sender, EventArgs e)
var cmd = Environment.CommandLine.ToLower();
if (Ribbon != null && !cmd.Contains("-embedding"))
{
var message = $"{module} started at {SafeDate.ToLongDate(DateTime.Now)}";
var message = $"{module} started at {SafeDate.ToLongDate(DateTime.UtcNow)}";
Debug.WriteLine(message);
StartUpTimings.Add(message);

Expand Down Expand Up @@ -293,7 +292,7 @@ private void SlowOperations()

try
{
var message = $"{module} started at {SafeDate.ToLongDate(DateTime.Now)}";
var message = $"{module} started at {SafeDate.ToLongDate(DateTime.UtcNow)}";

Debug.WriteLine(message);
StartUpTimings.Add(message);
Expand Down Expand Up @@ -639,7 +638,8 @@ private void PerformShutDownActions()
}
}

_configWatcher.Dispose();
_configWatcher?.Dispose();
_keeper?.Dispose();

GC.Collect();
GC.WaitForPendingFinalizers();
Expand Down Expand Up @@ -694,7 +694,7 @@ private void LoadPlugIns(bool mustBeSigned)
{
var module = $"{MethodBase.GetCurrentMethod().Name}()";
// http://www.codeproject.com/Articles/453778/Loading-Assemblies-from-Anywhere-into-a-New-AppDom
var message = $"{module} started at {SafeDate.ToLongDate(DateTime.Now)}";
var message = $"{module} started at {SafeDate.ToLongDate(DateTime.UtcNow)}";
StartUpTimings.Add(message);
Debug.WriteLine(message);

Expand Down
13 changes: 11 additions & 2 deletions src/Chem4Word.V3/Data/Chem4Word-Versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
<!-- This file must be uploaded to https://www.chem4word.co.uk/files3-3/ folder as Chem4Word-Versions.xml -->
<ChangeLog>
<Id>f3c4f4db-2fff-46db-b14a-feb8e09f7742</Id>
<Version>
<Number>3.3.2 Beta 2</Number>
<IsBeta>true</IsBeta>
<Released>12-Oct-2023</Released>
<Changes>
<Change>Ensure Help button is never disabled.</Change>
<Change>Add SketchEl file format support.</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-3/Chem4Word-Setup.3.3.2.Beta.2.msi</Url>
</Version>
<Version>
<Number>3.3.1 Beta 1</Number>
<IsBeta>true</IsBeta>
Expand All @@ -12,8 +22,8 @@
<Change>Fix Right Click Convert to chemistry issues</Change>
<Change>Fix Windows 11 detection issue</Change>
<Change>Update user manual</Change>
<Change>Private Beta of Chem4Word 2023 (V3.3)</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-3/Chem4Word-Setup.3.3.1.Beta.1.msi</Url>
</Version>
<Version>
<Number>3.3.0 Alpha 0</Number>
Expand All @@ -32,7 +42,6 @@
<Change>Add new Plug-In type (Driver) to manage multiple libraries</Change>
<Change>Add new converter to model which reads/writes byte[] from Google protocol buffer of model</Change>
<Change>Private Alpha of Chem4Word 2023 (V3.3)</Change>
<Change>Please download Chem4Word-Setup.exe via https://www.chem4word.co.uk/download/ if you encounter any difficulties updating</Change>
</Changes>
</Version>
<EndOfLife>31-Dec-2345</EndOfLife>
Expand Down
4 changes: 2 additions & 2 deletions src/Chem4Word.V3/Data/This-Version.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Version>
<Number>3.3.1 Beta 1</Number>
<Number>3.3.2 Beta 2</Number>
<IsBeta>true</IsBeta>
<Released>04-Oct-2023</Released>
<Released>12-Oct-2023</Released>
</Version>
2 changes: 1 addition & 1 deletion src/Chem4Word.V3/Helpers/CustomXMLPartHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static void RemoveOrphanedXmlParts(Word.Document document)
try
{
var guid = Guid.NewGuid().ToString("N");
var timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss", CultureInfo.InvariantCulture);
var timestamp = DateTime.UtcNow.ToString("yyyyMMdd-HHmmss", CultureInfo.InvariantCulture);

var fileName = Path.Combine(backupFolder, $"Chem4Word-Orphaned-Structure-{timestamp}-{guid}.cml");
File.WriteAllText(fileName, XmlHelper.AddHeader(customXmlPart.XML));
Expand Down
12 changes: 10 additions & 2 deletions src/Chem4Word.V3/Helpers/ReferenceKeeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@
// ---------------------------------------------------------------------------

using Azure.Messaging.ServiceBus;
using System;

namespace Chem4Word.Helpers
{
/// <summary>
/// The sole purpose of this class is to keep references to assemblies which may only be used in supporting assemblies
/// </summary>
public class ReferenceKeeper
public class ReferenceKeeper : IDisposable
{
private ServiceBusClient ServiceBusClient { get; }

private Guid _objectId;

public ReferenceKeeper()
{
// Nothing to do here ...
_objectId = Guid.NewGuid();
}

public void Dispose()
{
//
}
}
}
8 changes: 4 additions & 4 deletions src/Chem4Word.V3/Helpers/UpdateHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ public static void ReadSavedValues()
}
catch
{
Globals.Chem4WordV3.VersionLastChecked = DateTime.Now.AddDays(-30);
Globals.Chem4WordV3.VersionLastChecked = DateTime.UtcNow.AddDays(-30);
}
}
else
{
Globals.Chem4WordV3.VersionLastChecked = DateTime.Now.AddDays(-30);
Globals.Chem4WordV3.VersionLastChecked = DateTime.UtcNow.AddDays(-30);
}

if (names.Contains(Constants.RegistryValueNameVersionsBehind))
Expand Down Expand Up @@ -200,7 +200,7 @@ public static void ReadSavedValues()
}
else
{
Globals.Chem4WordV3.VersionLastChecked = DateTime.Now.AddDays(-30);
Globals.Chem4WordV3.VersionLastChecked = DateTime.UtcNow.AddDays(-30);
Globals.Chem4WordV3.VersionsBehind = 0;
}
}
Expand Down Expand Up @@ -252,7 +252,7 @@ public static bool FetchUpdateInfo()
if (expires != null)
{
var expiryDate = SafeDate.Parse(expires.Value);
if (DateTime.Now.ToUniversalTime() > expiryDate)
if (DateTime.UtcNow > expiryDate)
{
Globals.Chem4WordV3.IsEndOfLife = true;
registryKey?.SetValue(Constants.RegistryValueNameEndOfLife, "true");
Expand Down
2 changes: 1 addition & 1 deletion src/Chem4Word.V3/Helpers/Upgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public static void DoUpgrade(Word.Document document)
{
string extension = document.FullName.Split('.').Last();
string guid = Guid.NewGuid().ToString("N");
string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss", CultureInfo.InvariantCulture);
string timestamp = DateTime.UtcNow.ToString("yyyyMMdd-HHmmss", CultureInfo.InvariantCulture);
string destination = Path.Combine(Globals.Chem4WordV3.AddInInfo.ProductAppDataPath, "Backups", $"Chem4Word-{timestamp}-{guid}.{extension}");
File.Copy(document.FullName, destination);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Chem4Word.V3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.3.1.8677")]
[assembly: AssemblyFileVersion("3.3.1.8677")]
[assembly: AssemblyVersion("3.3.2.8685")]
[assembly: AssemblyFileVersion("3.3.2.8685")]
3 changes: 1 addition & 2 deletions src/Chem4Word.V3/Ribbon/Chem4WordRibbon.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 22 additions & 9 deletions src/Chem4Word.V3/Ribbon/Chem4WordRibbon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2143,21 +2143,28 @@ private void OnClick_CheckForUpdates(object sender, RibbonControlEventArgs e)
Globals.Chem4WordV3.LoadOptions();
}

var behind = UpdateHelper.CheckForUpdates(Globals.Chem4WordV3.SystemOptions.AutoUpdateFrequency);
if (Globals.Chem4WordV3.IsEndOfLife)
{
UserInteractions.InformUser("This version of Chem4Word is no longer supported");
}
else
if (Globals.Chem4WordV3.SystemOptions != null)
{
if (behind == 0)
var behind = UpdateHelper.CheckForUpdates(Globals.Chem4WordV3.SystemOptions.AutoUpdateFrequency);
if (Globals.Chem4WordV3.IsEndOfLife)
{
UserInteractions.InformUser("Your version of Chem4Word is the latest");
UserInteractions.InformUser("This version of Chem4Word is no longer supported");
}
else
{
if (behind == 0)
{
UserInteractions.InformUser("Your version of Chem4Word is the latest");
}
}
}

Globals.Chem4WordV3.EventsEnabled = true;
}
else
{
UserInteractions.InformUser("Unable to check for updates because Chem4Word has not been initialised.");
}

AfterButtonChecks(sender as RibbonButton);
}
Expand Down Expand Up @@ -2209,6 +2216,10 @@ private void OnClick_ReadManual(object sender, RibbonControlEventArgs e)

Globals.Chem4WordV3.EventsEnabled = true;
}
else
{
UserInteractions.InformUser("Unable to locate user manual because Chem4Word has not been initialised.");
}

AfterButtonChecks(sender as RibbonButton);
}
Expand Down Expand Up @@ -2251,7 +2262,9 @@ private void OnClick_YouTube(object sender, RibbonControlEventArgs e)
private void OnClick_ButtonsDisabled(object sender, RibbonControlEventArgs e)
{
var module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

BeforeButtonChecks();

if (Globals.Chem4WordV3.Telemetry != null)
{
Globals.Chem4WordV3.Telemetry.Write(module, "Action", "Triggered");
Expand Down Expand Up @@ -2308,7 +2321,7 @@ private void OnClick_ShowSystemInfo(object sender, RibbonControlEventArgs e)
}
else
{
UserInteractions.InformUser("Chem4Word is disabled because no plug Ins were found.");
UserInteractions.InformUser("System Info is unavailable because Chem4Word has not been initialised.");
}
}
catch (Exception ex)
Expand Down
4 changes: 2 additions & 2 deletions src/Chemistry/Chem4Word.ACME/EditController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3030,7 +3030,7 @@ public void AddObjectListToSelection(List<BaseObject> thingsToAdd)
Stopwatch sw = new Stopwatch();
sw.Start();

DebugHelper.WriteLine($"Started at {SafeDate.ToShortTime(DateTime.Now)}");
DebugHelper.WriteLine($"Started at {SafeDate.ToShortTime(DateTime.UtcNow)}");

//take a snapshot of the current selection
var currentSelection = SelectedItems.ToList();
Expand Down Expand Up @@ -3170,7 +3170,7 @@ select new
}

DebugHelper.WriteLine($"Timing: {sw.ElapsedMilliseconds}ms");
DebugHelper.WriteLine($"Finished at {DateTime.Now}");
DebugHelper.WriteLine($"Finished at {DateTime.UtcNow}");
}
catch (Exception exception)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Chemistry/Chem4Word.ACME/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.3.1.8677")]
[assembly: AssemblyFileVersion("3.3.1.8677")]
[assembly: AssemblyVersion("3.3.2.8685")]
[assembly: AssemblyFileVersion("3.3.2.8685")]
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ private void WriteHeader(StreamWriter writer, int atoms, int bonds)
// Ss == scaling factors
// E == Energy
// R == registry number
writer.WriteLine($" Chem4Wrd{SafeDate.ToMdlHeaderTime(DateTime.Now)}");
writer.WriteLine($" Chem4Wrd{SafeDate.ToMdlHeaderTime(DateTime.UtcNow)}");

// Line 3 - Comments (80)
writer.WriteLine("");
Expand Down
4 changes: 2 additions & 2 deletions src/Chemistry/Chem4Word.Model2/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.3.1.8677")]
[assembly: AssemblyFileVersion("3.3.1.8677")]
[assembly: AssemblyVersion("3.3.2.8685")]
[assembly: AssemblyFileVersion("3.3.2.8685")]
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.3.1.8677")]
[assembly: AssemblyFileVersion("3.3.1.8677")]
[assembly: AssemblyVersion("3.3.2.8685")]
[assembly: AssemblyFileVersion("3.3.2.8685")]
2 changes: 1 addition & 1 deletion src/Common/Chem4Word.Core/Helpers/FileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static string BackupFile(FileInfo file, DirectoryInfo directory, bool add

if (addPrefix)
{
destination = Path.Combine(directory.FullName, $"{SafeDate.ToIsoFilePrefix(DateTime.Now)} - {file.Name}");
destination = Path.Combine(directory.FullName, $"{SafeDate.ToIsoFilePrefix(DateTime.UtcNow)} - {file.Name}");
}

if (!File.Exists(destination))
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Chem4Word.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.3.1.8677")]
[assembly: AssemblyFileVersion("3.3.1.8677")]
[assembly: AssemblyVersion("3.3.2.8685")]
[assembly: AssemblyFileVersion("3.3.2.8685")]
4 changes: 2 additions & 2 deletions src/Common/Chem4Word.Telemetry/AzureServiceBusWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ private async Task WriteMessage(OutputMessage message)
try
{
var fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
$@"Chem4Word.V3\Telemetry\{SafeDate.ToIsoShortDate(DateTime.Now)}.log");
$@"Chem4Word.V3\Telemetry\{SafeDate.ToIsoShortDate(DateTime.UtcNow)}.log");
using (var streamWriter = File.AppendText(fileName))
{
await streamWriter.WriteLineAsync($"[{SafeDate.ToShortTime(DateTime.Now)}] Exception in WriteMessage: {exception.Message}");
await streamWriter.WriteLineAsync($"[{SafeDate.ToShortTime(DateTime.UtcNow)}] Exception in WriteMessage: {exception.Message}");
}
}
catch
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Chem4Word.Telemetry/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.3.1.8677")]
[assembly: AssemblyFileVersion("3.3.1.8677")]
[assembly: AssemblyVersion("3.3.2.8685")]
[assembly: AssemblyFileVersion("3.3.2.8685")]
8 changes: 4 additions & 4 deletions src/Common/Chem4Word.Telemetry/SystemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private List<string> Initialise()
{
List<string> timings = new List<string>();

string message = $"SystemHelper.Initialise() started at {SafeDate.ToLongDate(DateTime.Now)}";
string message = $"SystemHelper.Initialise() started at {SafeDate.ToLongDate(DateTime.UtcNow)}";
timings.Add(message);
Debug.WriteLine(message);

Expand Down Expand Up @@ -214,7 +214,7 @@ private List<string> Initialise()
// Dead Link [2022-12-08] _placesToTry.Add("https://api6.ipify.org/");
_placesToTry.Add("https://v4v6.ipv6-test.com/api/myip.php");

message = $"GetIpAddress started at {SafeDate.ToLongDate(DateTime.Now)}";
message = $"GetIpAddress started at {SafeDate.ToLongDate(DateTime.UtcNow)}";
StartUpTimings.Add(message);
Debug.WriteLine(message);

Expand Down Expand Up @@ -245,7 +245,7 @@ private List<string> Initialise()
GetScreens();

#if DEBUG
message = $"GetGitStatus started at {SafeDate.ToLongDate(DateTime.Now)}";
message = $"GetGitStatus started at {SafeDate.ToLongDate(DateTime.UtcNow)}";
StartUpTimings.Add(message);
Debug.WriteLine(message);

Expand Down Expand Up @@ -368,7 +368,7 @@ private void GetGitStatus(object o)
}
GitStatus = string.Join(Environment.NewLine, result.ToArray());

var message = $"GetGitStatus finished at {SafeDate.ToLongDate(DateTime.Now)}";
var message = $"GetGitStatus finished at {SafeDate.ToLongDate(DateTime.UtcNow)}";
StartUpTimings.Add(message);
Debug.WriteLine(message);
}
Expand Down
Loading

0 comments on commit 7f8d418

Please sign in to comment.