public NewTicketViewModel() { NewTicketViewModel.logger.Debug("VIEWMODEL LOADING: NewTicketViewModel"); AuthenticationService.Instance.SuspendService = false; this.OpenTickets = new ObservableCollection <TicketViewModel>(); this.Categories = new ObservableCollection <Category>(); this.UnitOfWork = new UnitOfWork(); this.LoadCategories(); SplashScreenHelper.ShowText(Resources.SplashScreenLoadingProducts); SplashScreenHelper.Close(); if (AuthenticationService.Instance.AuthenticatedMember == null) { LockScreenHelper.Show(); } this.CurrentTicket = new TicketViewModel() { Ticket = new Ticket(), Visibility = Visibility.Collapsed, NewTicket = true, ItemSelectedCommand = (ICommand) new RelayCommand(new Action(this.SelectedItemChanged)) }; this.OpenTickets.Add(this.CurrentTicket); this.OpenCheckoutSheet = this.UnitOfWork.CheckoutSheetRepository.GetLastOpenSheet(); if (this.OpenCheckoutSheet == null) { if (NavigatorHelper.NavigationService == null) { return; } NavigatorHelper.NavigationService.Navigate(new Uri("Views/NewTicket/NewCheckoutSheetPageView.xaml", UriKind.Relative)); NavigatorHelper.NavigationService.RemoveBackEntry(); } else { try { foreach (Ticket ticket in this.UnitOfWork.TicketRepository.GetOpenTicketsNoTracking()) { this.OpenTickets.Add(new TicketViewModel() { Ticket = ticket, TicketControlClicked = (ICommand) new RelayCommand <TicketViewModel>(new Action <TicketViewModel>(this.TicketSelected)) }); } } catch (SqlException ex) { SplashScreenHelper.CloseInstant(); int num = (int)WPFMessageBox.Show(Resources.ExceptionDbWarning + ex.Message, Resources.ExceptionDbWarningTitle, MessageBoxButton.OK, MessageBoxImage.Hand); NewTicketViewModel.logger.Error("Database error: {0}", ex.Message); } catch (DataException ex) { SplashScreenHelper.CloseInstant(); int num = (int)WPFMessageBox.Show(Resources.ExceptionDbWarning + ex.Message, Resources.ExceptionDbWarningTitle, MessageBoxButton.OK, MessageBoxImage.Hand); NewTicketViewModel.logger.Error("Database error: {0}", ex.Message); } NewTicketViewModel.logger.Debug("VIEWMODEL LOADED: NewTicketViewModel"); } }
/// <summary> /// Agent that runs a scheduled task /// </summary> /// <param name="task"> /// The invoked task /// </param> /// <remarks> /// This method is called when a periodic or resource intensive task is invoked /// </remarks> protected async override void OnInvoke(ScheduledTask task) { //TODO: Add code to perform your task in background await LockScreenHelper.HelloWP(); ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(30)); NotifyComplete(); }
/// <summary> /// Agent that runs a scheduled task /// </summary> /// <param name="task"> /// The invoked task /// </param> /// <remarks> /// This method is called when a periodic or resource intensive task is invoked /// </remarks> protected async override void OnInvoke(ScheduledTask task) { try { await PhoneTileUtil.UpdateNoTrack(); } catch (Exception) { } try { await LockScreenHelper.TrySetRandomLockScreenImage(); } catch (Exception) { } NotifyComplete(); }
public static async Task <bool> RequestThenSetLockScreen() { var accessGranted = await LockScreenUtil.EnsureOrRequestLockScreenAccess(); if (accessGranted) { var uri = await LockScreenHelper.GetRandomLockScreenImage(); try { // might throw LockScreen.SetImageUri(uri); } catch (Exception e) { // the value does not fall between the expected range error, wtf? MessagingService.Instance.Send("Unable to update lock screen image: " + e.Message); } } return(accessGranted); }
public App() { this.InitializeComponent(); MediaTypeNames.Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; if (Pos.Properties.Settings.Default.UpdateSettings) { Pos.Properties.Settings.Default.Upgrade(); Pos.Properties.Settings.Default.UpdateSettings = false; Pos.Properties.Settings.Default.Save(); } Dal.Settings.ConnectionString = new SqlConnectionStringBuilder() { Password = Pos.Properties.Settings.Default.DbPassword, UserID = Pos.Properties.Settings.Default.DbUser, InitialCatalog = Pos.Properties.Settings.Default.DbCatalog, DataSource = Pos.Properties.Settings.Default.DbInstance }.ToString(); MainWindowView mainWindowView = new MainWindowView(); MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(); mainWindowView.DataContext = (object)mainWindowViewModel; MediaTypeNames.Application.Current.MainWindow = (Window)mainWindowView; NavigatorHelper.NavigationService = mainWindowView.MainFrame.NavigationService; mainWindowView.Show(); mainWindowView.Visibility = Visibility.Hidden; if (!string.IsNullOrEmpty(Pos.Properties.Settings.Default.SerialPortCashDrawer)) { CashDrawerService.ComPortName = Pos.Properties.Settings.Default.SerialPortCashDrawer; if (!CashDrawerService.Connect()) { int num = (int)WPFMessageBox.Show(Resources.ExceptionSerial, Resources.ExceptionSerialTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation); } } try { new UnitOfWork().CategoryRepository.GetAll(); } catch (SqlException ex) { SplashScreenHelper.CloseInstant(); int num = (int)WPFMessageBox.Show(Resources.ExceptionDbWarning + ex.Message, Resources.ExceptionDbWarningTitle, MessageBoxButton.OK, MessageBoxImage.Hand); App.logger.Error("Database error: {0}", ex.Message); NavigatorHelper.NavigationService.Navigate(new Uri("Views/Settings/SettingsPageView.xaml", UriKind.Relative)); NavigatorHelper.NavigationService.RemoveBackEntry(); return; } catch (DataException ex) { SplashScreenHelper.CloseInstant(); int num = (int)WPFMessageBox.Show(Resources.ExceptionDbWarning + ex.Message, Resources.ExceptionDbWarningTitle, MessageBoxButton.OK, MessageBoxImage.Hand); App.logger.Error("Database error: {0}", ex.Message); NavigatorHelper.NavigationService.Navigate(new Uri("Views/Settings/SettingsPageView.xaml", UriKind.Relative)); NavigatorHelper.NavigationService.RemoveBackEntry(); return; } catch (InvalidOperationException ex) { SplashScreenHelper.CloseInstant(); int num = (int)WPFMessageBox.Show(Resources.ExceptionDbWarning + ex.Message, Resources.ExceptionDbWarningTitle, MessageBoxButton.OK, MessageBoxImage.Hand); App.logger.Error("Database error: {0}", ex.Message); NavigatorHelper.NavigationService.Navigate(new Uri("Views/Settings/SettingsPageView.xaml", UriKind.Relative)); NavigatorHelper.NavigationService.RemoveBackEntry(); return; } if (string.IsNullOrEmpty(Pos.Properties.Settings.Default.NfcReaderName)) { LockScreenHelper.Hide(); NavigatorHelper.NavigationService.Navigate(new Uri("Views/Settings/SettingsPageView.xaml", UriKind.Relative)); NavigatorHelper.NavigationService.RemoveBackEntry(); } else { AuthenticationService.Instance.Inititialize(new PcscService(Pos.Properties.Settings.Default.NfcReaderName), Pos.Properties.Settings.Default.AuthenticationTimeout); AuthenticationService.Instance.MemberAuthenticated += (AuthenticationService.AuthenticationEventHandler)((o, e) => { if (!e.AuthenticatedMember.Roles.Any <Role>()) { return; } LockScreenHelper.Hide(); }); AuthenticationService.Instance.MemberDeauthenticated += (AuthenticationService.AuthenticationEventHandler) delegate { LockScreenHelper.Show(); }; NavigatorHelper.NavigationService.Navigate(new Uri("Views/NewTicket/NewTicketPageView.xaml", UriKind.Relative)); NavigatorHelper.NavigationService.RemoveBackEntry(); } }
private void Button_Click(object sender, RoutedEventArgs e) { LockScreenHelper.HelloWP(); }