-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathAccountHelp.cs
86 lines (73 loc) · 2.39 KB
/
AccountHelp.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Text.Json;
namespace JD_Get
{
public class AccountHelp
{
public class Account {
public string Login { set; get; }
public string Password { set; get; }
public string Memo { set; get; }
public override string ToString()
{
return Login+" "+Memo;
}
}
public static List<Account> GetAccounts() {
//var list = GetAccountsStr().Split(new[] { "\r\n" }, StringSplitOptions.None);
try
{
var list = JsonSerializer.Deserialize<List<Account>>(GetAccountsStr());
list.Insert(0,new Account());
return list;
}
catch
{
return new List<Account>();
}
}
public static string GetAccountsStr()
{
return ConfigHelp.GetConfig("newAccountList");
}
public static void SaveAccountsStr(string text)
{
ConfigHelp.SetSetting("newAccountList", text);
}
/// <summary>
/// 从老数据格式
/// </summary>
/// <param name="text"></param>
public static void FormatFromAccountsStr()
{
var list = ConfigHelp.GetConfig("AccountList").Split(new[] { "\r\n" }, StringSplitOptions.None);
List<Account> account = new List<Account>() { new Account() { } };
foreach (var item in list) {
//var list = GetAccountsStr().Split(new[] { "\r\n" }, StringSplitOptions.None);
if (string.IsNullOrEmpty(item)) continue;
var info = item.Split(' ');
Account a = new Account();
if (info.Length > 0)
{
a.Login = info[0];
}
if (info.Length > 1)
{
a.Password = info[1];
}
else
{
a.Password = "";
}
account.Add(a);
}
SaveAccountsStr( JsonSerializer.Serialize(account));
}
}
}