Skip to content

Commit

Permalink
Merged PR 35: Creation of V3.0.9
Browse files Browse the repository at this point in the history
* Fix permissions issue with Library folder.
* Run downloaded files from C:\Users\{InsertNameHere}\Downloads instead of C:\Users\{InsertNameHere}\AppData\Local\Temp. Host Intrustion Protection System (HIPS) preventing execution of files from temp folders.
* Clearer message when initial setup is completed.

Related work items: #284
  • Loading branch information
MikeWilliams-UK committed Dec 6, 2017
2 parents f250cee + 10e6044 commit bf32d75
Show file tree
Hide file tree
Showing 71 changed files with 410 additions and 101,426 deletions.
3 changes: 3 additions & 0 deletions src/Chem4Word.V3/Chem4Word.V3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@
can be found.
-->
<ItemGroup>
<Compile Include="..\Shared\FolderHelper.cs">
<Link>Helpers\FolderHelper.cs</Link>
</Compile>
<Compile Include="AssemblyReflectionManager.cs" />
<Compile Include="Helpers\ConfigWatcher.cs" />
<Compile Include="Helpers\ReferenceKeeper.cs" />
Expand Down
17 changes: 14 additions & 3 deletions src/Chem4Word.V3/Data/Chem4Word-Versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@
<ChangeLog>
<Id>f3c4f4db-2fff-46db-b14a-feb8e09f7742</Id>
<Version>
<Number>3.0.7 Beta 8</Number>
<Number>3.0.9 Beta 9</Number>
<IsBeta>true</IsBeta>
<Released>22-Nov-2017</Released>
<Released>06-Dec-2017</Released>
<Changes>
<Change>Fix permissions issue with Library folder.</Change>
<Change>Run downloaded files from C:\Users\{InsertNameHere}\Downloads instead of C:\Users\{InsertNameHere}\AppData\Local\Temp. Host Intrustion Protection System (HIPS) preventing execution of files from temp folders.</Change>
<Change>Clearer message when initial setup is completed.</Change>
<Change>Please download Chem4Word-Setup.exe from https://github.com/Chem4Word/Version3/releases if you encounter any dificulties updating.</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3/Chem4Word-Setup.3.0.9.Beta.9.msi</Url>
</Version>
<Version>
<Number>3.0.8 Beta 8</Number>
<IsBeta>true</IsBeta>
<Released>21-Nov-2017</Released>
<Changes>
<Change>Handle documents in compatability mode.</Change>
<Change>Handle error in setting text of 1D labels.</Change>
<Change>Make config files self healing, when options are added or removed.</Change>
<Change>Please download Chem4Word-Setup.exe from https://github.com/Chem4Word/Version3/releases if you encounter any dificulties updating.</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3/Chem4Word-Setup.3.0.8.Beta.8.msi</Url>
</Version>
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.0.8 Beta 8</Number>
<Number>3.0.9 Beta 9</Number>
<IsBeta>true</IsBeta>
<Released>21-Nov-2017</Released>
<Released>06-Dec-2017</Released>
</Version>
8 changes: 8 additions & 0 deletions src/Chem4Word.V3/Data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ <h1>Chemistry for Word Add-In V3</h1>
<a href="/files3/Chem4Word-Setup.exe">Chem4Word.Setup</a>
</td>
</tr>
<tr>
<td>
Version 3.0.9 - Beta 9
</td>
<td>
<a href="/files3/Chem4Word-Setup.3.0.9.Beta.9.msi">Chem4Word.Setup.3.0.9 Beta 9</a>
</td>
</tr>
<tr>
<td>
Version 3.0.8 - Beta 8
Expand Down
15 changes: 15 additions & 0 deletions src/Chem4Word.V3/Helpers/C4wAddInInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.IO;
using System.Reflection;
using System.Security.AccessControl;
using System.Security.Principal;

