43 lines
1.7 KiB
C#
43 lines
1.7 KiB
C#
|
using Api.Framework;
|
|||
|
using Api.Framework.SDK;
|
|||
|
using Api.Framework.Tools;
|
|||
|
using Chat.Framework.WXSdk.Implement;
|
|||
|
using CsharpHttpHelper;
|
|||
|
using SqlSugar;
|
|||
|
using System.Linq;
|
|||
|
using UserFission.Entitys;
|
|||
|
|
|||
|
namespace UserFission
|
|||
|
{
|
|||
|
class ApplyFriendThread : TimerTask
|
|||
|
{
|
|||
|
SqlSugarClient session = ApiClient.GetSession();
|
|||
|
public override void Run(object state, bool timedOut)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (Class1.queue.Count != 0)
|
|||
|
{
|
|||
|
var id = Class1.queue.Dequeue();
|
|||
|
var friend = session.Find<fl_plugin_userfission_applyfriend_info>("select * from fl_plugin_userfission_applyfriend_info where id = @id", new { id = id }).FirstOrDefault();
|
|||
|
if (friend != null)
|
|||
|
{
|
|||
|
if (friend != null && friend.state == "已接受") return;
|
|||
|
var client = Chat.Framework.ChatClient.WXClient.Values.FirstOrDefault(f => f.WeixinHao == friend.robot_name && f.WeixinType == WeixinType.Grpc微信 && f.Status == Chat.Framework.WXSdk.WxStatus.在线);
|
|||
|
if (client != null)
|
|||
|
{
|
|||
|
string result = client.AgreeAddMe(HttpHelper.URLDecode(friend.token));
|
|||
|
if (string.IsNullOrEmpty(result)) friend.state = "已接受";
|
|||
|
else friend.state = result;
|
|||
|
session.Saveable(friend).ExecuteReturnEntity();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (System.Exception ex)
|
|||
|
{
|
|||
|
EventClient.OnEvent(this, "审核新加好友异常:" + ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|