public MainWindow( FlightInfoViewModel viewModel, SignalRLogic signalR, FlightLogic flightLogic, TestLogic testLogic, IFlightSimInterface flightSimInterface, FileWatcherLogic watcher, IStorageLogic storageLogic, ILogger <MainWindow> logger) { InitializeComponent(); this.viewModel = viewModel; this.signalR = signalR; this.flightLogic = flightLogic; this.testLogic = testLogic; this.flightSimInterface = flightSimInterface ?? throw new ArgumentNullException(nameof(flightSimInterface)); this.watcher = watcher ?? throw new ArgumentNullException(nameof(watcher)); this.storageLogic = storageLogic ?? throw new ArgumentNullException(nameof(storageLogic)); this.logger = logger; DataContext = viewModel; flightSimInterface.AircraftDataUpdated += FlightSimInterface_AircraftDataUpdated; flightSimInterface.FlightPlanUpdated += FlightSimInterface_FlightPlanUpdated; flightSimInterface.FlightStatusUpdated += FlightStatusUpdater_FlightStatusUpdated; watcher.FileCreated += Watcher_FileCreated; TextArchiveFolder.Text = storageLogic.ArchiveFolder; }
public async Task TestSaveFromClient() { var(webApplication, connection) = SetupServer(); using (connection) { var httpClient = webApplication.CreateClient(); var flightAPI = new FlightsAPIClient(Options.Create(new AppSettings { BaseUrl = "" }), httpClient); var flightSimInterface = Mock.Of <IFlightSimInterface>(); var imageUploader = Mock.Of <IImageUploader>(); var flightLogic = new FlightLogic(new LoggerFactory().CreateLogger <FlightLogic>(), flightAPI, flightSimInterface, imageUploader); flightLogic.FlightData.Aircraft = new DTOs.AircraftData { Title = "Test aircraft", Type = "Test aircraft type", Model = "Test aircraft model", TailNumber = "123", Airline = "", FlightNumber = "" }; flightLogic.FlightRoute.Add(new ClientFlightStatus { SimTime = 0.1, SimRate = 1, }); var result = await flightLogic.SaveAsync(); result.Should().BeTrue(); } }
public async Task <HttpResponseMessage> ChangeStatusPassanners(UserHandle user) { Result <string> result = new Result <string>(); using (FlightPostponedContext context = new FlightPostponedContext()) { try { string channel = "lockedChanges"; var ev = new SessionStatus(); ev.Users = new List <UserHandle> { user }; ev.State = (int)StateSignalREnum.Pub; FlightLogic logic = new FlightLogic(new Dal.Repository.FlightRepository(context), new Dal.Repository.FlightPostponedRepository(context)); var trackid = await logic.PassangersHandleUser(user); //Guid tarckId = Guid.NewGuid(); ev.TrackId = trackid.ToString(); //_context.Clients.Group(SessionStatus.TaskChannel).GetNotify(channel, ev); PulishEvent(channel, ev); result.Model = ev.TrackId; } catch (ErrorLogic errlogic) { result.IsErrUnandleException = false; result.IsErr = true; result.TitleErr = errlogic.ErrorTitle; result.ErrDesc = errlogic.Message; ErrorHandle(errlogic); } catch (Exception e) { result.IsErrUnandleException = true; result.IsErr = true; result.TitleErr = ErrorLogic.UNHANDLE_EXCECPTION; result.ErrDesc = e.Message; ErrorHandle(e); } } var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <Result>(result, new JsonMediaTypeFormatter(), new MediaTypeWithQualityHeaderValue("application/json")) }; response.Headers.CacheControl = new CacheControlHeaderValue(); response.Headers.CacheControl.NoStore = true; return(response); }
public async Task <HttpResponseMessage> CreateNewOrderFlightPostponed(OrderFlightPostponedRequest request) { Result <Guid> result = new Result <Guid>(); using (FlightPostponedContext context = new FlightPostponedContext()) { try { FlightLogic logic = new FlightLogic(new Dal.Repository.FlightRepository(context), new Dal.Repository.FlightPostponedRepository(context)); result.Model = await logic.CreateFlightPostponed(request.Flight, request.HandleBy, request.Passangers); } catch (ErrorLogic errlogic) { result.IsErrUnandleException = false; result.IsErr = true; result.TitleErr = errlogic.ErrorTitle; result.ErrDesc = errlogic.Message; ErrorHandle(errlogic); } catch (Exception e) { result.IsErrUnandleException = true; result.IsErr = true; result.TitleErr = ErrorLogic.UNHANDLE_EXCECPTION; result.ErrDesc = e.Message; ErrorHandle(e); } var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <Result <Guid> >(result, new JsonMediaTypeFormatter(), new MediaTypeWithQualityHeaderValue("application/json")) }; response.Headers.CacheControl = new CacheControlHeaderValue(); response.Headers.CacheControl.NoStore = true; return(response); } }