From 59a1150c0e1b91623a6b78cde656fdd5a387bd16 Mon Sep 17 00:00:00 2001 From: David Poindexter Date: Sun, 4 Mar 2018 17:41:22 -0500 Subject: [PATCH 1/7] initial testing --- Controllers/VersionController.cs | 26 ++++++++++++++++++++++++++ Main.cs | 4 ++++ Models/Version.cs | 13 +++++++++++++ data/currentVersion.json | 5 +++++ nvQuickSite.csproj | 3 +++ 5 files changed, 51 insertions(+) create mode 100644 Controllers/VersionController.cs create mode 100644 Models/Version.cs create mode 100644 data/currentVersion.json diff --git a/Controllers/VersionController.cs b/Controllers/VersionController.cs new file mode 100644 index 00000000..61d809ef --- /dev/null +++ b/Controllers/VersionController.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Net; + +namespace nvQuickSite.Controllers +{ + public class VersionController + { + public static decimal GetRemoteCurrentVersion() + { + WebClient client = new WebClient(); + try + { + var url = "https://github.com/nvisionative/nvQuickSite/blob/issue-151/data/currentVersion.json"; + string result = client.DownloadString(url); + var res = Newtonsoft.Json.JsonConvert.DeserializeObject(result); + return res.currentVersion; + } + catch (Exception ex) + { + } + return new decimal(); + } + + } +} diff --git a/Main.cs b/Main.cs index ec2e5bc0..c3344c26 100644 --- a/Main.cs +++ b/Main.cs @@ -22,6 +22,7 @@ using MetroFramework.Forms; using Segment; using JCS; +using nvQuickSite.Controllers; namespace nvQuickSite { @@ -39,6 +40,9 @@ public Main() }); lblVersion.Text = "v" + Application.ProductVersion; + + var currentVersion = VersionController.GetRemoteCurrentVersion(); + Start control = new Start(); control.Dock = DockStyle.Fill; Controls.Add(control); diff --git a/Models/Version.cs b/Models/Version.cs new file mode 100644 index 00000000..671e10a5 --- /dev/null +++ b/Models/Version.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace nvQuickSite.Models +{ + class Version + { + public decimal currentVersion { get; set; } + } +} diff --git a/data/currentVersion.json b/data/currentVersion.json new file mode 100644 index 00000000..d2676fc2 --- /dev/null +++ b/data/currentVersion.json @@ -0,0 +1,5 @@ +[ + { + "currentVersion": "1.2.0" + } +] \ No newline at end of file diff --git a/nvQuickSite.csproj b/nvQuickSite.csproj index da60f38d..6a39064b 100644 --- a/nvQuickSite.csproj +++ b/nvQuickSite.csproj @@ -131,6 +131,8 @@ + + Form @@ -174,6 +176,7 @@ + Designer From aad7c197825a96f8e8d187aa3cdedda268fc1dd4 Mon Sep 17 00:00:00 2001 From: David Poindexter Date: Sun, 4 Mar 2018 18:12:38 -0500 Subject: [PATCH 2/7] change JSON array to JSON object --- Controllers/VersionController.cs | 5 +++-- data/currentVersion.json | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Controllers/VersionController.cs b/Controllers/VersionController.cs index 61d809ef..dfa96ee7 100644 --- a/Controllers/VersionController.cs +++ b/Controllers/VersionController.cs @@ -11,9 +11,10 @@ public static decimal GetRemoteCurrentVersion() WebClient client = new WebClient(); try { - var url = "https://github.com/nvisionative/nvQuickSite/blob/issue-151/data/currentVersion.json"; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + var url = "https://raw.githubusercontent.com/nvisionative/nvQuickSite/issue-151/data/currentVersion.json"; string result = client.DownloadString(url); - var res = Newtonsoft.Json.JsonConvert.DeserializeObject(result); + Models.Version res = Newtonsoft.Json.JsonConvert.DeserializeObject(result); return res.currentVersion; } catch (Exception ex) diff --git a/data/currentVersion.json b/data/currentVersion.json index d2676fc2..ca2663bb 100644 --- a/data/currentVersion.json +++ b/data/currentVersion.json @@ -1,5 +1,3 @@ -[ - { - "currentVersion": "1.2.0" - } -] \ No newline at end of file +{ + "currentVersion": "1.2.0" +} \ No newline at end of file From 062801a88ef332165e08895ebc2250c6e507f821 Mon Sep 17 00:00:00 2001 From: David Poindexter Date: Sun, 4 Mar 2018 19:16:22 -0500 Subject: [PATCH 3/7] temp change to currentVersion JSON --- Controllers/VersionController.cs | 4 ++-- Main.cs | 7 ++++++- Models/Version.cs | 2 +- data/currentVersion.json | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Controllers/VersionController.cs b/Controllers/VersionController.cs index dfa96ee7..7d245efe 100644 --- a/Controllers/VersionController.cs +++ b/Controllers/VersionController.cs @@ -6,7 +6,7 @@ namespace nvQuickSite.Controllers { public class VersionController { - public static decimal GetRemoteCurrentVersion() + public static string GetRemoteCurrentVersion() { WebClient client = new WebClient(); try @@ -20,7 +20,7 @@ public static decimal GetRemoteCurrentVersion() catch (Exception ex) { } - return new decimal(); + return ""; } } diff --git a/Main.cs b/Main.cs index c3344c26..a2e3227d 100644 --- a/Main.cs +++ b/Main.cs @@ -41,7 +41,12 @@ public Main() lblVersion.Text = "v" + Application.ProductVersion; - var currentVersion = VersionController.GetRemoteCurrentVersion(); + var currentVersion = Decimal.Parse(VersionController.GetRemoteCurrentVersion()); + if (currentVersion > Decimal.Parse(Application.ProductVersion)) + { + //display link to latest release + Process.Start("https://github.com/nvisionative/nvQuickSite/releases/latest"); + } Start control = new Start(); control.Dock = DockStyle.Fill; diff --git a/Models/Version.cs b/Models/Version.cs index 671e10a5..641e3049 100644 --- a/Models/Version.cs +++ b/Models/Version.cs @@ -8,6 +8,6 @@ namespace nvQuickSite.Models { class Version { - public decimal currentVersion { get; set; } + public string currentVersion { get; set; } } } diff --git a/data/currentVersion.json b/data/currentVersion.json index ca2663bb..b59c8842 100644 --- a/data/currentVersion.json +++ b/data/currentVersion.json @@ -1,3 +1,3 @@ { - "currentVersion": "1.2.0" + "currentVersion": "1.3.0" } \ No newline at end of file From 2cd2d870c44ab739d7a18a9f57feea45c8143964 Mon Sep 17 00:00:00 2001 From: David Poindexter Date: Sun, 4 Mar 2018 19:55:17 -0500 Subject: [PATCH 4/7] changed currentVersion to latestVersion --- Controllers/VersionController.cs | 4 ++-- Main.Designer.cs | 22 ++++++++++++++++++++-- Main.cs | 12 ++++++++---- Models/Version.cs | 2 +- data/currentVersion.json | 3 --- data/latestVersion.json | 3 +++ nvQuickSite.csproj | 2 +- 7 files changed, 35 insertions(+), 13 deletions(-) delete mode 100644 data/currentVersion.json create mode 100644 data/latestVersion.json diff --git a/Controllers/VersionController.cs b/Controllers/VersionController.cs index 7d245efe..ab3d29ec 100644 --- a/Controllers/VersionController.cs +++ b/Controllers/VersionController.cs @@ -6,7 +6,7 @@ namespace nvQuickSite.Controllers { public class VersionController { - public static string GetRemoteCurrentVersion() + public static string GetRemoteLatestVersion() { WebClient client = new WebClient(); try @@ -15,7 +15,7 @@ public static string GetRemoteCurrentVersion() var url = "https://raw.githubusercontent.com/nvisionative/nvQuickSite/issue-151/data/currentVersion.json"; string result = client.DownloadString(url); Models.Version res = Newtonsoft.Json.JsonConvert.DeserializeObject(result); - return res.currentVersion; + return res.latestVersion; } catch (Exception ex) { diff --git a/Main.Designer.cs b/Main.Designer.cs index 52c4012b..37f2be4f 100644 --- a/Main.Designer.cs +++ b/Main.Designer.cs @@ -32,6 +32,7 @@ private void InitializeComponent() this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.lblVersion = new System.Windows.Forms.Label(); + this.tileGetNewVersion = new MetroFramework.Controls.MetroTile(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); @@ -64,17 +65,33 @@ private void InitializeComponent() this.lblVersion.Font = new System.Drawing.Font("Tahoma", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblVersion.Location = new System.Drawing.Point(444, 50); this.lblVersion.Name = "lblVersion"; - this.lblVersion.Size = new System.Drawing.Size(87, 18); + this.lblVersion.Size = new System.Drawing.Size(55, 18); this.lblVersion.TabIndex = 4; - this.lblVersion.Text = "Version Info"; + this.lblVersion.Text = "Version"; this.lblVersion.TextAlign = System.Drawing.ContentAlignment.BottomLeft; // + // tileGetNewVersion + // + this.tileGetNewVersion.Cursor = System.Windows.Forms.Cursors.Hand; + this.tileGetNewVersion.Location = new System.Drawing.Point(505, 50); + this.tileGetNewVersion.Name = "tileGetNewVersion"; + this.tileGetNewVersion.Size = new System.Drawing.Size(122, 17); + this.tileGetNewVersion.Style = MetroFramework.MetroColorStyle.Lime; + this.tileGetNewVersion.TabIndex = 29; + this.tileGetNewVersion.Text = "Get New Version"; + this.tileGetNewVersion.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.tileGetNewVersion.TileTextFontSize = MetroFramework.MetroTileTextSize.Small; + this.tileGetNewVersion.TileTextFontWeight = MetroFramework.MetroTileTextWeight.Bold; + this.tileGetNewVersion.Visible = false; + this.tileGetNewVersion.Click += new System.EventHandler(this.tileGetNewVersion_Click); + // // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BorderStyle = MetroFramework.Drawing.MetroBorderStyle.FixedSingle; this.ClientSize = new System.Drawing.Size(650, 580); + this.Controls.Add(this.tileGetNewVersion); this.Controls.Add(this.lblVersion); this.Controls.Add(this.pictureBox1); this.Controls.Add(this.pictureBox2); @@ -94,6 +111,7 @@ private void InitializeComponent() private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Label lblVersion; + private MetroFramework.Controls.MetroTile tileGetNewVersion; } } diff --git a/Main.cs b/Main.cs index a2e3227d..1d451eb6 100644 --- a/Main.cs +++ b/Main.cs @@ -41,11 +41,10 @@ public Main() lblVersion.Text = "v" + Application.ProductVersion; - var currentVersion = Decimal.Parse(VersionController.GetRemoteCurrentVersion()); - if (currentVersion > Decimal.Parse(Application.ProductVersion)) + var latestVersion = VersionController.GetRemoteLatestVersion(); + if (Version.Parse(latestVersion) > Version.Parse(Application.ProductVersion)) { - //display link to latest release - Process.Start("https://github.com/nvisionative/nvQuickSite/releases/latest"); + tileGetNewVersion.Visible = true; } Start control = new Start(); @@ -57,5 +56,10 @@ private void pictureBox1_Click(object sender, EventArgs e) { Process.Start("http://www.nvisionative.com"); } + + private void tileGetNewVersion_Click(object sender, EventArgs e) + { + Process.Start("https://github.com/nvisionative/nvQuickSite/releases/latest"); + } } } diff --git a/Models/Version.cs b/Models/Version.cs index 641e3049..a49b9391 100644 --- a/Models/Version.cs +++ b/Models/Version.cs @@ -8,6 +8,6 @@ namespace nvQuickSite.Models { class Version { - public string currentVersion { get; set; } + public string latestVersion { get; set; } } } diff --git a/data/currentVersion.json b/data/currentVersion.json deleted file mode 100644 index b59c8842..00000000 --- a/data/currentVersion.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "currentVersion": "1.3.0" -} \ No newline at end of file diff --git a/data/latestVersion.json b/data/latestVersion.json new file mode 100644 index 00000000..d9d6aad2 --- /dev/null +++ b/data/latestVersion.json @@ -0,0 +1,3 @@ +{ + "latestVersion": "1.3.0" +} \ No newline at end of file diff --git a/nvQuickSite.csproj b/nvQuickSite.csproj index 6a39064b..3de13644 100644 --- a/nvQuickSite.csproj +++ b/nvQuickSite.csproj @@ -176,7 +176,7 @@ - + Designer From e2c1cdeba56defe17b9edf281cde6d728b533d5d Mon Sep 17 00:00:00 2001 From: David Poindexter Date: Sun, 4 Mar 2018 19:57:28 -0500 Subject: [PATCH 5/7] corrected URL to JSON --- Controllers/VersionController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controllers/VersionController.cs b/Controllers/VersionController.cs index ab3d29ec..2c6c820b 100644 --- a/Controllers/VersionController.cs +++ b/Controllers/VersionController.cs @@ -12,7 +12,7 @@ public static string GetRemoteLatestVersion() try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - var url = "https://raw.githubusercontent.com/nvisionative/nvQuickSite/issue-151/data/currentVersion.json"; + var url = "https://raw.githubusercontent.com/nvisionative/nvQuickSite/issue-151/data/latestVersion.json"; string result = client.DownloadString(url); Models.Version res = Newtonsoft.Json.JsonConvert.DeserializeObject(result); return res.latestVersion; From 6d135f1ef5ba21482aa1ec2233b216840feebc40 Mon Sep 17 00:00:00 2001 From: David Poindexter Date: Sun, 4 Mar 2018 20:01:51 -0500 Subject: [PATCH 6/7] Set latestVersion in JSON --- data/latestVersion.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/latestVersion.json b/data/latestVersion.json index d9d6aad2..f90f5552 100644 --- a/data/latestVersion.json +++ b/data/latestVersion.json @@ -1,3 +1,3 @@ { - "latestVersion": "1.3.0" + "latestVersion": "1.2.0" } \ No newline at end of file From 6e89ea6435e63d697938b814dd1e6ba9ce128f1a Mon Sep 17 00:00:00 2001 From: David Poindexter Date: Sun, 4 Mar 2018 20:09:31 -0500 Subject: [PATCH 7/7] Set latestVersion.json URL for master branch --- Controllers/VersionController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controllers/VersionController.cs b/Controllers/VersionController.cs index 2c6c820b..27cf9bb7 100644 --- a/Controllers/VersionController.cs +++ b/Controllers/VersionController.cs @@ -12,7 +12,7 @@ public static string GetRemoteLatestVersion() try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - var url = "https://raw.githubusercontent.com/nvisionative/nvQuickSite/issue-151/data/latestVersion.json"; + var url = "https://raw.githubusercontent.com/nvisionative/nvQuickSite/master/data/latestVersion.json"; string result = client.DownloadString(url); Models.Version res = Newtonsoft.Json.JsonConvert.DeserializeObject(result); return res.latestVersion;