예제 #1
0
 public bool PushMassage(WebsiteInfo website, string title, string text, string link, UserInfo user, out string msg)
 {
     msg = "";
     if (website.AppPushType == "getui")
     {
         if (!HaveGetuiAppPush(website))
         {
             msg = "推送配置不完整";
             return(false);
         }
         if (title.Length > 40)
         {
             msg = "个推标题最多支持40个字";
             return(false);
         }
         text = text.Replace("\n", ",");
         if (text.Length > 600)
         {
             msg = "个推标题最多支持600个字";
             return(false);
         }
         List <AppPushClient> clientList = GetAppPushClientList(int.MaxValue, 1, website.WebsiteOwner, "", website.AppPushAppId, "", user.UserID, "", "1");
         if (clientList.Count == 0)
         {
             msg = "推送对象为空";
             return(false);
         }
         List <string>   clientIds = clientList.Select(p => p.PushClientId).ToList();
         GetuiPushHelper getui     = new GetuiPushHelper(website.AppPushAppKey, website.AppPushMasterSecret);
         msg = getui.PushMessageToList(website.AppPushAppId, website.AppPushAppKey, title, text, link, clientIds);
         JToken jto = JToken.Parse(msg);
         if (jto["result"] != null && jto["result"].ToString() == "ok")
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         msg = "推送类型不支持";
         return(false);
     }
 }
예제 #2
0
 public bool PushMassage(WebsiteInfo website, string title, string text, string link, List <UserInfo> users, out string msg)
 {
     msg = "";
     if (website.AppPushType == "getui")
     {
         if (!HaveGetuiAppPush(website))
         {
             msg = "推送配置不完整";
             return(false);
         }
         if (title.Length > 40)
         {
             msg = "个推标题最多支持40个字";
             return(false);
         }
         if (text.Length > 600)
         {
             msg = "个推标题最多支持600个字";
             return(false);
         }
         string userIds = users == null?"": ZentCloud.Common.MyStringHelper.ListToStr(users.Select(p => p.UserID).Distinct().ToList(), "", ",");
         List <AppPushClient> clientList = GetAppPushClientList(int.MaxValue, 1, website.WebsiteOwner, "", website.AppPushAppId, "", "", userIds, "1");
         if (clientList.Count == 0)
         {
             msg = "推送对象为空";
             return(false);
         }
         List <string>   clientIds    = clientList.Select(p => p.PushClientId).ToList();
         GetuiPushHelper getui        = new GetuiPushHelper(website.AppPushAppKey, website.AppPushMasterSecret);
         string          resultString = getui.PushMessageToList(website.AppPushAppId, website.AppPushAppKey, title, text, link, clientIds);
         return(true);
     }
     else
     {
         msg = "推送类型不支持";
         return(false);
     }
 }