Client Logger + Rest zum Testen auf app5

This commit is contained in:
2024-05-27 15:28:40 +02:00
parent 3dcfc8cb0e
commit f3855aaebb
14 changed files with 65 additions and 53 deletions

View File

@@ -13,19 +13,18 @@
<basicHttpBinding> <basicHttpBinding>
<binding name="BeWoBasicEndpoint" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text"> <binding name="BeWoBasicEndpoint" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" /> <security mode="Transport" />
<!-- mode="Transport" für echten Server und "None" sonst--> <!-- mode="Transport" für echten Server und "None" sonst-->
</binding> </binding>
<binding name="BeWoBasicEndpointTransport" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text"> <binding name="BeWoBasicEndpointTransport" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" /> <security mode="Transport" />
<!-- mode="Transport" für echten Server und "None" sonst--> <!-- mode="Transport" für echten Server und "None" sonst-->
</binding> </binding>
</basicHttpBinding> </basicHttpBinding>
</bindings> </bindings>
<client> <client>
<endpoint binding="basicHttpBinding" bindingConfiguration="BeWoBasicEndpointTransport" contract="BeWoLauncher.ServiceProxy.ILauncherService" name="LauncherServiceEndpoint" /> <endpoint binding="basicHttpBinding" bindingConfiguration="BeWoBasicEndpointTransport" contract="BeWoLauncher.ServiceProxy.ILauncherService" name="LauncherServiceEndpoint" />
<endpoint binding="basicHttpBinding" bindingConfiguration="BeWoBasicEndpointTransport" contract="BeWoLauncher.ServiceProxy.IEnumTranslationService" name="EnumTranslationEndpoint" />
<endpoint binding="basicHttpBinding" bindingConfiguration="BeWoBasicEndpoint" contract="BeWoLauncher.ServiceProxy.IDownloadBeWoService" name="DownloadBeWoEndpoint" /> <endpoint binding="basicHttpBinding" bindingConfiguration="BeWoBasicEndpoint" contract="BeWoLauncher.ServiceProxy.IDownloadBeWoService" name="DownloadBeWoEndpoint" />
</client> </client>
<behaviors> <behaviors>

View File

@@ -28,7 +28,7 @@ namespace BeWoLauncher.Logic.Behavior
// dlg.ShowDialog(); // dlg.ShowDialog();
//} //}
#else #else
if (ConnectionInformation.Tenant == "demo") if (SessionInformation.Login.Tenant == "demo")
{ {
var dlg = new ConfirmDemoDialog(); var dlg = new ConfirmDemoDialog();
dlg.ShowDialog(); dlg.ShowDialog();
@@ -38,7 +38,7 @@ namespace BeWoLauncher.Logic.Behavior
LauncherPaths.ActualPlanerLocation = LauncherPaths.GetInstallLocationFromSetting(); LauncherPaths.ActualPlanerLocation = LauncherPaths.GetInstallLocationFromSetting();
if (LauncherPaths.ActualPlanerLocation is object && !CheckForPermissions(LauncherPaths.ActualPlanerLocation)) if (!string.IsNullOrWhiteSpace(LauncherPaths.ActualPlanerLocation) && !CheckForPermissions(LauncherPaths.ActualPlanerLocation))
{ {
ViewBehavior.ShowFrame(FrameType.NoPermissionInfo); ViewBehavior.ShowFrame(FrameType.NoPermissionInfo);
EndWaiting(); EndWaiting();
@@ -52,7 +52,7 @@ namespace BeWoLauncher.Logic.Behavior
} }
else else
{ {
Task.Run(() => DownloadController.StartDownload(EndWaiting)); Task.Run(() => DownloadController.GetCurrentUpdateplan(EndWaiting));
} }
} }
} }

View File

