Files
BeWoPlaner/Service/ServiceImplementations/DownloadBeWoServiceImp.cs
rene 421fae3332 Feature: Download Server ignoreren, wenn nicht vorhanden
Client macht vorm Update Checken eine Anfrage an den Download Server und prüft dessen Verfügbarkeit. Sollte keine vorhanden sein, so wird der Client direkt gestartet.
2023-01-09 17:28:56 +01:00

98 lines
3.0 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);
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;
}
}
}