コード例 #1
0
ファイル: RockMobileUser.cs プロジェクト: J3057/MobileApp
                public void LoadFromDevice(  )
                {
                    // at startup, this should be called to allow current objects to be restored.
                    string filePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), MOBILEUSER_DATA_FILENAME);

                    // if the file exists
                    if (System.IO.File.Exists(filePath) == true)
                    {
                        // read it
                        using (StreamReader reader = new StreamReader(filePath))
                        {
                            // guard against corrupt data
                            string json = reader.ReadLine();
                            if (json != null)
                            {
                                try
                                {
                                    // guard against the mobile user model changing and the user having old data
                                    RockMobileUser loadedInstance = JsonConvert.DeserializeObject <RockMobileUser>(json) as RockMobileUser;
                                    if (_Instance.Version == loadedInstance.Version)
                                    {
                                        // temp upgrade: check for their cell phone number so we can set the HasCellPhoneNumber flag.
                                        if (string.IsNullOrEmpty(loadedInstance.CellPhoneNumberDigits( )) == false)
                                        {
                                            loadedInstance.HasCellNumber = true;
                                        }

                                        // as long as the versions match, we can take this.
                                        // We really don't want to bump up the version unless we HAVE to,
                                        // because it'll force them to re-sign in.
                                        _Instance = loadedInstance;
                                    }
                                }
                                catch (Exception e)
                                {
                                    Rock.Mobile.Util.Debug.WriteLine(string.Format("{0}", e));
                                }
                            }
                        }
                    }
                }
コード例 #2
0
ファイル: RockMobileUser.cs プロジェクト: jhawkzz/CCVApp
                public void LoadFromDevice(  )
                {
                    // at startup, this should be called to allow current objects to be restored.
                    string filePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), MOBILEUSER_DATA_FILENAME);

                    // if the file exists
                    if(System.IO.File.Exists(filePath) == true)
                    {
                        // read it
                        using (StreamReader reader = new StreamReader(filePath))
                        {
                            // guard against corrupt data
                            string json = reader.ReadLine();
                            if ( json != null )
                            {
                                try
                                {
                                    // guard against the mobile user model changing and the user having old data
                                    RockMobileUser loadedInstance = JsonConvert.DeserializeObject<RockMobileUser>( json ) as RockMobileUser;
                                    if( _Instance.Version == loadedInstance.Version )
                                    {
                                        _Instance = loadedInstance;
                                    }
                                }
                                catch( Exception e )
                                {
                                    Rock.Mobile.Util.Debug.WriteLine( string.Format( "{0}", e ) );
                                }
                            }
                        }
                    }
                }