private async Task BuildWebIdCache()
        {
            Dictionary<StreamsEnum, string> webIds = _sessionContext.UserContext.WebIDs;
            if (webIds == null)
            {
                string webID = await GetServerWebID();
                string nameFilter = string.Format("{0}.MobileData*", _sessionContext.UserContext.Username);

                HttpResponseMessage responseGetPoints = await _piWebClient.GetPoints(webID, nameFilter);

                dynamic valueResult;
                if (responseGetPoints.StatusCode == HttpStatusCode.Ok)
                {
                    using (StreamReader sr = new StreamReader((await responseGetPoints.Content.ReadAsInputStreamAsync()).AsStreamForRead()))
                    {
                        using (JsonTextReader jReader = new JsonTextReader(sr))
                        {
                            valueResult = JObject.ReadFrom(jReader);
                        }
                    }

                    IList<PointDTO> points = valueResult["Items"].ToObject<List<PointDTO>>();

                    ApplicationDataCompositeValue webIdsStored = new ApplicationDataCompositeValue();

                    foreach (var pt in points)
                    {
                        webIdsStored.Add(pt.Name, pt.WebId);
                    }

                    AppSettingsManager.Instance.LocalSettings.Containers["UserSettings"].AddOrUpdateValue("WebIds", webIdsStored);
                }
            
            }
        }
Exemple #2
0
        public static void SaveDataToAddress( string address, object data )
        {
            var state = new ApplicationDataCompositeValue();
            state["def"] = data;

            ApplicationData.Current.LocalSettings.Values[address] = state;
        }
Exemple #3
0
        public static void SavePuzzleState(SodukoPiece[,] p,int[,] originalState, int[,] currentPositions)
        {
            var state = new ApplicationDataCompositeValue();
            StringBuilder sb = new StringBuilder();
            foreach (SodukoPiece piece in p)
            {
                sb.Append(piece.GetInfoAsString());
            }

            state["Pieces"] = sb.ToString();

            sb.Clear();
            foreach (int i in originalState)
            {
                sb.Append(i.ToString());
                sb.Append(";");
            }

            state["OriginalState"] = sb.ToString();

            sb.Clear();
            foreach (int i in currentPositions)
            {
                sb.Append(i.ToString());
                sb.Append(";");
            }

            state["CurrentPos"] = sb.ToString();


            ApplicationData.Current.LocalSettings.Values["PuzzleState"] = state;
        }
 public override ApplicationDataCompositeValue Save()
 {
     ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();
     composite["name"] = "StackOverflowWidget";
     composite["source"] = Source;
     composite["site"] = Site;
     return composite;
 }
Exemple #5
0
 public static ApplicationDataCompositeValue GetCompositeValue(ApplicationDataContainer setting, string key)
 {
     ApplicationDataCompositeValue compositeValue = null;
     if (setting.Values.ContainsKey(key))
         compositeValue = setting.Values[key] as ApplicationDataCompositeValue;
     else
         compositeValue = new ApplicationDataCompositeValue();
     return compositeValue;
 }
Exemple #6
0
 public override ApplicationDataCompositeValue Save()
 {
     ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();
     composite["name"] = "WordpressWidget";
     composite["blog"] = Blog;
     composite["key"] = Key;
     composite["selection"] = mSelection.ToString();
     return composite;
 }
 public override void SaveSessionData(FacebookSession data)
 {
     var settings = ApplicationData.Current.RoamingSettings;
     var composite = new ApplicationDataCompositeValue();
     composite["AccessToken"] = data.AccessToken;
     composite["CurrentPermissions"] = string.Join(",", data.CurrentPermissions);
     composite["Expires"] = data.Expires.ToString();
     composite["FacebookId"] = data.FacebookId;
 }
Exemple #8
0
 public override ApplicationDataCompositeValue Save()
 {
     ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();
     composite["name"] = "CustomWidget";
     composite["widgetName"] = WidgetName;
     composite["url"] = URL;
     composite["data"] = Data;
     composite["title"] = Title;
     return composite;
 }
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);

            var settings = new ApplicationDataCompositeValue();
            settings["MenuState"] = _menuPanel.Visibility.ToString();
            settings["FavoritesState"] = _favoritesPanel.Visibility.ToString();
            _menuPanel.SaveSettings(settings);
            ApplicationData.Current.LocalSettings.Values["MainPageSettings"] = settings;
        }
        void WriteCompositeSetting_Click(Object sender, RoutedEventArgs e)
        {
            ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();
            composite[settingName1] = 1; // example value
            composite[settingName2] = "world"; // example value

            roamingSettings.Values[settingName] = composite;

            DisplayOutput();
        }
