海波 张
2025-06-23 0ac2d4112295d2d4ef9ca7502af509c2b165f337
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
using DingTalk.Api;
using DingTalk.Api.Request;
using DingTalk.Api.Response;
using HH.WCS.ZhongCeJinTan;
using HH.WCS.ZhongCeJinTan.util;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
 
namespace HanHe.Message
{
    public class DingTalk
    {
        private static string accessToken;
        private static long agentId = 3821174862;
        private static string appKey = "dingreswzhnbdarn9uby";
        private static string appSecret = "grCVjpohQOzmhZsmVwb-7-CsyZmg0G6d_X86xreuYjj6Y_YZgSSE4nCLpDIzUJ4P";
        private static DateTime expiresIn = DateTime.Now;
        private static List<OapiDepartmentListResponse.DepartmentDomain> department = new List<OapiDepartmentListResponse.DepartmentDomain>();
        private static List<OapiUserSimplelistResponse.UserlistDomain> userlist = new List<OapiUserSimplelistResponse.UserlistDomain>();
        private static bool param = false;
        //public static bool Init(long agentId, string appKey, string appSecret)
        //{
        //    if (agentId > 0 && !string.IsNullOrEmpty(appKey) && !string.IsNullOrEmpty(appSecret))
        //    {
 
        //        DingTalk.agentId = agentId;
        //        DingTalk.appKey = appKey;
        //        DingTalk.appSecret = appSecret;
        //        if (!GetToken())
        //        {
        //            DingTalk.agentId = 0;
        //            DingTalk.appKey = "";
        //            DingTalk.appSecret = "";
        //        }
        //        else
        //        {
        //            return true;
        //        }
        //    }
        //    return false;
        //}
        public static bool InitTest(long agentId, string appKey, string appSecret)
        {
            if (agentId > 0 && !string.IsNullOrEmpty(appKey) && !string.IsNullOrEmpty(appSecret))
            {
                return GetToken(appKey, appSecret, false);
            }
            return false;
        }
        /// <summary>
        /// 获取所有部门名称
        /// </summary>
        /// <returns></returns>
        public static List<string> GetDepartment()
        {
            List<string> names = new List<string>();
            if (department.Count > 0)
            {
                department.ForEach(d => names.Add(d.Name));
            }
            return names;
        }
        /// <summary>
        /// 根据部门名称发送消息
        /// </summary>
        /// <param name="deptName">部门名称</param>
        /// <param name="content">消息内容</param>
        /// <returns></returns>
        public static MessageResult SendMessageToParty(string deptName, string content)
        {
            MessageResult result = new MessageResult();
            if (string.IsNullOrEmpty(accessToken))
            {
                result.Errcode = -1;
                result.Errmsg = "不合法的token";
            }
            else
            {
                //获取部门id
                var deptId = CheckDepartment(deptName);
                if (deptId == "0")
                {
                    result.Errcode = -2;
                    result.Errmsg = "不存在的部门";
                }
                else
                {
                    result = SendMessage(deptId, content, true);
                }
            }
            return result;
        }
        public static MessageResult SendMessageToUser(string userName, string content)
        {
            MessageResult result = new MessageResult();
            if (string.IsNullOrEmpty(accessToken))
            {
                result.Errcode = -1;
                result.Errmsg = "不合法的token";
            }
            else
            {
                //获取人员id
                var userId = CheckUser(userName);
                if (userId == "0")
                {
                    result.Errcode = -2;
                    result.Errmsg = "不存在的人员";
                }
                else
                {
                    result = SendMessage(userId, content, false);
                }
            }
            return result;
        }
 
        #region 内部方法
 
        private static bool GetToken(string appKey = "", string appSecret = "", bool init = true)
        {
            if (string.IsNullOrEmpty(appKey))
            {
                appKey = DingTalk.appKey;
            }
            if (string.IsNullOrEmpty(appSecret))
            {
                appSecret = DingTalk.appSecret;
            }
 
            DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
            OapiGettokenRequest request = new OapiGettokenRequest();
            request.Appkey = appKey;
            request.Appsecret = appSecret;
            request.SetHttpMethod("GET");
 
            OapiGettokenResponse response = client.Execute(request);
            if (response.Errcode == 0)
            {
                //40089 不合法的corpid或corpsecret
                if (init)
                {
                    param = true;
                    accessToken = response.AccessToken;
                    ListDepartment();
                    ListUser();
                }
                return true;
            }
            return false;
        }
        /// <summary>
        /// 获取部门列表
        /// </summary>
        /// <param name="id">父Id</param>
        private static void ListDepartment(string id = "")
        {
            IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/department/list");
            OapiDepartmentListRequest request = new OapiDepartmentListRequest();
            request.Id = id;
            request.FetchChild = true;
            request.SetHttpMethod("GET");
            OapiDepartmentListResponse response = client.Execute(request, accessToken);
            if (response.Errcode == 0)
            {
                //40014 不合法的access_token
                department = response.Department;
            }
            else
            {
                LogHelper.Info("钉钉", response.Errmsg);
            }
        }
 
