protected override async Task <ComponentInitializeResponse> InitializeAsync(ComponentInitializeRequest request, ComponentOperationContext context) { var isAdvertisementDisplayDisabled = request.Settings.Get <bool?>("IsAdvertisementDisplayDisabled", mandatory: false) == true; if (!isAdvertisementDisplayDisabled) { await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Window.Current.Content = new AdvertisementDisplayView(); // You have to activate the window in order to show it later. Window.Current.Activate(); var secondaryViewId = ApplicationView.GetForCurrentView().Id; ThreadHelper.RunInUiThreadAsync(async() => { var isShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(secondaryViewId); if (isShown) { Log.Info(LogContextEnum.Application, "Advertisement display was shown."); } else { Log.Error(LogContextEnum.Application, "Advertisement display was not shown."); } }); }); } return(ComponentInitializeResponse.GetSuccess()); }
protected override async Task <ComponentInitializeResponse> InitializeAsync(ComponentInitializeRequest request, ComponentOperationContext context) { _logFolder = await Logger.GetLogFolderAsync(); _transactionFolder = await TransactionManager.GetTransactionFolderAsync(); #pragma warning disable 4014 SyncWorker.InvokeAsync(new EmptyOperationRequest()); #pragma warning restore 4014 Status.SetSelfStatus(ComponentStatusCodeEnum.Ok, null); return(ComponentInitializeResponse.GetSuccess()); }
protected override Task <ComponentInitializeResponse> InitializeAsync(ComponentInitializeRequest request, ComponentOperationContext context) { Status.SetSelfStatus(ComponentStatusCodeEnum.Ok, null); return(Task.FromResult(ComponentInitializeResponse.GetSuccess())); }
protected override async Task <ComponentInitializeResponse> InitializeAsync(ComponentInitializeRequest request, ComponentOperationContext context) { State.KioskAppVersion = VersionHelper.AppVersionString; // app configuration var _appConfiguration = await AppDataStorage.Current.LoadRecordAsync <KioskAppConfiguration>( KioskFolderNames.AppData_Configuration, KioskFileNames.KioskAppConfigurationWithoutExtension, true, CancellationToken.None); Assure.CheckFlowState(_appConfiguration.ServerUri != null, $"'{nameof(KioskFileNames.KioskAppConfigurationWithoutExtension)}.{nameof(KioskAppConfiguration.ServerUri)}' is null."); State.ServerUri = _appConfiguration.ServerUri; // serial key string serialKey; try { var kioskPublicFolder = await StorageHelper.GetKioskRootFolderAsync(); var storageFile = await kioskPublicFolder.GetFileAsync(KioskFileNames.Key); serialKey = await FileIO.ReadTextAsync(storageFile, UnicodeEncoding.Utf8); } catch (FileNotFoundException) { Status.SetSelfStatus(ComponentStatusCodeEnum.Error, $"'{KioskFileNames.Key}' was not found."); return(ComponentInitializeResponse.GetError()); } // init server API proxy ServerApiProxy.Current.Initialize(State.ServerUri, serialKey); // get kiosk configuration var loadedConfiguration = await GetKioskConfigurationAsync(context); var kioskConfiguration = loadedConfiguration.Configuration; Assure.CheckFlowState(kioskConfiguration != null, "Loaded kiosk configuration is null."); // state properties State.KioskConfiguration = kioskConfiguration; // ReSharper disable PossibleNullReferenceException State.KioskId = kioskConfiguration.KioskId; // ReSharper restore PossibleNullReferenceException State.SupportPhone = kioskConfiguration.SupportPhone; State.KioskAddress = kioskConfiguration.KioskAddress; // init languages LanguageManager.Current.Initialize(kioskConfiguration.LanguageCodes); if (loadedConfiguration.IsLoadedFromCache) { Status.SetSelfStatus(ComponentStatusCodeEnum.Warning, "Loaded from cache."); } else { Status.SetSelfStatus(ComponentStatusCodeEnum.Ok, null); } return(ComponentInitializeResponse.GetSuccess()); }