Exemple #11
0
 private UserSettings()
 {
     if (authSettings == null)
     {
         if (roamingSettings != null && roamingSettings.Values != null && roamingSettings.Values.ContainsKey(USER_AUTH_SETTINGS))
             authSettings = (ApplicationDataCompositeValue)roamingSettings.Values[USER_AUTH_SETTINGS];
         else
             authSettings = new Windows.Storage.ApplicationDataCompositeValue();
     }
 }
        public static ApplicationDataCompositeValue ConvertValueSetToApplicationDataCompositeValue(ValueSet valueSet)
        {
            ApplicationDataCompositeValue converted = new ApplicationDataCompositeValue();

            foreach (var value in valueSet)
            {
                converted[value.Key] = value.Value;
            }

            return converted;
        }
Exemple #13
0
        private static Dictionary<StreamsEnum, string> ConvertToDict(ApplicationDataCompositeValue webIds)
        {
            if (webIds == null) return null;

            Dictionary<StreamsEnum, string> webIdDict =  new Dictionary<StreamsEnum, string>();
            foreach (var setting in webIds)
            {
                webIdDict.Add(StreamsMapper.MapToEnum(setting.Key), setting.Value as string);
            }
            return webIdDict;
        }
 public void SaveSettings(ApplicationDataCompositeValue settings)
 {
     if (_lastButton != null)
     {
         settings["MenuButton"] = _lastButton.Tag;
     }
     else
     {
         settings["MenuButton"] = null;
     }
 }
 /// <summary>
 /// Установить куки.
 /// </summary>
 /// <param name="cookies">Куки.</param>
 /// <returns>Таск.</returns>
 public async Task SetCookies(Dictionary<string, string> cookies)
 {
     var composite = new ApplicationDataCompositeValue();
     if (cookies != null)
     {
         foreach (var kv in cookies)
         {
             composite[kv.Key] = kv.Value;
         }
     }
     Storage["EngineCookies"] = composite;
 }
 public override void SaveSessionData(AccessTokenData data)
 {
     var settings = ApplicationData.Current.LocalSettings;
     var composite = new ApplicationDataCompositeValue();
     composite["AccessToken"] = data.AccessToken;
     composite["AppId"] = data.AppId;
     composite["CurrentPermissions"] = string.Join(",", data.CurrentPermissions);
     composite["Expires"] = data.Expires.ToString();
     composite["Issued"] = data.Issued.ToString();
     composite["FacebookId"] = data.FacebookId;
     settings.Values[key] = composite;
 }
 /// <summary>
 /// Загрузить.
 /// </summary>
 public void Load()
 {
     if (container.Values.ContainsKey(Id))
     {
         compositeValue = container.Values[Id] as ApplicationDataCompositeValue;
     }
     if (compositeValue == null)
     {
         compositeValue = new ApplicationDataCompositeValue();
     }
     IsLoaded = true;
 }
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            bool suspending = ((App)App.Current).IsSuspending;

            if(suspending)
            {
                var composite = new ApplicationDataCompositeValue();
                composite["author"] = tbAuthor.Text;
                composite["comment"] = tbComment.Text;
                ApplicationData.Current.LocalSettings.Values["unsaved_data"] = composite;
            }
        }
 private void InitializeApplicationSettingsSections()
 {
     applicationData = ApplicationData.Current;
     localSettings = applicationData.LocalSettings;
     if (localSettings.Values["Credentials"] == null)
     {
         credentials = new Windows.Storage.ApplicationDataCompositeValue();
     }
     else
     {
         credentials = (ApplicationDataCompositeValue)localSettings.Values["Credentials"];
     }
 }
Exemple #20
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            var currentView = SystemNavigationManager.GetForCurrentView();
            currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
            currentView.BackRequested -= backButton_Tapped;

            //saving application data whenever the uer leaves the search for movie page
            var composite = new ApplicationDataCompositeValue();
            composite["movieSearch"] = SearchBox.Text;
            ApplicationData.Current.LocalSettings.Values["mainPage data"] = composite;

            base.OnNavigatedTo(e);
        }
Exemple #21
0
 public void UpdateCookies()
 {
     ApplicationDataCompositeValue cookiesComposite;
     if (!_setting.GetSetting(nameof(LoginUserInfo.Cookies), out cookiesComposite))
     {
         cookiesComposite = new ApplicationDataCompositeValue();
     }
     foreach (Cookie cookie in LoginUserInfo.Cookies)
     {
         cookiesComposite[cookie.Name] = cookie.Value;
     }
     _setting.SetSetting(nameof(LoginUserInfo.Cookies), cookiesComposite);
 }
Exemple #22
0
        private void LoadReviewStatus()
        {
            var roamingSettings = ApplicationData.Current.RoamingSettings;
            var reviewStatus = (ApplicationDataCompositeValue)roamingSettings.Values["reviewStatus"];

            if (reviewStatus == null)
            {
                reviewStatus = new ApplicationDataCompositeValue();
                reviewStatus["userReviewedApp"] = false;
                reviewStatus["userReviewAppLaunches"] = 0;
            }

            this.status = reviewStatus;
        }
