Exemplo n.º 1
0
        public override string GetWelcomeInfo()
        {
            //获取Senparc.Weixin.MP.dll版本信息
            //var fileVersionInfo = FileVersionInfo.GetVersionInfo(HttpContext.Current.Server.MapPath("~/bin/Senparc.Weixin.MP.dll"));
            //var version = string.Format("{0}.{1}", fileVersionInfo.FileMajorPart, fileVersionInfo.FileMinorPart);
            string website    = ConfigurationManager.AppSettings.Get("website");
            var    txtContent = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Welcome.txt"));
            var    result     = new StringBuilder();

            //  result.Append("您好,欢迎关注龙岩就业微信公众平台! " + "\n");
            result.Append(txtContent.Trim().Replace("\n", "").Replace("\r", "") + "\n");
            result.Append("        \n");
            result.AppendFormat("龙岩市人力资源市场网<a href=\"{0}\">{1}</a> \n", website, website.Replace("http://", ""));
            result.Append("        \n");
            var dataSevice = new DataAccessSerive();
            var jobList    = dataSevice.GetTopJobInfoList();

            if (jobList.Count > 0)
            {
                foreach (var job in jobList)
                {
                    result.Append(string.Format("<a href=\"{0}/html/detail.html?id={1}\">{2} 最新招聘信息</a> \n",
                                                WebConfigurationManager.AppSettings["domain"], job.JobId, job.ComName));
                    result.Append("        \n");
                }
            }
            return(result.ToString());//"欢迎关注【福建龙岩市人力资源市场 微信公众平台Demo】<br/><img src=\"http://fjlylm.com/imagesnews/tb1.gif\" />";
        }
        public virtual string GetWelcomeInfo()
        {
            //获取Senparc.Weixin.MP.dll版本信息


            //result.Append("感谢您关注了【福建龙岩市人力资源市场 微信公众平台】 \n");
            var txtContent = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Welcome.txt"));
            var result     = new StringBuilder();

            result.Append(txtContent.Trim().Replace("\n", "").Replace("\r", "") + "\n");
            result.Append("        \n");
            result.Append("龙岩市人力资源市场网<a href=\"http://www.fjlylm.com\">www.fjlylm.com</a> \n");
            result.Append("        \n");
            var dataSevice = new DataAccessSerive();
            var jobList    = dataSevice.GetTopJobInfoList();

            if (jobList.Count > 0)
            {
                foreach (var job in jobList)
                {
                    result.Append(string.Format("<a href=\"{0}/html/detail.html?id={1}\">{2} 最新招聘信息</a> \n",
                                                WebConfigurationManager.AppSettings["domain"], job.JobId, job.ComName));
                    result.Append("        \n");
                }
            }


            return(result.ToString());//"欢迎关注【福建龙岩市人力资源市场 微信公众平台Demo】<br/><img src=\"http://fjlylm.com/imagesnews/tb1.gif\" />";
        }
Exemplo n.º 3
0
        protected void btnSendMessage_Click(object sender, EventArgs e)
        {
            //获取 accessToken
            var accessToken = AccessTokenContainer.TryGetToken(WebConfigurationManager.AppSettings["LongNameAppId"],
                                                               WebConfigurationManager.AppSettings["LongNameAppSecret"]);


            OpenIdResultJson json = UserApi.Get(accessToken, "");

            txtResult.Text += json.count;

            foreach (var item in json.data.openid)
            {
                var userinfo = UserApi.Info(accessToken, item);
                txtResult.Text += item + " : " + userinfo.nickname + " " + userinfo.sex.ToString() + "   ";
            }

            var result = GroupsApi.Get(accessToken);
            List <GroupsJson_Group> list = result.groups;
            string content = "文本内容<a href='http://www.baidu.com'>百度</a>";
            string groupId = "100";//分组Id


            var dataSevice = new DataAccessSerive();
            var jobList    = dataSevice.GetTopJobInfoList();

            if (jobList.Count > 0)
            {
                List <Article> articles = new List <Article>();
                int            i        = 0;
                foreach (var job in jobList)
                {
                    string imgUrl = string.Format("{0}/image/{1}.jpg", WebConfigurationManager.AppSettings["domain"], i);
                    var    art1   = new Article()
                    {
                        Title       = job.ComName + "诚聘" + job.JobName,
                        Url         = WebConfigurationManager.AppSettings["domain"] + "/html/detail.html?id=" + job.JobId,
                        PicUrl      = imgUrl,
                        Description = ""
                    };
                    articles.Add(art1);
                    i++;
                }
                var rest = Senparc.Weixin.MP.AdvancedAPIs.Custom.CustomApi.SendNews(accessToken, "oJvzIt8go_mNhCAVE-M0D5EexLpU", articles);
            }
        }
