Exemple #1
0
        /// <summary>
        /// 获取所有定时配置的项
        /// </summary>
        /// <returns></returns>
        public static List <TimingServiceConfig> GetTimingServiceConfigs()
        {
            XElement ele = xele.Element("TimingService").Element("TSExtensionsItems");
            IEnumerable <XElement>     xeles   = ele.Elements();
            List <TimingServiceConfig> tscList = new List <TimingServiceConfig>();
            XmlSerializer xs = new XmlSerializer(typeof(TimingServiceConfig));

            foreach (XElement xe in xeles)
            {
                TimingServiceConfig tsc = ( TimingServiceConfig )xs.Deserialize(xe.CreateReader());
                tscList.Add(tsc);
            }
            return(tscList);
        }
Exemple #2
0
        /// <summary>
        ///  将xml配置项应用于定时器并与dll中要执行定时的方法绑定
        /// </summary>
        /// <param name="tscList"></param>
        /// <param name="ipts"></param>
        public static void TimerPluginBind(List <TimingServiceConfig> tscList, IEnumerable <IPluginTimer> ipts)
        {
            if (tscList == null || ipts == null || tscList.Count <= 0 || ipts.Count() <= 0)
            {
                return;
            }

            foreach (IPluginTimer ipt in ipts)
            {
                var tscs = from obj in tscList
                           where obj.TSExtensionsItemName == ipt.PluginName
                           select obj;
                if (tscs.Count() > 0)
                {
                    TimingServiceConfig tsc = tscs.First();
                    TimerTask           tt  = tm.CreateTask(tsc.TSExtensionsItemCron, ipt, tsc.TSExtensionsItemSendType);
                    tm.TaskStart(tt);
                }
            }
        }