Skip to content

Commit

Permalink
Fixed Updater
Browse files Browse the repository at this point in the history
  • Loading branch information
JWLMT88 committed Apr 24, 2023
1 parent bc2679d commit 62b47cf
Show file tree
Hide file tree
Showing 33 changed files with 217 additions and 34 deletions.
Binary file modified srvlocal/.vs/ProjectEvaluation/srvlocal.metadata.v7.bin
Binary file not shown.
Binary file modified srvlocal/.vs/ProjectEvaluation/srvlocal.projects.v7.bin
Binary file not shown.
Binary file modified srvlocal/.vs/srvlocal/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified srvlocal/.vs/srvlocal/v17/.futdcache.v2
Binary file not shown.
Binary file modified srvlocal/.vs/srvlocal/v17/.suo
Binary file not shown.
Binary file added srvlocal/.vs/srvlocal/v17/Preview/Browse.VC.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified srvlocal/.vs/srvlocal/v17/fileList.bin
Binary file not shown.
38 changes: 26 additions & 12 deletions srvlocal_gui/Form1.Designer.cs

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

122 changes: 110 additions & 12 deletions srvlocal_gui/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using LABLibary.Assistant;
using System.ComponentModel;
using LABLibary.Forms;
using System.Net.Http.Headers;
using Octokit;

namespace srvlocal_gui
{
Expand All @@ -22,11 +24,14 @@ public Form1()
InitializeComponent();
}

private const string repoName = "LILO-LocalServer";
NotifyIcon noty;

public static string filePath = ".\\srvlocal.exe";
public static Process consoleHandle;
public static Process? consoleHandle;
public string owner = "JW-Limited";
public string repo = "LILO-LocalServer";
public bool UpdateDetected = false;


public static string VersionApp()
{
Expand Down Expand Up @@ -94,18 +99,111 @@ private void lblDomain_Click(object sender, EventArgs e)
var Proc = Process.Start("explorer.exe", AppDomain.CurrentDomain.BaseDirectory);
}

private async void bntUpdate(object sender, EventArgs e)
private void bntUpdate(object sender, EventArgs e)
{
var ReleaseChecker = new GitHubReleaseChecker("JW-Limited", repo: repoName, "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");
if (bntCheck.Text == "Install")
{
Process.Start("explorer.exe", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)));
System.Windows.Forms.Application.ExitThread();
}
else
{
switch (UpdateDetected)
{
case true:
progressbar.Visible = true;
Task.Run(() =>
{
Updater.DownloadLatestRelease(owner, repo, UpdateProgress);
this.Invoke((MethodInvoker)delegate
{
richTxtStatus.ResetText();
});
});
break;
default:
if (Updater.HasNewRelease(owner, repo))
{
Console.WriteLine("A new release is available.");
richTxtStatus.Text = $"A new release is available. \nYour Version : {Updater.GetCurrentVersion()}\nLatest Version : {Updater.GetLatestVersion(owner, repo)}";
UpdateDetected = true;
bntCheck.Text = "Download";
}
else
{
Console.WriteLine("No new release available.");
}
break;
}
}

richTxtStatus.Text = null;
try


}

private void UpdateProgress(object sender, DownloadProgressChangedEventArgs e)
{
this.Invoke((MethodInvoker)delegate
{
await ReleaseChecker.CheckForNewRelease();
progressbar.Value = e.ProgressPercentage;
lblUpdaterPros.Text = $"{e.ProgressPercentage}%";

if (e.ProgressPercentage == 100)
{
richTxtStatus.Text += "\nLatest release downloaded successfully.";
lblUpdaterPros.Text = "Ready";
progressbar.Visible = false;
bntCheck.Text = "Install";
}
});
}

