using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WindowsFormsApp1.entity; using WindowsFormsApp1.entity.tb; namespace WindowsFormsApp1.utils { class TBAccountManager { //获取账号信息 public static List GetAccountList() { List list= SQLiteDataBaseUtil.getInstance().GetByTBUid(null); return list; } //登录成功 public static void LoginSuccess(int position, TBAccountLogin account) { SQLiteDataBaseUtil.getInstance().TBOnLine(account); if (!WindowsFormsApp1.utils.Constant.tbAccountMap.ContainsKey(position)|| WindowsFormsApp1.utils.Constant.tbAccountMap[position].Login==false) { //淘宝未授权的才显示 LogManager.AddLog(new LogInfo(DateTime.Now, "第" + position + "个淘宝账号(" + account.NickName + ")授权登录成功", LogInfo.TYPE_SAFE)); } if (WindowsFormsApp1.utils.Constant.tbAccountMap.ContainsKey(position)) { WindowsFormsApp1.utils.Constant.tbAccountMap.Remove(position); } WindowsFormsApp1.utils.Constant.tbAccountMap.Add(position, account); } public static void OFFLine(int index) { SQLiteDataBaseUtil.getInstance().TBOffLine(index); if (Constant.tbAccountMap.ContainsKey(index) && Constant.tbAccountMap[index].Login) { Constant.tbAccountMap[index].Login = false; Constant.tbAccountMap[index].UpdateTime = new DateTime(); LogManager.AddLog(new LogInfo(DateTime.Now, "第" + index + "个淘宝账号(" + Constant.tbAccountMap[index].NickName + ")授权登录失效", LogInfo.TYPE_SAFE)); } } public static void Delete(int index) { if (Constant.tbAccountMap.ContainsKey(index)) { TBAccountLogin account = Constant.tbAccountMap[index]; Constant.tbAccountMap.Remove(index); LogManager.AddLog(new LogInfo(DateTime.Now, "第" + index + "个淘宝账号(" + account.NickName + ")授权被删除", LogInfo.TYPE_NORMAL)); SQLiteDataBaseUtil.getInstance().TBDelete(index); } } public static bool IsHaveOffLine() { foreach (int key in Constant.tbAccountMap.Keys) { if (Constant.tbAccountMap != null && Constant.tbAccountMap[key].Login == false && !StringUtil.isEmpty(Constant.tbAccountMap[key].NickName)) return true; } return false; } } }