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>
<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" />
<security mode="Transport" />
<!-- mode="Transport" für echten Server und "None" sonst-->
</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">
<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-->
</binding>
</basicHttpBinding>
</bindings>
<client>
<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" />
</client>
<behaviors>

View File

@@ -28,7 +28,7 @@ namespace BeWoLauncher.Logic.Behavior
// dlg.ShowDialog();
//}
#else
if (ConnectionInformation.Tenant == "demo")
if (SessionInformation.Login.Tenant == "demo")
{
var dlg = new ConfirmDemoDialog();
dlg.ShowDialog();
@@ -38,7 +38,7 @@ namespace BeWoLauncher.Logic.Behavior
LauncherPaths.ActualPlanerLocation = LauncherPaths.GetInstallLocationFromSetting();
if (LauncherPaths.ActualPlanerLocation is object && !CheckForPermissions(LauncherPaths.ActualPlanerLocation))
if (!string.IsNullOrWhiteSpace(LauncherPaths.ActualPlanerLocation) && !CheckForPermissions(LauncherPaths.ActualPlanerLocation))
{
ViewBehavior.ShowFrame(FrameType.NoPermissionInfo);
EndWaiting();
@@ -52,7 +52,7 @@ namespace BeWoLauncher.Logic.Behavior
}
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))
{
DownloadController.InitLogger();
LauncherPaths.SetAndSaveInstallLocation(install.InstallLocation);
LauncherAppdataConfig.SetFirstInstallationSuccess(true);
ShowFrame(FrameType.InstallProgress);

View File

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

View File

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

View File

@@ -46,7 +46,8 @@ namespace BeWoLauncher.View.Frames
{
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)
{

View File

@@ -12,6 +12,7 @@ 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;
@@ -372,7 +373,7 @@ namespace BeWoLauncher.View
ConnectionProfile p = GenerateProfileFromUri(ApplicationDeployment.CurrentDeployment.ActivationUri);
if (!String.IsNullOrEmpty(p.Tenant) && !String.IsNullOrEmpty(p.Server))
{
ConnectionInformation.Tenant = p.Tenant;
SessionInformation.Login.Tenant = p.Tenant;
if (ProfileList.Count > 0)
{

View File

@@ -43,25 +43,13 @@
<system.serviceModel>
<bindings>
<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-->
<security mode="None">
<transport clientCredentialType="None" />
</security>
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="32" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" />
</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>
</bindings>
<behaviors>
@@ -82,7 +70,7 @@
</serviceBehaviors>
</behaviors>
<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>
<extensions>
<behaviorExtensions>

View File

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

View File

@@ -17,5 +17,9 @@ namespace BeWo.Service.ServiceContracts
[FaultContract(typeof(BeWoFault))]
[OperationContract]
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.");
VerifyLogin(request);
VerifyLogin(request.Login);
GenericTextLogger.Post("Login verifiziert. Baue Antwort.");
@@ -110,22 +110,18 @@ namespace BeWo.Service.ServiceImplementations
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(string username, string password, string tenant, string pin, string clientid)
{
if (!TryVerifyLogin(username, password, tenant, pin, clientid))
throw new UpdateException("Kann Anmeldung nicht bestätigen");
}
private bool TryVerifyLogin(string username, string password, string tenant, string pin, string clientid)
{
string server_address = string.Empty;
try
{
SessionInformation.Login.Username = username;
SessionInformation.Login.Password = password;
SessionInformation.Login.Tenant = tenant;
var server_address = GetServerFromTenant();
server_address = GetServerFromTenant();
#if DEBUG
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));
if (result == BS.SharedLauncher.Enums.UserValidationResult.UserValid)
return true;
return false;
if (result != BS.SharedLauncher.Enums.UserValidationResult.UserValid)
throw new HideClientUpdateException("Kann Anmeldung nicht bestätigen!");
}
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)
tenant = SessionInformation.Login.Tenant;
if (tenant == "demo")
return null;
try
{
@@ -229,12 +226,12 @@ namespace BeWo.Service.ServiceImplementations
String server = System.Text.Encoding.ASCII.GetString(response);
return server;
return $"https://{server}/service";
}
}
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()
{
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()
@@ -64,7 +70,7 @@ namespace BeWo.Service.ServiceUtils.Update
}
// 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
{
private static bool _started;
private static string _LogFileName;
private static string _LogFilePath;
private static string _Session;
static GenericTextLogger()
{
_started = false;
Started = false;
}
public static bool Started { get; set; }
public static void Init(string folder)
{
_LogFileName = DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
@@ -30,18 +30,19 @@ namespace BS.SharedLauncher.Information
_Session = new Random().Next(1, 10000).ToString("0000");
_started = true;
Started = true;
PostWithout("");
}
public static void PostWithout(string str)
{
File.AppendAllText(_LogFilePath, str + "\n");
if(Started)
File.AppendAllText(_LogFilePath, str + "\n");
}
public static void Post(string message)
{
if (!_started)
if (!Started)
return;
var log = $"[#{_Session} {DateTime.Now.ToString("HH:mm:ss")}]: {message}";

View File

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