        /// <summary>
        /// 根据部门名称获取部门id
        /// </summary>
        /// <param name="name"></param>
        private static string CheckDepartment(string deptName)
        {
            string id = "0";
            if (string.IsNullOrEmpty(deptName))
            {
                if (department.Count > 0)
                {
                    var list = department.Where(a => a.Parentid == 1).ToList();
                    if (list.Count > 0)
                    {
                        id = string.Join(",", list.Select(a => a.Id.ToString()).ToArray());
                    }
                }
            }
            else
            {
                if (department.Count > 0)
                {
                    for (int i = 0; i < department.Count; i++)
                    {
                        if (department[i].Name == deptName)
                        {
                            id = department[i].Id.ToString();
                            break;
                        }
                    }
                }
            }
            return id;
        }
        private static string CheckUser(string userName)
        {
            string id = "0";
            if (userlist.Count > 0)
            {
                for (int i = 0; i < userlist.Count; i++)
                {
                    if (userlist[i].Name == userName)
                    {
                        id = userlist[i].Userid;
                        break;
                    }
                }
            }
            return id;
        }
 
        private static MessageResult SendMessage(string id, string content, bool party)
        {
 
            OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request();
            request.AgentId = agentId;
            request.ToAllUser = false;
            if (party)
            {
                request.DeptIdList = id;//123,456
            }
            else
            {
                request.UseridList = id;//zhangsan,lisi
            }
            OapiMessageCorpconversationAsyncsendV2Request.MsgDomain msg = new OapiMessageCorpconversationAsyncsendV2Request.MsgDomain();
            msg.Msgtype = "text";
            msg.Text = new OapiMessageCorpconversationAsyncsendV2Request.TextDomain() { Content = content };
            request.Msg_ = msg;
 
            return SendMessage(request);
            //response.Errcode=88 ding talk error[subcode=40014,submsg=不合法的access_token]
        }
 
        private static MessageResult SendMessage(OapiMessageCorpconversationAsyncsendV2Request request)
        {
            IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
 
            OapiMessageCorpconversationAsyncsendV2Response response = client.Execute(request, accessToken);
            if (response.Errcode == 88 && DingTalk.param)
            {
                //token过期
                if (GetToken())
                {
                    return SendMessage(request);
                }
            }
            return new MessageResult { Errcode = response.Errcode, Errmsg = response.Errmsg };
        }
 
        public static void GetSendProgress(long taskId = 23017959620)
        {
            IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/getsendprogress");
            OapiMessageCorpconversationGetsendprogressRequest request = new OapiMessageCorpconversationGetsendprogressRequest();
            request.AgentId = agentId;
            request.TaskId = taskId;
            OapiMessageCorpconversationGetsendprogressResponse response = client.Execute(request, accessToken);
        }
 
        private static void GetDeptMember(string deptId)
        {
            IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/getDeptMember");
            OapiUserGetDeptMemberRequest req = new OapiUserGetDeptMemberRequest();
            req.DeptId = deptId;//93688589
            req.SetHttpMethod("GET");
            OapiUserGetDeptMemberResponse rsp = client.Execute(req, accessToken);
 
        }
 
