old_flsystem/类库/Api.Framework/Timers/Update_CpsStatus.cs

75 lines
2.6 KiB
C#

using Api.Framework.Enums;
using Api.Framework.SDK;
using Api.Framework.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Api.Framework.Timers
{
/// <summary>
/// 定时更新阿里和拼多多授权信息
/// </summary>
class Update_CpsStatus : TimerTask
{
public long count = 0;
public override void Run(object state, bool timeout)
{
count++;
//更新多多进宝状态
if (count == 0 || count % 24 == 0)
{
try
{
var members = CpsClient.Members.Where(f => f.cpstype == CpsType.);
foreach (var item in members)
{
var api = CpsClient.CreatePinduoduoRequest(item);
api.RefreshStatus();
}
}
catch (Exception ex)
{
EventClient.OnEvent(this, $"ERROR-:{this.GetType()}-{System.Reflection.MethodBase.GetCurrentMethod().Name}->Pdd->{ex.Message}");
}
}
//判断阿里妈妈状态
try
{
var members = CpsClient.Members.Where(f => f.cpstype == CpsType.).ToList();
foreach (var _item in members)
{
var item = _item;
Task.Run(() =>
{
try
{
var session = ApiClient.GetSession();
var api = CpsClient.CreateAlimamaRequest(item);
if (item.online)
{
api.UpdateCookies();
item = CpsClient.Members.FirstOrDefault(f => f.cpstype == CpsType. && f.username == item.username);
item.online = api.CheckLoginAlimama();
}
api.RefToken();
session.Saveable(item).ExecuteCommand();
}
catch (Exception ex)
{ }
});
Thread.Sleep(50);
}
}
catch (Exception ex)
{
EventClient.OnEvent(this, $"ERROR:{this.GetType()}-{System.Reflection.MethodBase.GetCurrentMethod().Name}- >TB->{ex.Message}");
}
}
}
}