Exemple #23
0
        public void SaveState()
        {
            var state = new ApplicationDataCompositeValue();
            StringBuilder sb = new StringBuilder();

            foreach(int i in _currentSolveState)
            {
                sb.Append(i);
                sb.Append(";");
            }
            string finalSaveData = sb.ToString();

            Serilizer.SaveDataToAddress(SAVE_ADDRESS, finalSaveData);
        }
Exemple #24
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            ((App)App.Current).BackRequested -= Page2_BackRequested;

            bool suspending = ((App)App.Current).IsSuspending;
            if (suspending)
            {
                // Save volatile state in case we get terminated later on, then
                // we can restore as if we'd never been gone :)
                var composite = new ApplicationDataCompositeValue();
                composite["Field1"] = textBox1.Text;
                composite["Field2"] = textBox2.Text;
                ApplicationData.Current.LocalSettings.Values["TheWorkInProgress"] = composite;
            }
        }
 public void RestoreSettings(ApplicationDataCompositeValue settings)
 {
     if (settings.ContainsKey("MenuButton"))
     {
         if (settings["MenuButton"] != null)
         {
             switch (settings["MenuButton"] as string)
             {
                 case "Search": _lastButton = _searchButton; _lastPanel = _searchPanel; break;
                 case "Bibles": _lastButton = _biblesButton; _lastPanel = _bibleListPanel; break;
                 case "BibleBooks": _lastButton = _biblesBookButton; _lastPanel = _bibleBookListPanel; break;
             }
             _lastButton.IsChecked = true;
             _lastPanel.Visibility = Visibility.Visible;
         }
     }
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
             //save navigation state and set back button event up
            var currentView = SystemNavigationManager.GetForCurrentView();
            currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            currentView.BackRequested += backButton_Tapped;
     
            //check to see if this is a new page load
            if (e.NavigationMode == NavigationMode.New)
            {
                //prepare local variable to hold new score data
                var newScore = new ApplicationDataCompositeValue();

                //check to see if new score data exists in storage
                if (ApplicationData.Current.LocalSettings.Values.ContainsKey("New Score Data"))
                {
                    //set the variablel to new score data
                    newScore = ApplicationData.Current.LocalSettings.Values["New Score Data"] as ApplicationDataCompositeValue;

                    //check to see if the same name has been entered twice
                    if (scoresAndName.ContainsKey(newScore["name"].ToString())){

                        //grab the current score from this already stored name
                        int checkScore = scoresAndName[newScore["name"].ToString()];
                        
                        //compare scores to see if new score is higher
                        if (checkScore < (int)newScore["score"])
                        {
                            //save new score
                            scoresAndName[newScore["name"].ToString()] = (int)newScore["score"];
                            ApplicationData.Current.LocalSettings.Values.Remove("New Score Data");
                        }
                    }
                    else {
                        //ignore new score
                        scoresAndName.Add(newScore["name"].ToString(), (int)newScore["score"]);
                        ApplicationData.Current.LocalSettings.Values.Remove("New Score Data");
                    }
                }
                //update score storage
                updateScoresStorage();
            }

            base.OnNavigatedTo(e);
        }
        async private void ReadSettings()
        {
            ApplicationDataCompositeValue values;

            try
            {
                Settings settings = await XmlIO.ReadObjectFromXmlFileAsync <Settings>(Settings.Path);

                values = settings;
            }
            catch (Exception)
            {
                values = new ApplicationDataCompositeValue();
                values = new Settings();
            }

            ApplicationData.Current.LocalSettings.Values["PlayerSettings"] = values;
        }
Exemple #28
0
        public void StoreTaskData(ApplicationDataContainer tasksContainer)
        {
            ApplicationDataCompositeValue currentTaskComposite = new ApplicationDataCompositeValue();

            currentTaskComposite["ID"]            = this.ID;
            currentTaskComposite["taskType"]      = (int)this.taskType;
            currentTaskComposite["repeatType"]    = (int)this.repeatType;
            currentTaskComposite["customRepeat"]  = "";
            currentTaskComposite["when"]          = DataStorageTransformations.DateTime_ToStorageString(this.when);
            currentTaskComposite["duration"]      = DataStorageTransformations.TimeSpan_ToStorageString(this.duration);
            currentTaskComposite["timeRemaining"] = DataStorageTransformations.TimeSpan_ToStorageString(this.timeRemaining);
            currentTaskComposite["required"]      = (int)this.required;
            currentTaskComposite["title"]         = this.title;
            currentTaskComposite["description"]   = this.description;
            currentTaskComposite["url"]           = this.url;
            currentTaskComposite["calendar"]      = this.calendar.StorageID();
            tasksContainer.Values[StorageID()]    = currentTaskComposite;
        }
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            if (((App)App.Current).issuspend)
            {
                ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();

                composite["seleted"]       = ViewModel.seleted;
                composite["seleted_item"]  = ViewModel.seleteItem;
                composite["title_right"]   = ViewModel.editing_item.Title;
                composite["content_right"] = ViewModel.editing_item.Content;
                composite["time_right"]    = ViewModel.editing_item.Plan_date;
                composite["img_right"]     = ViewModel.editing_item.ImageString;

                ApplicationData.Current.LocalSettings.Values["mainPage"] = composite;
            }

            DataTransferManager.GetForCurrentView().DataRequested -= OnShareDataRequested;
        }
