This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
UpTool2/UpTool2/Task/UploadTask.cs
2020-05-16 18:19:43 +02:00

49 lines
1.4 KiB
C#

using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using UpTool2.Properties;
using UpToolLib;
using UpToolLib.DataStructures;
using UpToolLib.Tool;
namespace UpTool2.Task
{
internal class UploadTask : IAppTask
{
private readonly string _name;
private readonly Action? _postInstall;
public readonly string ZipFile;
public UploadTask(string zipFile, string name, Action? postInstall = null)
{
ZipFile = zipFile;
_name = name;
_postInstall = postInstall;
}
public void Run()
{
#if !DEBUG
try
{
#endif
Guid id = Guid.NewGuid();
while (GlobalVariables.Apps.ContainsKey(id) || Directory.Exists(PathTool.GetAppPath(id)))
id = Guid.NewGuid();
App appI = new App(_name, "Locally installed package, removal only",
GlobalVariables.MinimumVer, "", true, "", id, Color.Red, Resources.C_64.ToBitmap(), false, "");
AppInstall.InstallZip(ZipFile, appI, true);
_postInstall?.Invoke();
#if !DEBUG
}
catch (Exception e1)
{
MessageBox.Show(e1.ToString(), "Install failed");
}
#endif
}
public override string ToString() => $"Install local {Path.GetFileName(ZipFile)}";
}
}