Esempio n. 1
0
        /// <summary>
        ///客服接口 群发
        /// </summary>
        /// <param name="timingTask"></param>
        /// <returns></returns>
        public bool SendImageTextMessage(TimingTask timingTask)
        {
            BLLWeixin bllWeixin = new BLLWeixin("");
            List <BLLWeixin.WeiXinArticle> articleList = new List <BLLWeixin.WeiXinArticle>();

            string[] idarray = timingTask.TaskInfo.Split(',');
            foreach (string id in idarray)
            {
                WeixinMsgSourceInfo msg = bllWeixin.Get <WeixinMsgSourceInfo>(string.Format("SourceID={0}", id));
                articleList.Add(new BLLWeixin.WeiXinArticle()
                {
                    Title       = msg.Title,
                    Description = msg.Description,
                    Url         = msg.Url,
                    PicUrl      = msg.PicUrl
                });
            }

            switch ((ReceiverType)timingTask.ReceiverType)
            {
            case ReceiverType.All:
                bllWeixin.BroadcastKeFuMessageImageText(timingTask.WebsiteOwner, articleList, timingTask.TaskInfo);
                return(true);

            case ReceiverType.Group:

                return(false);

            case ReceiverType.List:
                string[] openidArray = timingTask.Receivers.Split(',');
                foreach (string openid in openidArray)
                {
                    bllWeixin.SendKeFuMessageImageText(bllWeixin.GetAccessToken(timingTask.WebsiteOwner), openid, articleList);
                }
                return(openidArray.Length > 0);

            default:
                return(false);
            }
        }