Exemple #30
0
        public static void ResetCachedFileTimes()
        {
            ApplicationDataCompositeValue cachedFileTimes = null;

            var localSettings = ApplicationData.Current.LocalSettings;

            if (localSettings.Values.ContainsKey(CachedFileTimeName))
            {
                try
                {
                    cachedFileTimes = (ApplicationDataCompositeValue)localSettings.Values[CachedFileTimeName];
                    cachedFileTimes.Clear();
                    localSettings.Values[CachedFileTimeName] = cachedFileTimes;
                }
                catch (Exception)
                {
                }
            }
        }
Exemple #31
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            bool suspending = ((App)App.Current).issuspend;

            if (suspending)
            {
                ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();
                composite["title"]  = title.Text;
                composite["detail"] = detail.Text;
                composite["date"]   = date_picker.Date;
                for (int i = 0; i < ViewModel.AllItems.Count; ++i)
                {
                    composite["checked" + i] = ViewModel.AllItems[i].Completed;
                }
                ApplicationData.Current.LocalSettings.Values["mainPage"] = composite;
            }
            DataTransferManager.GetForCurrentView().DataRequested -= OnShareDataRequested;
            base.OnNavigatedFrom(e);
        }
Exemple #32
0
        public static void PutAccountBalances(Account account)
        {
            var value = new ApplicationDataCompositeValue();

            value["RD"] = account.RefreshDate == null ? (long?)null:account.RefreshDate.Value.ToBinary();
            value["RT"] = account.Token;
            if (account.Balance != null)
            {
                account.Balance.Serialize(value);
            }
            if (account.Balances != null)
            {
                foreach (IBalance balance in account.Balances)
                {
                    balance.Serialize(value);
                }
            }
            ApplicationData.Current.LocalSettings.Values[account.BalancesId] = value;
        }
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            var settings = new ApplicationDataCompositeValue();

            settings["gridSize"] = gridSize;

            if (radioButtonOther.IsChecked == true)
            {
                gridColor = colorPicker.SelectedColor.Color;
            }
            settings["gridColor"] = gridColor.ToString();
            ApplicationData.Current.LocalSettings.Values["settings"] = settings;

            // Must remove state if grid size is changed
            if (gridSize != origGridSize)
            {
                ApplicationData.Current.LocalSettings.Values.Remove("game");
            }
        }
Exemple #34
0
        // Save/Load application state section
        private async Task LoadAppState()
        {
            ApplicationDataContainer      roamingSettings = ApplicationData.Current.RoamingSettings;
            ApplicationDataCompositeValue composite       = (ApplicationDataCompositeValue)roamingSettings.Values["RoamingAppState"];

            if (composite != null)
            {
                partySize  = (int)composite["PartySize"];
                partyLevel = (int)composite["PartyLevel"];
                pageSize   = (int)composite["PageSize"];
            }

            // Preselect the ComboBox selected items
            PartySize.SelectedItem         = partySize;
            PartyMembersLevel.SelectedItem = partyLevel;
            PageSize.SelectedItem          = pageSize;

            try
            {
                StorageFolder applicationFolder = ApplicationData.Current.LocalFolder;
                StorageFile   lastEncounterFile = await applicationFolder.GetFileAsync("last_encounter.txt");

                var lastEncounterMonsters = await FileIO.ReadTextAsync(lastEncounterFile);

                dynamic deserializedMonsterList = JsonConvert.DeserializeObject(lastEncounterMonsters);

                foreach (var monster in deserializedMonsterList)
                {
                    MonsterEncounterList.Items.Add(new FullMonsterDetails(monster));
                }

                if (MonsterEncounterList.Items.Count > 0)
                {
                    ApplicationHelpText.Visibility = Visibility.Collapsed;
                }
            }
            catch
            {
                // if the file does not exist just skip this step
            }

            ComputeEncounterDifficulty();
        }
