48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using AllBase;
|
|
|
|
namespace Work
|
|
{
|
|
public class AddressSetIni
|
|
{
|
|
public static Dictionary<int, List<AddressBase>> Addresses = new Dictionary<int, List<AddressBase>>();
|
|
public static List<AddressBase> AddressList = new List<AddressBase>();
|
|
public void Ini()
|
|
{
|
|
string file = FileBase.ReadAllText("taobao_address.tjm", Encoding.UTF8);
|
|
if (string.IsNullOrEmpty(file))
|
|
{
|
|
MessageBox.Show("初始化淘宝地址信息错误,请检查网络", "提示");
|
|
return;
|
|
}
|
|
var m = BaseRegex.GetMatchRegex(ref file, @"\[""([\d]+)"",\[""([^""]+?)"",""[^""]+?""\],""([\d]+)""");
|
|
for (int i = 0; i < m.Count; i++)
|
|
{
|
|
AddressBase a = new AddressBase();
|
|
a.Id = int.Parse(m[i].Groups[1].Value);
|
|
a.Name = m[i].Groups[2].Value;
|
|
a.UpId = int.Parse(m[i].Groups[3].Value);
|
|
AddressList.Add(a);
|
|
if (!Addresses.ContainsKey(a.Id))
|
|
Addresses.Add(a.Id, new List<AddressBase>());
|
|
if (!Addresses.ContainsKey(a.UpId))
|
|
Addresses.Add(a.UpId, new List<AddressBase>());
|
|
Addresses[a.UpId].Add(a);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class AddressBase
|
|
{
|
|
public int Id = 0;
|
|
public string Name = "";
|
|
public int UpId = 0;
|
|
//public Dictionary<int, AddressBase> Address = new Dictionary<int, AddressBase>();
|
|
}
|
|
}
|