mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 22:31:24 +00:00
172 lines
5.1 KiB
C#
172 lines
5.1 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 AppleAccountChangeTask : BaseTask
|
|
{
|
|
public static AppleAccountChangeTask Instance { get; set; }
|
|
|
|
static AppleAccountChangeTask()
|
|
{
|
|
Instance = new AppleAccountChangeTask("资料修改");
|
|
}
|
|
|
|
public AppleAccountChangeTask(string _taskName)
|
|
: base(_taskName)
|
|
{
|
|
}
|
|
|
|
public void AppleChangeTask(bool openVpn, bool errorGoint, int TaskSize, List<AppleAcount> lvItems, AppleChangeItem changeItem, Action startAct, Action endTakAct, Action<string> sucessAct, Action<string, DisplyType, string> _action, Action<string, DisplyType, string> _applyAtion, int intType)
|
|
{
|
|
TaskSize = Tools.getTaskSize(openVpn, lvItems.Count);
|
|
if (!openVpn)
|
|
{
|
|
TaskSize = 2;
|
|
}
|
|
if (!base.isRun)
|
|
{
|
|
AppleExecuteTask.TaskRunAppleIdCount = 0L;
|
|
AppleExecuteTask.TaskRunModels.Clear();
|
|
startAct?.Invoke();
|
|
base.isRun = true;
|
|
Task.Run(delegate
|
|
{
|
|
ApiNetReq.startNowFun = intType;
|
|
base.TaskIsRun = true;
|
|
base.baseEndTakAct = endTakAct;
|
|
object lockObj = new object();
|
|
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 (lockObj)
|
|
{
|
|
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(intType);
|
|
if (isLogin.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
object obj = Tools.Todejosn<object>(isLogin.Html);
|
|
if (((dynamic)obj)["Code"] == "0000")
|
|
{
|
|
if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(intType).consNum)
|
|
{
|
|
_action?.Invoke(guidTag, DisplyType.chongzhi, "");
|
|
string accountName = "";
|
|
bool _flag = false;
|
|
AppleChangeItem changeItem2 = new AppleChangeItem
|
|
{
|
|
newGuojia = changeItem.newGuojia,
|
|
newPwd = changeItem.newPwd,
|
|
newQt1 = changeItem.newQt1,
|
|
newQt2 = changeItem.newQt2,
|
|
newQt3 = changeItem.newQt3,
|
|
newshengri = changeItem.newshengri,
|
|
pay = changeItem.pay,
|
|
isDeleteDevice = changeItem.isDeleteDevice,
|
|
CreatePin = changeItem.CreatePin,
|
|
isRemoveRescueEmail = changeItem.isRemoveRescueEmail,
|
|
isUnlinkFamily = changeItem.isUnlinkFamily
|
|
};
|
|
if ((!AppSysConfig.webProtocolS2k) ? new AppleManageWebUtlis(_action, _applyAtion, this).applyChangeAcount(appleAcount, changeItem2, errorGoint, openVpn, guidTag, ref accountName) : new AppleManageWeb(openVpn, _action, _applyAtion, this).applyChangeAcount(appleAcount, changeItem2, errorGoint, guidTag, ref accountName))
|
|
{
|
|
APIUtlis.ApiApplyAct(intType, (intType == 1) ? "修改资料" : "国家转换");
|
|
}
|
|
else if (!errorGoint)
|
|
{
|
|
base.isRun = false;
|
|
}
|
|
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_0706;
|
|
}
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
APIUtlis.ApiSeriveError(ex2);
|
|
if (appleAcount != null)
|
|
{
|
|
_action?.Invoke(appleAcount.guidTag, DisplyType.xinxi, "请求失败:" + ex2.Message);
|
|
}
|
|
goto IL_0706;
|
|
}
|
|
continue;
|
|
IL_0706:
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
}
|