public class Updater
{

public static bool HasNewRelease(string owner, string repo)
{
var client = new GitHubClient(new Octokit.ProductHeaderValue("srvlocal_gui"));
var releases = client.Repository.Release.GetAll(owner, repo).Result;

if (releases.Count > 0)
{
string latestTag = releases[0].TagName;
if (latestTag != GetCurrentVersion())
{
return true;
}
}

return false;
}
catch (Exception ex)

public static string GetLatestVersion(string owner, string repo)
{
var client = new GitHubClient(new Octokit.ProductHeaderValue("srvlocal_gui"));
var releases = client.Repository.Release.GetAll(owner, repo).Result;
return releases[0].TagName;
}

public static void DownloadLatestRelease(string owner, string repo, DownloadProgressChangedEventHandler progressHandler)
{
var client = new WebClient();
client.DownloadProgressChanged += progressHandler;
string latestUrl = GetLatestReleaseUrl(owner, repo);
client.DownloadFileAsync(new Uri(latestUrl), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "latest_release.zip"));
}

public static string GetLatestReleaseUrl(string owner, string repo)
{
var client = new GitHubClient(new Octokit.ProductHeaderValue("srvlocal_gui"));
var releases = client.Repository.Release.GetAll(owner, repo).Result;
return releases[0].Assets[0].BrowserDownloadUrl;
}

public static string GetCurrentVersion()
{
richTxtStatus.Text = ex.Message;
return System.Windows.Forms.Application.ProductVersion.ToLower();
}
}

Expand Down Expand Up @@ -140,7 +238,7 @@ public void RunConsoleApplication(string filePath)

