Exemple #1
0
        /// <summary>
        ///  将xml配置项应用于定时器并与dll中要执行定时的方法绑定
        /// </summary>
        /// <param name="tscList"></param>
        /// <param name="ipts"></param>
        public 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);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 获取所有定时配置的项
        /// </summary>
        /// <returns></returns>
        public List <TimingServiceConfig> GetTimingServiceConfigs(string[] strTSExtensionsItemName = null)
        {
            XElement ele = this.XElementXMLConfig.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());
                if (strTSExtensionsItemName != null && strTSExtensionsItemName.Length > 0)
                {
                    if (strTSExtensionsItemName.Contains(tsc.TSExtensionsItemName))
                    {
                        tscList.Add(tsc);
                    }
                }
                else
                {
                    tscList.Add(tsc);
                }
            }
            return(tscList);
        }