        private static void ListUser()
        {
            var list = new List<OapiUserSimplelistResponse.UserlistDomain>();
            department.ForEach(d =>
            {
                if (d.Id > 1)
                {
                    list.AddRange(Simplelist(d.Id));
                }
            });
            userlist = list.Distinct(new UserIdComparer()).ToList();
        }
        private static List<OapiUserSimplelistResponse.UserlistDomain> Simplelist(long deptId)
        {
            var list = new List<OapiUserSimplelistResponse.UserlistDomain>();
 
            IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/simplelist");
            OapiUserSimplelistRequest request = new OapiUserSimplelistRequest();
            request.DepartmentId = deptId;
            request.Offset = 0;
            request.Size = 50;
            request.SetHttpMethod("GET");
 
            OapiUserSimplelistResponse response = client.Execute(request, accessToken);
            //60020 访问ip不在白名单之中,request ip=117.71.57.100
            if (response.Errcode == 0)
            {
                //response.HasMore
                list.AddRange(response.Userlist);
                while (response.HasMore)
                {
                    request.Offset += 50;
                    response = client.Execute(request, accessToken);
                    if (response.Errcode == 0)
                    {
                        list.AddRange(response.Userlist);
                    }
                }
            }
            return list;
        }
        #endregion
 
    }
    public class UserIdComparer : IEqualityComparer<OapiUserSimplelistResponse.UserlistDomain>
    {
        public bool Equals(OapiUserSimplelistResponse.UserlistDomain x, OapiUserSimplelistResponse.UserlistDomain y)
        {
            if (x == null)
                return y == null;
            return x.Userid == y.Userid;
        }
 
        public int GetHashCode(OapiUserSimplelistResponse.UserlistDomain obj)
        {
            if (obj == null)
                return 0;
            return obj.Userid.GetHashCode();
        }
    }
    public class MessageResult
    {
        public long Errcode { get; set; }
        public string Errmsg { get; set; }
    }
 
 
 
    public class DingDingHelper
    {
        private static readonly HttpHelper apiHelper = new HttpHelper();
        string appkey = "dingitwnepteor0s0ywq";
        string appsecret = "6_jqU2EZYdfzz2Vx08PoOIsM3V3zWrQeNi3BkAP37pKMsWChJbRpxcWTaued_BhZ";
        string agentid = "3102306110";//
        string corpId = "";//企业号
        string AccessToken = String.Empty;
 
        #region 通过免登授权码和access_token获取用户的userid
        public string GetUserIdByCode(string code)
        {
            GetToken();
            if (string.IsNullOrWhiteSpace(AccessToken) || string.IsNullOrWhiteSpace(code))
                return "";
 
            try
            {
                string AccessUrl = string.Format("https://oapi.dingtalk.com/user/getuserinfo?access_token={0}&code={1}", AccessToken, code);
                //请求获取token  GET方式
                Newtonsoft.Json.Linq.JToken json = Newtonsoft.Json.Linq.JToken.Parse(apiHelper.Get(AccessUrl, null));
                return json["userid"].ToString();
            }
            catch (Exception ex)
            {
                return "";
            }
        }
        #endregion
 
        #region 根据手机号获取用户id
        /// <summary>
        /// 根据手机号获取用户id
        /// </summary>
        /// <param name="phoneNumber">用户手机号</param>
        /// <returns></returns>
        public string GetUserIdByPhoneNumber(string phoneNumber)
        {
            GetToken();
            if (string.IsNullOrWhiteSpace(AccessToken) || string.IsNullOrWhiteSpace(phoneNumber))
                return "";
 
            string MessageUrl = String.Format("https://oapi.dingtalk.com/user/get_by_mobile?access_token={0}&mobile={1}", AccessToken, phoneNumber);
 
            try
            {
                var sr = apiHelper.Get(MessageUrl, null);
                //Newtonsoft.Json.Linq.JToken json = Newtonsoft.Json.Linq.JToken.Parse(sr);
                return sr;// json["userid"].ToString();
            }
            catch (Exception ex)
            {
                return "";
            }
 
        }
        #endregion
 
        #region 根据用户id获取用户详细信息
        /// <summary>
        /// 根据用户id获取用户详细信息
        /// </summary>
        /// <param name="userid">用户id</param>
        /// <returns></returns>
        public string GetUseInfoByUid(string userid)
        {
            GetToken();
            if (string.IsNullOrWhiteSpace(AccessToken) || string.IsNullOrWhiteSpace(userid))
                return "";
 
            try
            {
                string AccessUrl = string.Format("https://oapi.dingtalk.com/user/get?access_token={0}&userid={1}", AccessToken, userid);
                //请求获取token  GET方式
                return apiHelper.Get(AccessUrl, null);
            }
            catch (Exception ex)
            {
                return "";
            }
        }
        #endregion
 