while (process.HasExited == false)
{
Application.DoEvents();
System.Windows.Forms.Application.DoEvents();
//process.WaitForExitAsync();
PingReply reply = ping.Send("localhost", 8080);
reachable = reply.Status == IPStatus.Success;
Expand Down Expand Up @@ -188,7 +286,7 @@ private void bntStartCon(object sender, EventArgs e)
process.BeginOutputReadLine();
while (process.HasExited == false)
{
Application.DoEvents();
System.Windows.Forms.Application.DoEvents();
//process.WaitForExitAsync();
PingReply reply = ping.Send("localhost", 8080);
reachable = reply.Status == IPStatus.Success;
Expand Down Expand Up @@ -307,7 +405,7 @@ private void bntStartWithArguments(object sender, EventArgs e)
process.BeginOutputReadLine();
while (process.HasExited == false)
{
Application.DoEvents();
System.Windows.Forms.Application.DoEvents();
process.WaitForExitAsync();
}

Expand Down
Binary file added srvlocal_gui/bin/Debug/net7.0-windows/Octokit.dll
Binary file not shown.
20 changes: 18 additions & 2 deletions srvlocal_gui/bin/Debug/net7.0-windows/srvlocal_gui.deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v7.0": {
"srvlocal_gui/1.0.0": {
"srvlocal_gui/1.2": {
"dependencies": {
"DarkUI": "1.0.0",
"Google.Apis.Auth": "1.59.0",
Expand All @@ -21,6 +21,7 @@
"Microsoft.ML.FastTree": "2.0.0",
"Microsoft.Web.WebView2": "1.0.1619-prerelease",
"Modern.Forms": "0.3.0",
"Octokit": "5.0.4",
"Ookii.Dialogs.WinForms": "4.0.0",
"ReactiveUI.Events.Winforms": "15.1.1",
"ReactiveUI.WinForms": "18.4.1",
Expand Down Expand Up @@ -511,6 +512,14 @@
}
}
},
"Octokit/5.0.4": {
"runtime": {
"lib/netstandard2.0/Octokit.dll": {
"assemblyVersion": "5.0.4.0",
"fileVersion": "5.0.4.0"
}
}
},
"Ookii.Dialogs.WinForms/4.0.0": {
"dependencies": {
"System.Resources.Extensions": "6.0.0"
Expand Down Expand Up @@ -1547,7 +1556,7 @@
}
},
"libraries": {
"srvlocal_gui/1.0.0": {
"srvlocal_gui/1.2": {
"type": "project",
"serviceable": false,
"sha512": ""
Expand Down Expand Up @@ -1776,6 +1785,13 @@
"path": "newtonsoft.json/13.0.2",
"hashPath": "newtonsoft.json.13.0.2.nupkg.sha512"
},
"Octokit/5.0.4": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Voup3PUC6YtiNQIvcOCqQXEA4qB1G2D7oWW1I+tjrBoEf2mHvz/6+IRnA7y6+Pd8sV+j9sr2rXhduIBO8k7guA==",
"path": "octokit/5.0.4",
"hashPath": "octokit.5.0.4.nupkg.sha512"
},
"Ookii.Dialogs.WinForms/4.0.0": {
"type": "package",
"serviceable": true,
Expand Down
Binary file modified srvlocal_gui/bin/Debug/net7.0-windows/srvlocal_gui.dll
Binary file not shown.
Binary file modified srvlocal_gui/bin/Debug/net7.0-windows/srvlocal_gui.exe
Binary file not shown.
Binary file modified srvlocal_gui/obj/Debug/net7.0-windows/apphost.exe
Binary file not shown.
Binary file modified srvlocal_gui/obj/Debug/net7.0-windows/ref/srvlocal_gui.dll
Binary file not shown.
Binary file modified srvlocal_gui/obj/Debug/net7.0-windows/refint/srvlocal_gui.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright© 2023 - JW Limited")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("An easy way to Build and Run youre LILO Apps")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.2.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.2")]
[assembly: System.Reflection.AssemblyProductAttribute("Local Server Manager")]
[assembly: System.Reflection.AssemblyTitleAttribute("srvlocal_gui")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.2.0.0")]
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cee68ec282e6657960e14fbf574debbe1f11ad67
f6b78bb498e84882f5ad5152f81291e09893ddc2
Binary file modified srvlocal_gui/obj/Debug/net7.0-windows/srvlocal_gui.assets.cache
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8a3dae2eccc1ca80a840081bd395b361a1380baf
d1c3047087c3c182dc05df706ee97f820da486e0
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,4 @@ C:\Users\joeva\Documents\GitHub\LILO-LocalServer\srvlocal_gui\bin\Debug\net7.0-w
C:\Users\joeva\Documents\GitHub\LILO-LocalServer\srvlocal_gui\bin\Debug\net7.0-windows\LABLibary.dll.config
C:\Users\joeva\Documents\GitHub\LILO-LocalServer\srvlocal_gui\bin\Debug\net7.0-windows\ICSharpCode.TextEditor.pdb
C:\Users\joeva\Documents\GitHub\LILO-LocalServer\srvlocal_gui\obj\Debug\net7.0-windows\RuFramework.RuProgressBar.resources
C:\Users\joeva\Documents\GitHub\LILO-LocalServer\srvlocal_gui\bin\Debug\net7.0-windows\Octokit.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,14 @@
}
}
},
"Octokit/5.0.4": {
"runtime": {
"lib/netstandard2.0/Octokit.dll": {
"assemblyVersion": "5.0.4.0",
"fileVersion": "5.0.4.0"
}
}
},
"Ookii.Dialogs.WinForms/4.0.0": {
"dependencies": {
"System.Resources.Extensions": "6.0.0"
Expand Down Expand Up @@ -2132,6 +2140,13 @@
"path": "newtonsoft.json/13.0.2",
"hashPath": "newtonsoft.json.13.0.2.nupkg.sha512"
},
"Octokit/5.0.4": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Voup3PUC6YtiNQIvcOCqQXEA4qB1G2D7oWW1I+tjrBoEf2mHvz/6+IRnA7y6+Pd8sV+j9sr2rXhduIBO8k7guA==",
"path": "octokit/5.0.4",
"hashPath": "octokit.5.0.4.nupkg.sha512"
},
"Ookii.Dialogs.WinForms/4.0.0": {
"type": "package",
"serviceable": true,
Expand Down
Binary file modified srvlocal_gui/obj/Debug/net7.0-windows/srvlocal_gui.dll
Binary file not shown.
Loading

0 comments on commit 62b47cf

Please sign in to comment.