mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 22:31:24 +00:00
170 lines
4.8 KiB
C#
170 lines
4.8 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 WebOrderTask : BaseTask
|
|
{
|
|
public static WebOrderTask Instance { get; private set; }
|
|
|
|
static WebOrderTask()
|
|
{
|
|
Instance = new WebOrderTask("密保查询余额");
|
|
}
|
|
|
|
public WebOrderTask(string _taskName)
|
|
: base(_taskName)
|
|
{
|
|
}
|
|
|
|
public void AppleQueryWebOrderTask(int TaskSize, bool openVpn, 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 = 47;
|
|
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, "正在处理");
|
|
int num = 47;
|
|
HttpResult isLogin = APIUtlis.getIsLogin(47);
|
|
if (isLogin.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
object obj = Tools.Todejosn<object>(isLogin.Html);
|
|
if (((dynamic)obj)["Code"] == "0000")
|
|
{
|
|
if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(num).consNum)
|
|
{
|
|
_action?.Invoke(guidTag, DisplyType.chongzhi, "");
|
|
AppleShopWeb appleShopWeb = new AppleShopWeb(openVpn, guidTag, _action, null, this);
|
|
string text = appleAcount.appleId.Trim();
|
|
if (!appleAcount.appleId.Trim().ToLower().StartsWith("http"))
|
|
{
|
|
List<AppleAcount> list = AppleUtlis.accountInput(appleAcount.appleId);
|
|
if (list.Count > 0)
|
|
{
|
|
appleAcount.appleId = list[0].appleId;
|
|
appleAcount.applePwd = list[0].applePwd;
|
|
appleAcount.isAccountException = true;
|
|
text = list[0].overflow.Trim();
|
|
}
|
|
}
|
|
if (appleShopWeb.WebOrderQuery(text))
|
|
{
|
|
if (appleAcount.isAccountException && !string.IsNullOrEmpty(appleShopWeb.signInURL))
|
|
{
|
|
_action?.Invoke(guidTag, DisplyType.xinxi, "正在登录查询.");
|
|
appleShopWeb.LoginWebOrderQuery(appleAcount, text);
|
|
}
|
|
APIUtlis.ApiApplyAct(num, "网单查询");
|
|
}
|
|
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_05ed;
|
|
}
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
APIUtlis.ApiSeriveError(ex2);
|
|
if (appleAcount != null)
|
|
{
|
|
_action?.Invoke(appleAcount.guidTag, DisplyType.xinxi, "请求失败:" + ex2.Message);
|
|
}
|
|
goto IL_05ed;
|
|
}
|
|
continue;
|
|
IL_05ed:
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
}
|