添加项目文件。
This commit is contained in:
241
TelegramService.Bl/CnblogsBl.cs
Normal file
241
TelegramService.Bl/CnblogsBl.cs
Normal file
@@ -0,0 +1,241 @@
|
||||
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using TelegramService.Bl;
|
||||
using TelegramService.Entity;
|
||||
using TelegramService.Help;
|
||||
namespace TelegramServiceV6.Bl
|
||||
{
|
||||
public class CnblogsBl
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 发送 消息
|
||||
/// </summary>
|
||||
private async void SendTextMessage(string title, string author, string authorUrl, string time, string preview, string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sHtml = "\r\n主 题:<b>" + title + "</b>\n";
|
||||
sHtml += "作 者:<a href=\"" + authorUrl + "\">" + author + "</a>\n";
|
||||
sHtml += "时 间:<b>" + time + "</b>\n";
|
||||
sHtml += "预 览:<b>" + preview + "</b>\n";
|
||||
sHtml += "链 接:<a href=\"" + url + "\">" + url + "</a>\n";
|
||||
JObject oObj = new JObject();
|
||||
oObj.Add("chat_id", "-1001341062469");
|
||||
oObj.Add("text", sHtml);
|
||||
oObj.Add("parse_mode", "HTML");
|
||||
//是否显示url 预览
|
||||
oObj.Add("disable_web_page_preview", "TRUE");
|
||||
SendMessageBl.SendWx("https://api.telegram.org/bot1879430057:AAHtwdwHLH0a7cNjTPBQsI92ivoKZI6P-5A/sendMessage", oObj.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[CnblogsBl.SendTextMessage] " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 发送微信
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="author"></param>
|
||||
/// <param name="authorUrl"></param>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="preview"></param>
|
||||
/// <param name="url"></param>
|
||||
private void SendWeixin(string title, string author, string authorUrl, string time, string preview, string url)
|
||||
{
|
||||
|
||||
string sHtml = "主 题:" + title + "\n";
|
||||
sHtml += "作 者:<a href=\"" + authorUrl + "\">" + author + "</a>\n";
|
||||
sHtml += "时 间:" + time + "\n";
|
||||
sHtml += "预 览:" + preview + "\n";
|
||||
sHtml += "链 接:<a href=\"" + url + "\">" + url + "</a>\n";
|
||||
JObject oObj = new JObject();
|
||||
oObj.Add("text", sHtml);
|
||||
|
||||
SendMessageBl.SendWx("https://111.230.99.204/weixin/api/send_text", oObj.ToString());
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取博客内容
|
||||
/// </summary>
|
||||
public async Task GetCnblogsHtml()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DateTime.Now.Hour < 6)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[CnblogsBl.GetCnblogsHtml] 晚上0-6点不执行!");
|
||||
return;
|
||||
}
|
||||
|
||||
EntrustHelper.STCB("show", "[CnblogsBl.GetCnblogsHtml] 开始执行!");
|
||||
string shtml =await GetHtml();
|
||||
|
||||
if (shtml.IsNullOrWhiteSpace())
|
||||
{
|
||||
EntrustHelper.STCB("show", "[CnblogsBl.GetCnblogsHtml] 获取不到数据!");
|
||||
return;
|
||||
}
|
||||
List<HtmlTag> listHtmlTag = HtmlTag.FindTagByAttr(shtml, "div", "id", "post_list");
|
||||
|
||||
List<HtmlTag> listObj = null;
|
||||
|
||||
if (listHtmlTag.Count > 0)
|
||||
{
|
||||
listHtmlTag = listHtmlTag[0].FindTag("article");
|
||||
}
|
||||
string stitle = "";
|
||||
string sauthor = "";
|
||||
string sauthorUrl = "";
|
||||
string stime = "";
|
||||
string spreview = "";
|
||||
string surl = "";
|
||||
int iCount = listHtmlTag.Count;
|
||||
for (int i = 1; i <= listHtmlTag.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
listObj = listHtmlTag[iCount - i].FindTagByAttr("a", "class", "post-item-title");
|
||||
stitle = listObj[0].InnerText;
|
||||
surl = listObj[0].GetAttribute("href");
|
||||
|
||||
listObj = listHtmlTag[iCount - i].FindTagByAttr("p", "class", "post-item-summary");
|
||||
spreview = listObj[0].InnerText.Trim();
|
||||
|
||||
listObj = listHtmlTag[iCount - i].FindTagByAttr("a", "class", "post-item-author");
|
||||
sauthor = listObj[0].InnerText.Trim();
|
||||
sauthorUrl = listObj[0].GetAttribute("href");
|
||||
|
||||
listObj = listHtmlTag[iCount - i].FindTagByAttr("span", "class", "post-meta-item");
|
||||
stime = listObj[0].FindTag("span")[0].InnerHTML;
|
||||
|
||||
if (!IsExistUrl(surl))
|
||||
{
|
||||
//写入数据库
|
||||
SetCnblogsDB(stitle, sauthor, sauthorUrl, stime, spreview, surl);
|
||||
//发送TG消息
|
||||
SendTextMessage(stitle, sauthor, sauthorUrl, stime, spreview, surl);
|
||||
//发送微信
|
||||
SendWeixin(stitle, sauthor, sauthorUrl, stime, spreview, surl);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[CnblogsBl.GetCnblogsHtml] " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
listHtmlTag.Clear();
|
||||
listObj.Clear();
|
||||
EntrustHelper.STCB("show", "[CnblogsBl.GetCnblogsHtml] 执行结束!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[CnblogsBl.GetCnblogsHtml] " + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
EntrustHelper.STCB("InitTimer", Appsettings.Conf.Interval);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否存在 true=存在 false=不存在
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
private bool IsExistUrl(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
int iCount = 0;
|
||||
iCount = Db.dbConnection.Queryable<cnblogsList>().Where(it => it.url == url).Count();
|
||||
if (iCount == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[CnblogsBl.IsExistUrl] " + ex.Message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入 数据库
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="author"></param>
|
||||
/// <param name="authorUrl"></param>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="preview"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
private int SetCnblogsDB(string title, string author, string authorUrl, string time, string preview, string url)
|
||||
{
|
||||
string sSql = "";
|
||||
int iCount = 0;
|
||||
cnblogsList encnblogsList = new cnblogsList();
|
||||
encnblogsList.url = url;
|
||||
encnblogsList.title = title;
|
||||
encnblogsList.preview = preview;
|
||||
encnblogsList.author = author;
|
||||
encnblogsList.authorUrl = authorUrl;
|
||||
encnblogsList.time = time;
|
||||
encnblogsList.addTime = DateTime.Now;
|
||||
iCount = Db.dbConnection.Insertable(encnblogsList).ExecuteCommand();
|
||||
return iCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取html
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<string> GetHtml()
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpResult httpResult = null;
|
||||
string html = "";
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
httpResult =await HttpHelper.GetAsync("https://www.cnblogs.com/");
|
||||
if (httpResult.StatusCode == 200)
|
||||
{
|
||||
if (httpResult.Html.IndexOfStr("id=\"post_list\""))
|
||||
{
|
||||
return httpResult.Html;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[CnblogsBl.GetHtml] " + ex.Message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
158
TelegramService.Bl/FundBl.cs
Normal file
158
TelegramService.Bl/FundBl.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using TelegramService.Help;
|
||||
using TelegramService.Entity;
|
||||
using TelegramService.Help;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramServiceV6.Bl
|
||||
{
|
||||
public class FundBl
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 发送微信
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="author"></param>
|
||||
/// <param name="authorUrl"></param>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="preview"></param>
|
||||
/// <param name="url"></param>
|
||||
public static void SendWeixinFund()
|
||||
{
|
||||
SendWeixinFundEastmoney();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送微信 http://fund.eastmoney.com/ 天天基金
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="author"></param>
|
||||
/// <param name="authorUrl"></param>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="preview"></param>
|
||||
/// <param name="url"></param>
|
||||
public static async Task SendWeixinFundEastmoney()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
EntrustHelper.STCB("show", "[FundBl.SendWeixinFundEastmoney] 开始发送基金");
|
||||
string code = string.Join(",", Appsettings.Conf.Fund);
|
||||
|
||||
Dictionary<string, string> form = new Dictionary<string, string>();
|
||||
form.Add("fcodes", code);
|
||||
|
||||
Dictionary<string, string> header = new Dictionary<string, string>();
|
||||
header.Add("Origin", "https://favor.fund.eastmoney.com");
|
||||
header.Add("Referer", "https://favor.fund.eastmoney.com/");
|
||||
|
||||
HttpResult httpResult = null;
|
||||
string html = "";
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
httpResult = await HttpHelper.PostFormAsync("https://api.fund.eastmoney.com/favor/GetFundsInfo?", form, header);
|
||||
if (httpResult.StatusCode == 200)
|
||||
{
|
||||
html = httpResult.Html;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (html.IsNull())
|
||||
{
|
||||
EntrustHelper.STCB("show", "[FundBl.SendWeixinFundEastmoney] 开始发送基金,请求失败");
|
||||
EntrustHelper.STCB("show", "[FundBl.SendWeixinFundEastmoney] "+html);
|
||||
EntrustHelper.STCB("show", "[FundBl.SendWeixinFundEastmoney] 开始发送基金,请求失败");
|
||||
return;
|
||||
}
|
||||
|
||||
JObject jsdata = JObject.Parse(html);
|
||||
if (jsdata["ErrCode"].ToString() != "0")
|
||||
{
|
||||
EntrustHelper.STCB("show", "[FundBl.SendWeixinFundEastmoney1] "+jsdata.ToString());
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder sb1 = new StringBuilder();
|
||||
sb1.Append("---------------------------------\n");
|
||||
int index = 0;
|
||||
foreach (var data in jsdata["Data"]["KFS"])
|
||||
{
|
||||
if (!code.Contains(data["FCODE"].ToString()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (data["RZDF"].ToDouble() >= 0)
|
||||
{
|
||||
if (sb.Length > 0) sb.Append("---------------------------------\n");
|
||||
|
||||
sb.Append(data["FSRQ"] + " (" + data["FCODE"].ToString() + ")\n");
|
||||
sb.Append(data["SHORTNAME"] + "\n");
|
||||
sb.Append(data["RZDF"] + "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb1.Append("---------------------------------\n");
|
||||
sb1.Append(data["FSRQ"] + " (" + data["FCODE"].ToString() + ")\n");
|
||||
sb1.Append(data["SHORTNAME"] + "\n");
|
||||
sb1.Append(data["RZDF"] + "\n");
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[FundBl.SendWeixinFundEastmoney] 请求微信api接口");
|
||||
httpResult=await HttpHelper.GetAsync("https://111.230.99.204/weixin/api/msgyq?id=CaiMengNan&text=" + sb.ToString() + sb1.ToString());
|
||||
if (httpResult.StatusCode==200 && httpResult.Html.IndexOfStr("\"errmsg\":\"ok\""))
|
||||
{
|
||||
EntrustHelper.STCB("show", "[FundBl.SendWeixinFundEastmoney] 发送基金成功");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[FundBl.SendWeixinFundEastmoney] "+ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
DateTime next22 = new DateTime(now.Year, now.Month, now.Day, 22, 0, 0);
|
||||
// 如果现在已经过了今天的 22:00,则计算明天的 22:00
|
||||
if (now >= next22)
|
||||
{
|
||||
next22 = next22.AddDays(1);
|
||||
}
|
||||
double millisecondsUntilNext22 = (next22 - now).TotalMilliseconds;
|
||||
|
||||
EntrustHelper.STCB("show", "[FundBl.SendWeixinFundEastmoney] 等待下次执行");
|
||||
EntrustHelper.STCB("sendWeixinFund", millisecondsUntilNext22);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[FundBl.SendWeixinFundEastmoney] " + ex.Message);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
55
TelegramService.Bl/SendMessageBl.cs
Normal file
55
TelegramService.Bl/SendMessageBl.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using NetTaste;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using TelegramService.Help;
|
||||
|
||||
namespace TelegramService.Bl
|
||||
{
|
||||
public class SendMessageBl
|
||||
{
|
||||
|
||||
|
||||
|
||||
public static async Task<bool> SendWx(string url,string msg)
|
||||
{
|
||||
HttpResult httpResult;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
httpResult = await HttpHelper.PostJsonAsync(url, msg);
|
||||
if (httpResult.StatusCode != 200)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (httpResult.Html.IndexOfStr("\"errmsg\":\"ok\""))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static async Task<bool> SendTg(string url,string msg)
|
||||
{
|
||||
HttpResult httpResult = null;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
httpResult = await HttpHelper.PostJsonAsync(url, msg);
|
||||
if (httpResult.StatusCode != 200)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (httpResult.Html.IndexOfStr("\"ok\":true,"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
14
TelegramService.Bl/TelegramService.Bl.csproj
Normal file
14
TelegramService.Bl/TelegramService.Bl.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TelegramService.Entity\TelegramService.Entity.csproj" />
|
||||
<ProjectReference Include="..\TelegramService.Help\TelegramService.Help.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
174
TelegramService.Bl/TieBaBl.cs
Normal file
174
TelegramService.Bl/TieBaBl.cs
Normal file
@@ -0,0 +1,174 @@
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using TelegramService.Bl;
|
||||
using TelegramService.Entity;
|
||||
using TelegramService.Help;
|
||||
|
||||
namespace TelegramServiceV6.Bl
|
||||
{
|
||||
public class TieBaBl
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 发送 消息
|
||||
/// </summary>
|
||||
private void SendTextMessage(string title, string sType, string stime, string surl)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string sHtml = "\r\n标 题:<b>" + title + "</b>\n";
|
||||
sHtml += "类 型:<b>" + sType + "</b>\n";
|
||||
sHtml += "入库时间:<b>" + stime + "</b>\n";
|
||||
sHtml += "链 接:<a href=\"" + surl + "\">" + surl + "</a>\n";
|
||||
JObject oObj = new JObject();
|
||||
oObj.Add("chat_id", "-1001523898048");
|
||||
oObj.Add("text", sHtml);
|
||||
oObj.Add("parse_mode", "HTML");
|
||||
//是否显示url 预览
|
||||
oObj.Add("disable_web_page_preview", "TRUE");
|
||||
SendMessageBl.SendTg("https://api.telegram.org/bot1918024418:AAHj_RNtA-XkWbodtzkzaTIxc0XYxBVoQKY/sendMessage", oObj.ToString());
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[TieBaBl.SendTextMessage] " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取贴吧
|
||||
/// </summary>
|
||||
public async void GetTieBaHtml()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
EntrustHelper.STCB("show", "[TieBaBl.GetTieBaHtml1] 开始执行!");
|
||||
|
||||
HttpResult httpResult = null;
|
||||
|
||||
foreach (var tk in Appsettings.Conf.TieBa)
|
||||
{
|
||||
string key = tk.ToString();
|
||||
string encodedUrl = HttpUtility.UrlEncode(key);
|
||||
string shtml = null;
|
||||
string tiebaUrl = "https://tieba.baidu.com/mo/m?kw=" + encodedUrl.ToUpper() + "&lm=&pn=0";
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
httpResult =await HttpHelper.GetAsync(tiebaUrl);
|
||||
if (httpResult.StatusCode == 200)
|
||||
{
|
||||
shtml = httpResult.Html;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (shtml.IsNullOrWhiteSpace())
|
||||
{
|
||||
EntrustHelper.STCB("show", "[TieBaBl.GetTieBaHtml2] 获取不到数据!");
|
||||
return;
|
||||
}
|
||||
List<HtmlTag> listHtmlTag = HtmlTag.FindTagByAttr(shtml, "ul", "id", "frslistcontent");
|
||||
List<HtmlTag> lista = null;
|
||||
if (listHtmlTag.Count == 0)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[TieBaBl.GetTieBaHtml3] 贴吧html匹配不到div!");
|
||||
return;
|
||||
}
|
||||
listHtmlTag = listHtmlTag[0].FindTagByAttr("li", "class", "tl_shadow tl_shadow_new ");
|
||||
for (int i = 0; i < listHtmlTag.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
lista = listHtmlTag[i].FindTag("a");
|
||||
if (lista.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string url = lista[0].GetAttribute("href");
|
||||
string id = Regex.Match(url, @"(?is)/p/(?<value>.*?)s*\?").Groups["value"].Value;
|
||||
if (id.IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
lista = lista[0].FindTagByAttr("div", "class", "ti_title");
|
||||
if (lista.Count <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string title = lista[0].InnerText;
|
||||
if (title.Contains(" "))
|
||||
{
|
||||
string[] arr = title.SplitRemoveEmptyEntries(" ");
|
||||
if (arr.Length > 1)
|
||||
{
|
||||
title = arr[1];
|
||||
}
|
||||
}
|
||||
tieba tb = new tieba();
|
||||
tb.id = id;
|
||||
tb.title = title;
|
||||
if (tb.title.Length > 149)
|
||||
{
|
||||
tb.title = tb.title.Substring(0, 149);
|
||||
}
|
||||
tb.key = key;
|
||||
tb.url = "tieba.baidu.com/p/" + tb.id;
|
||||
tb.sysaddtime = DateTime.Now;
|
||||
if (SetTieBaDB(tb) > 0)
|
||||
{
|
||||
SendTextMessage(tb.title, tb.key, tb.sysaddtime.ToDateStr(), "https://" + tb.url);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[TieBaBl.GetTieBaHtml4] " + ex.Message);
|
||||
}
|
||||
}
|
||||
listHtmlTag.Clear();
|
||||
lista.Clear();
|
||||
Thread.Sleep(5000);
|
||||
}
|
||||
EntrustHelper.STCB("show", "[TieBaBl.GetTieBaHtml5] 执行结束!");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
EntrustHelper.STCB("InitTimerTieBa", Appsettings.Conf.IntervalTieBa);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 写入 数据库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private int SetTieBaDB(tieba tb)
|
||||
{
|
||||
try
|
||||
{
|
||||
var x = Db.dbConnection.Storageable(tb).ToStorage();
|
||||
x.AsInsertable.ExecuteCommand();//不存在插入
|
||||
return x.InsertList.Count;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EntrustHelper.STCB("show", "[TieBaBl.SetTieBaDB] " + ex.Message);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user