        #region 获取TOKEN
        public void GetToken()
        {
            if (string.IsNullOrWhiteSpace(AccessToken))
            {
                string AccessUrl = string.Format("https://oapi.dingtalk.com/gettoken?appkey={0}&appsecret={1}", appkey, appsecret);
                //请求获取token  GET方式
                Newtonsoft.Json.Linq.JToken json = Newtonsoft.Json.Linq.JToken.Parse(apiHelper.Get(AccessUrl, null));
                AccessToken = json["access_token"].ToString();
            }
        }
        #endregion
 
        #region 消息推送
        /// <summary>
        /// 文本消息推送(Text格式)
        /// </summary>
        /// <param name="text">推送内容</param>
        /// <param name="userid_list">用户id,多个用户用,隔开(如:123,456)</param>
        public string SendTextMessageToUser(string text, string userid_list)
        {
            GetToken();
            if (string.IsNullOrWhiteSpace(AccessToken) || string.IsNullOrWhiteSpace(text) || string.IsNullOrWhiteSpace(userid_list))
                return "";
 
            string MessageUrl = String.Format("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token={0}", AccessToken);
 
 
            var json_req = SendCommonText(text, userid_list);
            //var json_req = SendCommonTextAndTitle("销售订单管理系统", content.ToString(), txtusesid.Text);
            //var json_req = SendCardMsg("销售订单管理系统", content.ToString(), "查看详情", "https://ding-doc.dingtalk.com/", txtusesid.Text);
 
            string jsonRequest = JsonConvert.SerializeObject(json_req);//将对象转换为json
            //POST请求 消息推送
            var sr = apiHelper.Post(MessageUrl, jsonRequest);
            return sr;
        }
 
        /// <summary>
        /// 文本消息推送(MarkDown格式)
        /// </summary>
        /// <param name="title">提醒用户的标题</param>
        /// <param name="text">提醒内容(支持markdown文本解析)</param>
        /// <param name="userid_list">用户id,多个用户用,隔开(如:123,456)</param>
        /// <returns></returns>
        public string SendMarkDownMessageToUser(string title, string text, string userid_list)
        {
            GetToken();
            if (string.IsNullOrWhiteSpace(AccessToken) || string.IsNullOrWhiteSpace(text) || string.IsNullOrWhiteSpace(userid_list))
                return "";
 
            string MessageUrl = String.Format("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token={0}", AccessToken);
 
 
            //var json_req = SendCommonText(text, userid_list);
            var json_req = SendCommonTextAndTitle(title, text, userid_list);
            //var json_req = SendCardMsg("销售订单管理系统", content.ToString(), "查看详情", "https://ding-doc.dingtalk.com/", txtusesid.Text);
 
            string jsonRequest = JsonConvert.SerializeObject(json_req);//将对象转换为json
            //POST请求 消息推送
            var sr = apiHelper.Post(MessageUrl, jsonRequest);
            return sr;
        }
 
        /// <summary>
        /// 文本消息推送(MarkDown格式)
        /// </summary>
        /// <param name="title">提醒用户的标题</param>
        /// <param name="text">提醒内容(支持markdown文本解析)</param>
        /// <param name="linkText">链接文本</param>
        /// <param name="linkUrl">链接地址</param>
        /// <param name="userid_list">用户id,多个用户用,隔开(如:123,456)</param>
        /// <returns></returns>
        public string SendActionCardMessageToUser(string title, string text, string linkText, string linkUrl, string userid_list)
        {
            GetToken();
            if (string.IsNullOrWhiteSpace(AccessToken) || string.IsNullOrWhiteSpace(text)
                || string.IsNullOrWhiteSpace(userid_list))
                return "";
 
            string MessageUrl = String.Format("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token={0}", AccessToken);
 
            var json_req = SendCardMsg(title, text, linkText, linkUrl, userid_list);
 
            string jsonRequest = JsonConvert.SerializeObject(json_req);//将对象转换为json
            //POST请求 消息推送
            var sr = apiHelper.Post(MessageUrl, jsonRequest);
            return sr;
        }
        #endregion
 
