|
@@ -1,3 +1,4 @@
|
|
|
+using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
using HTEXLib.COMM.Helpers;
|
|
|
using HTEXLib.Helpers.ShapeHelpers;
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
@@ -351,7 +352,7 @@ namespace TEAMModelOS.SDK
|
|
|
/// <param name="location"></param>
|
|
|
/// <param name="_configuration"></param>
|
|
|
/// <param name="_dingDing"></param>
|
|
|
- public void BIPushNotify(BINotice bINotice, Dictionary<string, object> replaceData,string location, IConfiguration _configuration, DI.DingDing _dingDing)
|
|
|
+ public void BIPushNotify(BINotice bINotice, Dictionary<string, object> replaceData,string location, IConfiguration _configuration, DingDing _dingDing)
|
|
|
{
|
|
|
|
|
|
try
|
|
@@ -360,16 +361,47 @@ namespace TEAMModelOS.SDK
|
|
|
var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
|
|
|
var url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
|
|
|
string site = location;
|
|
|
- if (location.Contains("China"))
|
|
|
+ string sendSite = "";
|
|
|
+ //处理action
|
|
|
+ string urlAction = "";
|
|
|
+ List<dynamic> actions = new List<dynamic>();
|
|
|
+ if (site.Equals("Global"))
|
|
|
{
|
|
|
- location = "China";
|
|
|
+ sendSite = "Global";
|
|
|
+ urlAction = "https://www.teammodel.net/core/process-notify";
|
|
|
}
|
|
|
- else if (location.Contains("Global"))
|
|
|
+ if (site.Equals("Global-Test") || site.Equals("Global-Dep"))
|
|
|
{
|
|
|
- location = "Global";
|
|
|
+ sendSite = "Global";
|
|
|
+ urlAction = "https://test.teammodel.net/core/process-notify";
|
|
|
+ }
|
|
|
+ if (site.Equals("China"))
|
|
|
+ {
|
|
|
+ sendSite = "China";
|
|
|
+ urlAction = "https://www.teammodel.cn/core/process-notify";
|
|
|
+ }
|
|
|
+ if (site.Equals("China-Test") || site.Equals("China-Dep"))
|
|
|
+ {
|
|
|
+ sendSite = "China";
|
|
|
+ urlAction = "https://test.teammodel.cn/core/process-notify";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bINotice.callbackName != null && bINotice.refuseName != null)
|
|
|
+ {
|
|
|
+ string urlA = $"{urlAction}¬ifyEvent=1&ticket=";
|
|
|
+ string urlB = $"{urlAction}¬ifyEvent=2&ticket=";
|
|
|
+ actions.Add(new { type = "click", label = bINotice.callbackName, url = urlA, tokenbindtype = 1 });
|
|
|
+ actions.Add(new { type = "click", label = bINotice.refuseName, url = urlB, tokenbindtype = 1 });
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (bINotice.callbackName != null && bINotice.refuseName == null)
|
|
|
+ {
|
|
|
+ string urlA = $"{urlAction}¬ifyEvent=1&ticket=";
|
|
|
+ actions.Add(new { type = "click", label = bINotice.callbackName, url = urlA, tokenbindtype = 1 });
|
|
|
}
|
|
|
+
|
|
|
var client = _httpClient;
|
|
|
- var token = CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, location).Result;
|
|
|
+ var token = CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, sendSite).Result;
|
|
|
if (client.DefaultRequestHeaders.Contains("Authorization"))
|
|
|
{
|
|
|
client.DefaultRequestHeaders.Remove("Authorization");
|
|
@@ -380,7 +412,12 @@ namespace TEAMModelOS.SDK
|
|
|
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
|
|
|
}
|
|
|
|
|
|
- NotifyData notifyData = new NotifyData
|
|
|
+ string data = new { value = replaceData }.ToJsonString();
|
|
|
+ if (actions.Any())
|
|
|
+ {
|
|
|
+ data = new { value = replaceData, action = actions }.ToJsonString();
|
|
|
+ }
|
|
|
+ NotifyData notifyData = new()
|
|
|
{
|
|
|
hubName = string.Join(",", bINotice.crowd.types),
|
|
|
sender = bINotice.source,
|
|
@@ -389,7 +426,7 @@ namespace TEAMModelOS.SDK
|
|
|
body = bINotice.content,
|
|
|
eventId = $"BI-send",
|
|
|
eventName = $"BI_SendNotice",
|
|
|
- data = bINotice.ToString()
|
|
|
+ data = data
|
|
|
};
|
|
|
|
|
|
string result = "";
|