läuft soweit, stand vorm testen aufm app5

This commit is contained in:
rene
2022-12-02 13:00:27 +01:00
parent 7fbdd1b945
commit c0c6a96f84
39 changed files with 1578 additions and 1545 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace BeWo
{

View File

@@ -23,12 +23,12 @@ namespace BeWo
ApplicationThemeHelper.ApplicationThemeName = "Office2010Black";
if (Loader.Loaded)
ShowMainControl();
ShowNewWay();
else
ShowLoginControl();
ShowOldWay(true);
}
private void ShowMainControl()
private void ShowNewWay()
{
Translator t = new Translator(new ServiceTranslator());
//WebRequest.DefaultWebProxy
@@ -42,17 +42,23 @@ namespace BeWo
mc.LogoutClicked += new EventHandler(mc_LogoutClicked);
rootGrid.Children.Add(mc);
}
private void ShowLoginControl()
private void ShowOldWay(bool skiplogin)
{
if (skiplogin)
{
Loader.Load("tedemo?undemo?pwdemo?ip?sn1?cs?vr1.0.4.1");
ShowNewWay();
}
else
{
//WebRequest.DefaultWebProxy
//WebRequest.DefaultWebProxy
//System.Net.WebRequest.GetSystemWebProxy()
var lc = new LoginControl();
rootGrid.Children.Add(lc);
lc.LoginSuccessful += lc_LoginSuccessful;
//System.Net.WebRequest.GetSystemWebProxy()
var lc = new LoginControl();
rootGrid.Children.Add(lc);
lc.LoginSuccessful += lc_LoginSuccessful;
}
}
void lc_LoginSuccessful(object sender, EventArgs e)

View File