Exemple #35
0
 public DataSource()
 {
     myInstance    = this;
     localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
     composite     = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["exampleCompositeSetting"];
     if (composite == null)
     {
         composite = new Windows.Storage.ApplicationDataCompositeValue();
         fName     = "Damian";
         lName     = "Smug";
     }
     else
     {
         fName       = (string)composite["fname"];
         lName       = (string)composite["lname"];
         Summary     = "";
         lifeHistory = (string)composite["lifehistory"];
     }
 }
        /// <summary>
        /// LoadData from LocalSetting
        /// </summary>
        public string LoadData(string key)
        {
            string value = string.Empty;
            ApplicationDataCompositeValue dict       = null;
            ApplicationDataContainer      appsetting = ApplicationData.Current.RoamingSettings;

            if (appsetting.Values.ContainsKey(conCacheKey))
            {
                dict = (ApplicationDataCompositeValue)appsetting.Values[conCacheKey];
            }
            if (dict != null)
            {
                if (dict.ContainsKey(key))
                {
                    value = dict[key].ToString();
                }
            }
            return(value);
        }
        public bool SaveSettings(Settings settings)
        {
            try
            {
                var composite = new ApplicationDataCompositeValue();
                composite[IsVibrationEnabledKey]            = settings.IsVibrationEnabled;
                composite[IsNewsNotificationEnabledKey]     = settings.IsNewsNotificationEnabled;
                composite[IsReviewerNotificationEnabledKey] = settings.IsReviewerNotificationEnabled;

                var localSettings = ApplicationData.Current.LocalSettings;
                localSettings.Values[AppSettingsKey] = composite;

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #38
0
        public static void GetAccount(string id, out KXTNetStruct.LoginRequest package)
        {
            package = null;
            ApplicationDataContainer setting = ApplicationData.Current.LocalSettings;
            object obj = setting.Values["AccountList"];

            if (null != obj)
            {
                ApplicationDataCompositeValue accounts = (ApplicationDataCompositeValue)obj;
                string[] vs = (accounts[id] as string).Split(";");
                int.TryParse(vs[1], out int result);
                package = new KXTNetStruct.LoginRequest
                {
                    UserID     = id,
                    UserPW     = vs[0],
                    UserIDType = (LoginType)result
                };
            }
        }
Exemple #39
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            bool suspending = ((App)App.Current).issuspend;

            if (suspending)
            {
                ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();
                composite["title"]  = title.Text;
                composite["detail"] = detail.Text;
                composite["date"]   = datepick.Date;
                if (current != null)
                {
                    composite["create_date"] = current.create_date;
                }
                Singleton tmp = Singleton.Instance;
                composite["signal"] = tmp.get_signal();
                ApplicationData.Current.LocalSettings.Values["newpage"] = composite;
            }
        }
Exemple #40
0
        private async Task SaveAppState()
        {
            ApplicationDataContainer      roamingSettings = ApplicationData.Current.RoamingSettings;
            ApplicationDataCompositeValue composite       = new ApplicationDataCompositeValue
            {
                ["PartySize"]  = partySize,
                ["PartyLevel"] = partyLevel,
                ["PageSize"]   = pageSize
            };

            roamingSettings.Values["RoamingAppState"] = composite;

            if (MonsterEncounterList.Items.Count >= 0)
            {
                StorageFile lastEncounterFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("last_encounter.txt", CreationCollisionOption.ReplaceExisting);

                await FileIO.WriteTextAsync(lastEncounterFile, JsonConvert.SerializeObject(MonsterEncounterList.Items));
            }
        }
Exemple #41
0
        /// <summary>
        /// Slaat bepaalde gegevens op in de AppSettings met een sleutel als referentie
        /// </summary>
        /// <param name="sleutel">Referentie</param>
        /// <param name="waarde">Object met waarde</param>
        public void SlaGegevensOp(string sleutel, object waarde)
        {
            List <string> objecten;
            object        waarden;

            try
            {
                objecten = (List <string>)waarde;
                waarden  = new ApplicationDataCompositeValue();
                for (int teller = 0; teller < objecten.Count; teller++)
                {
                    ((ApplicationDataCompositeValue)waarden)[teller.ToString()] = objecten[teller].ToString();
                }
            }
            catch (InvalidCastException)
            {
                waarden = waarde.ToString();
            }

            try
            {
                if (!localSettings.Containers.ContainsKey("AppSettings"))
                {
                    container = localSettings.CreateContainer("AppSettings", Windows.Storage.ApplicationDataCreateDisposition.Always);
                }

                if (localSettings.Containers.ContainsKey("AppSettings"))
                {
                    if (localSettings.Containers["AppSettings"].Values.ContainsKey(sleutel))
                    {
                        localSettings.Containers["AppSettings"].Values[sleutel] = waarden;
                    }
                    else
                    {
                        localSettings.Containers["AppSettings"].Values.Add(sleutel, waarden);
                    }
                }
            }
            catch (Exception ex)
            {
                paLogging.log.Error(String.Format("Gegevens voor {0} konden niet opgeslaan worden.\n{1}", sleutel, ex.Message));
            }
        }
Exemple #42
0
        /// <summary>
        /// LoadData from LocalSetting
        /// </summary>
        public object LoadData(string key)
        {
            object value = null;
            ApplicationDataCompositeValue dict       = null;
            ApplicationDataContainer      appsetting = ApplicationData.Current.LocalSettings;

            if (appsetting.Values.ContainsKey(conCacheKey))
            {
                dict = (ApplicationDataCompositeValue)appsetting.Values[conCacheKey];
            }
            if (dict != null)
            {
                if (dict.ContainsKey(key))
                {
                    value = dict[key].ToString();
                }
            }
            return(value);
        }
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            bool suspending = ((App)App.Current).issuspend;

            if (suspending)
            {
                ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();
                if (PageView != null && PageView.Content != null)
                {
                    ApplicationData.Current.LocalSettings.Values["pageNavigationState"] = PageView.GetNavigationState();
                }

                if (ViewModel.selectedItem != null)
                {
                    ApplicationData.Current.LocalSettings.Values["selected"] = ViewModel.selectedItem.id;
                }
            }
            base.OnNavigatedFrom(e);
        }
        public static void SetNotificationsEnabled(bool enabled)
        {
            var settings = ApplicationData.Current.LocalSettings;

            settings.Values[DISABLED_KEY] = !enabled;

            if (!enabled)
            {
                ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();
                foreach (var it in toastNotifier.GetScheduledToastNotifications())
                {
                    toastNotifier.RemoveFromSchedule(it);
                }

                long currentTime = GetCurrentUnixTimeSeconds();
                foreach (var it in new List <string>(settings.Values.Keys))
                {
                    if (it.StartsWith(STORE_KEY_PREFIX))
                    {
                        ApplicationDataCompositeValue registeredNotification = (ApplicationDataCompositeValue)settings.Values[it];
                        int intervalSeconds = (int)registeredNotification["intervalSeconds"];
                        if (intervalSeconds > 0)
                        {
                            //Repeated
                            int lastTriggerInSecondsFromNow = (int)((long)registeredNotification["lastTriggerInSeconds"] - currentTime);
                            lastTriggerInSecondsFromNow %= intervalSeconds;
                            if (lastTriggerInSecondsFromNow > 0)
                            {
                                lastTriggerInSecondsFromNow -= intervalSeconds;
                            }

                            registeredNotification["lastTriggerInSeconds"] = currentTime + lastTriggerInSecondsFromNow;
                            settings.Values[it] = registeredNotification;
                        }
                    }
                }
            }
            else
            {
                Reschedule(true);
            }
        }
        /// <summary>
        /// Сохраняет данные авторизаии в настройки
        /// </summary>
        /// <param name="accessToken">Токен доступа</param>
        /// <param name="refreshToken">Токен обновления</param>
        /// <param name="secondsToExpiration">Время жизни токена доступа (в секундах)</param>
        public static void SaveAuthData(
            string accessToken,
            string refreshToken,
            int secondsToExpiration)
        {
            var composite = new ApplicationDataCompositeValue();

            composite[SettingsConstants.AuthAccessToken]  = accessToken;
            composite[SettingsConstants.AuthRefreshToken] = refreshToken;

            var accessTokenExpiration = DateTimeOffset.Now.AddSeconds(secondsToExpiration);

            composite[SettingsConstants.AuthAccessTokenExpiration] = accessTokenExpiration;

            var refreshTokenExpiration = DateTimeOffset.Now.AddMonths(1);

            composite[SettingsConstants.AuthRefreshTokenExpiration] = refreshTokenExpiration;

            SettingsManager.SetLocalCompositeContainer(SettingsConstants.AuthData, composite);
        }
