/// <summary> /// 后台HangFire调用定时任务 /// </summary> /// <param name="settingId"></param> public static void ExcuteTimerTask(int settingId) { //从后台任务列表获取到需要发送的记录 ConditionSettingModel.SettingModel model = ConditionSettingBLL.GetSendingTaskItem(settingId); string batchId = ""; if (string.IsNullOrEmpty(model.LatestBatchId)) { //从后台设置的任务生成消息批次 batchId = PreparePushingMsg(model.AccIdSet, model.AccIdCount, 3, model.MobileTitle, model.PubTitle, model.EmailTitle, model.SmsContent, model.MobileContent, model.PubContent, model.EmailContent, model.Remark + "(" + model.SendingDate + "定时发送)", model.Verification, "1"); //更新任务的批次Id防止重复提交 ConditionSettingBLL.SetBatchId(settingId, batchId); } else { batchId = model.LatestBatchId; } string uName = Sys_Manage_UserBLL.GetManageUserNameById(model.Operator); SendMsgAuto(batchId, model.Operator, uName); }
/// <summary> /// 后台HangFire调用循环任务 /// </summary> /// <param name="settingId"></param> public static void ExcuteRecurringTask(int settingId) { //从后台任务列表获取到需要发送的记录 ConditionSettingModel.SettingModel model = ConditionSettingBLL.GetSendingTaskItem(settingId); //获取循环任务的Sql List <string> sqlSet = CommonLib.Helper.JsonDeserializeObject <List <string> >(ConditionSettingBLL.GetSqlJsonById(settingId)); //拼装Sql组的字典 Dictionary <int, List <int> > dicData = new Dictionary <int, List <int> >(); for (int i = 0; i < sqlSet.Count; i++) { dicData[i] = RuleListBLL.GetAccIdByStr(sqlSet[i]); } #region 处理产生的集合并合并 if (dicData.Count > 0) { List <int> temp = dicData.First().Value; foreach (var item in dicData) { temp = temp.Intersect(item.Value).ToList(); } if (temp.Count > 0) { string accIdSet = CommonLib.Helper.JsonSerializeObject(temp); int accIdCount = temp.Count; //从后台设置的任务生成消息批次 string batchId = PreparePushingMsg(accIdSet, accIdCount, 4, model.MobileTitle, model.PubTitle, model.EmailTitle, model.SmsContent, model.MobileContent, model.PubContent, model.EmailContent, model.Remark + "(" + model.SendingDate + "循环定时发送)", model.Verification, "1"); //更新任务的批次Id防止重复提交 ConditionSettingBLL.SetBatchId(settingId, batchId); string uName = Sys_Manage_UserBLL.GetManageUserNameById(model.Operator); SendMsgAuto(batchId, model.Operator, uName); } } #endregion }