@@ -131,6 +131,7 @@ namespace BeWoLauncher.Logic.Behavior
if (CheckForPermissions(install.InstallLocation)) if (CheckForPermissions(install.InstallLocation))
{ {
DownloadController.InitLogger();
LauncherPaths.SetAndSaveInstallLocation(install.InstallLocation); LauncherPaths.SetAndSaveInstallLocation(install.InstallLocation);
LauncherAppdataConfig.SetFirstInstallationSuccess(true); LauncherAppdataConfig.SetFirstInstallationSuccess(true);
ShowFrame(FrameType.InstallProgress); ShowFrame(FrameType.InstallProgress);

View File

@@ -5,6 +5,7 @@ using BS.SharedLauncher.Information;
using BS.SharedLauncher.Utils; using BS.SharedLauncher.Utils;
using System; using System;
using System.IO; using System.IO;
using System.Windows;
namespace BeWoLauncher.Logic.Controller namespace BeWoLauncher.Logic.Controller
{ {
@@ -16,11 +17,16 @@ namespace BeWoLauncher.Logic.Controller
public static long NeededSpace => Manager.UpdatePlanResponse.DownloadSize; public static long NeededSpace => Manager.UpdatePlanResponse.DownloadSize;
static DownloadController() static DownloadController()
{
}
public static void InitLogger()
{ {
GenericTextLogger.Init(LauncherPaths.GetLoggerPath()); GenericTextLogger.Init(LauncherPaths.GetLoggerPath());
} }
public static void StartDownload(Action endWaiting = null) public static void GetCurrentUpdateplan(Action endWaiting = null)
{ {
bool not_called = true; bool not_called = true;
@@ -28,6 +34,9 @@ namespace BeWoLauncher.Logic.Controller
{ {
Manager = new DownloadManager(); Manager = new DownloadManager();
if (LauncherAppdataConfig.GetFirstInstallationSuccess())
InitLogger();
GenericTextLogger.PostImportantInfo("Starting Download Process"); GenericTextLogger.PostImportantInfo("Starting Download Process");
Manager.GetUpdatePlan(); Manager.GetUpdatePlan();
@@ -79,6 +88,7 @@ namespace BeWoLauncher.Logic.Controller
public static string UpdateDiskSpace(string path) public static string UpdateDiskSpace(string path)
{ {
FileInfo f = new FileInfo(path); FileInfo f = new FileInfo(path);
string drive = System.IO.Path.GetPathRoot(f.FullName); string drive = System.IO.Path.GetPathRoot(f.FullName);
FreeSpace = NonspecificTools.GetTotalFreeSpace(drive); FreeSpace = NonspecificTools.GetTotalFreeSpace(drive);

View File

@@ -20,6 +20,11 @@ namespace BeWoLauncher.Logic.Controller
public static bool Running { get; set; } public static bool Running { get; set; }
static ProcessController()
{
Running = true;
}
internal static void CheckForOtherInstance() internal static void CheckForOtherInstance()
{ {
string procName = Process.GetCurrentProcess().ProcessName; string procName = Process.GetCurrentProcess().ProcessName;
@@ -69,8 +74,8 @@ namespace BeWoLauncher.Logic.Controller
} }
else else
{ {
string message = "Möchten Sie es schließen? Dadurch können nicht gespeicherte Daten verloren gehen."; string message = "BeWoPlaner Anwendung läuft bereits.";
string caption = "BeWo Anwendung läuft bereits. "; string caption = "Kann BeWoLauncher nicht starten";
MessageBox.Show(message, caption); MessageBox.Show(message, caption);
@@ -83,8 +88,6 @@ namespace BeWoLauncher.Logic.Controller
CheckForOtherInstance(); CheckForOtherInstance();
LauncherServiceFacade.UpdateServerAddresses(); LauncherServiceFacade.UpdateServerAddresses();
Running = true;
} }
internal static void StartLauncherShutdown() internal static void StartLauncherShutdown()

View File

@@ -46,7 +46,8 @@ namespace BeWoLauncher.View.Frames
{ {
txtLoc.Text = value; txtLoc.Text = value;
var size2 = DownloadController.UpdateDiskSpace(LauncherPaths.ActualPlanerLocation).Split(' '); // Login Selection - Aktueller Login Ort in Auswahl
var size2 = DownloadController.UpdateDiskSpace(LauncherPaths.LoginSelectionPlanerLocation).Split(' ');
if (size2.Length > 1) if (size2.Length > 1)
{ {

View File

@@ -12,6 +12,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.ComponentModel; using System.ComponentModel;
using System.Deployment.Application;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
@@ -372,7 +373,7 @@ namespace BeWoLauncher.View
ConnectionProfile p = GenerateProfileFromUri(ApplicationDeployment.CurrentDeployment.ActivationUri); ConnectionProfile p = GenerateProfileFromUri(ApplicationDeployment.CurrentDeployment.ActivationUri);
if (!String.IsNullOrEmpty(p.Tenant) && !String.IsNullOrEmpty(p.Server)) if (!String.IsNullOrEmpty(p.Tenant) && !String.IsNullOrEmpty(p.Server))
{ {
ConnectionInformation.Tenant = p.Tenant; SessionInformation.Login.Tenant = p.Tenant;
if (ProfileList.Count > 0) if (ProfileList.Count > 0)
{ {

View File

@@ -43,25 +43,13 @@
<system.serviceModel> <system.serviceModel>
<bindings> <bindings>
<basicHttpBinding> <basicHttpBinding>
<binding name="TransportSecurityDownloadLarge" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="StreamedRequest"> <binding name="BasicStreamedRequest" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="StreamedResponse">
<!-- mode="Transport" für echten Server und "None" sonst--> <!-- mode="Transport" für echten Server und "None" sonst-->
<security mode="None"> <security mode="None">
<transport clientCredentialType="None" /> <transport clientCredentialType="None" />
</security> </security>
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="32" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" /> <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="32" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" />
</binding> </binding>
<binding name="BasicStreamedRequest" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="StreamedRequest">
<!-- mode="Transport" für echten Server und "None" sonst-->
<security mode="None">
<transport clientCredentialType="None" />
</security>
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="32" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" />
</binding>
<binding name="BeWoBasicEndpoint" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" />
<!-- mode="Transport" für echten Server und "None" sonst-->
</binding>
</basicHttpBinding> </basicHttpBinding>
</bindings> </bindings>
<behaviors> <behaviors>
@@ -82,7 +70,7 @@
</serviceBehaviors> </serviceBehaviors>
</behaviors> </behaviors>
<client> <client>
<endpoint binding="basicHttpBinding" bindingConfiguration="BeWoBasicEndpoint" contract="BeWo.Service.ServiceProxy.ILauncherService" name="LauncherServiceEndpoint" /> <endpoint binding="basicHttpBinding" bindingConfiguration="BasicStreamedRequest" contract="BeWo.Service.ServiceProxy.ILauncherService" name="LauncherServiceEndpoint" />
</client> </client>
<extensions> <extensions>
<behaviorExtensions> <behaviorExtensions>

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<NameOfLastUsedPublishProfile>BeWo2.0</NameOfLastUsedPublishProfile> <NameOfLastUsedPublishProfile>BeWo2.0</NameOfLastUsedPublishProfile>
<UseIISExpress>true</UseIISExpress> <UseIISExpress>true</UseIISExpress>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig> <LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<Use64BitIISExpress>false</Use64BitIISExpress> <Use64BitIISExpress>false</Use64BitIISExpress>
<IISExpressSSLPort /> <IISExpressSSLPort />
<IISExpressAnonymousAuthentication /> <IISExpressAnonymousAuthentication />

View File

@@ -17,5 +17,9 @@ namespace BeWo.Service.ServiceContracts
[FaultContract(typeof(BeWoFault))] [FaultContract(typeof(BeWoFault))]
[OperationContract] [OperationContract]
UpdateFileResponse GetUpdateFile(UpdateFileRequest request); UpdateFileResponse GetUpdateFile(UpdateFileRequest request);
//[FaultContract(typeof(BeWoFault))]
//[OperationContract]
//UpdateFileResponse GetUpdateFileStream(UpdateFileRequest request);
} }
} }

View File

@@ -42,7 +42,7 @@ namespace BeWo.Service.ServiceImplementations
GenericTextLogger.Post("Plan Request erfolreich validiert. Verifiziere Login."); GenericTextLogger.Post("Plan Request erfolreich validiert. Verifiziere Login.");
VerifyLogin(request); VerifyLogin(request.Login);
GenericTextLogger.Post("Login verifiziert. Baue Antwort."); GenericTextLogger.Post("Login verifiziert. Baue Antwort.");
@@ -110,22 +110,18 @@ namespace BeWo.Service.ServiceImplementations
return true; return true;
} }
private void VerifyLogin(UpdatePlanRequest request) => VerifyLogin(request.Login);
private void VerifyLogin(LoginDC login) => VerifyLogin(login.Username, login.Password, Tenant, login.Pin, login.ClientID); private void VerifyLogin(LoginDC login) => VerifyLogin(login.Username, login.Password, Tenant, login.Pin, login.ClientID);
private void VerifyLogin(string username, string password, string tenant, string pin, string clientid) private void VerifyLogin(string username, string password, string tenant, string pin, string clientid)
{ {
if (!TryVerifyLogin(username, password, tenant, pin, clientid)) string server_address = string.Empty;
throw new UpdateException("Kann Anmeldung nicht bestätigen");
}
private bool TryVerifyLogin(string username, string password, string tenant, string pin, string clientid)
{
try try
{ {
SessionInformation.Login.Username = username; SessionInformation.Login.Username = username;
SessionInformation.Login.Password = password; SessionInformation.Login.Password = password;
SessionInformation.Login.Tenant = tenant; SessionInformation.Login.Tenant = tenant;
var server_address = GetServerFromTenant(); server_address = GetServerFromTenant();
#if DEBUG #if DEBUG
server_address = "http://localhost:3777/Host"; server_address = "http://localhost:3777/Host";
@@ -135,14 +131,12 @@ namespace BeWo.Service.ServiceImplementations
var result = ServiceFacade.DoLauncherServiceSync(x => x.IsUserValid(username, password, pin, clientid, true)); var result = ServiceFacade.DoLauncherServiceSync(x => x.IsUserValid(username, password, pin, clientid, true));
if (result == BS.SharedLauncher.Enums.UserValidationResult.UserValid) if (result != BS.SharedLauncher.Enums.UserValidationResult.UserValid)
return true; throw new HideClientUpdateException("Kann Anmeldung nicht bestätigen!");
return false;
} }
catch (Exception e) catch (Exception e)
{ {
return false; throw new HideClientUpdateException("Kann Anmeldung nicht bestätigen! ", e);
} }
} }
@@ -218,6 +212,9 @@ namespace BeWo.Service.ServiceImplementations
if (tenant is null) if (tenant is null)
tenant = SessionInformation.Login.Tenant; tenant = SessionInformation.Login.Tenant;
if (tenant == "demo")
return null;
try try
{ {
@@ -229,12 +226,12 @@ namespace BeWo.Service.ServiceImplementations
String server = System.Text.Encoding.ASCII.GetString(response); String server = System.Text.Encoding.ASCII.GetString(response);
return server; return $"https://{server}/service";
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
return null; throw new HideClientUpdateException("Login konnte nicht verifiziert werden.", ex);
} }
} }
} }

View File

@@ -33,9 +33,15 @@ namespace BeWo.Service.ServiceUtils.Update
private static void calculate() private static void calculate()
{ {
var path = Path.Combine(getSourceFolderPath(), _Request.UpdateFile.RelativePath); var relative_path = _Request.UpdateFile.RelativePath;
var path = Path.Combine(getSourceFolderPath(), relative_path);
_Response.FileData = File.ReadAllBytes(path); var file_data = File.ReadAllBytes(path);
if (file_data.Length > 512 * 1024 * 1024 - 1)
throw new HideClientUpdateException($"Die angefragte File \"{relative_path}\" überschreitet die maximale Größe von 512 MB.");
_Response.FileData = file_data;
} }
private static string getSourceFolderPath() private static string getSourceFolderPath()
@@ -64,7 +70,7 @@ namespace BeWo.Service.ServiceUtils.Update
} }
// User bekommt eigene Daten Feature // User bekommt eigene Daten Feature
throw new NotImplementedException("#479839129"); throw new HideClientUpdateException("#479839129");
} }
} }
} }