Exemple #46
0
        public void UpdateLoginUserInfo(string userName, string password, bool isRemerber = false, Cookie cookie = null)
        {
            LoginUserInfo.UserName   = userName;
            LoginUserInfo.Password   = password;
            LoginUserInfo.IsRemerber = isRemerber;
            ApplicationDataCompositeValue composite;

            if (!_setting.GetSetting(nameof(LoginUserInfo), out composite))
            {
                composite = new ApplicationDataCompositeValue();
            }
            composite[nameof(LoginUserInfo.UserName)]   = userName;
            composite[nameof(LoginUserInfo.Password)]   = password;
            composite[nameof(LoginUserInfo.IsRemerber)] = isRemerber;
            if (cookie != null)
            {
                UpdateCookies(cookie);
            }
            _setting.SetSetting(nameof(LoginUserInfo), composite);
        }
Exemple #47
0
        public static void StartServers()
        {
            ReloadServersFromConfig();
            started = true;
            Database.InitializeDatabase("mCPPS.db");

            foreach (MattsCPPS server in servers)
            {
                server.StartServer();
            }

            ApplicationDataCompositeValue webServer = (ApplicationDataCompositeValue)configuration_settings.Values["WebServer"];

            if ((bool)webServer["enabled"])
            {
                HTTP http = new HTTP("DefaultHTTP", (string)webServer["port"]);
                http.StartServer();
                servers.Add(http);
            }
        }
