Files
BeWoPlaner/Service/ServiceImplementations/DownloadBeWoServiceImp.cs
rene 7c12915a30 Bug der langsamen Ladezeit behoben(Lädt nichtmehr unnötig herunter)
ToDo: Logik in Mvvm umschreiben -> Bessere Übersicht
- Datenlogik in Model lagern
- Logik aus Views holen
- ViewLogik in ViewModel
- Bindings
2023-01-12 13:30:29 +01:00

99 lines
3.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.ServiceModel;
using System.Threading;
using System.Xml;
using BeWo.Data;
using BeWo.Service.ServiceContracts;
using BeWo.Service.ServiceProxy;
using BeWo.Service.ServiceUtils.Paths;
using BeWo.Service.ServiceUtils.Update;
using BS.SharedLauncher.DataContract;
using BS.SharedLauncher.Enums;
using BS.SharedLauncher.Exceptions;
using BS.SharedLauncher.Extensions;
using BS.SharedLauncher.Information;
using BS.SharedLauncher.Logic;
using BS.SharedLauncher.Update;
namespace BeWo.Service.ServiceImplementations
{
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
public class DownloadBeWoServiceImp : IDownloadBeWoService
{
public string Tenant => MultitenancyOperationContextExt.Current.Tenant;
public UpdateFileResponse Download2(UpdatePlanRequest request)
{
return null;
}
public UpdatePlanResponse DownloadInfo(UpdatePlanRequest request)
{
return null;
}
public UpdatePlanResponse GetUpdatePlan(UpdatePlanRequest request)
{
try
{
var exception = UpdateRequestValidator.IsUpdatePlanRequestValid(request, Tenant);
if (exception is object)
throw new InvalidUpdatePlanRequestException(exception);
var response = UpdatePlanResponseHelper.GetUpdatePlanResponse(request, Tenant);
if (response.HasToDo)
UpdateServerSessionManager.CreateSession(response, Tenant);
return response;
}
catch (UpdateException update)
{
throw WaitBeforeSend(update);
}
catch (Exception ex)
{
throw WaitBeforeSend(new UpdateException("Update - GetUpdatePlan - Exception", ex));
}
}
public UpdateFileResponse GetUpdateFile(UpdateFileRequest request)
{
try
{
var exception = UpdateRequestValidator.Validate(request, Tenant);
if (exception is object)
{
UpdateServerSessionManager.CloseSession(request.UpdateSessionId);
throw new InvalidUpdateFileRequestException(exception);
}
UpdateServerSessionManager.LoadAbsolutePath(request);
var response = UpdateFileResponseHelper.GetUpdateFileResponse(request, Tenant);
return response;
}
catch (UpdateException update)
{
throw WaitBeforeSend(update);
}
catch (Exception ex)
{
throw WaitBeforeSend(new UpdateException("Update - GetUpdateFile - Exception", ex));
}
}
public Exception WaitBeforeSend(Exception ex)
{
Thread.Sleep(3000);
return ex;
}
}
}