mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 21:21:34 +00:00
166 lines
4.7 KiB
C#
166 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
using AppleBatch_June.AppleWebServace;
|
|
using AppleBatch_June.Model;
|
|
using AppleBatch_June.StartTaskModel;
|
|
using DotNet.Utilities;
|
|
|
|
namespace AppleBatch_June.ExecuteTasks
|
|
{
|
|
public class OpenAuthenTask : BaseTask
|
|
{
|
|
public static OpenAuthenTask Instance { get; private set; }
|
|
|
|
static OpenAuthenTask()
|
|
{
|
|
Instance = new OpenAuthenTask("开通双重认证");
|
|
}
|
|
|
|
public OpenAuthenTask(string _taskName)
|
|
: base(_taskName)
|
|
{
|
|
}
|
|
|
|
public void AppleOpenAuthenTask(int TaskSize, string countryCode, string countryValue, string mode, bool openVpn, List<AppleAcount> lvItems, Action startAct, Action endTakAct, Action<string> sucessAct, Action<string, DisplyType, string> _action, Func<string, int, string> actGetCode)
|
|
{
|
|
TaskSize = Tools.getTaskSize(openVpn, lvItems.Count);
|
|
if (!base.isRun)
|
|
{
|
|
AppleExecuteTask.TaskRunAppleIdCount = 0L;
|
|
AppleExecuteTask.TaskRunModels.Clear();
|
|
startAct?.Invoke();
|
|
base.isRun = true;
|
|
Task.Run(delegate
|
|
{
|
|
ApiNetReq.startNowFun = 21;
|
|
base.TaskIsRun = true;
|
|
base.baseEndTakAct = endTakAct;
|
|
Task[] array = new Task[TaskSize];
|
|
for (int i = 0; i < TaskSize; i++)
|
|
{
|
|
array[i] = Task.Run(delegate
|
|
{
|
|
string guid = Guid.NewGuid().ToString("n");
|
|
TaskRunModel taskRunModel = new TaskRunModel
|
|
{
|
|
guid = guid,
|
|
isRuning = false
|
|
};
|
|
AppleExecuteTask.TaskRunModels.Add(taskRunModel);
|
|
while (base.isRun)
|
|
{
|
|
AppleAcount appleAcount = null;
|
|
try
|
|
{
|
|
lock (lvItems)
|
|
{
|
|
appleAcount = lvItems.Where((AppleAcount c) => !c.isAct).FirstOrDefault();
|
|
if (appleAcount == null)
|
|
{
|
|
break;
|
|
}
|
|
appleAcount.isAct = true;
|
|
}
|
|
string guidTag = appleAcount.guidTag;
|
|
if (BaseTask.startRuning(taskRunModel, _action, guidTag))
|
|
{
|
|
_action?.Invoke(guidTag, DisplyType.xinxi, "正在处理");
|
|
HttpResult isLogin = APIUtlis.getIsLogin(21);
|
|
if (isLogin.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
object obj = Tools.Todejosn<object>(isLogin.Html);
|
|
if (((dynamic)obj)["Code"] == "0000")
|
|
{
|
|
if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(21).consNum)
|
|
{
|
|
_action?.Invoke(guidTag, DisplyType.chongzhi, "");
|
|
new AppleChangeItem
|
|
{
|
|
countryCode = countryCode,
|
|
mode = mode
|
|
};
|
|
bool flag = false;
|
|
if ((!AppSysConfig.webProtocolS2k) ? new AppleManageWebUtlis(_action, null, this).OpenAuthen(appleAcount, new AppleChangeItem
|
|
{
|
|
countryCode = countryCode,
|
|
mode = mode
|
|
}, openVpn, actGetCode, guidTag) : new AppleManageWeb(openVpn, _action, null, this).OpenAuthen(appleAcount, new AppleChangeItem
|
|
{
|
|
countryCode = countryCode,
|
|
mode = mode
|
|
}, actGetCode, guidTag))
|
|
{
|
|
_action?.Invoke(guidTag, DisplyType.mima, "成功");
|
|
APIUtlis.ApiApplyAct(21, "开启双重认证");
|
|
}
|
|
else
|
|
{
|
|
_action?.Invoke(guidTag, DisplyType.normal, "失败");
|
|
}
|
|
sucessAct?.Invoke(guidTag);
|
|
}
|
|
else
|
|
{
|
|
_action?.Invoke(guidTag, DisplyType.xinxi, "点数不足,请联系客服充值");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_action?.Invoke(guidTag, DisplyType.xinxi, ((dynamic)obj)["Message"]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_action?.Invoke(guidTag, DisplyType.xinxi, "网络请求失败");
|
|
}
|
|
goto IL_05d2;
|
|
}
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
APIUtlis.ApiSeriveError(ex2);
|
|
if (appleAcount != null)
|
|
{
|
|
_action?.Invoke(appleAcount.guidTag, DisplyType.xinxi, "请求失败:" + ex2.Message);
|
|
}
|
|
goto IL_05d2;
|
|
}
|
|
continue;
|
|
IL_05d2:
|
|
BaseTask.endRuning(taskRunModel);
|
|
}
|
|
});
|
|
}
|
|
Task.WaitAll(array);
|
|
try
|
|
{
|
|
Task[] array2 = array;
|
|
foreach (Task task in array2)
|
|
{
|
|
if (task.Status == TaskStatus.RanToCompletion)
|
|
{
|
|
task.Dispose();
|
|
}
|
|
}
|
|
array = null;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
AppleExecuteTask.TaskRunModels.Clear();
|
|
base.TaskIsRun = false;
|
|
base.isRun = false;
|
|
endTakAct?.Invoke();
|
|
});
|
|
}
|
|
else
|
|
{
|
|
endTakAct?.Invoke();
|
|
}
|
|
}
|
|
}
|
|
}
|