old_flsystem/应用/TBAppraisalTools/RefreshTbCookiesThread.cs

58 lines
2.1 KiB
C#
Raw Permalink Normal View History

2022-09-20 03:10:29 +00:00
using Api.Framework;
using Api.Framework.Enums;
using Api.Framework.SDK;
using CsharpHttpHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TBAppraisalTools
{
class RefreshTbCookiesThread : TimerTask
{
private HttpHelper http = new HttpHelper();
public override void Run(object state, bool timedOut)
{
try
{
var loginInfos = Class1.Config.TbLoginInfos.Where(f => f.OnLine == SwitchType.);
foreach (var tbInfo in loginInfos)
{
try
{
var item = http.GetItem("https://shoucang.taobao.com/shop_collect_list.htm", tbInfo.Cookies);
var result = http.GetHtml(item);
var html = result.Html.Trim();
if (html.Contains("\"登录页面\"改进建议"))
{
tbInfo.OnLine = SwitchType.;
EventClient.OnEvent(this, $"评价工具 - {tbInfo.TbLoginName} 的心跳包已经过期");
}
else
{
tbInfo.Cookies = result.UpdateCookies(tbInfo.Cookies);
tbInfo.OnLine = SwitchType.;
EventClient.OnEvent(this, $"评价工具 - {tbInfo.TbLoginName} 的心跳成功");
}
}
catch (Exception ex)
{
EventClient.OnEvent(this, $"评价工具 - 淘宝心跳异常:{ex.Message}");
}
finally
{
//Api.Framework.Tools.Util.Save(Class1.Config);
}
}
}
catch (Exception ex)
{
EventClient.OnEvent(this, $"评价工具 - 淘宝心跳:{ex.Message}");
}
}
}
}