Auto update for ZIP deploy
Bug fix of SystemLogging
This commit is contained in:
rykoma 2019-04-25 17:52:27 +09:00
Родитель 588f8fceaf
Коммит eb36300c5c
15 изменённых файлов: 5199 добавлений и 47 удалений

Просмотреть файл

@ -7,7 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Office365APIEditor", "Offic
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup", "Setup\Setup.vdproj", "{55B2F04A-B5B1-4DD3-9149-D10750198019}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PublishSite", "PublishSite\PublishSite.csproj", "{7D59CBD1-778D-4EBF-8A9D-B7C55CEA32FD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PublishSite", "PublishSite\PublishSite.csproj", "{7D59CBD1-778D-4EBF-8A9D-B7C55CEA32FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Просмотреть файл

@ -173,6 +173,12 @@
<DependentUpon>AttachmentViewerForm.cs</DependentUpon>
</Compile>
<Compile Include="ClientInformation.cs" />
<Compile Include="UI\CheckUpdateForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\CheckUpdateForm.Designer.cs">
<DependentUpon>CheckUpdateForm.cs</DependentUpon>
</Compile>
<Compile Include="UI\DetailedTokenViewer.cs">
<SubType>Form</SubType>
</Compile>
@ -288,6 +294,9 @@
<EmbeddedResource Include="UI\AttachmentViewerForm.resx">
<DependentUpon>AttachmentViewerForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\CheckUpdateForm.resx">
<DependentUpon>CheckUpdateForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\DetailedTokenViewer.resx">
<DependentUpon>DetailedTokenViewer.cs</DependentUpon>
</EmbeddedResource>

Просмотреть файл

@ -11,9 +11,6 @@ namespace Office365APIEditor
{
class MyApplicationContext : ApplicationContext
{
const string LatestVersionUri = "https://office365apieditor.azurewebsites.net/latestmsi.txt";
const string LatestInstallerUri = "https://office365apieditor.azurewebsites.net/installers/Setup.msi";
public MyApplicationContext()
{
MailboxViewerForm mailboxViewerForm = new MailboxViewerForm();
@ -25,7 +22,7 @@ namespace Office365APIEditor
{
Util.WriteSystemLog("Office365APIEditor Closing Log", "Exit. Code 20");
if (!string.IsNullOrEmpty(Properties.Settings.Default.NewerInstallerPath) && File.Exists(Properties.Settings.Default.NewerInstallerPath))
if (!string.IsNullOrEmpty(Properties.Settings.Default.NewerInstallerPath) && File.Exists(Properties.Settings.Default.NewerInstallerPath) && Util.IsMsiDeployed)
{
// Newer installer is available
@ -43,6 +40,22 @@ namespace Office365APIEditor
}
}
}
else if (!string.IsNullOrEmpty(Properties.Settings.Default.NewerInstallerPath) && Properties.Settings.Default.NewerInstallerPath == Util.LatestZipUri)
{
if (MessageBox.Show("Do you want to download the latest version of Office365APIEditor?", "Office365APIEditor", MessageBoxButtons.YesNo, MessageBoxIcon.None) == DialogResult.Yes)
{
try
{
System.Diagnostics.Process zip = System.Diagnostics.Process.Start(Properties.Settings.Default.NewerInstallerPath);
Properties.Settings.Default.NewerInstallerPath = "";
Properties.Settings.Default.Save();
}
catch
{
}
}
}
Environment.Exit(0);
}
@ -85,6 +98,8 @@ namespace Office365APIEditor
startupLog.AppendLine("CommandLine : " + Environment.CommandLine);
string[] switches = Environment.GetCommandLineArgs();
bool systemLogging = false;
foreach (string command in switches)
{
if (command.ToLower() == ("/NoSetting").ToLower())
@ -127,13 +142,19 @@ namespace Office365APIEditor
}
else if (command.ToLower() == ("/SystemLogging").ToLower())
{
// Turn on SystemLogging flag.
startupLog.AppendLine("Enable SystemLogging.");
Properties.Settings.Default.SystemLogging = true;
Properties.Settings.Default.Save();
// Turn on SystemLogging flag later.
systemLogging = true;
}
}
if (systemLogging)
{
// Turn on SystemLogging flag.
startupLog.AppendLine("Enable SystemLogging.");
Properties.Settings.Default.SystemLogging = true;
Properties.Settings.Default.Save();
}
// Set default log folder path.
startupLog.AppendLine("Current log folder : " + Properties.Settings.Default.LogFolderPath);
if (!Directory.Exists(Properties.Settings.Default.LogFolderPath))
@ -205,7 +226,7 @@ namespace Office365APIEditor
ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
HttpWebRequest versionRequest = WebRequest.CreateHttp(LatestVersionUri);
HttpWebRequest versionRequest = WebRequest.CreateHttp(Util.LatestVersionUri);
versionRequest.Method = "GET";
versionRequest.ContentType = "text/plain";
@ -241,29 +262,39 @@ namespace Office365APIEditor
{
// Newer version is available
string newerMsiDirectory = Path.Combine(Path.GetTempPath(), "Office365APIEditor");
if (!Directory.Exists(newerMsiDirectory))
if (Util.IsMsiDeployed)
{
Directory.CreateDirectory(newerMsiDirectory);
string newerMsiDirectory = Path.Combine(Path.GetTempPath(), "Office365APIEditor");
if (!Directory.Exists(newerMsiDirectory))
{
Directory.CreateDirectory(newerMsiDirectory);
}
string newerMsiPath = Path.Combine(newerMsiDirectory, "Setup.msi");
WebClient wc = new WebClient();
wc.DownloadFile(Util.LatestMsiUri, newerMsiPath);
Properties.Settings.Default.NewerInstallerPath = newerMsiPath;
}
else
{
Properties.Settings.Default.NewerInstallerPath = Util.LatestZipUri;
}
string newerMsiPath = Path.Combine(newerMsiDirectory, "Setup.msi");
WebClient wc = new WebClient();
wc.DownloadFile(LatestInstallerUri, newerMsiPath);
Properties.Settings.Default.NewerInstallerPath = newerMsiPath;
}
else
{
Properties.Settings.Default.NewerInstallerPath = "";
Properties.Settings.Default.Save();
}
}
catch(Exception)
{
Properties.Settings.Default.NewerInstallerPath = "";
}
finally
{
Properties.Settings.Default.Save();
}
}
}
}

