private void Run() { try { List <ChatMsg> chatMsgList = new List <ChatMsg>();//聊天记录集合 DateTime time = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); string startTime = (DateTime.Parse(DateTime.Now.AddDays(-1).ToShortDateString()) - time).TotalSeconds.ToString(); string endTime = (DateTime.Parse(DateTime.Now.AddDays(-1).ToShortDateString() + " 23:59:59") - time).TotalSeconds.ToString(); WeChatServiceNumberBll.GetWeChatMsgList(new GetWeChatMsgListReqeust { PlatForm = 0, StartTime = startTime, EndTime = endTime, Number = 10000, MsgId = 1 }, ref chatMsgList); Logger.Info($"微信服务号 - 导入微信服务号聊天记录 JOB,{DateTime.Now.AddDays(-1).Year}年{DateTime.Now.AddDays(-1).Month}月{DateTime.Now.AddDays(-1).Day}日" + $"微信服务号的聊天记录数量是{chatMsgList.Count}条"); if (chatMsgList != null && chatMsgList.Any()) { WeChatServiceNumberDal.ImportWechatServiceNumberChatLog(chatMsgList.Split(500)); } } catch (Exception ex) { Logger.Error($"WechatServiceNumberChatLogJob -> Run -> error ,异常消息:{ex.Message},堆栈信息:{ex.StackTrace}"); } }
private void Run() { try { List <ChatMsg> chatMsgList = new List <ChatMsg>();//聊天记录集合 DateTime nowTime = Convert.ToDateTime("2019-07-20 00:00:00"); DateTime localTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); for (int i = 0; i < 30; i++) { nowTime = nowTime.AddDays(1); string startTime = (DateTime.Parse(nowTime.ToShortDateString()) - localTime).TotalSeconds.ToString(); string endTime = (DateTime.Parse(nowTime.ToShortDateString() + " 23:59:59") - localTime).TotalSeconds.ToString(); WeChatServiceNumberBll.GetWeChatMsgList(new GetWeChatMsgListReqeust { PlatForm = 0, StartTime = startTime, EndTime = endTime, Number = 10000, MsgId = 1 }, ref chatMsgList); } Logger.Info($"微信服务号 - 导入微信服务号聊天记录 JOB,2019/07/21 - 2019/08/19号,微信服务号的聊天记录总数量是{chatMsgList.Count}条"); if (chatMsgList != null && chatMsgList.Any()) { WeChatServiceNumberDal.ImportWechatServiceNumberChatLog(chatMsgList.Split(500)); } } catch (Exception ex) { Logger.Error($"WechatServiceHistoricalChatLogJob -> Run -> error ,异常消息:{ex.Message},堆栈信息:{ex.StackTrace}"); } }