1.优化企业小程序发送

This commit is contained in:
老道 2022-12-31 22:28:29 +08:00
parent 2c840168cf
commit 0f0d9b3134
1 changed files with 28 additions and 4 deletions

View File

@ -110,7 +110,15 @@ namespace PCRobot.PCWechat.Enterprise
weapppagethumbrawurl = regKey.Groups["weapppagethumbrawurl"].Value; weapppagethumbrawurl = regKey.Groups["weapppagethumbrawurl"].Value;
//小程序 //小程序
SendProgramMessage(conversation_id, ghid.XMLReplace(false), ghid.XMLReplace(false), title, image_url, desc, pagepath); if (!string.IsNullOrWhiteSpace(image_url))
{
SendProgramMessage(conversation_id, ghid.XMLReplace(false), ghid.XMLReplace(false), title,
image_url, desc, pagepath);
}
else
{
SendProgramMessage(conversation_id, ghid.XMLReplace(false), ghid.XMLReplace(false), title, image_url, desc, pagepath, image_key1, image_key2, image_key3, image_size);
}
return; return;
} }
else else
@ -706,10 +714,10 @@ namespace PCRobot.PCWechat.Enterprise
#endregion #endregion
FileC2cCdnInfo cdn = GetCdnByUpLoadFile(appicon, 1).Result; FileC2cCdnInfo cdn = GetCdnByUpLoadFile(appicon, 1).Result;
if (cdn == null) //if (cdn == null)
throw new Exception("小程序图片获取Cdn失败"); // throw new Exception("小程序图片获取Cdn失败");
var _json = JsonConvert.SerializeObject(new { type = Wechat_Xiaoxie_QY.MsgType.MT_SEND_MINI_PROGRAM_MSG, data = new { conversation_id = GetConversationId(username), username = appUsername, appid = appId, appName = appName, appicon = appicon, title = title, page_path = page_path, file_id = cdn.file_id, aes_key = cdn.file_aes_key, md5 = cdn.file_md5, size = cdn.file_size } }); var _json = JsonConvert.SerializeObject(new { type = Wechat_Xiaoxie_QY.MsgType.MT_SEND_MINI_PROGRAM_MSG, data = new { conversation_id = GetConversationId(username), username = appUsername, appid = appId, appName = appName, appicon = appicon, title = title, page_path = page_path, file_id = cdn?.file_id ?? string.Empty, aes_key = cdn?.file_aes_key ?? string.Empty, md5 = cdn?.file_md5 ?? string.Empty, size = cdn?.file_size ?? 0 } });
SendWxWorkData(User.DwClientId, _json); SendWxWorkData(User.DwClientId, _json);
} }
@ -719,6 +727,22 @@ namespace PCRobot.PCWechat.Enterprise
} }
} }
private void SendProgramMessage(string username, string appUsername, string appId, string appName, string appicon, string title,
string page_path, string file_id, string file_aes_key, string file_md5, int file_size)
{
try
{
var _json = JsonConvert.SerializeObject(new { type = Wechat_Xiaoxie_QY.MsgType.MT_SEND_MINI_PROGRAM_MSG, data = new { conversation_id = GetConversationId(username), username = appUsername, appid = appId, appName = appName, appicon = appicon, title = title, page_path = page_path, file_id = file_id, aes_key = file_aes_key, md5 = file_md5, size = file_size } });
SendWxWorkData(User.DwClientId, _json);
}
catch (Exception ex)
{
LogHelper.GetSingleObj().Error(new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name, $"发送小程序Cdn:{ex.Message}");
}
}
public override void SendVideoHao(string username, string avatar, string cover_url, string desc, int feed_type, string nickname, public override void SendVideoHao(string username, string avatar, string cover_url, string desc, int feed_type, string nickname,
string thumb_url, string url, string extras) string thumb_url, string url, string extras)
{ {