Files
kami_itunes_june/AppleBatch_June.Interfaces/iTunesAccountDisabled.cs
2024-07-22 00:43:14 +08:00

62 lines
2.1 KiB
C#

using System;
using AppleBatch_June.ExecuteTasks;
using AppleBatch_June.Model;
using AppleBatch_June.Utils;
namespace AppleBatch_June.Interfaces
{
public class iTunesAccountDisabled : IAccountDisabled
{
private Action<string, DisplyType, string> action;
private Action<string, DisplyType, string> applyAtion;
public ITaskRunState taskState;
private bool openVpn { get; set; }
public iTunesAccountDisabled(bool _openVpn, Action<string, DisplyType, string> _action, Action<string, DisplyType, string> _applyAtion, ITaskRunState _taskState)
{
taskState = _taskState ?? throw new Exception("任务运行状态不能是空的");
openVpn = _openVpn;
action = _action;
applyAtion = _applyAtion;
}
public bool accountCheck(string account, string pwd, string notityKey)
{
ItunesUtlis itunesUtlis = new ItunesUtlis(taskState, notityKey, action, openVpn);
string msgReust = "";
if (string.IsNullOrEmpty(itunesUtlis.ProxyIp))
{
itunesUtlis.ProxyIp = ProxyAccountCache.getProxyAccountIP(account);
}
AppleItunesLogin appleItunesLogin = null;
appleItunesLogin = ((!AppSysConfig.iTunesisRemoteLogin) ? itunesUtlis.appleLogin(account, pwd, 1, ref msgReust, out var _) : itunesUtlis.remoteAppleLogin(account, pwd, ref msgReust));
if (appleItunesLogin == null)
{
action?.Invoke(notityKey, DisplyType.xinxi, msgReust);
return false;
}
action?.Invoke(notityKey, DisplyType.area, appleItunesLogin.Area.ToString());
action?.Invoke(notityKey, DisplyType.xinxi, "登录完成,正在检测");
DisplyState displyState = ((!(appleItunesLogin.isDisabledAccount.ToLower() == "true")) ? DisplyState.None : DisplyState.Disply);
action?.Invoke(notityKey, DisplyType.xinxi, "查询完成");
switch (displyState)
{
default:
return false;
case DisplyState.Disply:
applyAtion?.Invoke(notityKey, DisplyType.forbidden, "禁用");
return true;
case DisplyState.None:
applyAtion?.Invoke(notityKey, DisplyType.normal, "正常");
return true;
case DisplyState.Unknown:
action?.Invoke(notityKey, DisplyType.xinxi, "未知异常,请重新检测");
return true;
}
}
}
}