Просмотреть файл

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.10.6.1")]
[assembly: AssemblyFileVersion("0.10.6.1")]
[assembly: AssemblyVersion("0.10.10.1")]
[assembly: AssemblyFileVersion("0.10.10.1")]

81
Office365APIEditor/UI/CheckUpdateForm.Designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,81 @@
namespace Office365APIEditor.UI
{
partial class CheckUpdateForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CheckUpdateForm));
this.button_OK = new System.Windows.Forms.Button();
this.label_CheckResult = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button_OK
//
this.button_OK.Location = new System.Drawing.Point(297, 36);
this.button_OK.Name = "button_OK";
this.button_OK.Size = new System.Drawing.Size(75, 23);
this.button_OK.TabIndex = 0;
this.button_OK.Text = "OK";
this.button_OK.UseVisualStyleBackColor = true;
this.button_OK.Click += new System.EventHandler(this.button_OK_Click);
//
// label_CheckResult
//
this.label_CheckResult.AutoSize = true;
this.label_CheckResult.Location = new System.Drawing.Point(12, 9);
this.label_CheckResult.Name = "label_CheckResult";
this.label_CheckResult.Size = new System.Drawing.Size(61, 13);
this.label_CheckResult.TabIndex = 1;
this.label_CheckResult.Text = "Checking...";
//
// CheckUpdateForm
//
this.AcceptButton = this.button_OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(384, 71);
this.Controls.Add(this.label_CheckResult);
this.Controls.Add(this.button_OK);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "CheckUpdateForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Office365APIEditor";
this.Load += new System.EventHandler(this.CheckUpdateForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button_OK;
private System.Windows.Forms.Label label_CheckResult;
}
}

Просмотреть файл

