llj
2026-02-25 c14f8a94958772b5aa0fdd8e128c4e8a2edc2100
WebAPI/Service/GeTuiService.cs
@@ -9,6 +9,7 @@
using Newtonsoft.Json;
using com.igetui.api.openservice.igetui.template;
using com.igetui.api.openservice.igetui;
using WebApiWithFleck;
namespace WebAPI.Service
{
@@ -46,15 +47,16 @@
                {
                    string title = ds.Tables[0].Rows[0]["主题"].ToString();
                    string content = ds.Tables[0].Rows[0]["内容"].ToString();
                    template = GetNotificationTemplate(title, content, "/pages/ZLGL/OA_WorkLink/OA_WorkLinkBillList", "0");
                    template = GetNotificationTemplate(title, content, "/pages/ZLGL/OA_WorkLink/OA_WorkLinkBillQuery", "0"); // 跳转到工作联系单查询页面
                    bool pushSuccess = false;
                    // 广播
                    if(ds.Tables[0].Rows[0]["发送类型"].ToString() == "公共")
                    {
                        // 遍历 全推送
                        foreach(DataRow row in ds.Tables[1].Rows)
                        {
                            PushMessageToSingle(template, row["HClientID"].ToString());
                            pushSuccess = PushMessageToSingle(template, row["HClientID"].ToString());
                        }
                    }else // 单独推送
                    {
@@ -63,8 +65,17 @@
                        {
                            if(ds.Tables[0].Rows[0]["接收人"].ToString() == row["HUserName"].ToString()
                                || ds.Tables[0].Rows[0]["抄送接收人"].ToString() == row["HUserName"].ToString())
                            PushMessageToSingle(template, row["HClientID"].ToString());
                            {
                               pushSuccess = PushMessageToSingle(template, row["HClientID"].ToString());
                            }
                        }
                    }
                    if(!pushSuccess)
                    {
                        // 个推 推送不成功(内网环境) 使用webSocket进行推送
                        // TODO: 使用 rabbitMQ 实现消息队列
                        // WebSocketServer.PushOne(HInterID);
                    }
                }
            }
@@ -76,7 +87,7 @@
        }
        // 单推 使用通知消息模型
        private static void PushMessageToSingle(NotificationTemplate template, string ClientID)
        private static bool PushMessageToSingle(NotificationTemplate template, string ClientID)
        {
            IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);
@@ -100,6 +111,7 @@
                LogService.Write("-----------------------------------------------");
                LogService.Write("-----------------------------------------------");
                LogService.Write("----------------服务端返回结果:" + pushResult);
                return true;
            }
            catch (RequestException e)
            {
@@ -109,6 +121,7 @@
                LogService.Write("-----------------------------------------------");
                LogService.Write("-----------------------------------------------");
                LogService.Write("----------------服务端返回结果:" + pushResult);
                return false;
            }
        }
@@ -156,8 +169,8 @@
            template.IsClearable = true;
            var customData = new Dictionary<string, string>
            {
                {"pagePath", pagePath}, // 示例:"/pages/detail/detail"
                {"itemId", HItemID}      // 示例:"123456"
                {"pagePath", pagePath},
                {"itemId", HItemID}
            };
            template.TransmissionContent = JsonConvert.SerializeObject(customData); // 序列化为 JSON 字符串
            template.TransmissionType = 1; // 1=点击通知后触发客户端回调(透传内容给客户端)