@@ -8,6 +8,7 @@ using System.Windows.Documents;
using System.Windows.Navigation;
using BeWo.Core;
using BeWo.ServiceProxy;
using BeWo.View;
using BeWo.ViewModel;
using BS.Shared.Core;
using BS.Shared.DataContracts;
@@ -21,7 +22,7 @@ using MessageBox = System.Windows.MessageBox;
namespace BeWo.SchulbegleitenderDienst
{
public partial class VertretungsMainView2
public partial class VertretungsMainView2 : BeWoView
{
private readonly ObservableCollection<TagesansichtVM> _AbwesendeMitarbeiter = new ObservableCollection<TagesansichtVM>();
private readonly ObservableCollection<TagesansichtVM> _AbwesendeKlienten = new ObservableCollection<TagesansichtVM>();

View File

@@ -13,18 +13,18 @@
<ContextMenu x:Name="contextMenu" x:Key="cm" MenuItem.Click="ContextMenu_Click" Opened="ContextMenu_Opened">
<MenuItem Header="Neu" >
<MenuItem.Icon>
<Image Source="..\Ressources\Icons\Add24.png"/>
<Image Source="../BeWo/BeWo/Ressources/Icons/Add24.png"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Umbenennen">
<MenuItem.Icon>
<Image Source="..\Ressources\Icons\Rename24.png"/>
<Image Source="../BeWo/BeWo/Ressources/Icons/Rename24.png"/>
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header="Löschen" >
<MenuItem.Icon>
<Image Source="..\Ressources\Icons\Delete24.png"/>
<Image Source="../BeWo/BeWo/Ressources/Icons/Delete24.png"/>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
@@ -33,24 +33,24 @@
<ContextMenu x:Name="TemplateContextMenu" x:Key="templatecm" MenuItem.Click="TemplateContextMenu_Click" Opened="TemplateContextMenu_Opened">
<MenuItem Header="Neu" >
<MenuItem.Icon>
<Image Source="..\Ressources\Icons\Add24.png"/>
<Image Source="../../Ressources/Icons/Add24.png"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Umbenennen">
<MenuItem.Icon>
<Image Source="..\Ressources\Icons\Rename24.png"/>
<Image Source="../../Ressources/Icons/Rename24.png"/>
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header="Neue Vorlage" >
<MenuItem.Icon>
<Image Source="..\Ressources\Icons\DocumentWithAdd.png"/>
<Image Source="../../Ressources/Icons/DocumentWithAdd.png"/>
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header="Löschen" >
<MenuItem.Icon>
<Image Source="..\Ressources\Icons\Delete24.png"/>
<Image Source="../../Ressources/Icons/Delete24.png"/>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>

View File

@@ -41,7 +41,7 @@ using BS.Shared.Translation;
namespace BeWo.View.Master
{
public partial class DokumenteView
public partial class DokumenteView : BeWoView
{
private string _UploadFileName;
private string _NormalFileName = null;

View File

@@ -1,10 +1,11 @@
using System;
using BeWo.Scheduler.View;
using BeWo.View;
using BS.Shared.DataContracts;
namespace BeWo.View.Master
{
public partial class SchedulerMasterView
public partial class SchedulerMasterView : BeWoView
{
public SchedulerMasterView()
{

View File

@@ -99,6 +99,9 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Logic\Behavior\LaunchBehavior.cs" />
<Compile Include="Logic\Behavior\ViewSwitchBehavior.cs" />
<Compile Include="Logic\ViewBuilder.cs" />
<Compile Include="View\Components\ConfirmDemoDialog.xaml.cs">
<DependentUpon>ConfirmDemoDialog.xaml</DependentUpon>
</Compile>
@@ -160,14 +163,13 @@
<Compile Include="View\Frames\UninstallInfoFrame.xaml.cs">
<DependentUpon>UninstallInfoFrame.xaml</DependentUpon>
</Compile>
<Compile Include="Logic\Utils\BeWoHelper.cs" />
<Compile Include="Logic\Utils\BeWoLocalConfig.cs" />
<Compile Include="Logic\Utils\BeWoPaths.cs" />
<Compile Include="Logic\Utils\LauncherAppdataConfig.cs" />
<Compile Include="Logic\Utils\LauncherPaths.cs" />
<Compile Include="Logic\Utils\Download\DownloadManager.cs" />
<Compile Include="View\Components\PasswortAenderungsView.xaml.cs">
<DependentUpon>PasswortAenderungsView.xaml</DependentUpon>
</Compile>
<Compile Include="Logic\ConnectionProfile.cs" />
<Compile Include="Models\ConnectionProfile.cs" />
<Compile Include="View\Windows\PopUpWindow.xaml.cs">
<DependentUpon>PopUpWindow.xaml</DependentUpon>
</Compile>
@@ -461,9 +463,6 @@
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1,21 +1,12 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
using BeWoLauncher.Components;
using BeWoLauncher.Logic;
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.Utils.Download;
using BS.SharedLauncher;
using BS.SharedLauncher.Information;
namespace BeWoLauncher
{
@@ -26,20 +17,15 @@ namespace BeWoLauncher
private Grid _ModalPopUpBackGround;
private WaitLayer2 _WaitLayer;
//public IShadowPage CurrentShadowPage { get; set; }
public LauncherWindow()
{
InitializeComponent();
_ModalPopUpControls = new Stack<Control>();
ViewController.CurrentWindow = this;
ViewController.InitWindow(this);
ViewController.StartView();
// RE Test
// LauncherServiceFacade.DoDownloadBeWoServiceSync(x => x.Download2(new BS.SharedLauncher.DataContract.DownloadPlanerRequestDC() { }));
}
private void MainWindow_OnClosing(object s, CancelEventArgs e)

View File

@@ -0,0 +1,73 @@
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.Logic.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using static BeWoLauncher.Logic.Controller.ViewController;
namespace BeWoLauncher.Logic.Behavior
{
public class LaunchBehavior
{
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
{
Task.Run(() =>
{
DownloadController.Start();
DownloadController.Manager.StartDownloadInfo();
if (DownloadController.Manager.ResponseInfo.HasSomethingToDo)
{
ViewBehavior.ShowInfo();
}
else
{
ViewBehavior.ShowLoading();
}
EndWaiting();
});
}
}
public void LaunchPlaner()
{
Task.Run(() => ProcessController.StartPlanerProcess());
}
}
}

View File

@@ -0,0 +1,151 @@
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.Logic.Utils;
using BeWoLauncher.View;
using BeWoLauncher.View.Frames;
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Threading;
using static BeWoLauncher.Logic.Controller.ViewController;
namespace BeWoLauncher.Logic.Behavior
{
public class ViewSwitchBehavior
{
private UserControl _currentView;
private FrameBase _currentFrame;
private UserControl CurrentView
{
get => _currentView;
set
{
_currentView = value;
CurrentWindow.Dispatcher.BeginInvoke(DispatcherPriority.Render,
(Action)delegate
{
CurrentWindow.SetMainContent(value);
});
}
}
private FrameBase CurrentFrame
{
get => _currentFrame; set
{
_currentFrame = value;
if (CurrentView is FrameView frameview)
CurrentWindow.Dispatcher.BeginInvoke(DispatcherPriority.Render,
(Action)delegate
{
frameview.SetFrame(value);
});
else
CurrentView = new FrameView(value);
}
}
public ViewSwitchBehavior()
{
}
public void ShowView(ViewType vt)
{
CurrentView = ViewController.ViewBuilder.GetNewView(vt);
}
public void ShowFrame(FrameType ft)
{
CurrentFrame = ViewController.ViewBuilder.GetNewFrame(ft);
}
public void ShowInfo()
{
ViewController.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
{
if (LauncherAppdataConfig.GetFirstInstallationSuccess() &&
File.Exists(LauncherPaths.GetPlanerExePath()))
{
ShowFrame(FrameType.UpdateInfo);
}
else
{
ShowFrame(FrameType.InstallInfo);
}
}));
}
public void ShowLoading()
{
ViewController.Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() =>
{
ShowFrame(FrameType.LoadingScreen);
}));
}
public void BackToLogin(object sender, EventArgs e)
{
ShowView(ViewType.LoginView);
}
public void LoginSuccessful(object sender, EventArgs e)
{
ViewController.LaunchBehavior.LoginSuccessful();
}
public void InstallInfoAccept(object sender, EventArgs e)
{
var install = sender as InstallInfoFrame;
if (CheckForPermissions(install.InstallLocation))
{
LauncherPaths.SetAndSaveInstallLocation(install.InstallLocation);
LauncherAppdataConfig.SetFirstInstallationSuccess(true);
ShowFrame(FrameType.InstallProgress);
}
else
{
ShowFrame(FrameType.NoPermissionInfo);
}
}
public void InstallSuccesss(object sender, EventArgs e)
{
LauncherAppdataConfig.SetFirstInstallationSuccess(true);
ShowFrame(FrameType.LoadingScreen);
}
public void InstallationFailed(Exception exception)
{
Error = exception;
ShowFrame(FrameType.InstallFailed);
}
public void UpdateStarting(object sender, EventArgs e)
{
ShowFrame(FrameType.UpdateProgress);
}
public void UpdateSuccess(object sender, EventArgs e)
{
ShowFrame(FrameType.LoadingScreen);
}
public void UpdateFailed(Exception exception)
{
Error = exception;
ShowFrame(FrameType.UpdateFailed);
}
public void UninstallStarting(object sender, EventArgs e)
{
ShowFrame(FrameType.UninstallProgress);
}
public void UninstallSuccess(object sender, EventArgs e)
{
ShowFrame(FrameType.UninstallSuccessful);
}
public void UninstallFailed(Exception exception)
{
Error = exception;
ShowFrame(FrameType.UninstallFailed);
}
}
}

View File

@@ -1,19 +1,13 @@
using BeWoLauncher.Utils.Download;
using BS.SharedLauncher.Update;
using BeWoLauncher.Logic.Utils.Download;
using BS.SharedLauncher.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeWoLauncher.Logic.Controller
{
public static class DownloadController
{
public static DownloadManager Manager { get; set; }
public static long FreeSpace { get; set; }
public static long NeededSpace => Manager.ResponseInfo.DownloadSize;
@@ -27,7 +21,7 @@ namespace BeWoLauncher.Logic.Controller
FileInfo f = new FileInfo(path);
string drive = System.IO.Path.GetPathRoot(f.FullName);
FreeSpace = NonspecificTools.GetTotalFreeSpace(drive);
string txt;
if (FreeSpace >= 0)
return NonspecificTools.SizeSuffix((ulong)FreeSpace);
else

View File

@@ -1,14 +1,10 @@
using BeWoLauncher.Utils;
using BeWoLauncher.Logic.Utils;
using BS.SharedLauncher.Information;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
@@ -52,7 +48,7 @@ namespace BeWoLauncher.Logic.Controller
StartLauncherShutdown();
}
}
internal static void StartLauncherShutdown()
{
Current.Shutdown();
@@ -63,7 +59,7 @@ namespace BeWoLauncher.Logic.Controller
// based on https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-use-anonymous-pipes-for-local-interprocess-communication?redirectedfrom=MSDN
PlanerProcess = new Process();
PlanerProcess.StartInfo.FileName = BeWoPaths.GetPlanerExePath();
PlanerProcess.StartInfo.FileName = LauncherPaths.GetPlanerExePath();
PlanerProcess.EnableRaisingEvents = true;
PlanerProcess.Exited += PlanerProcess_Exit;
@@ -76,7 +72,7 @@ namespace BeWoLauncher.Logic.Controller
PlanerProcess.OutputDataReceived += MessageFromPlanerClient;
PlanerProcess.Start();
PlanerProcess.BeginOutputReadLine();
pipeServer.DisposeLocalCopyOfClientHandle();
@@ -110,7 +106,7 @@ namespace BeWoLauncher.Logic.Controller
}
}
}
internal static void PlanerProcess_Exit(object sender, EventArgs e)
{
// ExitCode Übersicht:
@@ -120,7 +116,8 @@ namespace BeWoLauncher.Logic.Controller
if (PlanerProcess.ExitCode == 100)
{
CurrentLauncher.Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)delegate {
CurrentLauncher.Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)delegate
{
Thread.Sleep(500);
ViewController.RestartView();
});

View File

@@ -1,87 +1,71 @@
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.Utils;
using BeWoLauncher.Logic.Behavior;
using BeWoLauncher.Logic.Utils;
using BeWoLauncher.View;
using BeWoLauncher.View.Frames;
using BeWoLauncher.WindowImp;
using BS.SharedLauncher.Extensions;
using BS.SharedLauncher.Information;
using BS.SharedLauncher.Logic;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Threading;
namespace BeWoLauncher.Logic.Controller
{
public enum ViewType
{
LoginView,
FrameView
}
public enum FrameType
{
InstallInfo,
InstallProgress,
InstallFailed,
UpdateInfo,
UpdateProgress,
UpdateFailed,
UninstallInfo,
UninstallProgress,
UninstallFailed,
UninstallSuccessful,
LoadingScreen,
NoPermissionInfo
}
public static class ViewController
{
private static UserControl _currentView;
private static FrameBase _currentFrame;
private static Exception error;
public enum LauncherPageType
{
Login,
InstallInfo,
InstallProgress,
InstallFailed,
UpdateInfo,
UpdateProgress,
UpdateFailed,
UninstallInfo,
UninstallProgress,
UninstallFailed,
UninstallSuccessful,
LoadingScreen,
NoPermissionInfo
}
public static LauncherWindow CurrentWindow { get; set; }
public static UserControl CurrentView
{
get => _currentView;
set
{
_currentView = value;
Dispatcher.BeginInvoke(DispatcherPriority.Render,
(Action)delegate
{
CurrentWindow.SetMainContent(value);
});
}
}
public static FrameBase CurrentFrame
{
get => _currentFrame; set
{
_currentFrame = value;
if (CurrentView is FrameView frameview)
Dispatcher.BeginInvoke(DispatcherPriority.Render,
(Action)delegate
{
frameview.SetFrame(value);
});
else
CurrentView = new FrameView(value);
}
}
public static Exception Error{ get; set; }
public static LauncherWindow CurrentWindow { get; private set; }
public static Dispatcher Dispatcher => CurrentWindow.Dispatcher;
public static ViewSwitchBehavior ViewBehavior { get; set; }
public static LaunchBehavior LaunchBehavior { get; set; }
public static ViewBuilder ViewBuilder { get; set; }
static ViewController()
{
LaunchBehavior = new LaunchBehavior();
ViewBehavior = new ViewSwitchBehavior();
ViewBuilder = new ViewBuilder();
}
public static void InitWindow(LauncherWindow window)
{
if (CurrentWindow is null)
CurrentWindow = window;
}
public static void StartView()
{
ShowPage(LauncherPageType.Login);
ViewBehavior.ShowView(ViewType.LoginView);
}
public static void RestartView()
{
ShowPage(LauncherPageType.Login);
ViewBehavior.ShowView(ViewType.LoginView);
CurrentWindow.Show();
CurrentWindow.Activate();
}
@@ -93,54 +77,6 @@ namespace BeWoLauncher.Logic.Controller
{
return FileController.IsDirectoryWritable(path, false);
}
public static void CheckForNewestVersion()
{
Task.Run(() =>
{
DownloadController.Start();
DownloadController.Manager.StartDownloadInfo();
Dispatcher.BeginInvoke(DispatcherPriority.Render,
(Action)delegate
{
if (DownloadController.Manager.ResponseInfo.HasSomethingToDo)
{
if (BeWoLocalConfig.GetFirstInstallationSuccess() &&
File.Exists(BeWoPaths.GetPlanerExePath()))
{
ShowPage(LauncherPageType.UpdateInfo);
}
else
{
ShowPage(LauncherPageType.InstallInfo);
}
}
else
{
ShowPage(LauncherPageType.LoadingScreen);
}
EndWaiting();
});
});
}
public static void InstallationFailed(Exception exception)
{
error = exception;
ShowPage(LauncherPageType.InstallFailed);
}
public static void UpdateFailed(Exception exception)
{
error = exception;
ShowPage(LauncherPageType.UpdateFailed);
}
public static void UninstallFailed(Exception exception)
{
error = exception;
ShowPage(LauncherPageType.UninstallFailed);
}
public static void CheckForAutoLogin(object sender, EventArgs e)
{
var autologin = bool.TryParse(ConfigurationManager.AppSettings.Get("AutoLogin"), out bool c) && c;
@@ -149,222 +85,5 @@ namespace BeWoLauncher.Logic.Controller
if (sender is LoginView loginPage)
loginPage.ClickLogin();
}
public static void LoginSuccessful(object sender, EventArgs e)
{
#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
BeWoPaths.ActualPlanerLocation = BeWoPaths.GetInstallLocationFromSetting();
if (BeWoPaths.ActualPlanerLocation is object && !CheckForPermissions(BeWoPaths.ActualPlanerLocation))
{
ShowPage(LauncherPageType.NoPermissionInfo);
EndWaiting();
}
else
{
CheckForNewestVersion();
}
}
private static UserControl GetNewPage(LauncherPageType type)
{
switch (type)
{
case LauncherPageType.Login:
var login = new LoginView();
login.Loaded += CheckForAutoLogin;
login.LoginSuccessful += LoginSuccessful;
return login;
case LauncherPageType.InstallInfo:
var install = new InstallInfoFrame();
install.Accept += (s, e) =>
{
if (CheckForPermissions(install.InstallLocation))
{
BeWoPaths.SetAndSaveInstallLocation(install.InstallLocation);
BeWoLocalConfig.SetFirstInstallationSuccess(true);
ShowPage(LauncherPageType.InstallProgress);
}
else
{
ShowPage(LauncherPageType.NoPermissionInfo);
}
};
install.Abort += (s, e) => { ShowPage(LauncherPageType.Login); };
return GetControlInFrameView(install);
case LauncherPageType.InstallProgress:
var installprogress = new InstallProgressInfoFrame();
installprogress.InstallSuccessful += (s, e) =>
{
BeWoLocalConfig.SetFirstInstallationSuccess(true);
ShowPage(LauncherPageType.LoadingScreen);
};
return GetControlInFrameView(installprogress);
case LauncherPageType.InstallFailed:
var installError = new InfoFrame();
installError.Title = "Installation fehlgeschlagen!";
installError.Text = error.ToString();
installError.Button1Click += (s, e) => { ShowPage(LauncherPageType.Login); };
return GetControlInFrameView(installError);
case LauncherPageType.UpdateInfo:
var update = new UpdateInfoFrame();
update.Accept += (s, e) => { ShowPage(LauncherPageType.UpdateProgress); };
update.Abort += (s, e) => { ShowPage(LauncherPageType.Login); };
return GetControlInFrameView(update);
case LauncherPageType.UpdateProgress:
var updateProgress = new UpdateProgressInfoFrame();
updateProgress.UpdateSuccessful += (s, e) => { ShowPage(LauncherPageType.LoadingScreen); };
return GetControlInFrameView(updateProgress);
case LauncherPageType.UpdateFailed:
var updateError = new InfoFrame();
updateError.Title = "Update fehlgeschlagen!";
updateError.Text = error.ToString();
updateError.Button1Click += (s, e) => { ShowPage(LauncherPageType.Login); };
return GetControlInFrameView(updateError);
case LauncherPageType.UninstallInfo:
var uninstall = new UninstallInfoFrame();
uninstall.Accept += (s, e) => { ShowPage(LauncherPageType.UpdateProgress); };
uninstall.Abort += (s, e) => { ShowPage(LauncherPageType.Login); };
return GetControlInFrameView(uninstall);
case LauncherPageType.UninstallProgress:
var uninstallProgress = new UninstallProgressInfoFrame();
uninstallProgress.UninstallSuccessful += (s, e) => { ShowPage(LauncherPageType.UninstallSuccessful); };
return GetControlInFrameView(uninstallProgress);
case LauncherPageType.UninstallFailed:
var uninstallFailed = new InfoFrame();
uninstallFailed.Title = "Deinstallation fehlgeschlagen!";
uninstallFailed.Text = error.ToString();
uninstallFailed.Button1Click += (s, e) => { ShowPage(LauncherPageType.Login); };
return GetControlInFrameView(uninstallFailed);
case LauncherPageType.UninstallSuccessful:
var uninstallSuccessful = new InfoFrame();
uninstallSuccessful.Title = "Deinstallation erfolgreich!";
uninstallSuccessful.Text = "Kehre zum Login zurück...";
uninstallSuccessful.CollapseCopyButton();
uninstallSuccessful.Button1Click += (s, e) => { ShowPage(LauncherPageType.Login); };
return GetControlInFrameView(uninstallSuccessful);
case LauncherPageType.LoadingScreen:
var loading = new LoadingScreen();
loading.Loaded += (s, e) =>
{
Task.Run(() => ProcessController.StartPlanerProcess());
};
return GetControlInFrameView(loading);
case LauncherPageType.NoPermissionInfo:
var noper = new InfoFrame();
noper.Title = "Keine Rechte auf Speicherort!";
noper.Text = "Es liegt eine neue Version. Sie besitzen aber nicht die benötigten Rechte, um diese anzuwenden. Bitte wenden Sie sich an Ihren System-Administrator!";
noper.Button1Click += (s, e) => { ShowPage(LauncherPageType.Login); };
return GetControlInFrameView(noper);
}
throw new NotImplementedException();
}
private static UserControl GetControlInFrameView(UserControl uc)
{
if (CurrentView is FrameView)
return uc;
var frame = uc as FrameBase;
if (frame is null)
{
throw new NotImplementedException("uc ist kein Frame");
}
var view = new FrameView();
view.SetFrame(frame);
return view;
}
private static void ShowPage(LauncherPageType type)
{
var page = GetNewPage(type);
if (page is LoginView login)
{
CurrentView = login;
}
else if (page is FrameView frameview)
{
CurrentView = frameview;
}
else if(page is FrameBase frame)
{
CurrentFrame = frame;
}
else
{
throw new NotImplementedException("Page Error 1063");
}
}
}
}

View File

@@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace BeWoLauncher.Utils
{
public static class BeWoHelper
{
}
}

View File

@@ -18,17 +18,16 @@ using System.Threading.Tasks;
using System.Windows;
using System.Xml.Serialization;
namespace BeWoLauncher.Utils.Download
namespace BeWoLauncher.Logic.Utils.Download
{
public class DownloadManager
{
public DownloadPlanerRequestDC Request { get; set; }
public DownloadPlanerResponseInfoDC ResponseInfo { get; set; }
public DownloadPlanerResponseDC Response { get; set; }
public string DownloadZipPath { get; set; }
public string DownloadFolder => BeWoPaths.GetDownloadPath();
public string ApplyFolder => BeWoPaths.GetApplyPath();
public string DownloadFolder => LauncherPaths.GetDownloadPath();
public string ApplyFolder => LauncherPaths.GetApplyPath();
public DownloadManager()
{
@@ -45,47 +44,6 @@ namespace BeWoLauncher.Utils.Download
ConnectionInformation.Version = ResponseInfo.Version;
}
private void CreateDownloadRequest()
{
Request = new DownloadPlanerRequestDC();
if (Request.PlanerRootFolderExists = BeWoPaths.ActualPlanerLocation.Exists())
{
if (Request.DownloadFolderExists = DownloadFolder.Exists())
if (!(Request.DownloadFolderIsEmpty = DownloadFolder.IsFolderEmpty()))
Request.DownloadedPackages = FileController.LoadInfos(DownloadFolder);
if (Request.ApplyFolderExists = ApplyFolder.Exists())
if (!(Request.ApplyFolderIsEmpty = ApplyFolder.IsFolderEmpty()))
{
var files = FileController.GetPlanerFiles(ApplyFolder);
if (files is object)
files.ForEach(file => file.LoadHash());
FileController.TryGetPackageInfo(ApplyFolder, out var package);
if (package == null)
package = new PlanerPackageInfoDC();
package.Files = files.ToPlanerFileInfoDCList();
Request.ApplyPackage = package;
}
}
}
private void GetDownloadResponse()
{
Response = LauncherServiceFacade.DoDownloadBeWoServiceSync(x => x.Download2(Request));
}
private void GetDownloadResponseInfo()
{
ResponseInfo = LauncherServiceFacade.DoDownloadBeWoServiceSync(x => x.DownloadInfo(Request));
}
public void StartDownload(bool skipLock)
{
GetDownloadResponse();
@@ -103,18 +61,17 @@ namespace BeWoLauncher.Utils.Download
DownloadFolder.Lock(skipLock);
DownloadZipPath = FileController.GetNewZipPath(BeWoPaths.GetDownloadPath());
LauncherPaths.CurrentDownloadZipLocation = FileController.GetNewZipPath(LauncherPaths.GetDownloadPath());
FileController.SaveDZip(DownloadZipPath, Response.NewZipData);
FileController.SaveInfo(DownloadZipPath, Response.NewZipInfo);
FileController.SaveInfo(BeWoPaths.GetRootPath().Combine("latest"), Response.LatestApplicationInfo);
FileController.SaveDZip(LauncherPaths.CurrentDownloadZipLocation, Response.NewZipData);
FileController.SaveInfo(LauncherPaths.CurrentDownloadZipLocation, Response.NewZipInfo);
FileController.SaveInfo(LauncherPaths.GetRootPath().Combine("latest"), Response.LatestApplicationInfo);
Response.NewZipData = null;
DownloadFolder.Unlock();
}
}
public void StartApply(bool skiplock, Action<int, object> apply)
{
ApplyFolder.CreateFolder();
@@ -128,7 +85,7 @@ namespace BeWoLauncher.Utils.Download
if (Response.HasToDoNewZip())
{
FileController.ApplyDZip(DownloadZipPath, ApplyFolder, apply);
FileController.ApplyDZip(LauncherPaths.CurrentDownloadZipLocation, ApplyFolder, apply);
}
if (Response.HasToRemoveFiles)
@@ -148,7 +105,6 @@ namespace BeWoLauncher.Utils.Download
Thread.Sleep(1000);
}
public void StartUninstall(Action<int, object> apply)
{
apply(3, null);
@@ -160,7 +116,45 @@ namespace BeWoLauncher.Utils.Download
Files = new List<PlanerFileInfoDC>()
};
FileController.RemoveUnsuedFiles(t, BeWoPaths.ActualPlanerLocation, apply);
FileController.RemoveUnsuedFiles(t, LauncherPaths.ActualPlanerLocation, apply);
}
private void CreateDownloadRequest()
{
Request = new DownloadPlanerRequestDC();
if (Request.PlanerRootFolderExists = LauncherPaths.ActualPlanerLocation.Exists())
{
if (Request.DownloadFolderExists = DownloadFolder.Exists())
if (!(Request.DownloadFolderIsEmpty = DownloadFolder.IsFolderEmpty()))
Request.DownloadedPackages = FileController.LoadInfos(DownloadFolder);
if (Request.ApplyFolderExists = ApplyFolder.Exists())
if (!(Request.ApplyFolderIsEmpty = ApplyFolder.IsFolderEmpty()))
{
var files = FileController.GetPlanerFiles(ApplyFolder);
if (files is object)
files.ForEach(file => file.LoadHash());
FileController.TryGetPackageInfo(ApplyFolder, out var package);
if (package == null)
package = new PlanerPackageInfoDC();
package.Files = files.ToPlanerFileInfoDCList();
Request.ApplyPackage = package;
}
}
}
private void GetDownloadResponse()
{
Response = LauncherServiceFacade.DoDownloadBeWoServiceSync(x => x.Download2(Request));
}
private void GetDownloadResponseInfo()
{
ResponseInfo = LauncherServiceFacade.DoDownloadBeWoServiceSync(x => x.DownloadInfo(Request));
}
}
}

