|
1 | 1 | using Microsoft.Win32; |
2 | 2 | using System; |
3 | 3 | using System.Collections.Generic; |
| 4 | +using System.Globalization; |
4 | 5 | using System.IO; |
5 | 6 | using System.Security.Principal; |
6 | 7 | using System.Threading.Tasks; |
@@ -135,29 +136,23 @@ public void setLatestVersionDate() |
135 | 136 | Task<string> jsonRequest = Task.Run(async () => { return await downloader.GetJSONBodyRequest(downloader.GetURLGitHubAPI()); }); |
136 | 137 | //TO DO Find a better way to parse JSON aswell |
137 | 138 | string json = jsonRequest.Result; |
138 | | - string published_at = json.Substring(json.IndexOf("\"published_at\":")); |
139 | | - published_at = published_at.Remove(published_at.IndexOf("\",")); |
140 | | - this.latestVersionDate = published_at.Remove(0, "\"published_at\":\"".Length); |
| 139 | + string created_at = json.Substring(json.IndexOf("\"created_at\":")); |
| 140 | + created_at = created_at.Remove(created_at.IndexOf("\",")); |
| 141 | + this.latestVersionDate = created_at.Remove(0, "\"created_at\":\"".Length); |
141 | 142 | } |
142 | 143 |
|
143 | 144 | public bool isLatestVersionInstalled(string soft, string version, string location) |
144 | 145 | {// To ensure latest version, we compare between last modified time of files and the publish date of github release |
145 | | - string[] latestDateSplit = this.latestVersionDate.Split('-'); |
146 | | - string year = latestDateSplit[0]; |
147 | | - string month = latestDateSplit[1]; |
148 | | - string day = latestDateSplit[2].Substring(0, 2); |
149 | | - bool isLatestversion = false; |
150 | | - string lastUpdate = ""; |
| 146 | + var latest = DateTime.Parse(this.latestVersionDate, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal); |
| 147 | + var isLatestversion = false; |
151 | 148 | switch (soft) |
152 | 149 | { |
153 | 150 | case "Max": |
154 | | - lastUpdate = File.GetLastWriteTime(location + "bin\\assemblies\\Max2Babylon.dll").ToString(); |
155 | | - if (lastUpdate.Contains(year) && lastUpdate.Contains(month) && lastUpdate.Contains(day)) isLatestversion = true; |
| 151 | + if (latest <= File.GetLastWriteTime(location + "bin\\assemblies\\Max2Babylon.dll")) isLatestversion = true; |
156 | 152 | break; |
157 | 153 |
|
158 | 154 | case "Maya": |
159 | | - lastUpdate = File.GetLastWriteTime(location + "bin\\plug-ins\\Maya2Babylon.nll.dll").ToString(); |
160 | | - if (lastUpdate.Contains(year) && lastUpdate.Contains(month) && lastUpdate.Contains(day)) isLatestversion = true; |
| 155 | + if (latest <= File.GetLastWriteTime(location + "bin\\plug-ins\\Maya2Babylon.nll.dll")) isLatestversion = true; |
161 | 156 | break; |
162 | 157 |
|
163 | 158 | default: |
|
0 commit comments