using System; using System.Collections.Generic; using System.Configuration; using System.IO; using System.Linq; using System.ServiceModel; 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 { if (!isUpdatePlanRequestValid(request)) throw new InvalidUpdatePlanRequestException(); if (!VerifyLogin(request)) throw new InvalidUpdatePlanRequestException("Login konnte nicht aufm Download Server verifiziert werden."); var response = UpdatePlanResponseBuilder.GetUpdatePlanResponse(request, Tenant); return response; } catch (UpdateException update) { throw update; } catch (Exception ex) { throw new UpdateException("Update - GetUpdatePlan - Exception", ex); } } public UpdateFileResponse GetUpdateFile(UpdateFileRequest request) { try { if (!isUpdateFileRequestValid(request)) throw new InvalidUpdateFileRequestException(); var response = UpdateFileResponseBuilder.GetUpdateFileResponse(request, Tenant); return response; } catch (UpdateException update) { throw update; } catch (Exception ex) { throw new UpdateException("Update - GetUpdateFile - Exception", ex); } } private bool VerifyLogin(UpdatePlanRequest request) { SessionInformation.Login.Username = request.Login.Username; SessionInformation.Login.Password = request.Login.Password; SessionInformation.Login.Tenant = Tenant; ServiceFacade.UpdateServerAddresses(request.Login.CoreServerAddress); var result = ServiceFacade.DoLauncherServiceSync(x => x.IsUserValid(request.Login.TempUsername, request.Login.Password, request.Login.Pin, request.Login.ClientID, true)); if (result == UserValidationResult.UserValid) return true; return false; } private bool isUpdatePlanRequestValid(UpdatePlanRequest request) { return true; } private bool isUpdateFileRequestValid(UpdateFileRequest request) { // Check for Login // Check for Correct Version // Check for File Permissions return true; } } }