From d6b713200bd046d5b3764ac2fc716a49e35dc1f3 Mon Sep 17 00:00:00 2001 From: wugang <425674808@qq.com> Date: Wed, 31 Jan 2018 15:26:13 +0800 Subject: [PATCH] add task --- BWP.B3_YunKen/TimerTask/StoppedCarrier.cs | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 BWP.B3_YunKen/TimerTask/StoppedCarrier.cs diff --git a/BWP.B3_YunKen/TimerTask/StoppedCarrier.cs b/BWP.B3_YunKen/TimerTask/StoppedCarrier.cs new file mode 100644 index 0000000..05eaaf6 --- /dev/null +++ b/BWP.B3_YunKen/TimerTask/StoppedCarrier.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using BWP.B3Frameworks; +using BWP.B3Frameworks.BL; +using BWP.B3Frameworks.BO; +using BWP.B3Frameworks.Utils; +using BWP.B3Sale.BL; +using BWP.B3Sale.BO; +using Forks.EnterpriseServices.BusinessInterfaces; +using Forks.EnterpriseServices.DomainObjects2; +using Forks.EnterpriseServices.DomainObjects2.DQuery; +using TSingSoft.WebPluginFramework; +using TSingSoft.WebPluginFramework.TimerTasks; + +namespace BWP.B3_YunKen.TimerTask { + + public class StoppedCarrierTask : ITimerTask { + + public string Name { get { return "耘垦停用【承运方】,当前时间超过合同结束时间自动停用"; } } + + volatile static object _lockObj = new object(); + + public void Execute() { + if (!Monitor.TryEnter(_lockObj)) { + throw new SameTaskNotFinishException(this); + } + + try { + DoExecute(); + } finally { + Monitor.Exit(_lockObj); + } + } + + private void DoExecute() { + var mDmoTypeID = DmoTypeIDAttribute.GetID(typeof(Customer)); + var dom = new DQUpdateDom(typeof(Carrier)); + dom.Columns.Add(new DQUpdateColumn("Stopped", true)); + dom.Columns.Add(new DQUpdateColumn("RowVersion",DQExpression.Add(DQExpression.Field("RowVersion"),DQExpression.Value(1)))); + dom.Where.Conditions.Add(DQCondition.EQ("Stopped", false)); + dom.Where.Conditions.Add(DQExpression.Snippet("cast(EndDateStr as datetime) < getdate()")); + dom.EExecute(); + } + + } +}