public async Task Export(StorageFile storageFile)
        {
            var jsonSerializerSettings = JsonStorage.GetJsonSerializerSettings();

            jsonSerializerSettings.Formatting = Formatting.Indented;
            var json = JsonConvert.SerializeObject(ProfilesList, jsonSerializerSettings);
            await FileIO.WriteTextAsync(storageFile, json);
        }
        public async Task Import(StorageFile storageFile)
        {
            var json = await FileIO.ReadTextAsync(storageFile);

            var newProfiles = JsonConvert.DeserializeObject <List <Profile> >(json,
                                                                              JsonStorage.GetJsonSerializerSettings());

            ProfilesList.Clear();
            _db.DropCollection(DbCollectionName);
            foreach (var newProfile in newProfiles)
            {
                ProfilesList.Add(newProfile);
            }
        }
Пример #3
0
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            var result = await MainWebView.InvokeScriptAsync("eval", new[] { ScriptBuilder.GetSaveScript() });

            List <List <ProfileField> > forms;

            try
            {
                forms = JsonConvert.DeserializeObject <List <List <ProfileField> > >(result,
                                                                                     JsonStorage.GetJsonSerializerSettings());
            }
            catch (JsonException)
            {
                await ShowDialog("Error", "Cannot save form.");

                return;
            }

            if (!forms.Any())
            {
                await ShowDialog("Forms not found", "We didn't find any forms that can be saved.");

                return;
            }

            var newSSid = await WifiInfo.GetSsid();

            if (!string.IsNullOrWhiteSpace(newSSid))
            {
                _currentSsid = newSSid;
            }
            var saveFormContentDialog = new SaveFormContentDialog(_currentSsid, forms);
            await saveFormContentDialog.ShowAsync();

            Page_Loaded(null, null);
        }