/// <summary> /// 获取Github主题邮件内容 /// </summary> /// <param name="theme">关注的Github主题</param> /// <param name="type">邮件内容格式</param> /// <returns></returns> public static string GetThemeContents(string theme, MailContentType type) { ATLog.Info("获取Github关注的话题"); List <ThemeRepo> repos = JsonParserGithub.GetThemeRepos(theme); string content = ""; switch (type) { case MailContentType.TEXT: content = MailTextTemplate.CreateMailByThemeTemplate(repos); break; case MailContentType.HTML: content = MailHTMLTemplate.GetHTMLContentByTheme(repos); break; } //File.WriteAllText(Path.Combine(System.Environment.CurrentDirectory, "B.html"), content); return(content); }
/// <summary> /// 获取Github趋势邮件内容 /// </summary> /// <param name="fllowLanguage">关注何种语言趋势</param> /// <param name="type">邮件内容格式</param> /// <returns></returns> public static string GetFollowContents(string fllowLanguage, MailContentType type) { ATLog.Info("获取Github每日趋势"); List <TrendingRepo> repos = HTMLParserGitHub.Trending("daily", fllowLanguage).Result; string content = ""; switch (type) { case MailContentType.TEXT: ATLog.Info("创建Text格式的邮件模板"); content = MailTextTemplate.CreateMailTemplate(repos); break; case MailContentType.HTML: ATLog.Info("创建HTML格式的邮件模板"); content = MailHTMLTemplate.GetHTMLContentByLanguage(repos); break; } //File.WriteAllText(Path.Combine(System.Environment.CurrentDirectory, "A.html"),content); return(content); }
/// <summary> /// 与知乎数据相关的行为 /// </summary> private static void ZhihuAction() { if ((zhihuConf.isDebug && !zhihuConf.isDebugSend) || UpdateNoticeCondition(zhihuConf.noticeRate)) { List <HotRepo> repos = HTMLParserZhihu.GetHotData(); if (zhihuConf.database) { ZhihuOp.Instance.SaveRangeData(repos); } List <HotRepo> dataList = ZhihuOp.Instance.GetRangeHotData(DateTime.Now); string mailContent = MailTextTemplate.CreateMailTemplate(dataList); ATLog.Info("查找热点的订阅者"); //查找热点订阅者 List <string> users = new List <string>(); foreach (var mailAddress in zhihuConf.SubscribeHot.Keys) { if (zhihuConf.SubscribeHot[mailAddress]) { users.Add(mailAddress); } } ATLog.Info("向订阅者发送邮件"); MailManager.SendMail(zhihuConf, SubscriptionSubject.Hots, mailContent, users, false); if (zhihuConf.isDebug) { zhihuConf.isDebugSend = true; } SendStatus.SetSendSatus(zhihuConf.noticeRate); } if (!zhihuConf.isDebug) { CheckSendStatusForReset(zhihuConf.noticeRate); } }