Exemplo n.º 4
0
        private void SendGroupMessage(string tempStr, string accessToken, MediaList_OthersResult imgResult, string strAction)
        {
            string sendCountTxt = Server.MapPath("sendcount.txt");
            var    sendCount    = int.Parse(File.ReadAllText(sendCountTxt));

            NewsModel[] newsList   = new NewsModel[sendCount];
            var         dataSevice = new DataAccessSerive();
            var         jobList    = dataSevice.GetTopJobInfoList();

            if (jobList.Count > 0)
            {
                List <Article> articles = new List <Article>();
                int            i        = 0;
                string         imgName;
                foreach (var job in jobList)
                {
                    if (i == sendCount)
                    {
                        break;
                    }
                    imgName = "send" + i.ToString() + ".jpg";
                    string imgUrl    = string.Format("{0}/image/{1}", WebConfigurationManager.AppSettings["domain"], imgName);
                    var    jobDetail = dataSevice.GetJobDetail(job.JobId);
                    var    news      = new NewsModel();
                    news.author  = "";
                    news.content = tempStr.Replace("[ComName]", job.ComName)
                                   .Replace("[ComBrief]", jobDetail.ComBrief)
                                   .Replace("[DetailPalce]", jobDetail.DetailPalce)
                                   .Replace("[LinkMan]", jobDetail.LinkMan)
                                   .Replace("[Phone]", jobDetail.Phone)
                                   .Replace("[JobName]", jobDetail.JobName)
                                   .Replace("[JobType]", jobDetail.JobType)
                                   .Replace("[LowMoney]", jobDetail.LowMoney)
                                   .Replace("[HrNum]", jobDetail.HrNum)
                                   .Replace("[Edu]", jobDetail.Edu)
                                   .Replace("[RegisterDate]", jobDetail.RegisterDate)
                                   .Replace("[EffectDate]", jobDetail.EffectDate)
                                   .Replace("[Other]", jobDetail.Other)
                                   .Replace("[Sex]", jobDetail.Sex)
                    ;
                    //news.content_source_url = WebConfigurationManager.AppSettings["domain"] + "/html/detail.html?id=" + job.JobId;
                    news.content_source_url = WebConfigurationManager.AppSettings["website"];
                    news.digest             = job.ComName + "诚聘" + job.JobName;
                    news.show_cover_pic     = "0";
                    news.thumb_media_id     = imgResult.item.Find(p => p.name == imgName).media_id;
                    news.title  = job.ComName + "诚聘" + job.JobName;
                    newsList[i] = news;
                    i++;
                }
                UploadForeverMediaResult mediaResult = MediaApi.UploadNews(accessToken, 100000, newsList);
                try
                {
                    GroupMessageApi.SendGroupMessageByGroupId
                        (accessToken, "-1", mediaResult.media_id, GroupMessageType.mpnews, true);
                    txtResult.Text += "提交成功一次" + strAction + " 推送成功";
                }
                catch (Exception ex)
                {
                    txtResult.Text += "提交成功一次订" + strAction + " 推送失败 " + ex.Message;
                }
            }
        }