View File

@@ -10,17 +10,17 @@ namespace BS.SharedLauncher.Information
{ {
public static class GenericTextLogger public static class GenericTextLogger
{ {
private static bool _started;
private static string _LogFileName; private static string _LogFileName;
private static string _LogFilePath; private static string _LogFilePath;
private static string _Session; private static string _Session;
static GenericTextLogger() static GenericTextLogger()
{ {
_started = false; Started = false;
} }
public static bool Started { get; set; }
public static void Init(string folder) public static void Init(string folder)
{ {
_LogFileName = DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; _LogFileName = DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
@@ -30,18 +30,19 @@ namespace BS.SharedLauncher.Information
_Session = new Random().Next(1, 10000).ToString("0000"); _Session = new Random().Next(1, 10000).ToString("0000");
_started = true; Started = true;
PostWithout(""); PostWithout("");
} }
public static void PostWithout(string str) public static void PostWithout(string str)
{ {
File.AppendAllText(_LogFilePath, str + "\n"); if(Started)
File.AppendAllText(_LogFilePath, str + "\n");
} }
public static void Post(string message) public static void Post(string message)
{ {
if (!_started) if (!Started)
return; return;
var log = $"[#{_Session} {DateTime.Now.ToString("HH:mm:ss")}]: {message}"; var log = $"[#{_Session} {DateTime.Now.ToString("HH:mm:ss")}]: {message}";

View File

@@ -11,6 +11,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;
namespace BS.SharedLauncher.Logic namespace BS.SharedLauncher.Logic
{ {
@@ -174,7 +175,7 @@ namespace BS.SharedLauncher.Logic
{ } { }
return true; return true;
} }
catch catch (Exception e)
{ {
if (throwIfFails) if (throwIfFails)
throw; throw;