public async void Run(IBackgroundTaskInstance taskInstance) { this._deferral = taskInstance.GetDeferral(); try { taskInstance.Canceled += (s, e) => this.Close(); var triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails; if (triggerDetails != null && triggerDetails.Name == "CTime2VoiceCommandService") { this._connection = VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails); this._connection.VoiceCommandCompleted += (s, e) => this.Close(); var voiceCommand = await this._connection.GetVoiceCommandAsync(); Logger.Info($"Executing voice command '{voiceCommand.CommandName}'."); var applicationStateService = new ApplicationStateService(); await applicationStateService.RestoreStateAsync(); var cTimeService = new CTimeService(new EventAggregator(), applicationStateService, new GeoLocationService()); var stampHelper = new CTimeStampHelper(applicationStateService, cTimeService); var stampHelperCallback = new CTimeStampHelperCallback( this.OnNotLoggedIn, this.SupportsQuestions, this.OnDidNothing, this.OnAlreadyCheckedInWannaCheckOut, this.OnAlreadyCheckedIn, this.OnAlreadyCheckedOutWannaCheckIn, this.OnAlreadyCheckedOut, this.OnSuccess); switch (voiceCommand.CommandName) { case "checkIn": await stampHelper.Stamp(stampHelperCallback, TimeState.Entered); break; case "checkOut": await stampHelper.Stamp(stampHelperCallback, TimeState.Left); break; } } } catch (Exception exception) { Logger.Warn("Exception occured in the voice command service."); Logger.Error(exception); } finally { this.Close(); } }
public void SetUp() { _filter = new FakeFilter(); _row = new RowBuilder().Build(); _rows = new List <Row> { _row }; _mockState = new Mock <IApplicationState>(); _mockState.SetupGet(p => p.IsStartMenuVisible).Returns(true); _mockState.SetupGet(p => p.IsNavigationTreeVisible).Returns(true); _mockState.SetupGet(p => p.SelectedFilter).Returns(_filter); _mockState.SetupGet(p => p.SelectedRows).Returns(_rows); _mockEventBus = new Mock <IEventBus>(); _service = new ApplicationStateService( _mockState.Object, _mockEventBus.Object); }
public void Run(IBackgroundTaskInstance taskInstance) { try { this._deferral = taskInstance.GetDeferral(); taskInstance.Canceled += (s, e) => this.Close(); var triggerDetails = (AppServiceTriggerDetails)taskInstance.TriggerDetails; if (triggerDetails.Name == "com.microsoft.band.observer") { var applicationStateService = new ApplicationStateService(); var cTimeService = new CTimeService(new EventAggregator(), applicationStateService, new GeoLocationService()); var bandService = new Core.Services.Band.BandService(applicationStateService, cTimeService); triggerDetails.AppServiceConnection.RequestReceived += async (sender, e) => { var deferral = e.GetDeferral(); await applicationStateService.RestoreStateAsync(); //Restore session state with every event await e.Request.SendResponseAsync(new ValueSet()); deferral.Complete(); //Handle the tile event outside of the deferral //Otherwise the band will just queue up the tile events //And we want to not allow the user to press buttons multiple times //So we let our own method handle waiting or not await bandService.HandleTileEventAsync(e.Request.Message); }; } } catch (Exception exception) { Logger.Error(exception); this.Close(); } }
public HomeController(IHostingEnvironment env, ApplicationStateService appState) { _env = env; _appState = appState; }
private bool CanReportPicture(ReportContentData data) { return(picture != null && ApplicationStateService.HasUserRole(UserRole.USER)); }
private bool CanSetPictureApproval(UserApprovalModifier modifier) { return(picture != null && ApplicationStateService.HasUserRole(UserRole.USER)); }
private bool CanRepostPicture() { return(picture != null && ApplicationStateService.HasUserRole(UserRole.USER)); }
private bool CanReportComment(Guid commentId) { return(ApplicationStateService.HasUserRole(UserRole.USER)); }
private bool CanPostComment() { return(NewComment != null && ApplicationStateService.HasUserRole(UserRole.USER)); }
private bool CanCreateComment() { return(mediaUri != null && ApplicationStateService.HasUserRole(UserRole.USER)); }