View File

@@ -4,9 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeWoLauncher.Utils
namespace BeWoLauncher.Logic.Utils
{
public static class BeWoLocalConfig
public static class LauncherAppdataConfig
{
public static string GetInstallLocation()
{

View File

@@ -8,9 +8,9 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace BeWoLauncher.Utils
namespace BeWoLauncher.Logic.Utils
{
public static class BeWoPaths
public static class LauncherPaths
{
private static readonly string planerExeName = "BeWoPlaner.exe";
@@ -19,6 +19,8 @@ namespace BeWoLauncher.Utils
public static string LoginSelectionPlanerLocation { get; set; }
public static string ActualPlanerLocation { get; set; }
public static string CurrentDownloadZipLocation { get; set; }
/// <summary>
/// Holt den Install Ort aus den Properties Settings.
/// Sollte dieser nicht verfügbar sein, wird als default - "CurrentBaseDir"/BeWoPlaner - verwendet
@@ -38,7 +40,7 @@ namespace BeWoLauncher.Utils
public static string GetInstallLocationFromSetting()
{
return BeWoLocalConfig.GetInstallLocation();
return LauncherAppdataConfig.GetInstallLocation();
}
/// <summary>
@@ -71,14 +73,14 @@ namespace BeWoLauncher.Utils
{
ActualPlanerLocation = path;
BeWoLocalConfig.SetInstallLocation(path);
LauncherAppdataConfig.SetInstallLocation(path);
}
public static string GetRootPath()
{
return ActualPlanerLocation;
}
public static string GetDownloadPath()
{
return Path.Combine(new string[] { GetRootPath(), "download" });
@@ -92,7 +94,6 @@ namespace BeWoLauncher.Utils
{
return Path.Combine(GetApplyPath(), GetPlanerExeName());
}
public static string GetApplyPackagePath()
{
return Path.Combine(GetApplyPath(), BeWoPathFileConfig.LatestBeWoInfo);

View File

@@ -10,7 +10,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
namespace BeWoLauncher
namespace BeWoLauncher.Logic.Utils
{
public static class LauncherUtils
{

View File

@@ -0,0 +1,200 @@
using BeWoLauncher.Logic.Behavior;
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.View;
using BeWoLauncher.View.Frames;
using System;
using System.Threading.Tasks;
using System.Windows.Controls;
using static BeWoLauncher.Logic.Controller.ViewController;
namespace BeWoLauncher.Logic
{
public class ViewBuilder
{
public ViewBuilder()
{
}
public UserControl GetNewView(ViewType type)
{
switch (type)
{
case ViewType.LoginView:
return getLoginView();
}
throw new NotImplementedException("ViewBuilder: View nicht implementiert");
}
public FrameBase GetNewFrame(FrameType type)
{
switch (type)
{
case FrameType.InstallInfo:
return getInstallInfoFrame();
case FrameType.InstallProgress:
return getInstallProgressFrame();
case FrameType.InstallFailed:
return getInstallFailedFrame();
case FrameType.UpdateInfo:
return getUpdateInfoFrame();
case FrameType.UpdateProgress:
return getUpdateProgressFrame();
case FrameType.UpdateFailed:
return getUpdateFailedFrame();
case FrameType.UninstallInfo:
return getUninstallInfoFrame();
case FrameType.UninstallProgress:
return getUninstallProgressFrame();
case FrameType.UninstallFailed:
return getUninstallFailedFrame();
case FrameType.UninstallSuccessful:
return getUninstallSuccessfulFrame();
case FrameType.LoadingScreen:
return getLoadingScreenFrame();
case FrameType.NoPermissionInfo:
return getNoPermissionInfoFrame();
}
throw new NotImplementedException("ViewBuilder: Frame nicht implementiert");
}
private UserControl getLoginView()
{
var login = new LoginView();
login.Loaded += CheckForAutoLogin;
login.LoginSuccessful += ViewBehavior.LoginSuccessful;
return login;
}
private FrameBase getNoPermissionInfoFrame()
{
var noper = new InfoFrame();
noper.Title = "Keine Rechte auf Speicherort!";
noper.Text = "Es liegt eine neue Version. Sie besitzen aber nicht die benötigten Rechte, um diese anzuwenden. Bitte wenden Sie sich an Ihren System-Administrator!";
noper.Button1Click += ViewBehavior.BackToLogin;
return noper;
}
private FrameBase getLoadingScreenFrame()
{
var loading = new LoadingScreen();
loading.Loaded += (s,e)=> ViewController.LaunchBehavior.LaunchPlaner();
return loading;
}
private FrameBase getUninstallSuccessfulFrame()
{
var uninstallSuccessful = new InfoFrame();
uninstallSuccessful.Title = "Deinstallation erfolgreich!";
uninstallSuccessful.Text = "Kehre zum Login zurück...";
uninstallSuccessful.CollapseCopyButton();
uninstallSuccessful.Button1Click += ViewBehavior.BackToLogin;
return uninstallSuccessful;
}
private FrameBase getUninstallFailedFrame()
{
var uninstallFailed = new InfoFrame();
uninstallFailed.Title = "Deinstallation fehlgeschlagen!";
uninstallFailed.Text = Error.ToString();
uninstallFailed.Button1Click += ViewBehavior.BackToLogin;
return uninstallFailed;
}
private FrameBase getUninstallProgressFrame()
{
var uninstallProgress = new UninstallProgressInfoFrame();
uninstallProgress.UninstallSuccessful += ViewBehavior.UninstallSuccess;
return uninstallProgress;
}
private FrameBase getUninstallInfoFrame()
{
var uninstall = new UninstallInfoFrame();
uninstall.Accept += ViewBehavior.UpdateStarting;
uninstall.Abort += ViewBehavior.BackToLogin;
return uninstall;
}
private FrameBase getUpdateFailedFrame()
{
var updateError = new InfoFrame();
updateError.Title = "Update fehlgeschlagen!";
updateError.Text = Error.ToString();
updateError.Button1Click += ViewBehavior.BackToLogin;
return updateError;
}
private FrameBase getUpdateProgressFrame()
{
var updateProgress = new UpdateProgressInfoFrame();
updateProgress.UpdateSuccessful += ViewBehavior.UpdateSuccess;
return updateProgress;
}
private FrameBase getUpdateInfoFrame()
{
var update = new UpdateInfoFrame();
update.Accept += ViewBehavior.UpdateStarting;
update.Abort += ViewBehavior.BackToLogin;
return update;
}
private FrameBase getInstallFailedFrame()
{
var installError = new InfoFrame();
installError.Title = "Installation fehlgeschlagen!";
installError.Text = Error.ToString();
installError.Button1Click += ViewBehavior.BackToLogin;
return installError;
}
private FrameBase getInstallProgressFrame()
{
var installprogress = new InstallProgressInfoFrame();
installprogress.InstallSuccessful += ViewBehavior.InstallSuccesss;
return installprogress;
}
private FrameBase getInstallInfoFrame()
{
var install = new InstallInfoFrame();
install.Accept += ViewBehavior.InstallInfoAccept;
install.Abort += ViewBehavior.BackToLogin;
return install;
}
}
}

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeWoLauncher.Logic
namespace BeWoLauncher.Models
{
public class ConnectionProfile
{

View File

@@ -1,4 +1,5 @@
using BeWoLauncher.Logic;
using BeWoLauncher.Models;
using BS.SharedLauncher;
using System.Collections.Generic;
using System.Collections.ObjectModel;

View File

@@ -1,4 +1,5 @@
using System;
using BeWoLauncher.Logic.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

View File

@@ -38,7 +38,7 @@ namespace BeWoLauncher.View
lblVersion.Content = LauncherApp.Version;
}
public FrameView(FrameBase frame)
public FrameView(FrameBase frame) : this()
{
SetFrame(frame);
}
@@ -62,26 +62,5 @@ namespace BeWoLauncher.View
{
contentGrid.Children.Clear();
}
// Zum Debuggen
//int i = 0;
//private void Button_Click(object sender, RoutedEventArgs e)
//{
// switch (i)
// {
// case 0:
// //ViewController.ShowPage(ViewController.LauncherPageType.UpdateInfo1);
// break;
// case 1:
// //ViewController.ShowPage(ViewController.LauncherPageType.UpdateInfo2);
// break;
// case 2:
// //ViewController.ShowPage(ViewController.LauncherPageType.UpdateInfo3);
// break;
// }
// i++;
//}
}
}

View File

@@ -1,34 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Deployment.Application;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BeWoLauncher.Logic;
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.ServiceProxy;
using BeWoLauncher.Utils;
using BeWoLauncher.Utils.Download;
using BS.SharedLauncher;
using BS.SharedLauncher.DataContract;
using BS.SharedLauncher.Information;
using BS.SharedLauncher.Update;
using Path = System.IO.Path;
namespace BeWoLauncher.View.Frames
{
@@ -82,7 +56,7 @@ namespace BeWoLauncher.View.Frames
public void Bar2SetLimit(int max) => proBar2.Maximum = max;
public void Bar2MakeStep(int step)
{
if(step > lastStep)
if (step > lastStep)
{
lastStep = step;
proBar2.Value++;
@@ -91,7 +65,7 @@ namespace BeWoLauncher.View.Frames
public void Bar2Fill() => proBar2.Value = proBar2.Maximum;
public void Bar2Hide() => proBar2.Visibility = Visibility.Collapsed;
public void Bar2Show() => proBar2.Visibility = Visibility.Visible;
public void Bar2SetPercent(double percentage)
{
DoubleAnimation animation = new DoubleAnimation(percentage, duration);

View File

@@ -46,10 +46,10 @@
<Label Grid.Column="2" Grid.Row="3" Margin="0,-5,0,0" x:Name="lblVerfuegbar" HorizontalAlignment="Right">20.0t</Label>
<Label Grid.Column="3" Grid.Row="3" Margin="0,-5,0,0" x:Name="lblVerfuegbarSize" HorizontalAlignment="Left">GB</Label>
<Label Grid.Column="0" Grid.Row="5">Nicht vorhandene Datei(en):</Label>
<Label Grid.Column="0" Grid.Row="5" x:Name="lblcountnewtxt">Nicht vorhandene Datei(en):</Label>
<Label Grid.Column="2" Grid.Row="5" x:Name="lblcountnew" HorizontalAlignment="Right">80</Label>
<Label Grid.Column="0" Grid.Row="6" Margin="0,-5,0,0">Bereits vorhandene Datei(en):</Label>
<Label Grid.Column="0" Grid.Row="6" Margin="0,-5,0,0" x:Name="lblcountalreadytxt" >Bereits vorhandene Datei(en):</Label>
<Label Grid.Column="2" Grid.Row="6" Margin="0,-5,0,0" x:Name="lblcountalready" HorizontalAlignment="Right">80</Label>
</Grid>

View File

@@ -1,24 +1,10 @@
using BeWoLauncher.Logic;
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.Utils;
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.Logic.Utils;
using BS.SharedLauncher.Information;
using BS.SharedLauncher.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Path = System.IO.Path;
namespace BeWoLauncher.View.Frames
@@ -35,7 +21,7 @@ namespace BeWoLauncher.View.Frames
{
InitializeComponent();
InstallLocation = BeWoPaths.GetInstallLocationFromSettingOrDefault();
InstallLocation = LauncherPaths.GetInstallLocationFromSettingOrDefault();
var size = NonspecificTools.SizeSuffix((ulong)DownloadController.Manager.ResponseInfo.DownloadSize).Split(' ');
@@ -46,24 +32,29 @@ namespace BeWoLauncher.View.Frames
lblcountalready.Content = $"{DownloadController.Manager.ResponseInfo.FileCount - DownloadController.Manager.ResponseInfo.NewFileCount}";
lblversion.Content = DownloadController.Manager.ResponseInfo.Version;
lblcountalready.Visibility = Visibility.Hidden;
lblcountalreadytxt.Visibility = Visibility.Hidden;
lblcountnew.Visibility = Visibility.Hidden;
lblcountnewtxt.Visibility = Visibility.Hidden;
}
public string InstallLocation
{
get
{
return BeWoPaths.LoginSelectionPlanerLocation;
return LauncherPaths.LoginSelectionPlanerLocation;
}
set
{
if (!endPathWithSubDir(value))
value = Path.Combine(value, BeWoPathFileConfig.SubDirectory);
if (BeWoPaths.ChangePath(value))
if (LauncherPaths.ChangePath(value))
{
txtLoc.Text = value;
var size2 = DownloadController.UpdateDiskSpace(BeWoPaths.ActualPlanerLocation).Split(' ');
var size2 = DownloadController.UpdateDiskSpace(LauncherPaths.ActualPlanerLocation).Split(' ');
if (size2.Length > 1)
{

View File

@@ -1,29 +1,23 @@
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.Utils;
using BeWoLauncher.Utils.Download;
using BS.SharedLauncher.Logic;
using BeWoLauncher.Logic.Utils.Download;
using BS.SharedLauncher.Update;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace BeWoLauncher.View.Frames
{
public class InstallProgressInfoFrame : GenericProgressInfo
{
public event EventHandler InstallSuccessful;
public DownloadManager Manager => DownloadController.Manager;
public InstallProgressInfoFrame() : base()
{
Bar1SetLimit(Manager.ResponseInfo.FileCount);
Bar1Deactivate();
}
@@ -36,10 +30,10 @@ namespace BeWoLauncher.View.Frames
Worker.RunWorkerCompleted += worker_completed;
Worker.WorkerReportsProgress = true;
Worker.RunWorkerAsync(skipLock);
}
void worker_DoWork(object sender, DoWorkEventArgs e)
{
bool skipLock = (bool)e.Argument;
@@ -65,9 +59,9 @@ namespace BeWoLauncher.View.Frames
private void worker_completed(object sender, RunWorkerCompletedEventArgs e)
{
if(e.Error != null)
if (e.Error != null)
{
ViewController.InstallationFailed(e.Error);
ViewController.ViewBehavior.InstallationFailed(e.Error);
}
else
{

View File

@@ -42,7 +42,7 @@ namespace BeWoLauncher.View.Frames
{
if (e.Error != null)
{
ViewController.UninstallFailed(e.Error);
ViewController.ViewBehavior.UninstallFailed(e.Error);
}
else
{

View File

@@ -32,6 +32,9 @@
<RowDefinition Height="3"/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0">Version:</Label>
@@ -45,11 +48,13 @@
<Label Grid.Column="2" Grid.Row="3" Margin="0,-5,0,0" x:Name="lblVerfuegbar" HorizontalAlignment="Right">20.0t</Label>
<Label Grid.Column="3" Grid.Row="3" Margin="0,-5,0,0" x:Name="lblVerfuegbarSize" HorizontalAlignment="Left">GB</Label>
<Label Grid.Column="0" Grid.Row="5">Nicht vorhandene Datei(en):</Label>
<Label Grid.Column="2" Grid.Row="5" x:Name="lblcountnew" HorizontalAlignment="Right">80</Label>
<Label Grid.Column="0" Grid.Row="7" x:Name="lblcountnewtxt">Nicht vorhandene Datei(en):</Label>
<Label Grid.Column="2" Grid.Row="7" x:Name="lblcountnew" HorizontalAlignment="Right">80</Label>
<Label Grid.Column="0" Grid.Row="6" Margin="0,-5,0,0">Bereits vorhandene Datei(en):</Label>
<Label Grid.Column="2" Grid.Row="6" Margin="0,-5,0,0" x:Name="lblcountalready" HorizontalAlignment="Right">80</Label>
<Label Grid.Column="0" Grid.Row="8" Margin="0,-5,0,0" x:Name="lblcountalreadytxt">Bereits vorhandene Datei(en):</Label>
<Label Grid.Column="2" Grid.Row="8" Margin="0,-5,0,0" x:Name="lblcountalready" HorizontalAlignment="Right">80</Label>
<Label Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="9" Margin="0,3,0,0" x:Name="lblfound" HorizontalAlignment="Left">Bereits heruntergeladene Dateien gefunden</Label>
</Grid>
<StackPanel DockPanel.Dock="Bottom" VerticalAlignment="Bottom" HorizontalAlignment="Center" Orientation="Horizontal" Margin="0,10,0,0">

View File

@@ -1,5 +1,5 @@
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.Utils;
using BeWoLauncher.Logic.Utils;
using BS.SharedLauncher.Utils;
using System;
using System.Collections.Generic;
@@ -31,14 +31,14 @@ namespace BeWoLauncher.View.Frames
{
InitializeComponent();
BeWoPaths.ActualPlanerLocation = BeWoPaths.GetInstallLocationFromSetting();
LauncherPaths.ActualPlanerLocation = LauncherPaths.GetInstallLocationFromSetting();
var size = NonspecificTools.SizeSuffix((ulong)DownloadController.Manager.ResponseInfo.DownloadSize).Split(' ');
lblErforderlich.Content = size[0];
lblErforderlichSize.Content = size[1];
var size2 = DownloadController.UpdateDiskSpace(BeWoPaths.ActualPlanerLocation).Split(' ');
var size2 = DownloadController.UpdateDiskSpace(LauncherPaths.ActualPlanerLocation).Split(' ');
if(size2.Length > 1)
{
@@ -51,10 +51,21 @@ namespace BeWoLauncher.View.Frames
lblVerfuegbarSize.Content = string.Empty;
}
lblcountnew.Content = $"{DownloadController.Manager.ResponseInfo.NewFileCount}";
lblcountalready.Content = $"{DownloadController.Manager.ResponseInfo.FileCount - DownloadController.Manager.ResponseInfo.NewFileCount}";
var total = DownloadController.Manager.ResponseInfo.FileCount;
var download = DownloadController.Manager.ResponseInfo.NewFileCount;
var already = total - download;
lblcountnew.Content = $"{download}";
lblcountalready.Content = $"{already}";
lblversion.Content = DownloadController.Manager.ResponseInfo.Version;
lblcountalready.Visibility = Visibility.Hidden;
lblcountalreadytxt.Visibility = Visibility.Hidden;
lblcountnew.Visibility = Visibility.Hidden;
lblcountnewtxt.Visibility = Visibility.Hidden;
lblfound.Visibility = already == 0 ? Visibility.Hidden : Visibility.Visible;
}
private void Button_Click(object sender, RoutedEventArgs e)

View File

@@ -1,16 +1,10 @@
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.Utils;
using BeWoLauncher.Utils.Download;
using BS.SharedLauncher.Logic;
using BeWoLauncher.Logic.Utils.Download;
using BS.SharedLauncher.Update;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace BeWoLauncher.View.Frames
{
@@ -67,7 +61,7 @@ namespace BeWoLauncher.View.Frames
{
if (e.Error != null)
{
ViewController.UpdateFailed(e.Error);
ViewController.ViewBehavior.UpdateFailed(e.Error);
}
else
{

View File

@@ -1,11 +1,9 @@
using BeWoLauncher;
using BeWoLauncher.Components;
using BeWoLauncher.Logic;
using BeWoLauncher.Components;
using BeWoLauncher.Logic.Controller;
using BeWoLauncher.Logic.Utils;
using BeWoLauncher.Models;
using BeWoLauncher.ServiceProxy;
using BeWoLauncher.WindowImp;
using BS.SharedLauncher;
using BS.SharedLauncher.Enums;
using BS.SharedLauncher.Information;
@@ -14,23 +12,18 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Deployment.Application;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Threading;
@@ -50,9 +43,6 @@ namespace BeWoLauncher.View
private string _ProfilesFilePath;
private string _ConfigFilePath;
private string _Proxyname;
private string _ProxyUsername;
private string _Proxypasswd;
private bool isNet45OrNewer = false;
private bool pwvViewOffen;
@@ -65,11 +55,11 @@ namespace BeWoLauncher.View
private string GETSERVER_URL = "https://support.bewoplaner.de/api/getserver.php?k={0}&t=1";
private string GETSTATUSMESSAGE_URL = "https://support.bewoplaner.de/api/getstate.php?k={0}&t=1&v={1}";
private string GETNETMESSAGE_URL = "https://support.bewoplaner.de/api/getxmlstate.php?k={0}&t=1";
public LoginView()
{
InitializeComponent();
_ModalPopUpControls = new Stack<Control>();
DoTooMuchInitStuffIDontHaveANameForThisMethod();
@@ -116,22 +106,22 @@ namespace BeWoLauncher.View
private void button_login_Click(object sender, RoutedEventArgs e)
{
if (!String.IsNullOrEmpty(_Proxyname))
if (!String.IsNullOrEmpty(ConnectionInformation.ProxyName))
{
var webProxy = WebProxy.GetDefaultProxy();
webProxy.UseDefaultCredentials = true;
System.Net.WebRequest.DefaultWebProxy = new WebProxy(_Proxyname, true);
System.Net.WebRequest.DefaultWebProxy = new WebProxy(ConnectionInformation.ProxyName, true);
if (String.IsNullOrEmpty(_ProxyUsername))
if (String.IsNullOrEmpty(ConnectionInformation.ProxyUsername))
{
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
}
else
{
WebRequest.DefaultWebProxy.Credentials = new NetworkCredential(_ProxyUsername, _Proxypasswd);
WebRequest.DefaultWebProxy.Credentials = new NetworkCredential(ConnectionInformation.ProxyUsername, ConnectionInformation.ProxyPassword);
}
}
if (ProfileList.Count == 0 || profileSelectionComboBox.SelectedItem == null)
{
MessageBox.Show(
@@ -158,7 +148,7 @@ namespace BeWoLauncher.View
return;
}
#else
if (!CheckStatusMessage(profile, String.Format(GETSTATUSMESSAGE_URL, profile.Tenant, MainSession.Version)))
if (!CheckStatusMessage(profile, String.Format(GETSTATUSMESSAGE_URL, profile.Tenant, LauncherApp.ShortVersion)))
{
return;
}
@@ -195,18 +185,18 @@ namespace BeWoLauncher.View
}
private void PasswordBox_Password_OnGotFocus(object sender, RoutedEventArgs e)
{
PasswordBox_Password.SelectAll();
PasswordBox_Password.SelectAll();
}
private void button_addProfile_Click(object sender, RoutedEventArgs rea)
{
var newProfileList = new ObservableCollection<ConnectionProfile>(ProfileList);
try
{
Mouse.OverrideCursor = Cursors.Wait;
var p = new ProfileEditView() { Profiles = newProfileList };
profileEditPopUp.Child = p;
if (p.CommandBindings.Count != 0)
@@ -249,7 +239,7 @@ namespace BeWoLauncher.View
proxyLogin.ShowDialog();
ReadProxyName();
}
private void PasswortVergessenLinkOnRequestNavigate(object sender, RequestNavigateEventArgs e)
{
if (pwvViewOffen) return;
@@ -318,7 +308,7 @@ namespace BeWoLauncher.View
TextBox_Username.Focus();
}
}
public void DoTooMuchInitStuffIDontHaveANameForThisMethod()
{
ConnectionProfile selectedProfile = null;
@@ -371,10 +361,10 @@ namespace BeWoLauncher.View
{
//Start über IE
//MessageBox.Show(String.Format("Start über IE.\nActivationUri: {0}\nUpdateLocation: {1}", ApplicationDeployment.CurrentDeployment.ActivationUri, ApplicationDeployment.CurrentDeployment.UpdateLocation));
BeWoLaProfile p = GenerateProfileFromUri(ApplicationDeployment.CurrentDeployment.ActivationUri);
ConnectionProfile p = GenerateProfileFromUri(ApplicationDeployment.CurrentDeployment.ActivationUri);
if (!String.IsNullOrEmpty(p.Tenant) && !String.IsNullOrEmpty(p.Server))
{
LauncherApp.Tenant = p.Tenant;
ConnectionInformation.Tenant = p.Tenant;
if (ProfileList.Count > 0)
{
@@ -461,22 +451,94 @@ namespace BeWoLauncher.View
ChangeServerAndTenant(profileSelectionComboBox.SelectedItem as ConnectionProfile);
if (!String.IsNullOrEmpty(_Proxyname))
if (!String.IsNullOrEmpty(ConnectionInformation.ProxyName))
{
var webProxy = WebProxy.GetDefaultProxy();
webProxy.UseDefaultCredentials = true;
System.Net.WebRequest.DefaultWebProxy = new WebProxy(_Proxyname, true);
System.Net.WebRequest.DefaultWebProxy = new WebProxy(ConnectionInformation.ProxyName, true);
if (String.IsNullOrEmpty(_ProxyUsername))
if (String.IsNullOrEmpty(ConnectionInformation.ProxyUsername))
{
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
}
else
{
WebRequest.DefaultWebProxy.Credentials = new NetworkCredential(_ProxyUsername, _Proxypasswd);
WebRequest.DefaultWebProxy.Credentials = new NetworkCredential(ConnectionInformation.ProxyUsername, ConnectionInformation.ProxyPassword);
}
}
}
private ConnectionProfile ReadSelectedProfile()
{
try
{
if (File.Exists(_ConfigFilePath))
{
using (var myFile = new StreamReader(_ConfigFilePath, Encoding.Default))
{
while (!myFile.EndOfStream)
{
var data = myFile.ReadLine();
if (!String.IsNullOrEmpty(data))
{
if (data.Contains("selected"))
{
var pos = data.IndexOf("=");
if (pos > 0)
{
var pData = data.Substring(pos + 1).Trim().Split('|');
if (pData.Length >= 3)
{
if (!String.IsNullOrEmpty(pData[1]) && !String.IsNullOrEmpty(pData[2]))
return new ConnectionProfile(pData[0], pData[1], pData[2]);
}
}
}
}
}
}
}
}
catch (Exception e)
{
}
return null;
}
private ConnectionProfile GenerateProfileFromUri(Uri uri)
{
var paramDic = LauncherUtils.ParseQuery(uri.Query);
string v1, v2;
paramDic.TryGetValue("k", out v1);
paramDic.TryGetValue("s", out v2);
//if (String.IsNullOrEmpty(v1))
//{
// v1 = "demo";
//}
//if (String.IsNullOrEmpty(v2))
//{
// v2 = "Ungültiger Server";
// String uriStr = uri.ToString();
// if (!String.IsNullOrEmpty(uriStr))
// {
// v2 = uriStr;
// if (uriStr.IndexOf("://") >= 0)
// v2 = uriStr.Substring(uriStr.IndexOf("://") + 3);
// if (v2.ToLower().IndexOf("/bewo.application") > 0)
// v2 = v2.Substring(0, v2.ToLower().IndexOf("/bewo.application"));
// }
//}
return new ConnectionProfile(v1, v2, v1);
}
private void PinCertificate()
{
ServicePointManager.ServerCertificateValidationCallback = PinPublicKey;
@@ -575,7 +637,7 @@ namespace BeWoLauncher.View
private string GetAdminUrl()
{
String address = String.Empty;
#if DEBUG
if (true)
{
@@ -639,11 +701,11 @@ namespace BeWoLauncher.View
file.Close();
_Proxyname = datai[0];
_ProxyUsername = datai[1];
_Proxypasswd = datai[2];
ConnectionInformation.ProxyName = datai[0];
ConnectionInformation.ProxyUsername = datai[1];
ConnectionInformation.ProxyPassword = datai[2];
proxyTextBox.Text = _Proxyname;
proxyTextBox.Text = ConnectionInformation.ProxyName;
}
catch (IOException)
@@ -783,7 +845,7 @@ namespace BeWoLauncher.View
ConnectionInformation.Tenant = profile.Tenant;
ConnectionInformation.ServerName = GetNumericServerName(profile.Server);
ConnectionInformation.LauncherServerAddress = profile.Server;
#if DEBUG
//CB ZUM TESTEN
//ConnectionInformation.Tenant = "9876543210";
@@ -1128,9 +1190,10 @@ namespace BeWoLauncher.View
}
else if (result == UserValidationResult.PasswordExpired)
{
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate {
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate
{
PopUpWindow window = null;
PasswortAenderungsView view = new PasswortAenderungsView(window);
PasswortAenderungsView view = new PasswortAenderungsView(window);
window = new PopUpWindow(view);
window.ShowDialog();

View File

@@ -93,9 +93,10 @@
</service>
</services>
</system.serviceModel>
<appSettings>
<add key="UpdateRootPath" value="d:\Projects\BeWoPlaner\BeWo\BeWo\bin\Debug" />
<add key="DownloadFolderPath" value="D:\Rene\ServerBeWoDataExample2" />
<add key="DownloadVersionFilePath" value="D:\Rene\ServerBeWoDataExample2\version\update.config" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

View File

@@ -169,121 +169,6 @@ namespace BeWo.Service.ServiceImplementations
}
//public BeWoProgramPackageDC Update(BeWoProgramPackageDC current)
//{
// try
// {
// DirectoryInfo dirUpdateRoot = new DirectoryInfo(ConfigurationManager.AppSettings.Get("UpdateRootPath"));
// var newest = GetNewestVersionSet(dirUpdateRoot, MultitenancyOperationContextExt.Current.Tenant);
// var res = CreateUpdatePackage(current, newest);
// res.toLoad = "BeWoPlaner.dll";
// return res;
// }
// catch (Exception e)
// {
// throw Core.Utils.CreateBeWoFaultException(e);
// }
//}
//private BeWoProgramPackageDC GetNewestVersionSet(DirectoryInfo dirUpdateRoot, string tenant)
//{
// var res = new BeWoProgramPackageDC();
// var dirTenant = dirUpdateRoot.GetDirectories().FirstOrDefault(dict => dict.Name == tenant);
// var filesRoot = dirUpdateRoot.GetFiles().Select(file => new BeWoProgramFileDC(file));
// if (dirUpdateRoot is null)
// throw new Exception("Couldn't find update root path for launcher updates");
// res.Files.AddRange(filesRoot);
// if (dirTenant is null)
// return res;
// foreach (var newFile in dirTenant.GetFiles().Select(file => new BeWoProgramFileDC(file)))
// {
// var search = res.Files.FirstOrDefault(x => x.FileName == newFile.FileName);
// if (search is null)
// {
// res.Files.Add(newFile);
// }
// else
// {
// res.Files.Remove(search);
// res.Files.Add(newFile);
// }
// }
// return res;
//}
//private BeWoProgramPackageDC CreateUpdatePackage(BeWoProgramPackageDC oldSet, BeWoProgramPackageDC newSet)
//{
// var res = new BeWoProgramPackageDC();
// if (!(oldSet is null))
// res.Files.AddRange(oldSet.Files);
// foreach (var newFile in newSet.Files)
// {
// var oldFile = res.Files.FirstOrDefault(x => x.FileName == newFile.FileName);
// if (oldFile is null)
// {
// newFile.FileData = File.ReadAllBytes(newFile.FullPath);
// newFile.ToDo = FileToDo.Add;
// res.Files.Add(newFile);
// }
// else
// {
// if (oldFile.FileVersion is null || newFile.FileVersion is null)
// {
// oldFile.FileVersion = newFile.FileVersion;
// oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
// oldFile.ToDo = FileToDo.Update;
// }
// else
// {
// if (oldFile.FileVersion == newFile.FileVersion)
// {
// if (oldFile.Checksum != newFile.Checksum)
// {
// oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
// oldFile.ToDo = FileToDo.Update;
// }
// else
// {
// oldFile.ToDo = FileToDo.Nuthing;
// }
// }
// else
// {
// oldFile.FileVersion = newFile.FileVersion;
// oldFile.FileData = File.ReadAllBytes(newFile.FullPath);
// oldFile.ToDo = FileToDo.Update;
// }
// }
// }
// }
// foreach (var oldFile in oldSet.Files)
// {
// var newFile = newSet.Files.FirstOrDefault(x => x.FileName == oldFile.FileName);
// if (newFile is default(BeWoProgramFileDC))
// {
// oldFile.ToDo = FileToDo.Remove;
// }
// }
// return res;
//}
public BS.SharedLauncher.Enums.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant)
=> UserValidationMapper[(new UserServiceImp()).IsUserValid(pUserName, pPassword, pPIN)];
@@ -295,7 +180,5 @@ namespace BeWo.Service.ServiceImplementations
public bool GetEmailForUserName(string pUserName, Uri serverName, out string email)
=> (new UserServiceImp()).GetEmailForUserName(pUserName, serverName, out email);
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
@@ -26,19 +27,44 @@ namespace BeWo.Service.ServiceUtils.Paths
// L exampleData#5
// L version.config
public static string UpdateRootFolderPath
=> @"d:\Rene\ServerBeWoDataExample2";
//=> ConfigurationManager.AppSettings.Get("UpdateRootPath");
private static string _DownloadVersionFilePath;
private static string _DownloadFolderPath;
public static string GetSpecialTenantFolderPath() => Path.Combine(UpdateRootFolderPath, "overridetenant");
public static string DownloadVersionFilePath
{
get {
if(_DownloadVersionFilePath is null)
_DownloadVersionFilePath = ConfigurationManager.AppSettings.Get("DownloadVersionFilePath");
return _DownloadVersionFilePath;
}
}
public static string DownloadFolderPath
{
get
{
if (_DownloadFolderPath is null)
_DownloadFolderPath = ConfigurationManager.AppSettings.Get("DownloadFolderPath");
return _DownloadFolderPath;
}
}
static ServerFilePaths()
{
}
public static string GetSpecialTenantFolderPath() => Path.Combine(DownloadFolderPath, "overridetenant");
public static string GetOverrideTenantFolderPath(string tenant) => Path.Combine(GetSpecialTenantFolderPath(), tenant);
public static string GetVersionFolderPath() => Path.Combine(UpdateRootFolderPath, "version");
public static string GetVersionFolderPath() => Path.Combine(DownloadFolderPath, "version");
public static string GetVersionFolderPath(string version) => Path.Combine(GetVersionFolderPath(), version);
public static string GetVersionTenantFolderPath(string version, string tenant) => Path.Combine(GetVersionFolderPath(version), tenant);
public static string GetVersionDefaultFolderPath(string version) => GetVersionTenantFolderPath(version, "default");
public static string GetVersionConfigFilePath() => Path.Combine(GetVersionFolderPath(), "update.config");
public static string GetVersionConfigFilePath() => DownloadVersionFilePath;
//ConfigurationManager.AppSettings.Get("UpdateRootPath");
}
}

View File

@@ -116,28 +116,7 @@ namespace BeWo.Service.ServiceUtils.Update
res.HasToRemoveFiles = request.ApplyPackage?.Files?.Any(x => !res.LatestApplicationInfo.Files.Any(y => x.EqualsFile(y))) ?? false;
//bool needToRemove = false;
//foreach (var file in request.ApplyPackage.Files)
//{
// bool found = false;
// foreach (var file2 in res.LatestApplicationInfo.Files)
// {
// if (file.EqualsFile(file2))
// {
// found = true;
// break;
// }
// }
// if(!found)
// {
// needToRemove = true;
// res.HasToRemoveFiles = true;
// break;
// }
//}
return res;
}

View File

@@ -23,6 +23,9 @@ namespace BS.SharedLauncher.DataContract
[DataMember]
public long DownloadSize { get; set; }
[DataMember]
public long TotalSize { get; set; }
[DataMember]
public int FileCount { get; set; }

View File

@@ -12,6 +12,10 @@ namespace BS.SharedLauncher.Information
public string Username { get; set; }
public string Password { get; set; }
public string ProxyName { get; set; }
public string ProxyPassword { get; set; }
public string ProxyUsername { get; set; }
public string IpAddress{ get; set; }
public string LauncherServerAddress { get; set; }
public string Servername { get; set; }
@@ -73,6 +77,23 @@ namespace BS.SharedLauncher.Information
return connection;
}
}
public static string ProxyName
{
get { return Connection.ProxyName; }
set { Connection.ProxyName = value; }
}
public static string ProxyPassword
{
get { return Connection.ProxyPassword; }
set { Connection.ProxyPassword = value; }
}
public static string ProxyUsername
{
get { return Connection.ProxyUsername; }
set { Connection.ProxyUsername = value; }
}
public static string ChatServerAddress
{
@@ -139,8 +160,8 @@ namespace BS.SharedLauncher.Information
String url = Connection.LauncherServerAddress?.ToLower();
#if DEBUG
url = String.Format("http://localhost:3778");
//return new Uri("https://app4.bewoplaner.de/servicesbd");
//url = String.Format("http://localhost:3778");
return new Uri("https://app5.bewoplaner.de/launcher");
//url = String.Format("app1.bewoplaner.de/service");
#endif
@@ -154,9 +175,9 @@ namespace BS.SharedLauncher.Information
url += ".bewoplaner.de";
}
if (url.IndexOf("/servicesbd") < 0)
if (url.IndexOf("/service") < 0)
{
url += "/servicesbd";
url += "/service";
}
return new Uri(string.Format("https://{0}", url));