Files
BeWoPlaner/Service/ServiceImplementations/DownloadBeWoServiceImp.cs

131 lines
4.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.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.ServiceContracts;
using BeWo.Service.ServiceProxy;
using BeWo.Service.ServiceUtils.DistanceCalculator;
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 object CallMeForTesting(string token, object input)
{
try
{
if (token != "dafslihjkriouuorgha3431342..")
return "Nö";
return null;
var address1 = DAOFactory.GenericDAO.LoadByID<Address>(3000);
var address2 = DAOFactory.GenericDAO.LoadByID<Address>(3001);
var address3 = DAOFactory.GenericDAO.LoadByID<Address>(3002);
var address4 = DAOFactory.GenericDAO.LoadByID<Address>(3003);
var address5 = DAOFactory.GenericDAO.LoadByID<Address>(3004);
var add1 = new Address[] { address1, address2, address5 };
var add2 = new Address[] { address3, address4 };
AddressRouteManager.GetMatrix(add1, add2);
}
catch(Exception e)
{
}
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;
}
}
}