Exemplo n.º 5
0
        public void PushNews(string accessToken, string webPath, string tempStr)
        {
            OpenIdResultJson json = UserApi.Get(accessToken, "");
            var imgResult         = MediaApi.GetOthersMediaList(accessToken, UploadMediaFileType.image, 0, 10000);
            var DircetPath        = Environment.CurrentDirectory + "/image/";

            if (!Directory.Exists(DircetPath))
            {
                Directory.CreateDirectory(DircetPath);
            }

            for (int i = 0; i < 6; i++)
            {
                string imgName = string.Format("send{0}.jpg", i);
                if (imgResult.item.Find(p => p.name == imgName) == null)
                {
                    var imgPath  = webPath + "/image/" + imgName;
                    var filePath = DircetPath + "/image/" + imgName;
                    CommonUtility.HttpUtility.DownloadFile(imgPath, filePath);
                    var mediaId = MediaApi.UploadForeverMedia(accessToken, filePath).media_id;
                }
            }
            imgResult = MediaApi.GetOthersMediaList(accessToken, UploadMediaFileType.image, 0, 10000);


            string sendCountTxtUrl = webPath + "/" + "sendcount.txt";
            var    sendCountTxt    = CommonUtility.HttpUtility.Get(sendCountTxtUrl);
            var    sendCount       = int.Parse(sendCountTxt);

            NewsModel[] newsList = new NewsModel[sendCount];

            var dataSevice = new DataAccessSerive();
            var jobList    = dataSevice.GetTopJobInfoList();

            if (jobList.Count > 0)
            {
                List <Article> articles = new List <Article>();
                int            i        = 0;
                string         imgName;
                foreach (var job in jobList)
                {
                    if (i == sendCount)
                    {
                        break;
                    }
                    string domain  = ConfigurationManager.AppSettings.Get("domain");
                    string website = ConfigurationManager.AppSettings.Get("website");
                    imgName = "send" + i.ToString() + ".jpg";
                    string imgUrl    = string.Format("{0}/image/{1}", domain, imgName);
                    var    jobDetail = dataSevice.GetJobDetail(job.JobId);
                    var    news      = new NewsModel()
                    {
                        author  = "",
                        content = tempStr.Replace("[ComName]", job.ComName)
                                  .Replace("[ComBrief]", jobDetail.ComBrief)
                                  .Replace("[DetailPalce]", jobDetail.DetailPalce)
                                  .Replace("[LinkMan]", jobDetail.LinkMan)
                                  .Replace("[Phone]", jobDetail.Phone)
                                  .Replace("[JobName]", jobDetail.JobName)
                                  .Replace("[JobType]", jobDetail.JobType)
                                  .Replace("[LowMoney]", jobDetail.LowMoney)
                                  .Replace("[HrNum]", jobDetail.HrNum)
                                  .Replace("[Edu]", jobDetail.Edu)
                                  .Replace("[RegisterDate]", jobDetail.RegisterDate)
                                  .Replace("[EffectDate]", jobDetail.EffectDate)
                                  .Replace("[Other]", jobDetail.Other)
                                  .Replace("[Sex]", jobDetail.Sex)
                        ,
                        //content_source_url = domain + "/html/detail.html?id=" + job.JobId,
                        content_source_url = website,
                        digest             = job.ComName + "诚聘" + job.JobName,
                        show_cover_pic     = "0",
                        thumb_media_id     = imgResult.item.Find(p => p.name == imgName).media_id,
                        title = job.ComName + "诚聘" + job.JobName
                    };
                    newsList[i] = news;
                    i++;
                }
                UploadForeverMediaResult mediaResult = MediaApi.UploadNews(accessToken, 100000, newsList);
                try
                {
                    if (isDebug != "1")
                    {
                        GroupMessageApi.SendGroupMessageByGroupId(accessToken, "-1", mediaResult.media_id, GroupMessageType.mpnews, true);
                    }
                    Console.WriteLine("素材提交推送  推送成功");
                    logger.Info(DateTime.Now.ToString() + " 素材提交推送  推送成功");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("素材提交推送  推送失败 " + ex.Message);
                    var MailService = new MailSendFunc();
                    MailService.SendMail("*****@*****.**", ex.Message, "素材提交推送异常", mailCfg);
                    logger.ErrorException(DateTime.Now.ToString() + "素材提交推送失败 " + ex.Message, ex);
                }
            }
        }