async public static Task <ResumeOperationResult> SaveResumeAsync(Resume resume,
                                                                         CreationCollisionOption creation_option = CreationCollisionOption.OpenIfExists)
        {
            await CreateOrOpenFolder("resumes");

            ResumeOperationResult result = ResumeOperationResult.Success;


            if (resume.Name != null)
            {
                //write model string to file
                var file = await ApplicationData.Current
                           .RoamingFolder
                           .CreateFileAsync($"resumes\\{resume.ResumeID}.resume", creation_option);

                await file.WriteTextAsync(resume.AsSerializedString());

                var total_storage = await AppStorageManager.GetTotalStorage();

                if (total_storage > ApplicationData.Current.RoamingStorageQuota)
                {
                    result = ResumeOperationResult.SuccessOverLimit;
                }
            }
            else
            {
                throw new Exception("Resume objects require a name.");
            }
            return(result);
        }
        async public static Task <ResumeOperationResult> CheckStorage()
        {
            ResumeOperationResult result = ResumeOperationResult.Success;
            var total_storage            = await AppStorageManager.GetTotalStorage();

            if (total_storage > ApplicationData.Current.RoamingStorageQuota)
            {
                result = ResumeOperationResult.SuccessOverLimit;
            }
            return(result);
        }
예제 #3
0
        async private void RemoveResume(object sender, RoutedEventArgs e)
        {
            var resume_list = await AppStorageManager.ListResumes();

            var oldest_resume = resume_list.LastOrDefault();

            var result = await AppStorageManager.
                         DeleteResume(oldest_resume);

            _count--;
            await RefreshUIAsync(result);
        }
예제 #4
0
        async private void AddResume(object sender, RoutedEventArgs e)
        {
            var result = await AppStorageManager.
                         SaveResumeAsync(new Resume()
            {
                Name = $"Resume {_count}"
            });

            _count++;

            await RefreshUIAsync(result);
        }
예제 #5
0
        async Task RefreshUIAsync(ResumeOperationResult?result = null)
        {
            var app_view    = ApplicationView.GetForCurrentView();
            var resume_list = await AppStorageManager.ListResumes();

            app_view.Title = $"{resume_list.Count} resumes, {(await AppStorageManager.GetTotalStorage())} KB, QUOTA={ApplicationData.Current.RoamingStorageQuota} KB";
            Resumes        = resume_list;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Resumes"));

            if (result != null)
            {
                if (result == ResumeOperationResult.SuccessOverLimit)
                {
                    app_view.TitleBar.BackgroundColor = Windows.UI.Colors.Red;
                }
                else
                {
                    app_view.TitleBar.BackgroundColor = null;
                }
            }
        }
        async public static Task <ResumeOperationResult> DeleteResume(Resume resume)
        {
            ResumeOperationResult result = ResumeOperationResult.Success;

            try
            {
                await resume.DeleteAsync();

                var total_storage = await AppStorageManager.GetTotalStorage();

                if (total_storage > ApplicationData.Current.RoamingStorageQuota)
                {
                    result = ResumeOperationResult.SuccessOverLimit;
                }
            }
            catch (Exception ex)
            {
                result = ResumeOperationResult.Failure;
            }
            return(result);
        }
예제 #7
0
        async private void ImportResume(object sender, RoutedEventArgs e)
        {
            var app_view = ApplicationView.GetForCurrentView();

            FileOpenPicker opener = new FileOpenPicker();

            opener.ViewMode = PickerViewMode.Thumbnail;
            opener.SuggestedStartLocation = PickerLocationId.Desktop;
            opener.CommitButtonText       = "Import the resume";
            opener.FileTypeFilter.Add(".resume");
            var selected_file = await opener.PickSingleFileAsync();

            if (selected_file != null)
            {
                //read and deserialize resume
                var resume = await Resume.FromStorageFileAsync(selected_file);

                if (resume == null)
                {
                    MessageDialog md = new MessageDialog("Cannot read resume data.");
                    await md.ShowAsync();

                    return;
                }

                //name resume
                var new_resume_id         = Guid.NewGuid().ToString();
                int current_storage_count = (await AppStorageManager.ListResumes()).Count;
                resume.Name     = $"resume import [{new_resume_id}]";
                resume.ResumeID = new_resume_id;


                //now store the resume in AppData
                var result = await AppStorageManager.
                             SaveResumeAsync(resume, CreationCollisionOption.GenerateUniqueName);
                await RefreshUIAsync(result);
            }
        }
예제 #8
0
 async private void LandingPage_Loaded(object sender, RoutedEventArgs e)
 {
     _count = (await AppStorageManager.ListResumes()).Count;
     await RefreshUIAsync();
 }
예제 #9
0
        async private void ClearLibrary(object sender, RoutedEventArgs e)
        {
            await AppStorageManager.ClearStorageAsync();

            await RefreshUIAsync();
        }
        async private void ResumeFilePicker_Loaded(object sender, RoutedEventArgs e)
        {
            Resumes = await AppStorageManager.ListResumes();

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Resumes"));
        }