@ -0,0 +1,107 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Windows.Forms;
namespace Office365APIEditor.UI
{
public partial class CheckUpdateForm : Form
{
public CheckUpdateForm()
{
InitializeComponent();
}
private void CheckUpdateForm_Load(object sender, EventArgs e)
{
StartLatestVersionCheck();
}
private void StartLatestVersionCheck()
{
// If the latest release check has already finished, use the result.
if (!string.IsNullOrEmpty(Properties.Settings.Default.NewerInstallerPath))
{
label_CheckResult.Text = "You can update to the latest version when you close Office365APIEditor.";
}
else
{
// Get the build number of the latest release using the other thread
// Download is not performed because another thread is also performing download and there is a possibility of conflict.
ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
HttpWebRequest versionRequest = WebRequest.CreateHttp(Util.LatestVersionUri);
versionRequest.Method = "GET";
versionRequest.ContentType = "text/plain";
try
{
IAsyncResult r = versionRequest.BeginGetResponse(new AsyncCallback(VersionCheckResponseCallback), versionRequest);
}
catch
{
label_CheckResult.Text = "Failed to get the latest release information.";
}
}
}
private void VersionCheckResponseCallback(IAsyncResult ar)
{
try
{
HttpWebRequest versionRequest = (HttpWebRequest)ar.AsyncState;
HttpWebResponse versionResponse = (HttpWebResponse)versionRequest.EndGetResponse(ar);
string latestVersionString = "";
using (Stream stream = versionResponse.GetResponseStream())
{
using (StreamReader streamReader = new StreamReader(stream, Encoding.UTF8))
{
latestVersionString = streamReader.ReadToEnd().Trim();
}
}
Version.TryParse(latestVersionString, out Version latestVersion);
if (latestVersion != null && latestVersion.CompareTo(Version.Parse(Application.ProductVersion)) > 0)
{
// Newer version is available
UpdateStatus("An update was found and now downloading it. Check it again later.");
}
else
{
// Newer version is not available
UpdateStatus("There are currently no updates available.");
}
}
catch (Exception)
{
UpdateStatus("Failed to get the latest release information.");
}
}
private void UpdateStatus(string message)
{
if (label_CheckResult.InvokeRequired)
{
label_CheckResult.Invoke(new MethodInvoker(delegate { label_CheckResult.Text = message; }));
}
else
{
label_CheckResult.Text = message;
}
}
private void button_OK_Click(object sender, EventArgs e)
{
Close();
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

14
Office365APIEditor/UI/MailboxViewerForm.Designer.cs сгенерированный
Просмотреть файл

@ -47,6 +47,7 @@
this.accessTokenViewerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.versionInformationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -140,14 +141,14 @@
// newSessionToolStripMenuItem
//
this.newSessionToolStripMenuItem.Name = "newSessionToolStripMenuItem";
this.newSessionToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.newSessionToolStripMenuItem.Size = new System.Drawing.Size(149, 22);
this.newSessionToolStripMenuItem.Text = "&New Session...";
this.newSessionToolStripMenuItem.Click += new System.EventHandler(this.newSessionToolStripMenuItem_Click);
//
// closeSessionToolStripMenuItem
//
this.closeSessionToolStripMenuItem.Name = "closeSessionToolStripMenuItem";
this.closeSessionToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.closeSessionToolStripMenuItem.Size = new System.Drawing.Size(149, 22);
this.closeSessionToolStripMenuItem.Text = "&Close Session";
this.closeSessionToolStripMenuItem.Click += new System.EventHandler(this.closeSessionToolStripMenuItem_Click);
//
@ -200,6 +201,7 @@
// helpToolStripMenuItem
//
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.checkForUpdatesToolStripMenuItem,
this.versionInformationToolStripMenuItem});
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
@ -212,6 +214,13 @@
this.versionInformationToolStripMenuItem.Text = "&Version Information";
this.versionInformationToolStripMenuItem.Click += new System.EventHandler(this.versionInformationToolStripMenuItem_Click);
//
// checkForUpdatesToolStripMenuItem
//
this.checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem";
this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.checkForUpdatesToolStripMenuItem.Text = "&Check for updates...";
this.checkForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click);
//
// MailboxViewerForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -256,5 +265,6 @@
private System.Windows.Forms.ToolStripMenuItem focusedInboxOverridesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem versionInformationToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem;
}
}

Просмотреть файл

@ -839,7 +839,15 @@ namespace Office365APIEditor
private void versionInformationToolStripMenuItem_Click(object sender, EventArgs e)
{
VersionInformation versionInformation = new VersionInformation();
versionInformation.Owner = this;
versionInformation.ShowDialog();
}
private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
{
CheckUpdateForm checkUpdateForm = new CheckUpdateForm();
checkUpdateForm.Owner = this;
checkUpdateForm.ShowDialog();
}
}
}

1
Office365APIEditor/UI/VersionInformation.Designer.cs сгенерированный
Просмотреть файл

@ -76,6 +76,7 @@
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "VersionInformation";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Office365APIEditor";
this.Load += new System.EventHandler(this.VersionInformation_Load);
this.ResumeLayout(false);

Просмотреть файл

