public void Dispose() { this.jobDetail = null; if (this.quartzScheduler != null) { this.Stop(); if (!this.quartzScheduler.IsShutdown) { this.quartzScheduler.Shutdown(); } this.quartzScheduler = null; for (int i = 0; i < 3; i++) { Thread.Sleep(200); } } if (Schedulers.ContainsKey(this.name)) { Schedulers.Remove(this.name); } this.Trigger = null; if (schedulers != null) { schedulers.Clear(); } this.jobDetail = null; }
public async void Stop() { Schedulers.Remove(baseUrl); await scheduler.Shutdown(false); Logger.GetLogger(baseUrl).Info(baseUrl + " feed scheduler stoped"); }
protected override void Execute(object state) { var model = state as MallOrderLateReceiveModel; if (null == model) { return; } try { //从备份区将备份删除 DeleteBackAfterDone(model.OrderID); var lastOrder = MallOrderProvider.GetOrder(model.OrderID); if (null == lastOrder) { throw new CustomException(string.Format("〖精品汇订单(ID:{0})〗信息已不存在!", model.OrderID)); } if (lastOrder.OrderStatus != (int)B2COrderStatus.WaitingReceipt) { throw new CustomException(string.Format("〖精品汇订单(ID:{0})〗状态已发生变更,不能自动完成收货!", lastOrder.OrderID)); } if (model.ShipTime != model.ShipTime) { throw new CustomException(string.Format("〖精品汇订单(ID:{0})〗不能确定发货时间,不能自动完成收货!", lastOrder.OrderID)); } //结算并自动收货 var settlement = new MallOrderSettlementCenter(model.OrderID, true); settlement.Execute(); string message = string.Empty; if (settlement.Success) { message = string.Format("〖精品汇订单(ID:{0}/{1})〗自动确认收货完成!", lastOrder.OrderID, lastOrder.ProductInfo); } else { message = string.Format("〖精品汇订单(ID:{0}/{1})〗自动确认收货失败,原因:{2}", lastOrder.OrderID, lastOrder.ProductInfo, settlement.ErrorMessage); } RunLogger(message); } catch (Exception ex) { this.OnThrowException(ex); } finally { Schedulers.Remove(model.OrderID); } }
protected override void Execute(object state) { var model = state as LegworkAutoConfirmTimeModel; if (null == model) { return; } try { //从备份区将备份删除 DeleteBackAfterDone(model.OrderID); var lastOrder = LegworkOrderProvder.GetLegworkOrder(model.OrderID); if (null == lastOrder) { throw new CustomException(string.Format("〖跑腿订单(ID:{0})〗信息已不存在!", model.OrderID)); } if (lastOrder.Status != (int)LegworkOrderStatus.Delivered) { throw new CustomException(string.Format("〖跑腿订单(ID:{0})〗状态已发生变更,不能自动完成收货!", lastOrder.OrderID)); } //if (model.ShipTime != model.ShipTime) throw new CustomException(string.Format("订单(编号{0})不能确定发货时间,不能自动完成收货!", lastOrder.OrderCode)); //结算并自动收货 var settlement = LegworkOrderProvder.UpdateAutoConfirmTime(lastOrder); string message = string.Empty; if (settlement.Result) { message = string.Format("〖跑腿订单(ID:{0})〗自动确认收货完成!", lastOrder.OrderID); } else { message = string.Format("〖跑腿订单(ID:{0})〗自动确认收货失败!", lastOrder.OrderID); } RunLogger(message); } catch (Exception ex) { this.OnThrowException(ex); } finally { Schedulers.Remove(model.OrderID); } }
protected override void Execute(object state) { var model = state as ReservationOrderLateReceiveModel; if (null == model) { return; } try { //从备份区将备份删除 DeleteBackAfterDone(model.OrderID); var lastOrder = AppointOrderProvider.GetAppointOrder(model.OrderID); if (null == lastOrder) { throw new CustomException(string.Format("〖预约订单(ID:{0})〗信息已不存在!", model.OrderID)); } if (lastOrder.Status != (int)ReservationServiceOrderStatus.MerchantServiceDone) { throw new CustomException(string.Format("〖预约订单(ID:{0})〗状态已发生变更,不能自动确认服务完成!", lastOrder.OrderID)); } //结算并自动收货 var settlement = new ReservationOrderSettlementCenter(model.OrderID, true); settlement.Execute(); string message = string.Empty; if (settlement.Success) { message = string.Format("〖预约订单(ID:{0})〗自动确认服务完成!", lastOrder.OrderID); } else { message = string.Format("〖预约订单(ID:{0})〗自动确认服务完成失败,原因:{1}", lastOrder.OrderID, settlement.ErrorMessage); } RunLogger(message); } catch (Exception ex) { this.OnThrowException(ex); } finally { Schedulers.Remove(model.OrderID); } }
protected override void Execute(object state) { var model = state as LegworkOrderTimeoutModel; if (null == model) { return; } try { //从备份区将备份删除 DeleteBackAfterDone(model.OrderID); var lastOrder = LegworkOrderProvder.GetLegworkOrder(model.OrderID); if (null == lastOrder) { throw new CustomException(string.Format("〖跑腿订单(ID:{0})〗信息已不存在!", model.OrderID)); } if (lastOrder.Status != (int)LegworkOrderStatus.WaitingHandle) { throw new CustomException(string.Format("〖跑腿订单(ID:{0})〗状态已发生变更,不能取消订单!", lastOrder.OrderID)); } //结算并自动收货 var settlement = LegworkOrderProvder.UpdateOrderTimeout(lastOrder); string message = string.Empty; if (settlement.Result) { message = string.Format("〖跑腿订单(ID:{0})〗自动取消订单完成!", lastOrder.OrderID); } else { message = string.Format("〖跑腿订单(ID:{0})〗自动取消订单失败!", lastOrder.OrderID); } RunLogger(message); } catch (Exception ex) { this.OnThrowException(ex); } finally { Schedulers.Remove(model.OrderID); } }
protected override void Execute(object state) { var model = state as MallOrderNoPaymentModel; if (null == model) { return; } try { //从备份区将备份删除 DeleteBackAfterDone(model.OrderID); var lastOrder = MallOrderProvider.GetOrder(model.OrderID); if (null == lastOrder) { throw new CustomException(string.Format("〖精品汇订单(ID:{0})〗信息已不存在!", model.OrderID)); } if (lastOrder.OrderStatus != (int)B2COrderStatus.WaitingPayment) { throw new CustomException(string.Format("〖精品汇订单(ID:{0})〗状态发生变更,不能自动取消订单", lastOrder.OrderID)); } //自动取消订单 bool cancelSuccess = MallOrderProvider.AutoCancelOrder(lastOrder.OrderID).Result; string message = string.Empty; if (cancelSuccess) { message = string.Format("〖精品汇订单(ID:{0}/{1})〗因超时未付款,系统已自动取消订单!", lastOrder.OrderID, lastOrder.ProductInfo); } else { message = string.Format("〖精品汇订单(ID:{0}/{1})〗因超时未付款,系统自动取消订单时操作失败!", lastOrder.OrderID, lastOrder.ProductInfo); } RunLogger(message); } catch (Exception ex) { this.OnThrowException(ex); } finally { Schedulers.Remove(model.OrderID); } }
private void DelBtn_Click(object sender, EventArgs e) { var btn = sender as DelButton; var colorEditBtn = btn.Item; var colorCheckBox = colorEditBtn.Item; calendarsPanel.Controls.Remove(colorCheckBox); calendarsPanel.Controls.Remove(colorEditBtn); calendarsPanel.Controls.Remove(btn); Schedulers.Remove(colorCheckBox.Item); if (IsOnlineMode) { CalendarRequests.RemoveCalendar(colorCheckBox.Item); } UpdateTable(null, null); }
/// <summary> /// Stop service plugin /// </summary> public void Stop() { try { if (_scheduler != null) { _scheduler.Shutdown(); if (Schedulers.Contains(_scheduler)) { Schedulers.Remove(_scheduler); } _scheduler = null; } _logger.Info($"Scheduler [{SchedulerName}] has been succesfully terminated (stop action)"); } catch (Exception e) { _logger.Error(e, $"Scheduler [{SchedulerName}] stop error"); } }
protected override void Execute(object state) { var model = state as VisitingOrderLateNoPaymentModel; if (null == model) { return; } try { //从备份区将备份删除 DeleteBackAfterDone(model.OrderID); var lastOrder = AppointOrderProvider.GetAppointOrder(model.OrderID); if (null == lastOrder) { throw new CustomException(string.Format("〖上门订单(ID:{0})〗信息已不存在!", model.OrderID)); } bool statusRight = false; if (lastOrder.QuoteWays == (int)BusinessServiceQuote.WhenOrder && lastOrder.Status == (int)VisitingServiceOrderStatus.WaitingMerchantReceive && !lastOrder.PaiedTime.HasValue) { statusRight = true; } else if (lastOrder.QuoteWays == (int)BusinessServiceQuote.WhenMeeting && lastOrder.Status == (int)VisitingServiceOrderStatus.UserConfirmQuote && !lastOrder.PaiedTime.HasValue) { statusRight = true; } if (!statusRight) { throw new CustomException(string.Format("〖上门订单(ID:{0})〗状态已发生变更,不能自动完成收货!", lastOrder.OrderID)); } //自动取消订单 bool success = AppointOrderProvider.AutoCancelOrder(lastOrder.OrderID); string message = string.Empty; if (success) { message = string.Format("〖上门订单(ID:{0}/{1})〗因超时未付款,系统已自动取消订单!", lastOrder.OrderID, lastOrder.BusinessName); } else { message = string.Format("〖上门订单(ID:{0}/{1})〗因超时未付款,系统自动取消订单时操作失败!", lastOrder.OrderID, lastOrder.BusinessName); } RunLogger(message); } catch (Exception ex) { this.OnThrowException(ex); } finally { Schedulers.Remove(model.OrderID); } }
protected override void Execute(object state) { var model = state as WelfareRemindModel; if (null == model) { return; } try { //从备份区将备份删除 DeleteBackAfterDone(model.WelfareID); var lastWelfare = WelfareProvider.GetWelfare(model.WelfareID); if (null == lastWelfare || lastWelfare.IsDelete == true) { throw new CustomException(string.Format("〖福利ID:{0}〗不存在或已被删除", model.WelfareID)); } if (lastWelfare.Status != (int)WelfareStatus.InProgress) { throw new CustomException(string.Format("〖福利:{0}〗状态异常,不能被提醒", lastWelfare.WelfareName)); } if (model.ApplyStartTime != lastWelfare.ApplyStartTime) { throw new CustomException(string.Format("〖福利:{0}〗开始报名时间异常", lastWelfare.WelfareName)); } #region 推送消息给需要提醒的用户 //获取需要提醒的用户 IEnumerable <WelfareRemindContent> remindContentList = WelfareProvider.GetRemindContentList(model.WelfareID); if (null != remindContentList && remindContentList.Count() > 0) { var pushRedis = Startup.PushRedisConfigs[RedisPushType.WelfareRemind]; if (null != pushRedis) { var pushDb = PushRedisContext.Redis.GetDatabase(pushRedis.DbIndex); if (pushDb != null) { pushDb.ListRightPush <WelfareRemindContent>(pushRedis.Key, remindContentList); } } } #endregion } catch (Exception ex) { this.OnThrowException(ex); } finally { Schedulers.Remove(model.WelfareID); } }
/// <summary> /// 执行任务 /// </summary> /// <param name="state"></param> protected override void Execute(object state) { var model = state as WelfareLotteryModel; if (null == model) { return; } try { //从备份区将备份删除 DeleteBackAfterDone(model.WelfareID); var lastWelfare = WelfareProvider.GetWelfare(model.WelfareID); #region //验证开奖的有效性 if (null == lastWelfare) { throw new CustomException(string.Format("〖福利:{0}〗已不存在!", model.Name)); } if (DateTime.Now >= lastWelfare.ExpiryEndTime) { throw new CustomException(string.Format("〖福利:{0}〗已失效,不能被开奖!", lastWelfare.WelfareName)); } if (lastWelfare.Status != (int)WelfareStatus.InProgress) { throw new CustomException(string.Format("无效的开奖请求,〖福利:{0}〗不被允许开奖!", lastWelfare.WelfareName)); } if (lastWelfare.IsDelete == true) { throw new CustomException(string.Format("〖福利:{0}〗已被下架,不能开奖!", lastWelfare.WelfareName)); } if (model.LotteryTime != lastWelfare.LotteryTime) { throw new CustomException(string.Format("〖福利:{0}〗不明确的开奖时间(在{1}与{2}之间不明确)!", lastWelfare.WelfareName, model.LotteryTime, lastWelfare.LotteryTime)); } bool timeRight = DateTime.Now.AddMilliseconds(-Startup.ErrorRangeMillisecond) <= lastWelfare.LotteryTime && lastWelfare.LotteryTime <= DateTime.Now.AddMilliseconds(Startup.ErrorRangeMillisecond); if (!timeRight) { throw new CustomException(string.Format("〖福利:{0}〗开奖时间({1})无效!", lastWelfare.WelfareName, lastWelfare.LotteryTime.ToString("yyyy/MM/dd HH:mm:ss"))); } if (lastWelfare.WinNumber > 0) { throw new CustomException(string.Format("〖福利:{0}〗活动不能重复开奖!", lastWelfare.WelfareName)); } //if (lastWelfare.PartNumber < 1) throw new Exception("没有报名参与的人员,不能开奖!"); #endregion #region //获取活动的所有参与编号 string[] partCodes = WelfareProvider.GetAllPartCode(model.WelfareID); #endregion #region //开奖并得到中奖编号集合 //中奖的编号 string[] winnerPartCodes = null; if (partCodes.Length <= lastWelfare.Number) { winnerPartCodes = partCodes; } else { LotteryContext context = new LotteryContext(partCodes, lastWelfare.Number); context.Run(); winnerPartCodes = context.LotteryResult; } #endregion #region //写入中奖结果 WelfareWinnerContent pushContent = WelfareProvider.WriteLotteryResult(model.WelfareID, winnerPartCodes); if (null != pushContent) { string sucMessage = string.Format("〖福利:{0}〗已开奖,本次共有 {1} 名人员中奖(总参与人数:{2})!", model.Name, winnerPartCodes.Length, lastWelfare.PartNumber); RunLogger(sucMessage); } else { throw new CustomException(string.Format("〖福利:{0}〗开奖失败!", lastWelfare.WelfareName)); } #endregion #region //推送消息给中奖用户 var pushRedis = Startup.PushRedisConfigs[RedisPushType.WelfareLottery]; if (null != pushRedis) { var pushDb = PushRedisContext.Redis.GetDatabase(pushRedis.DbIndex); if (pushDb != null) { pushDb.ListRightPush(pushRedis.Key, pushContent); } } #endregion } catch (Exception ex) { this.OnThrowException(ex); } finally { Schedulers.Remove(model.WelfareID); } }
protected override void Execute(object state) { var model = state as CircleEventRemindModel; if (null == model) { return; } try { //从备份区将备份删除 DeleteBackAfterDone(model.EventID); var lastEvent = CircleProvider.GetEvent(model.EventID); if (null == lastEvent) { throw new CustomException(string.Format("〖社区活动(ID:{0})〗不存在或已被删除", model.EventID)); } if (lastEvent.EventStatus == (int)CircleEventStatus.Canceled) { throw new CustomException(string.Format("〖社区活动(ID:{0})〗已被取消", lastEvent.EventID)); } if (model.StartTime != lastEvent.StartTime) { throw new CustomException(string.Format("〖社区活动(ID:{0})〗开始时间异常", lastEvent.EventID)); } #region 推送消息给需要提醒的用户 //获取需要提醒的用户 IEnumerable <CircleEventRemindContent> remindContentList = CircleProvider.GetRemindContentList(model.EventID); if (null != remindContentList && remindContentList.Count() > 0) { var pushRedis = Startup.PushRedisConfigs[RedisPushType.CircleEventRemind]; if (null != pushRedis) { var pushDb = PushRedisContext.Redis.GetDatabase(pushRedis.DbIndex); if (pushDb != null) { pushDb.ListRightPush <CircleEventRemindContent>(pushRedis.Key, remindContentList); } } } #endregion } catch (Exception ex) { this.OnThrowException(ex); } finally { Schedulers.Remove(model.EventID); } }