private async void passwordResetButton_Click(object sender, RoutedEventArgs e) { if(string.IsNullOrEmpty(passwordResetBox.Password)||string.IsNullOrWhiteSpace(passwordResetBox.Password)) { var messageDialog = new MessageDialog("Type password before you click on change"); await messageDialog.ShowAsync(); } else { try { passwordResetButton.IsEnabled = false; ProgressRingPasswordReset.IsActive = true; ProgressRingPasswordReset.Visibility = Visibility.Visible; string empId = ""; string newPassword = ""; var localObjectStorageHelper = new LocalObjectStorageHelper(); // Read and Save with simple objects string keySimpleObject = "47"; if (localObjectStorageHelper.KeyExists(keySimpleObject)) { empId = localObjectStorageHelper.Read<string>(keySimpleObject); } newPassword = passwordResetBox.Password; await EmployeeSync.GetAllEmployeesAsnc(EmployeeCharacters, empId); string condition = EmployeeCharacters[0]._id.Oid.ToString(); string setValue = String.Format("{{\"$set\":{{\"Password\":\"{0}\"}}}}", newPassword); await EmployeeSync.EmpPasswordPutAsync(condition, setValue); var messageDialog = new MessageDialog("Password changed"); await messageDialog.ShowAsync(); passwordResetButton.IsEnabled = true; ProgressRingPasswordReset.Visibility = Visibility.Collapsed; ProgressRingPasswordReset.IsActive = false; passwordResetBox.Password = ""; } catch { var messageDialog = new MessageDialog("Password not changed !Error "); await messageDialog.ShowAsync(); ProgressRingPasswordReset.Visibility = Visibility.Collapsed; ProgressRingPasswordReset.IsActive = false; passwordResetButton.IsEnabled = true; } } }
protected override void OnNavigatedTo(NavigationEventArgs e) { Contact = e.Parameter as Passenger; LocalObjectStorageHelper localObjectStorage = new LocalObjectStorageHelper(); if (localObjectStorage.KeyExists("passenger")) { Passenger = localObjectStorage.Read <Passenger>("passenger"); } ViewModel.Connect(Passenger.Email, Contact.Email); ViewModel.SetMessages(Contact.Email); }
public async Task InitializeAsync() { if (_storageHelper.KeyExists(current_api_key)) { var config = _storageHelper.Read <ApiConfig>(current_api_key); CurrentApiMode = ApiModes.FirstOrDefault(i => i.ApiConfig == config); } if (CurrentApiMode == null) { CurrentApiMode = ApiModes.First(); _storageHelper.Save(current_api_key, CurrentApiMode.ApiConfig); } await rebuildForumListAsync(CurrentApiMode.ApiConfig); }
public MainPage() { this.InitializeComponent(); _stravaService = new StravaService(); _loginService = new LoginService(_stravaService); DataContext = new MainViewModel(_stravaService); var storageHelper = new LocalObjectStorageHelper(); if (storageHelper.KeyExists(StorageKeys.ACCESSTOKEN)) { _stravaService.AccessToken = storageHelper.Read <string>(StorageKeys.ACCESSTOKEN); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { string LeaveType = (string)e.Parameter; string empId = ""; var localObjectStorageHelper = new LocalObjectStorageHelper(); // Read and Save with simple objects string keySimpleObject = "47"; if (localObjectStorageHelper.KeyExists(keySimpleObject)) { empId = localObjectStorageHelper.Read <string>(keySimpleObject); } await LeaveTransactionGetPostPut.GetLeaveTransactionAsnc(LeaveTransactions, empId, LeaveType); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } var storageHelper = new LocalObjectStorageHelper(); if (!storageHelper.KeyExists(StorageKeys.ACCESSTOKEN)) { var stravaService = new StravaService(); var loginService = new LoginService(stravaService); await loginService.Login(); } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } }
public static User LoginFromCache() { var wCache = new LocalObjectStorageHelper(); var key = CacheKeys.UserKey; if (wCache.KeyExists(key)) { var json = wCache.Read(key, ""); if (json.Length < 4) { return(null); } return(JsonConvert.DeserializeObject <User>(json)); } else { return(null); } }
private async void InitRules() { LocalObjectStorageHelper LocalObjectStorageHelper = new LocalObjectStorageHelper(); if (!await LocalObjectStorageHelper.FileExistsAsync("rules_origin")) { var Folder = await Package.Current.InstalledLocation.GetFolderAsync("Data"); var FileRules = await Folder.GetFileAsync("rules.json"); string StringRules = await FileIO.ReadTextAsync(FileRules); var TempRules = JsonConvert.DeserializeObject <Rules>(StringRules); await LocalObjectStorageHelper.SaveFileAsync("rules_origin", TempRules); } if (!await LocalObjectStorageHelper.FileExistsAsync("rules")) { var Folder = await Package.Current.InstalledLocation.GetFolderAsync("Data"); var FileRules = await Folder.GetFileAsync("rules.json"); string StringRules = await FileIO.ReadTextAsync(FileRules); Rules = JsonConvert.DeserializeObject <Rules>(StringRules); await LocalObjectStorageHelper.SaveFileAsync("rules", Rules); } else { Rules = await LocalObjectStorageHelper.ReadFileAsync <Rules>("rules"); } if (!LocalObjectStorageHelper.KeyExists("settings")) { LocalObjectStorageHelper.Save("settings", Rules.GetSettings()); } else { var settings = LocalObjectStorageHelper.Read <Dictionary <string, bool> >("settings"); Rules.SetSettings(settings); } }
private async void ApplyButton_Click(object sender, RoutedEventArgs e) { ApplyButton.IsEnabled = false; ProgressRingApply.IsActive = true; ProgressRingApply.Visibility = Visibility.Visible; string Empid = ""; var localObjectStorageHelper = new LocalObjectStorageHelper(); // Read and Save with simple objects string keySimpleObject = "47"; if (localObjectStorageHelper.KeyExists(keySimpleObject)) { Empid = localObjectStorageHelper.Read <string>(keySimpleObject); } await EmployeeSync.GetAllEmployeesAsnc(EmployeeCharacters, Empid); // not used //string condition = String.Format("{{\"_id\":\"{0}\"}}", "58fdd151c2ef16688202ffa8"); //Update the data working code //string condition = "58fde913bd966f74dc8f846d"; //string setValue = String.Format("{{\"$set\":{{\"LeaveStatus\":\"{0}\"}}}}", "4"); //await LeaveTransactionPost.LeaveTransactionPutAsync(condition, setValue); string EmpFirstName = ""; string EmpLastName = ""; string EmpDesignation = ""; string EmpReportingTo = ""; string EmpTeam = ""; string intitDeparturedate = ""; string intitDepartureHour = ""; string intitArrivaldate = ""; string intitArrivalHour = ""; string AppliedDate = ""; string AppliedTime = ""; string LeavePeriodF = ""; string LeaveType = ""; string Description = ""; string ApprovedBy = ""; string ApprovedDate = ""; string ApprovedTime = ""; string LeaveStatus = ""; string TransPkey = ""; string EmpPath = ""; EmpFirstName = EmployeeCharacters[0].EmpFirstName; EmpLastName = EmployeeCharacters[0].EmpLastName; EmpDesignation = EmployeeCharacters[0].EmpDesignation; EmpReportingTo = EmployeeCharacters[0].EmpReportingTo; EmpTeam = EmployeeCharacters[0].EmpTeam; EmpPath = EmployeeCharacters[0].EmpPath; intitDeparturedate = DateTimeToDateIndian.GetDateFromDateTime(DepartureDateCalendar.Date.Value.ToString("G")); intitDepartureHour = DeparturetimeComboBox.SelectionBoxItem.ToString(); intitArrivaldate = DateTimeToDateIndian.GetDateFromDateTime(ArrivalDateCalendar.Date.Value.ToString("G")); intitArrivalHour = ArrivaltimeComboBox.SelectionBoxItem.ToString(); AppliedDate = DateTimeToDateIndian.GetDateFromDateTime(DateTime.Now.ToString("G")); AppliedTime = DateTime.Now.ToString("hh:mm tt"); LeavePeriodF = GetNumberOfLeaveDays(intitDepartureHour, intitArrivalHour).ToString(); LeaveType = LeaveTypeComboBox.SelectionBoxItem.ToString(); Description = DescriptionTextBox.Text.ToString(); LeaveStatus = "1"; TransPkey = RandomNumGen.GenerateRandomNumber().ToString() + Empid; if (Convert.ToDouble(LeavePeriodF) > 0.5) { if (await LeaveTransactionGetPostPut.LeaveDataPostAsync ( TransPkey, Empid, EmpFirstName, EmpLastName, EmpDesignation, EmpReportingTo, EmpTeam, EmpPath, intitDeparturedate, intitDepartureHour, intitArrivaldate, intitArrivalHour, AppliedDate, AppliedTime, LeavePeriodF, LeaveType, Description, ApprovedBy, ApprovedDate, ApprovedTime, LeaveStatus ) == "OK") { var messageDialog = new MessageDialog("Applied sucessfully"); await messageDialog.ShowAsync(); DepartureDateCalendar.Date = DateTime.Now; ArrivalDateCalendar.Date = DateTime.Now.AddHours(24); DescriptionTextBox.Text = ""; LeaveTypeComboBox.SelectedIndex = 0; } else { var messageDialog = new MessageDialog("Not applied"); await messageDialog.ShowAsync(); } } else { Result.Text = "Your leave period less than half day,Please take oral approve"; } ProgressRingApply.IsActive = false; ProgressRingApply.Visibility = Visibility.Collapsed; ApplyButton.IsEnabled = true; }
/// <summary> /// Load la game précédemment sauvegardée (fichier local). /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void btn_Load_Tapped(object sender, TappedRoutedEventArgs e) { var helper = new LocalObjectStorageHelper(); Vaisseau tempVaisseau = new Vaisseau(); if (helper.KeyExists("vaisseau")) { tempVaisseau = helper.Read <Vaisseau>("vaisseau"); List <Membre> tempMembres = new List <Membre>(); for (int i = 0; i < 4; i++) { if (helper.KeyExists("membre" + i)) { tempMembres.Add(helper.Read <Membre>("membre" + i)); } } List <Module> tempModules = new List <Module>(); for (int i = 0; i < 7; i++) { if (helper.KeyExists("module" + i)) { tempModules.Add(helper.Read <Module>("module" + i)); } } int tempNumeroSemaine = 0; if (helper.KeyExists("numeroSemaine")) { tempNumeroSemaine = helper.Read <int>("numeroSemaine"); } bool tempHardMode = false; if (helper.KeyExists("hardMode")) { tempHardMode = helper.Read <bool>("hardMode"); } bool tempGameStarted = false; if (helper.KeyExists("gameStarted")) { tempGameStarted = helper.Read <bool>("gameStarted"); } int tempIndexCurrentClickMembre = 0; if (helper.KeyExists("indexCurrentClickMembre")) { tempIndexCurrentClickMembre = helper.Read <int>("indexCurrentClickMembre"); } int tempIndexCurrentClickModule = 0; if (helper.KeyExists("indexCurrentClickModule")) { tempIndexCurrentClickModule = helper.Read <int>("indexCurrentClickModule"); } CurrentParameters parameters = new CurrentParameters(tempMembres, tempModules, tempIndexCurrentClickMembre, tempIndexCurrentClickModule, tempHardMode, tempVaisseau, tempNumeroSemaine, tempGameStarted); this.Frame.Navigate(typeof(MainPage), parameters); } else { MessageDialog msgbox = new MessageDialog("Vous n'avez pas de partie sauvegardée"); await msgbox.ShowAsync(); } }
protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args) { base.OnBackgroundActivated(args); var deferral = args.TaskInstance.GetDeferral(); var helper = new LocalObjectStorageHelper(); if (args.TaskInstance.Task.Name == "FloatPlane.ContentChecker") { // Process is enabled if (helper.KeyExists(EnableDownload) && helper.Read(EnableDownload, false)) { var lastCheckTime = helper.Read(LastCheckTime, DateTime.UtcNow).ToLocalTime(); var source = new RecentVideoSource(); var downloader = new BackgroundDownloader(); // Check that a folder has been picked var folder = await Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.GetFolderAsync(SaveLocationFolder); if (folder != null) { // Get latest videos var videos = await source.GetPagedItemsAsync(0, 10); foreach (var videoModel in videos) { if (videoModel.Created <= lastCheckTime) { continue; } var fileName = videoModel.Title; // Remove invalid characters from title to use as a file name foreach (var c in Path.GetInvalidFileNameChars()) { if (!fileName.Contains(c.ToString())) { continue; } fileName = fileName.Remove(fileName.IndexOf(c), 1); } System.Diagnostics.Debug.WriteLine("NEW VIDEO: " + videoModel.Title); var file = await folder.CreateFileAsync(fileName + ".mp4", CreationCollisionOption.OpenIfExists); var remoteVideoFile = await VideoHelper.GetVideoStreamUrlAsync(videoModel, true); var operation = downloader.CreateDownload(new Uri(remoteVideoFile), file); // Construct the visuals of the toast var toastContent = new ToastContent { Visual = new ToastVisual { BindingGeneric = new ToastBindingGeneric { Children = { new AdaptiveText { Text = fileName }, new AdaptiveText { Text = "New Video! Saving to your library :)" }, new AdaptiveImage { Source = videoModel.ImageUrl } } } } }; // Show the toast var toast = new ToastNotification(toastContent.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toast); // Start downloading var progressCallback = new Progress <DownloadOperation>(ProgressCallback); await operation.StartAsync().AsTask(CancellationToken.None, progressCallback); } } else { System.Diagnostics.Debug.WriteLine("Folder is null"); } } } // Save the key helper.Save(LastCheckTime, DateTime.UtcNow); deferral.Complete(); }