public ParametersViewModel( Interfaces.ISettingsManager settingsManager, Services.IInteractionService interactionService, Services.IDispatcherService dispatcherService, Interfaces.IGoogleManager googleManager, IEventAggregator eventAggregator) { if (settingsManager == null) { throw new ArgumentNullException("settingsManager"); } if (interactionService == null) { throw new ArgumentNullException("InteractionService"); } if (dispatcherService == null) { throw new ArgumentNullException("dispatcherService"); } if (eventAggregator == null) { throw new ArgumentNullException("EventAggregator"); } if (googleManager == null) { throw new ArgumentNullException("googleManager"); } this.settingsManager = settingsManager; this.interactionService = interactionService; this.dispatcherService = dispatcherService; this.eventAggregator = eventAggregator; this.googleManager = googleManager; this.Calendars = new ObservableCollection <Entity.Calendar>(); this.SelectCollectionneurDbPathCommand = new DelegateCommand(new Action(() => { this.SelectCollectionneurDbPath(); })); this.SaveCommand = new DelegateCommand( new Action(this.Save), new Func <bool>(() => this.CanSave)); this.IsGmailAccountAlreadyConfigured = this.googleManager.IsAccountAlreadyConfigured(); this.currentSettings = this.settingsManager.LoadSettings(); this.DaysToSyncBefore = this.currentSettings.DaysToSyncBefore; this.DaysToSyncAfter = this.currentSettings.DaysToSyncAfter; this.collectionneurRecetteDbPath = this.currentSettings.CollectionneurDabasePath; }
public ParametersViewModel( Interfaces.ISettingsManager settingsManager, Services.IInteractionService interactionService, Services.IDispatcherService dispatcherService, Interfaces.IGoogleManager googleManager, IEventAggregator eventAggregator) { if (settingsManager == null) { throw new ArgumentNullException("settingsManager"); } if (interactionService == null) { throw new ArgumentNullException("InteractionService"); } if (dispatcherService == null) { throw new ArgumentNullException("dispatcherService"); } if (eventAggregator == null) { throw new ArgumentNullException("EventAggregator"); } if (googleManager == null) { throw new ArgumentNullException("googleManager"); } this.settingsManager = settingsManager; this.interactionService = interactionService; this.dispatcherService = dispatcherService; this.eventAggregator = eventAggregator; this.googleManager = googleManager; this.Calendars = new ObservableCollection<Entity.Calendar>(); this.SelectCollectionneurDbPathCommand = new DelegateCommand(new Action(() => { this.SelectCollectionneurDbPath(); })); this.SaveCommand = new DelegateCommand( new Action(this.Save), new Func<bool>(() => this.CanSave)); this.IsGmailAccountAlreadyConfigured = this.googleManager.IsAccountAlreadyConfigured(); this.currentSettings = this.settingsManager.LoadSettings(); this.DaysToSyncBefore = this.currentSettings.DaysToSyncBefore; this.DaysToSyncAfter = this.currentSettings.DaysToSyncAfter; this.collectionneurRecetteDbPath = this.currentSettings.CollectionneurDabasePath; }
async void LoginButtonClicked(object sender, EventArgs e) //Login Routine { StatusLabel.Text = null; //Reset error message loadingWheel.IsVisible = true; User user = new User(usernameEntry.Text, passwordEntry.Text); if (user.checkCredentials()) { var result = new Token(); //Work around: here we will impliment a token API call await DisplayAlert("Login Success", "Login Successful", "Okay"); if (App.SettingsDatabase.GetSettings() == null) { Settings settings = new Entity.Settings(); App.SettingsDatabase.SaveSettings(settings); } if (result != null) { //App.UserDatabase.saveUser(user); //Save user to DB when credentials are correct //App.TokenDatabase.saveToken(result); //Save token to memory (SQLite db held in .txt file) loadingWheel.IsVisible = false; if (Device.OS == TargetPlatform.Android) //Deals with navigation to homepage on each platform { Application.Current.MainPage = new MasterDetail(); } else if (Device.OS == TargetPlatform.iOS) { await Navigation.PushAsync(new MasterDetail()); //Move to home page } } } else if (!App.CheckInternetConnection()) //Bad internet Connection { StatusLabel.Text = Constants.NoInternetText; loadingWheel.IsVisible = false; passwordEntry.Text = string.Empty; } else //Bad Username/Password { StatusLabel.Text = Constants.WrongLoginText; loadingWheel.IsVisible = false; passwordEntry.Text = string.Empty; } }
/// <summary> /// Initializes a new instance of the <see cref="CollectorReceiptManager" /> class. /// </summary> /// <param name="receiptRepository">The receipt repository.</param> /// <param name="processRepository">The process repository.</param> /// <param name="settingsManager">The settings manager.</param> /// <param name="networkHelper">The network helper.</param> /// <param name="logger">The logger.</param> /// <exception cref="System.ArgumentNullException">settingsManager /// or /// receiptRepository /// or /// processRepository /// or /// networkHelper /// or /// logger</exception> public CollectorReceiptManager( Interfaces.ICollectorReceiptRepository receiptRepository, Interfaces.IProcessRepository processRepository, Interfaces.ISettingsManager settingsManager, Interfaces.INetworkHelper networkHelper, ILoggerService logger) { if (settingsManager == null) { throw new ArgumentNullException("settingsManager"); } if (receiptRepository == null) { throw new ArgumentNullException("receiptRepository"); } if (processRepository == null) { throw new ArgumentNullException("processRepository"); } if (networkHelper == null) { throw new ArgumentNullException("networkHelper"); } if (logger == null) { throw new ArgumentNullException("logger"); } this.receiptRepository = receiptRepository; this.processRepository = processRepository; this.settingsManager = settingsManager; this.settings = this.settingsManager.LoadSettings(); this.networkHelper = networkHelper; this.logger = logger; this.databaseConnectionString = "jdbc:h2:" + this.settings.CollectionneurDabasePath.Replace(".h2.db", string.Empty); }
public static Entity.Settings GetSettings() { var setting = new Entity.Settings(); if (Application.Current.Properties.ContainsKey(LogonDate)) { setting.LogonDate = (DateTime)Application.Current.Properties[LogonDate]; } if (Application.Current.Properties.ContainsKey(LogonStatus)) { setting.LogonStatus = Application.Current.Properties[LogonStatus] as string; } if (Application.Current.Properties.ContainsKey(LogonURL)) { setting.LogonURL = Application.Current.Properties[LogonURL] as string; } if (Application.Current.Properties.ContainsKey(LogonUser)) { setting.LogonUser = Application.Current.Properties[LogonUser] as string; } return(setting); }