- more logs - download controller + manager überarbeitet - Retry wird besser angezeigt - Formatierungen
158 lines
4.6 KiB
C#
158 lines
4.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Specialized;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
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.Shared;
|
|
using BS.SharedLauncher.DataContract;
|
|
using BS.SharedLauncher.Exceptions;
|
|
using BS.SharedLauncher.Information;
|
|
|
|
namespace BeWo.Service.ServiceImplementations
|
|
{
|
|
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
|
|
public class DownloadBeWoServiceImp : IDownloadBeWoService
|
|
{
|
|
private const int FILE_REQUEST_COUNT = 5;
|
|
|
|
public string Tenant => MultitenancyOperationContextExt.Current.Tenant;
|
|
|
|
public UpdatePlanResponse GetUpdatePlan(UpdatePlanRequest request)
|
|
{
|
|
GenericTextLogger.Init(ServerFilePaths.GetLogFolderPath(Tenant));
|
|
|
|
GenericTextLogger.PostImportantInfo("GetUpdatePlan Anfrage");
|
|
|
|
var response = new UpdatePlanResponse(false);
|
|
|
|
response.TriesPerFile = FILE_REQUEST_COUNT;
|
|
|
|
try
|
|
{
|
|
GenericTextLogger.Post("Validiere Plan Request.");
|
|
|
|
UpdateRequestValidator.ValidatePlanRequest(request);
|
|
|
|
GenericTextLogger.Post("Plan Request erfolreich validiert. Baue Antwort.");
|
|
|
|
UpdatePlanResponseBuilder.BuildResponse(request, Tenant, response);
|
|
|
|
if(response.HasToDo)
|
|
UpdateServerSessionManager.CreateSession(response, Tenant);
|
|
|
|
response.Successful = true;
|
|
response.Error = null;
|
|
|
|
GenericTextLogger.Post("Antwort erfolgreich gebaut.");
|
|
|
|
GenericTextLogger.PostLine();
|
|
}
|
|
catch (HideClientUpdateException e)
|
|
{
|
|
// Serverseitig loggen
|
|
GenericTextLogger.PostException(e);
|
|
|
|
response.Error = "Serverseitiger Fehler";
|
|
}
|
|
catch (UpdateException e)
|
|
{
|
|
// Muss nachher nicht
|
|
GenericTextLogger.PostException(e);
|
|
|
|
response.Error = e.ToString();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// Unerwartet - nicht gewollt
|
|
GenericTextLogger.PostException(e);
|
|
|
|
response.Error = e.ToString();
|
|
}
|
|
|
|
if(response.Error is object)
|
|
{
|
|
Thread.Sleep(3000);
|
|
}
|
|
|
|
return response;
|
|
}
|
|
public UpdateFileResponse GetUpdateFile(UpdateFileRequest request)
|
|
{
|
|
GenericTextLogger.Init(ServerFilePaths.GetLogFolderPath(Tenant));
|
|
|
|
GenericTextLogger.PostImportantInfo("GetUpdateFile Anfrage");
|
|
|
|
var response = new UpdateFileResponse(false);
|
|
|
|
try
|
|
{
|
|
GenericTextLogger.Post("Validiere File Request.");
|
|
|
|
UpdateRequestValidator.ValidateFileRequest(request);
|
|
|
|
GenericTextLogger.Post("Plan Request erfolreich validiert.");
|
|
|
|
GenericTextLogger.PostArrow($"File: {request.UpdateFile.RelativePath}");
|
|
|
|
GenericTextLogger.Post("Baue Antwort.");
|
|
|
|
UpdateServerSessionManager.LoadAbsolutePath(request);
|
|
|
|
UpdateFileResponseBuilder.BuildResponse(request, Tenant, response);
|
|
|
|
response.Successful = true;
|
|
response.Error = null;
|
|
|
|
GenericTextLogger.Post("Antwort erfolgreich gebaut.");
|
|
|
|
GenericTextLogger.PostLine();
|
|
}
|
|
catch (HideClientUpdateException e)
|
|
{
|
|
// Serverseitig loggen
|
|
GenericTextLogger.PostException(e);
|
|
|
|
response.Error = "Serverseitiger Fehler";
|
|
}
|
|
catch (UpdateException e)
|
|
{
|
|
// Muss nachher nicht
|
|
GenericTextLogger.PostException(e);
|
|
|
|
response.Error = e.ToString();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// Unerwartet - nicht gewollt
|
|
GenericTextLogger.PostException(e);
|
|
|
|
response.Error = e.ToString();
|
|
}
|
|
|
|
if(response.Error is object)
|
|
{
|
|
UpdateServerSessionManager.CloseSession(request.SessionId);
|
|
|
|
Thread.Sleep(3000);
|
|
}
|
|
|
|
return response;
|
|
}
|
|
|
|
public bool TestConnection()
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|