예제 #1
0
        public void WriteUser(string login, DateTime? expire)
        {
            CurrentUser = new User() { Login = login };
            Settings = new Settings() { LastUserName = login, LoginDate = DateTime.Now, Expire = expire ?? DateTime.Now };
            StorageLocalWrite(GetHashString(login), CurrentUser);
            StorageLocalWrite(Const.FileSettings, Settings);

        }
예제 #2
0
        public bool LoadLastUser()
        {
            Settings = StorageLocalRead<Settings>(Const.FileSettings);
            if (Settings != null && !string.IsNullOrWhiteSpace(Settings.LastUserName))
            {

                if (Settings.Expire > DateTime.Now)
                {
                    CurrentUser = StorageLocalRead<User>(GetHashString(Settings.LastUserName));
                    return true;
                }
                else
                {
                    CurrentUser = null;
                    Settings = null;
                }
            }

            return false;
        }
예제 #3
0
        public void ClearData()
        {
            if (!string.IsNullOrEmpty(Settings.LastUserName))
            {
                StorageLocalDelete(GetHashString(Settings.LastUserName));
            }
            CurrentUser = null;
            Settings = null;
            StorageLocalDelete(Const.FileSettings);

        }