@ -18,6 +18,10 @@ namespace Office365APIEditor
{
public static class Util
{
public const string LatestVersionUri = "https://office365apieditor.azurewebsites.net/latestmsi.txt";
public const string LatestMsiUri = "https://office365apieditor.azurewebsites.net/installers/Setup.msi";
public const string LatestZipUri = "https://office365apieditor.azurewebsites.net/installers/Office365APIEditor.zip";
// DefaultApplicationPath is used as the default log path.
public static string DefaultApplicationPath
{
@ -49,6 +53,16 @@ namespace Office365APIEditor
}
}
public static bool IsMsiDeployed
{
get
{
string programFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles).Replace(" (x86)", "");
return Application.StartupPath.StartsWith(programFilesPath);
}
}
public static bool IsValidUrl(string StringUri)
{
return Uri.TryCreate(StringUri, UriKind.Absolute, out Uri temp);

Двоичный файл не отображается.

Двоичные данные
PublishSite/wwwroot/installers/Setup.msi

Двоичный файл не отображается.

Просмотреть файл

@ -1 +1 @@
0.10.6
0.10.10

Просмотреть файл

@ -130,13 +130,13 @@
"Entry"
{
"MsmKey" = "8:_1C7B872EE61AA0BD2CED65776F1CA061"
"OwnerKey" = "8:_A2C7549793E3F567D5DD7A863917B10A"
"OwnerKey" = "8:_916ECA9F59D1CEB0FF37DC0EBC6ADBAD"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_1C7B872EE61AA0BD2CED65776F1CA061"
"OwnerKey" = "8:_916ECA9F59D1CEB0FF37DC0EBC6ADBAD"
"OwnerKey" = "8:_A2C7549793E3F567D5DD7A863917B10A"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
@ -280,13 +280,13 @@
"Entry"
{
"MsmKey" = "8:_368133AF517A83A1ADFE254C8AD56055"
"OwnerKey" = "8:_61F41F93EF4F9815C9FA05A7C9CEBC23"
"OwnerKey" = "8:_D274852DABCB4A4494D3A2692AAA9A5D"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_368133AF517A83A1ADFE254C8AD56055"
"OwnerKey" = "8:_D274852DABCB4A4494D3A2692AAA9A5D"
"OwnerKey" = "8:_61F41F93EF4F9815C9FA05A7C9CEBC23"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
@ -952,7 +952,13 @@
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_1C7B872EE61AA0BD2CED65776F1CA061"
"OwnerKey" = "8:_F2AA992CC4AB6876A55EB1558D678429"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_368133AF517A83A1ADFE254C8AD56055"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
@ -970,18 +976,6 @@
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_368133AF517A83A1ADFE254C8AD56055"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_F2AA992CC4AB6876A55EB1558D678429"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_1A51967364D01C1AC0F52D84E82854F1"
"MsmSig" = "8:_UNDEFINED"
}
@ -1339,6 +1333,12 @@
"OwnerKey" = "8:_E12A78DB43F94C3C321512AB019F14E6"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_1C7B872EE61AA0BD2CED65776F1CA061"
"MsmSig" = "8:_UNDEFINED"
}
}
"Configurations"
{
@ -1357,6 +1357,14 @@
"PrivateKeyFile" = "8:"
"TimeStampServer" = "8:"
"InstallerBootstrapper" = "3:2"
"BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
{
"Enabled" = "11:TRUE"
"PromptEnabled" = "11:TRUE"
"PrerequisitesLocation" = "2:1"
"Url" = "8:"
"ComponentsUrl" = "8:"
}
}
"Release"
{
@ -3644,15 +3652,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Office365APIEditor"
"ProductCode" = "8:{A00DFE28-EDFD-47BA-B242-EF7FA0A3D682}"
"PackageCode" = "8:{E95CC4D6-843E-4E4F-B94A-ABE7C6CE8041}"
"ProductCode" = "8:{0B61F1CD-3079-4E9E-8ADC-A0CA88B72826}"
"PackageCode" = "8:{D56A8367-DB90-4E59-8267-0D17E73EBDEC}"
"UpgradeCode" = "8:{8A442988-BA7D-43E0-A2B9-F7790CA105FD}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:0.10.6"
"ProductVersion" = "8:0.10.10"
"Manufacturer" = "8:Microsoft Corporation"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
@ -4264,7 +4272,7 @@
}
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_D274852DABCB4A4494D3A2692AAA9A5D"
{
"SourcePath" = "8:..\\Office365APIEditor\\obj\\Debug\\Office365APIEditor.exe"
"SourcePath" = "8:..\\Office365APIEditor\\obj\\Release\\Office365APIEditor.exe"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_6ED438E281C34CC29FC697D0A01E610D"