Exemple #48
0
        public void UpdateLogout()
        {
            ApplicationDataCompositeValue cookiesComposite;

            if (_setting.GetSetting(nameof(LoginUserInfo.Cookies), out cookiesComposite))
            {
                cookiesComposite = null;
            }
            _setting.SetSetting(nameof(LoginUserInfo.Cookies), cookiesComposite);

            ApplicationDataCompositeValue composite;

            if (!_setting.GetSetting(nameof(LoginUserInfo), out composite))
            {
                composite = new ApplicationDataCompositeValue();
            }
            composite[nameof(LoginUserInfo.Blogger.BlogApp)] = null;
            composite[nameof(LoginUserInfo.Blogger.Guid)]    = null;
            _setting.SetSetting(nameof(LoginUserInfo), composite);
        }
Exemple #49
0
        private void SaveData()
        {
            if (_wasGameBeaten)
            {
                return;
            }
            if (_hasInitialized)
            {
                return;
            }
            // Save the page data.
            var adcv = new ApplicationDataCompositeValue();

            adcv["SecondsTicking"] = _secondsTicking;
            adcv["Difficulty"]     = (int)_difficulty;
            ApplicationData.Current.LocalSettings.Values["AppData"] = adcv;

            // Save the puzzle specific data.
            _puzzle.SaveState();
        }
        public static async Task <List <Tuple <int, string> > > GetAllEvents()
        {
            List <Tuple <int, string> > events = new List <Tuple <int, string> >();

            Debug.WriteLine(UserAccount.getSetting("calendars"));
            ApplicationDataCompositeValue cals = (ApplicationDataCompositeValue)UserAccount.getSetting("calendars");

            if (cals == null)
            {
                cals = new ApplicationDataCompositeValue();
            }
            foreach (KeyValuePair <String, Object> cal in cals)
            {
                if ((bool)cal.Value && cal.Key != "#[email protected]" && cal.Key != "*****@*****.**" && cal.Key != "en.usa#[email protected]")
                {
                    events.AddRange(await GetEvents(cal.Key));
                }
            }
            return(events);
        }
Exemple #51
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            bool suspending = ((App)App.Current).isSuspending;

            if (suspending)
            {
                ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();

                //保存窗口大小和状态
                if (Window.Current.Bounds.Width >= 800)
                {
                    state = stateAllView;
                }
                composite["state"] = state;

                //记录要序列化的数据
                int count = ViewModels.AllItems.Count;
                composite["count"]    = count;
                composite["selected"] = -1;
                for (int i = 0; i < count; i++)
                {
                    if (ViewModels.SelectedItem != null && ViewModels.SelectedItem.Id == ViewModels.AllItems[i].Id)
                    {
                        composite["selected"] = i;
                    }
                    composite["id" + i]          = ViewModels.AllItems[i].Id;
                    composite["title" + i]       = ViewModels.AllItems[i].Title;
                    composite["description" + i] = ViewModels.AllItems[i].Description;
                    composite["completed" + i]   = ViewModels.AllItems[i].Completed;
                    composite["date" + i]        = ViewModels.AllItems[i].Date;
                    composite["imageType" + i]   = ViewModels.AllItems[i].ImageType;
                }

                composite["editId"]          = EditItem.latestInstance.Id;
                composite["editTitle"]       = EditItem.latestInstance.Title;
                composite["editDescription"] = EditItem.latestInstance.Description;
                composite["editDate"]        = EditItem.latestInstance.Date;

                ApplicationData.Current.LocalSettings.Values["newPage"] = composite;
            }
        }
Exemple #52
0
        /// <summary>
        /// Gets a list of when each different bookmark file was read in last. This lets us
        /// efficiently keep all bookmark files up to date without having to constantly
        /// reread all of them. See also the Reset and the Save items
        /// </summary>
        /// <returns></returns>

        public static Dictionary <string, DateTimeOffset> GetCachedFileTimes()
        {
            var retval = new Dictionary <string, DateTimeOffset>();
            ApplicationDataCompositeValue cachedFileTimes = null;

            var localSettings = ApplicationData.Current.LocalSettings;

            if (localSettings.Values.ContainsKey(CachedFileTimeName))
            {
                try
                {
                    cachedFileTimes = (ApplicationDataCompositeValue)localSettings.Values[CachedFileTimeName];
                }
                catch (Exception)
                {
                    App.Error($"Getting last read file time cache for all files isn't a Composite value?");
                }
            }

            // On error, just completely reset the file times cache.
            if (cachedFileTimes == null)
            {
                cachedFileTimes = new ApplicationDataCompositeValue();
                localSettings.Values[CachedFileTimeName] = cachedFileTimes;
            }
            else
            {
                foreach (var(name, value) in cachedFileTimes)
                {
                    try
                    {
                        retval[name] = (DateTimeOffset)value;
                    }
                    catch (Exception ex)
                    {
                        App.Error($"Getting last read file time cache for all files isn't a DateTimeOffset value for {name}=={value} exception {ex.Message}?");
                    }
                }
            }
            return(retval);
        }
