Beispiel #1
0
 private static void SaveData(string filePath, AccountCollection sourceObj)
 {
     if (!string.IsNullOrEmpty(filePath) && sourceObj != null)
     {
         var json = NimUtility.Json.JsonParser.SerializeWithIndented(sourceObj);
         File.WriteAllText(filePath, json);
     }
 }
Beispiel #2
0
        public static void SaveLoginAccounts(AccountCollection collection)
        {
            var path = System.IO.Path.Combine(System.Environment.CurrentDirectory, SettingFilePath);

            foreach (var item in collection.List)
            {
                item.Password = DESEncrypt(item.Password, DESKey, DESIV);
            }
            SaveData(path, collection);
        }
Beispiel #3
0
        private static AccountCollection LoadData(string filePath)
        {
            AccountCollection result = null;

            if (File.Exists(filePath))
            {
                var content = File.ReadAllText(filePath);
                result = NimUtility.Json.JsonParser.Deserialize <AccountCollection>(content);
            }

            return(result);
        }
Beispiel #4
0
 private void InitLoginAccount()
 {
     _accounts = AccountManager.GetAccountList();
     if (_accounts != null)
     {
         foreach (var item in _accounts.List)
         {
             if (!UserNameComboBox.Items.Contains(item.Name))
             {
                 UserNameComboBox.Items.Add(item.Name);
             }
         }
         UserNameComboBox.Text = _accounts.List[_accounts.LastIndex].Name;
         textBox2.Text         = _accounts.List[_accounts.LastIndex].Password;
     }
 }
Beispiel #5
0
        private void SaveLoginAccount()
        {
            if (_accounts == null)
            {
                _accounts = new AccountCollection();
            }
            var index = _accounts.IndexOf(_userName);

            if (index != -1)
            {
                _accounts.List[index].Password = _password;
                _accounts.LastIndex            = index;
            }
            else
            {
                Account account = new Account();
                account.Name     = _userName;
                account.Password = _password;
                _accounts.List.Insert(0, account);
                _accounts.LastIndex = 0;
            }
            AccountManager.SaveLoginAccounts(_accounts);
        }