mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 22:31:24 +00:00
148 lines
4.2 KiB
C#
148 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
using AppleBatch_June.Model;
|
|
using AppleBatch_June.StartTaskModel;
|
|
using DotNet.Utilities;
|
|
|
|
namespace AppleBatch_June.ExecuteTasks
|
|
{
|
|
public class OrderQueryTask : BaseTask
|
|
{
|
|
public static OrderQueryTask Instance { get; private set; }
|
|
|
|
static OrderQueryTask()
|
|
{
|
|
Instance = new OrderQueryTask("订单查询");
|
|
}
|
|
|
|
public OrderQueryTask(string _taskName)
|
|
: base(_taskName)
|
|
{
|
|
}
|
|
|
|
public void AppleOrderQueryTask(int TaskSize, bool openVpn, string amountSpik, List<AppleAcount> lvItems, Action startAct, Action endTakAct, Action<string> sucessAct, Action<string, DisplyType, string> _action)
|
|
{
|
|
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 = 17;
|
|
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;
|
|
}
|
|
if (appleAcount != null)
|
|
{
|
|
if (!BaseTask.startRuning(taskRunModel, _action, appleAcount.appleId))
|
|
{
|
|
continue;
|
|
}
|
|
_action?.Invoke(appleAcount.appleId, DisplyType.xinxi, "正在处理");
|
|
HttpResult isLogin = APIUtlis.getIsLogin(17);
|
|
if (isLogin.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
object obj = Tools.Todejosn<object>(isLogin.Html);
|
|
if (((dynamic)obj)["Code"] == "0000")
|
|
{
|
|
if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(17).consNum)
|
|
{
|
|
_action?.Invoke(appleAcount.appleId, DisplyType.chongzhi, "");
|
|
AppleManageWebUtlis appleManageWebUtlis = new AppleManageWebUtlis(_action, _action, this);
|
|
appleManageWebUtlis.checkDisable(openVpn, appleAcount.appleId, appleAcount.applePwd, appleAcount.appleId);
|
|
if (appleManageWebUtlis.idIsNormal && appleManageWebUtlis.sponsorRefund(appleAcount.appleId, amountSpik))
|
|
{
|
|
appleManageWebUtlis.reportSingOut();
|
|
sucessAct?.Invoke(appleAcount.appleId);
|
|
APIUtlis.ApiApplyAct(17, "Apple订单提取");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_action?.Invoke(appleAcount.appleId, DisplyType.xinxi, "点数不足,请联系客服充值");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_action?.Invoke(appleAcount.appleId, DisplyType.xinxi, ((dynamic)obj)["Message"]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_action?.Invoke(appleAcount.appleId, DisplyType.xinxi, "网络请求失败");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
APIUtlis.ApiSeriveError(ex2);
|
|
if (appleAcount != null)
|
|
{
|
|
_action?.Invoke(appleAcount.appleId, DisplyType.xinxi, "请求失败:" + ex2.Message);
|
|
}
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
}
|