        #region 推送消息类型
        /// <summary>
        /// 推送普通文本内容
        /// </summary>
        /// <param name="content"></param>
        /// <param name="usesid"></param>
        /// <returns></returns>
        public object SendCommonText(string content, string usesid)
        {
            return new
            {
                userid_list = usesid,  //接受推送userid,不同用户用|分割
                //dept_id_list = "127577105",   //接受推送部门id
                agent_id = agentid,//应用Id
                to_all_user = "true",
                msg = new
                {
                    msgtype = "text",
                    text = new { content = content.ToString() }//内容text
 
                }
            };
        }
 
 
        /// <summary>
        /// 推送markdown内容
        /// </summary>
        /// <param name="_title"></param>
        /// <param name="_content"></param>
        /// <param name="usesid"></param>
        /// <returns></returns>
        public object SendCommonTextAndTitle(string _title, string _content, string usesid)
        {
            return new
            {
                userid_list = usesid,  //接受推送userid,不同用户用|分割
                dept_id_list = "",   //接受推送部门id
                agent_id = agentid,//应用Id                
                msg = new
                {
                    msgtype = "markdown",//推送类型
                    markdown = new
                    {
                        title = _title,
                        text = _content//内容text
                    }
                }
            };
        }
        /// <summary>
        /// 推送action_card格式内容
        /// </summary>
        /// <param name="_title">标题</param>
        /// <param name="_content">内容</param>
        /// <param name="_single_title">链接标题</param>
        /// <param name="_single_url">链接地址</param>
        /// <param name="usesid"></param>
        /// <returns></returns>
        public object SendCardMsg(string _title, string _content, string _single_title, string _single_url, string usesid)
        {
            return new
            {
                userid_list = usesid,  //接受推送userid,不同用户用|分割
                //dept_id_list = "",   //接受推送部门id
                agent_id = agentid,//应用Id               
                msg = new
                {
                    msgtype = "action_card",
                    action_card = new
                    {
                        title = _title,//提示信息
                        markdown = _content,
                        single_title = _single_title,
                        single_url = _single_url
                    }
                }
            };
        }
 
        #endregion
        #region 群机器人 推送消息
 
        static void SendMarkdownMessage(string webhookUrl, string accessToken, string secret, string title, string markdownContent, string phone)
        {
            long timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
            string sign = ComputeSignature(secret, timestamp);
            string url = $"{webhookUrl}?access_token={accessToken}&timestamp={timestamp}&sign={sign}";
            using (HttpClient client = new HttpClient())
            {
                List<string> Mobiles = new List<string>() { phone };
                var pay = new
                {
                    at = new
                    {
                        atMobiles = Mobiles,
                        isAtAll = false
                    },
                    msgtype = "text",
                    text = new
                    {
                        content = markdownContent
                    }
                };
                var payload = new
                {
                    msgtype = "text",
                    text = new
                    {
                        content = markdownContent
                    }
                };
                //string jsonPayload = Newtonsoft.Json.JsonConvert.SerializeObject(payload);
                string jsonPayload = Newtonsoft.Json.JsonConvert.SerializeObject(pay);
                var content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
                var response = apiHelper.Post(url, jsonPayload);
                LogHelper.Info("返回" + response, "钉钉通知");
            }
        }
 
        static string ComputeSignature(string secret, long timestamp)
        {
            string stringToSign = $"{timestamp}\n{secret}";
            byte[] secretBytes = Encoding.UTF8.GetBytes(secret);
            byte[] stringToSignBytes = Encoding.UTF8.GetBytes(stringToSign);
 
            using (var hmac = new HMACSHA256(secretBytes))
            {
                byte[] hashBytes = hmac.ComputeHash(stringToSignBytes);
                return Convert.ToBase64String(hashBytes);
            }
        }
 
        /// <summary>
        /// 钉钉通知
        /// </summary>
        /// <param name="JqrValue">发送的内容</param>
        /// <param name="phone">手机账号(非必填)</param>
        public void button1_Click(string JqrValue = "", string phone = "")
        {
            LogHelper.Info(JqrValue, "钉钉通知");
            string webhookUrl = "https://oapi.dingtalk.com/robot/send";
            string accessToken = "8fd9cdb520d37f706abe2db307909f0756b3be4a339db52acaeec197651694f2";
            string secret = "SEC484c1305c61ed9c72a7c124cd338f46aa7b88f6b4c88c8b469c06ec9b6076962";
            string markdownContent = JqrValue;
            string title = "Markdown Message";
            SendMarkdownMessage(webhookUrl, accessToken, secret, title, markdownContent, phone);
        }
        #endregion
    }
}