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
CreepyCrafter24 c186afa8b4 Stage changes
2020-04-08 20:57:50 +02:00

51 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using UpTool2.Properties;
using UpToolLib;
using UpToolLib.DataStructures;
using UpToolLib.Tool;
namespace UpTool2.Task
{
class UploadTask : IAppTask
{
public readonly string ZipFile;
private readonly string _name;
private readonly Action? _postInstall;
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)}";
}
}