Files
BeWoPlaner/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs

81 lines
2.3 KiB
C#

using BeWoLauncher.Components;
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.Logic.Utils;
using BS.SharedLauncher.Information;
using System;
using System.Threading.Tasks;
using static BeWoLauncher.Logic.Controller.ViewController;
namespace BeWoLauncher.Logic.Behavior
{
public class LaunchBehavior
{
public bool UninstallMode { get; set; }
public LaunchBehavior()
{
}
public void LoginSuccessful()
{
#region confirm demo
#if DEBUG
//if (ConnectionInformation.Tenant == "demo")
//{
// var dlg = new ConfirmDemoDialog();
// dlg.ShowDialog();
//}
#else
if (ConnectionInformation.Tenant == "demo")
{
var dlg = new ConfirmDemoDialog();
dlg.ShowDialog();
}
#endif
#endregion
LauncherPaths.ActualPlanerLocation = LauncherPaths.GetInstallLocationFromSetting();
if (LauncherPaths.ActualPlanerLocation is object && !CheckForPermissions(LauncherPaths.ActualPlanerLocation))
{
ViewBehavior.ShowFrame(FrameType.NoPermissionInfo);
EndWaiting();
}
else
{
if (UninstallMode)
ViewBehavior.ShowUninstallInfo();
else
Task.Run(() =>
{
try
{
DownloadController.Start();
DownloadController.Manager.StartDownloadInfo();
if (DownloadController.Manager.ResponseInfo.HasSomethingToDo)
{
ViewBehavior.ShowInfo();
}
else
{
ViewBehavior.ShowLoading();
}
}
catch(Exception ex)
{
ViewBehavior.ShowError(ex);
}
EndWaiting();
});
}
}
public void LaunchPlaner()
{
Task.Run(() => ProcessController.StartPlanerProcess());
}
}
}