Exemple #53
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            bool issuspend = ((App)App.Current).issuspend;

            if (issuspend)
            {
                ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();
                composite["title"]    = title.Text;
                composite["detail"]   = detail.Text;
                composite["Path"]     = path;
                composite["date"]     = date.Date;
                composite["MySlider"] = MySlider.Value;
                composite["isDelete"] = isDelete;
                ApplicationData.Current.LocalSettings.Values["NewPage"] = composite;
            }
            if (one.selectedItem != null)
            {
                ApplicationData.Current.LocalSettings.Values["selectItem"] = one.selectedItem.id;
            }
            DataTransferManager.GetForCurrentView().DataRequested -= OnShareDataRequested;
        }
        public static void ToggleFavourite(IExampleInfo exampleInfo)
        {
            var favorites = ApplicationData.Current.RoamingSettings.Values;

            string exampleName      = exampleInfo.Name;
            string controlName      = exampleInfo.ExampleGroup.Control.Name;
            string exampleUniqueKey = controlName + "|" + exampleName;

            if (favorites[exampleUniqueKey] != null)
            {
                // there is an example here added with that name and control, so remove it
                favorites.Remove(exampleUniqueKey);
                return;
            }

            ApplicationDataCompositeValue compositeValue = new ApplicationDataCompositeValue();

            compositeValue["ExampleName"] = exampleName;
            compositeValue["ControlName"] = controlName;
            favorites[exampleUniqueKey]   = compositeValue;
        }
Exemple #55
0
        internal static void SetCacheValue(ApplicationDataCompositeValue composite, string stringValue)
        {
            byte[] encryptedValue = CryptographyHelper.Encrypt(stringValue.ToByteArray());
            composite[CacheValueLength] = encryptedValue.Length;

            int segmentCount = (encryptedValue.Length / MaxCompositeValueLength) +
                               ((encryptedValue.Length % MaxCompositeValueLength == 0) ? 0 : 1);

            byte[] subValue = new byte[MaxCompositeValueLength];
            for (int i = 0; i < segmentCount - 1; i++)
            {
                Array.Copy(encryptedValue, i * MaxCompositeValueLength, subValue, 0, MaxCompositeValueLength);
                composite[CacheValue + i] = subValue;
            }

            int copiedLength = (segmentCount - 1) * MaxCompositeValueLength;

            Array.Copy(encryptedValue, copiedLength, subValue, 0, encryptedValue.Length - copiedLength);
            composite[CacheValue + (segmentCount - 1)] = subValue;
            composite[CacheValueSegmentCount]          = segmentCount;
        }
Exemple #56
0
        private bool isPlayerPresent(string mcid)
        {
            ApplicationDataContainer database = ApplicationData.Current.LocalSettings;

            var playerContainer = database.Containers["key"];


            ApplicationDataCompositeValue data = (ApplicationDataCompositeValue)playerContainer.Values[mcid];


            bool isPlayerExists = data != null;

            if (isPlayerExists)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #57
0
        /// <summary>
        /// Slaat bepaalde gegevens op in de AppSettings met een sleutel als referentie
        /// </summary>
        /// <param name="sleutel">Referentie</param>
        /// <param name="waarde">Object met waarde</param>
        public void SlaGegevensOp(string sleutel, object waarde)
        {
            List<string> objecten;
            object waarden;
            try
            {
                objecten = (List<string>)waarde;
                waarden = new ApplicationDataCompositeValue();
                for (int teller = 0; teller < objecten.Count; teller++)
                {
                    ((ApplicationDataCompositeValue)waarden)[teller.ToString()] = objecten[teller].ToString();
                }
            }
            catch (InvalidCastException)
            {
                waarden = waarde.ToString();
            }

            try
            {
                if (!localSettings.Containers.ContainsKey("AppSettings"))
                {
                    container = localSettings.CreateContainer("AppSettings", Windows.Storage.ApplicationDataCreateDisposition.Always);
                }

                if (localSettings.Containers.ContainsKey("AppSettings"))
                {
                    if (localSettings.Containers["AppSettings"].Values.ContainsKey(sleutel))
                        localSettings.Containers["AppSettings"].Values[sleutel] = waarden;
                    else
                        localSettings.Containers["AppSettings"].Values.Add(sleutel, waarden);
                }
            }
            catch (Exception ex)
            {
                paLogging.log.Error(String.Format("Gegevens voor {0} konden niet opgeslaan worden.\n{1}", sleutel, ex.Message));
            }
        }
 public void Write(ApplicationDataCompositeValue composite, string key)
 {
     roamingSettings.Values[key] = composite;
 }
Exemple #59
0
 public override ApplicationDataCompositeValue Save()
 {
     ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();
     composite["name"] = "RedditWidget";
     return composite;
 }
 /// <summary>
 /// Установить значение.
 /// </summary>
 /// <param name="value">Значение.</param>
 protected override void SetValue(ApplicationDataCompositeValue value)
 {
     ApplicationData.Current.LocalSettings.Values["MakabaEngine"] = value;
 }