| | |
| | | using Newtonsoft.Json; |
| | | using com.igetui.api.openservice.igetui.template; |
| | | using com.igetui.api.openservice.igetui; |
| | | using WebApiWithFleck; |
| | | using System.Collections.Concurrent; |
| | | |
| | | namespace WebAPI.Service |
| | | { |
| | |
| | | // 推送服务实例 |
| | | private static IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET); |
| | | |
| | | private static Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | |
| | | |
| | | // 单条消息推送 |
| | | public static void PubishSingle(int HInterID) |
| | | { |
| | |
| | | select * from Gy_UserClientIdRelation |
| | | ", "h_v_OA_WorkLinkBillAllList"); |
| | | NotificationTemplate template = null; |
| | | ConcurrentDictionary<string, List<string>> userClientIDDictionary = new ConcurrentDictionary<string, List<string>>(); |
| | | // 将用户设备关联表 收集为 Map |
| | | if (ds.Tables[1].Rows.Count > 0) |
| | | { |
| | | foreach (DataRow row in ds.Tables[1].Rows) |
| | | { |
| | | if (userClientIDDictionary.ContainsKey(row["HUserName"].ToString())){ |
| | | userClientIDDictionary[row["HUserName"].ToString()].Add(row["HClientID"].ToString()); |
| | | } |
| | | else |
| | | { |
| | | userClientIDDictionary.TryAdd(row["HUserName"].ToString(), new List<string>() { row["HClientID"].ToString() }); |
| | | } |
| | | } |
| | | } |
| | | if(ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | string title = ds.Tables[0].Rows[0]["主题"].ToString(); |
| | |
| | | // 广播 |
| | | if(ds.Tables[0].Rows[0]["发送类型"].ToString() == "公共") |
| | | { |
| | | // 遍历 全推送 |
| | | foreach(DataRow row in ds.Tables[1].Rows) |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | | { |
| | | pushSuccess = PushMessageToSingle(template, row["HClientID"].ToString()); |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "华舟") |
| | | { |
| | | // 推送给接收人 和 抄送人 |
| | | foreach (DataRow row in ds.Tables[0].Rows) |
| | | { |
| | | List<string> clientIDList = new List<string>(); |
| | | if (userClientIDDictionary.ContainsKey(row["接收人"].ToString())) |
| | | { |
| | | clientIDList = userClientIDDictionary[row["接收人"].ToString()]; |
| | | } |
| | | else if (userClientIDDictionary.ContainsKey(row["抄送接收人"].ToString())) |
| | | { |
| | | clientIDList = userClientIDDictionary[row["抄送接收人"].ToString()]; |
| | | } |
| | | |
| | | |
| | | foreach(string clientID in clientIDList) |
| | | { |
| | | pushSuccess = PushMessageToSingle(template, clientID); |
| | | |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // 遍历 全推送 |
| | | foreach (DataRow row in ds.Tables[1].Rows) |
| | | { |
| | | pushSuccess = PushMessageToSingle(template, row["HClientID"].ToString()); |
| | | } |
| | | } |
| | | } |
| | | }else // 单独推送 |
| | | { |
| | | // 推送给接收人 和 抄送人 |
| | | foreach (DataRow row in ds.Tables[1].Rows) |
| | | foreach (DataRow row in ds.Tables[0].Rows) |
| | | { |
| | | if(ds.Tables[0].Rows[0]["接收人"].ToString() == row["HUserName"].ToString() |
| | | || ds.Tables[0].Rows[0]["抄送接收人"].ToString() == row["HUserName"].ToString()) |
| | | List<string> clientIDList = new List<string>(); |
| | | if (userClientIDDictionary.ContainsKey(row["接收人"].ToString())) |
| | | { |
| | | pushSuccess = PushMessageToSingle(template, row["HClientID"].ToString()); |
| | | clientIDList = userClientIDDictionary[row["接收人"].ToString()]; |
| | | } |
| | | else if (userClientIDDictionary.ContainsKey(row["抄送接收人"].ToString())) |
| | | |
| | | { |
| | | clientIDList = userClientIDDictionary[row["抄送接收人"].ToString()]; |
| | | } |
| | | |
| | | |
| | | foreach (string clientID in clientIDList) |
| | | { |
| | | pushSuccess = PushMessageToSingle(template, clientID); |
| | | |
| | | } |
| | | } |
| | | } |