From 5d837aea828df2a957f5a260118f5171fa3508a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=88=E6=A3=AE=E5=90=B4?= <8402134@qq.com> Date: Tue, 13 Dec 2022 22:23:42 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BB=A3=E8=BF=90=E8=90=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FLSystem/Tools.cs | 2 +- 应用/ProductClient/MonitorThread.cs | 143 ++++++++++++++-------------- 2 files changed, 74 insertions(+), 71 deletions(-) diff --git a/FLSystem/Tools.cs b/FLSystem/Tools.cs index 362d468..2b33fb8 100644 --- a/FLSystem/Tools.cs +++ b/FLSystem/Tools.cs @@ -427,7 +427,7 @@ namespace FLSystem } catch (Exception ex) { - EventClient.OnEvent("", $"商户状态查询异常:{ex.Message} - {ex.StackTrace} , {html}"); + EventClient.OnEvent("", $"商户状态查询异常.:{ex.Message} - {ex.StackTrace} , {html}"); } finally { diff --git a/应用/ProductClient/MonitorThread.cs b/应用/ProductClient/MonitorThread.cs index f5ee790..7e8c98d 100644 --- a/应用/ProductClient/MonitorThread.cs +++ b/应用/ProductClient/MonitorThread.cs @@ -522,81 +522,87 @@ namespace ProductClient return string.Empty; } + ///// + ///// 执行发送任务 + ///// + //private void _ExecuteSend(string objectDesc, string comment) + //{ + // try + // { + // if (string.IsNullOrWhiteSpace(objectDesc)) return; + // var clients = Chat.Framework.ChatClient.WXClient.Values.ToList().Where(f => (f.WeixinType == WeixinType.Grpc微信 || f.WeixinType == WeixinType.Hook微信) && f.Status == WxStatus.在线).ToList(); + // if (clients.Count != 0) + // { + // foreach (var _item in clients) + // { + // var item = _item; + // //Task.Run(() => + // //{ + // try + // { + // //objectDesc = Regex.Replace(objectDesc, @"videomd5=""(.{32})""", @"videomd5=""" + Util.GetMD5Hash(Guid.NewGuid().ToByteArray()) + @""""); + // //objectDesc = Regex.Replace(objectDesc, @"md5=""(.{32})""", @"md5=""" + Util.GetMD5Hash(Guid.NewGuid().ToByteArray()) + @""""); + + // objectDesc = objectDesc.Replace("[活动口令]", Class1.Config.actionLink); + + // var json = item.SendCircle(objectDesc);//发送朋友圈的主内容 + // if (string.IsNullOrWhiteSpace(json)) + // EventClient.OnEvent(this, $"【代运营朋友圈】 => {item.WeixinHao},转发失败"); + // else + // EventClient.OnEvent(this, $"【代运营朋友圈】 => {item.WeixinHao},转发成功"); + + // if (!Class1.Config.isPl) + // { + // var reg = Regex.Match(json.Replace("", ""), @"(?\d{15,})");//获取返回的朋友圈id + // if (reg.Success && !string.IsNullOrWhiteSpace(comment)) + // { + // var id = reg.Groups["id"].Value; + // var commentStr = string.Empty; + // if (string.IsNullOrWhiteSpace(Class1.Config.appendComment)) + // commentStr = string.Join("[分段]", comment); + // else + // commentStr = string.Join("[分段]", comment, Class1.Config.appendComment); + // if (!string.IsNullOrWhiteSpace(commentStr)) + // item.SendCircleComment(item.User.Username, id, commentStr.Replace("[活动口令]", Class1.Config.actionLink)); + // } + // } + // } + // catch (Exception ex) + // { + // EventClient.OnEvent(this, $"【代运营朋友圈】 发送异常:{ex.Message} - {ex.StackTrace}"); + // } + // //}); + // } + + // if (Class1.Config.Monitor_Interval != 0) + // { + // Class1.Config.LastSendTime = DateTime.Now; + // Util.Save(Class1.Config); + // } + // EventClient.OnEvent(this, $"【代运营朋友圈】 所有账号发送完毕"); + // } + // } + // catch (Exception ex) + // { + // EventClient.OnEvent(this, $"【代运营朋友圈】 发送失败:{ex.Message} - {ex.StackTrace}"); + // } + //} + + /// /// 执行发送任务 /// - private void _ExecuteSend(string objectDesc, string comment) + public static void _ExecuteSend(string objectDesc, List comments, bool isGoods, string taskId) { try { - if (string.IsNullOrWhiteSpace(objectDesc)) return; - var clients = Chat.Framework.ChatClient.WXClient.Values.ToList().Where(f => (f.WeixinType == WeixinType.Grpc微信 || f.WeixinType == WeixinType.Hook微信) && f.Status == WxStatus.在线).ToList(); - if (clients.Count != 0) + if (string.IsNullOrWhiteSpace(objectDesc)) { - foreach (var _item in clients) - { - var item = _item; - //Task.Run(() => - //{ - try - { - //objectDesc = Regex.Replace(objectDesc, @"videomd5=""(.{32})""", @"videomd5=""" + Util.GetMD5Hash(Guid.NewGuid().ToByteArray()) + @""""); - //objectDesc = Regex.Replace(objectDesc, @"md5=""(.{32})""", @"md5=""" + Util.GetMD5Hash(Guid.NewGuid().ToByteArray()) + @""""); - - objectDesc = objectDesc.Replace("[活动口令]", Class1.Config.actionLink); - - var json = item.SendCircle(objectDesc);//发送朋友圈的主内容 - if (string.IsNullOrWhiteSpace(json)) - EventClient.OnEvent(this, $"【代运营朋友圈】 => {item.WeixinHao},转发失败"); - else - EventClient.OnEvent(this, $"【代运营朋友圈】 => {item.WeixinHao},转发成功"); - - if (!Class1.Config.isPl) - { - var reg = Regex.Match(json.Replace("", ""), @"(?\d{15,})");//获取返回的朋友圈id - if (reg.Success && !string.IsNullOrWhiteSpace(comment)) - { - var id = reg.Groups["id"].Value; - var commentStr = string.Empty; - if (string.IsNullOrWhiteSpace(Class1.Config.appendComment)) - commentStr = string.Join("[分段]", comment); - else - commentStr = string.Join("[分段]", comment, Class1.Config.appendComment); - if (!string.IsNullOrWhiteSpace(commentStr)) - item.SendCircleComment(item.User.Username, id, commentStr.Replace("[活动口令]", Class1.Config.actionLink)); - } - } - } - catch (Exception ex) - { - EventClient.OnEvent(this, $"【代运营朋友圈】 发送异常:{ex.Message} - {ex.StackTrace}"); - } - //}); - } - - if (Class1.Config.Monitor_Interval != 0) - { - Class1.Config.LastSendTime = DateTime.Now; - Util.Save(Class1.Config); - } - EventClient.OnEvent(this, $"【代运营朋友圈】 所有账号发送完毕"); + return; } - } - catch (Exception ex) - { - EventClient.OnEvent(this, $"【代运营朋友圈】 发送失败:{ex.Message} - {ex.StackTrace}"); - } - } + comments.Add(Class1.Config.appendComment); + var commentStr = string.Join("[分段]", comments); - - /// - /// 执行发送任务 - /// - public static void _ExecuteSend(string objectDesc, List comments,bool isGoods,string taskId) - { - try - { - if (string.IsNullOrWhiteSpace(objectDesc)) return; var clients = Chat.Framework.ChatClient.WXClient.Values.ToList().Where(f => (f.WeixinType == WeixinType.Grpc微信 || f.WeixinType == WeixinType.Hook微信) && f.Status == WxStatus.在线).ToList(); if (clients.Count != 0) { @@ -621,12 +627,9 @@ namespace ProductClient //if (!Class1.Config.isPl) //{ var reg = Regex.Match(json.Replace("", ""), @"(?\d{15,})");//获取返回的朋友圈id - if (reg.Success && comments != null && comments.Count > 0) + if (reg.Success && !string.IsNullOrWhiteSpace(commentStr)) { var id = reg.Groups["id"].Value; - comments.Add(Class1.Config.appendComment); - var commentStr = string.Join("[分段]", comments); - EventClient.OnEvent(null, $"【代运营朋友圈】 => {item.WeixinHao},评论内容:{commentStr}"); if (!string.IsNullOrWhiteSpace(commentStr))