namespace Chem4Word.Helpers
{
Expand Down Expand Up @@ -67,6 +69,19 @@ public C4wAddInInfo()
{
Directory.CreateDirectory(ProgramDataPath);
}

try
{
// Allow all users to Modify files in this folder
DirectorySecurity sec = Directory.GetAccessControl(ProgramDataPath);
SecurityIdentifier users = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null);
sec.AddAccessRule(new FileSystemAccessRule(users, FileSystemRights.Modify | FileSystemRights.Synchronize, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
Directory.SetAccessControl(ProgramDataPath, sec);
}
catch
{
// Do Nothing
}
}
}
}
4 changes: 2 additions & 2 deletions src/Chem4Word.V3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.0.8.6534")]
[assembly: AssemblyFileVersion("3.0.8.6534")]
[assembly: AssemblyVersion("3.0.9.6549")]
[assembly: AssemblyFileVersion("3.0.9.6549")]
4 changes: 2 additions & 2 deletions src/Chem4Word.V3/Ribbon/Chem4WordRibbon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2162,8 +2162,8 @@ private void OnCheckForUpdatesClick(object sender, RibbonControlEventArgs e)
RegistryKey key = Registry.CurrentUser.CreateSubKey(Constants.Chem4WordRegistryKey);
if (key != null)
{
key.DeleteValue(Constants.RegistryValueNameLastCheck);
key.DeleteValue(Constants.RegistryValueNameVersionsBehind);
key.DeleteValue(Constants.RegistryValueNameLastCheck, false);
key.DeleteValue(Constants.RegistryValueNameVersionsBehind, false);
}
}
catch (Exception ex)
Expand Down
59 changes: 34 additions & 25 deletions src/Chem4Word.V3/UI/AutomaticUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

using Chem4Word.Core.Helpers;
using Chem4Word.Core.UI.Forms;
using Chem4Word.Shared;
using IChem4Word.Contracts;
using Microsoft.Win32;
using System;
Expand Down Expand Up @@ -115,39 +116,47 @@ private void OnUpdateNowClick(object sender, EventArgs e)
try
{
string source = Path.Combine(Globals.Chem4WordV3.AddInInfo.DeploymentPath, "Chem4WordUpdater.exe");
string userTempPath = Path.GetTempPath();
if (Directory.Exists(userTempPath))

string downloadPath = FolderHelper.GetPath(KnownFolder.Downloads);
if (!Directory.Exists(downloadPath))
{
// Ensure filename to be launched is unique
string guid = Guid.NewGuid().ToString("N");
string destination = Path.Combine(userTempPath, $"{guid}-Chem4WordUpdater.exe");
File.Copy(source, destination, true);
downloadPath = Path.GetTempPath();
}

if (File.Exists(destination)
&& new FileInfo(destination).Length > 0)
{
_telemetry.Write(module, "AutomaticUpdate", "Starting updater, to download " + _downloadUrl);
// Ensure filename to be launched is unique
string guid = Guid.NewGuid().ToString("N");
string destination = Path.Combine(downloadPath, $"Chem4WordUpdater-{guid}.exe");

ProcessStartInfo psi = new ProcessStartInfo();
psi.WorkingDirectory = userTempPath;
psi.Arguments = _downloadUrl;
psi.FileName = destination;
Process.Start(psi);
File.Copy(source, destination, true);

_closedByCode = true;
Close();
}
else
{
_telemetry.Write(module, "AutomaticUpdate", $"Copy of 'Chem4WordUpdater.exe' to {userTempPath} failed.");
MessageBox.Show($"Copy of 'Chem4WordUpdater.exe' to {userTempPath} failed. Please download {_downloadUrl} manually and install it.");
}
if (File.Exists(destination)
&& new FileInfo(destination).Length > 0)
{
_telemetry.Write(module, "AutomaticUpdate", "Starting updater, to download " + _downloadUrl);

ProcessStartInfo psi = new ProcessStartInfo();
psi.WorkingDirectory = downloadPath;
psi.Arguments = _downloadUrl;
psi.FileName = destination;
Process.Start(psi);

_closedByCode = true;
Close();
}
else
{
_telemetry.Write(module, "AutomaticUpdate", $"Folder '{userTempPath}' not found.");
MessageBox.Show($"Folder '{userTempPath}' not found. Please download {_downloadUrl} manually and install it.");
_telemetry.Write(module, "AutomaticUpdate", $"Copy of 'Chem4WordUpdater.exe' to {downloadPath} failed.");
MessageBox.Show($"Copy of 'Chem4WordUpdater.exe' to {downloadPath} failed. Please download {_downloadUrl} manually and install it.");
}

//if (Directory.Exists(downloadPath))
//{
//}
//else
//{
// _telemetry.Write(module, "AutomaticUpdate", $"Folder '{downloadPath}' not found.");
// MessageBox.Show($"Folder '{downloadPath}' not found. Please download {_downloadUrl} manually and install it.");
//}
}
catch (Exception ex)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Chem4WordTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.0.8.6534")]
[assembly: AssemblyFileVersion("3.0.8.6534")]
[assembly: AssemblyVersion("3.0.9.6549")]
[assembly: AssemblyFileVersion("3.0.9.6549")]
Loading

0 comments on commit bf32d75

Please sign in to comment.