Exemplo n.º 1
0
        private static List<TaskConfig> LoadXML()
        {
            List<TaskConfig> taskConfigList = new List<TaskConfig>();

            try
            {
                XmlDocument xmlDoc = new System.Xml.XmlDocument();
                xmlDoc.Load(MiddlewareTask.taskfile);

                XmlNodeList tasklist = xmlDoc.DocumentElement.SelectNodes("task");
                foreach (XmlNode xe in tasklist)
                {
                    TaskConfig taskconfig = new TaskConfig();
                    taskconfig.taskname = xe.Attributes["name"].Value;
                    taskconfig.qswitch = xe.Attributes["switch"].Value == "1" ? true : false;
                    taskconfig.execfrequency = (TimingTaskType)Convert.ToInt32(xe.Attributes["execfrequency"].Value);
                    string[] vals = xe.Attributes["shorttime"].Value.Split(':');
                    taskconfig.shorttime = new ShortTime(Convert.ToInt32(vals[0]), Convert.ToInt32(vals[1]), Convert.ToInt32(vals[2]));
                    taskconfig.serialorparallel = Convert.ToInt32(xe.Attributes["serialorparallel"].Value);
                    taskconfig.taskService = new List<TackServiceConfig>();

                    XmlNodeList servicelist = xe.SelectNodes("service");
                    foreach (XmlNode se in servicelist)
                    {
                        TackServiceConfig serviceconfig = new TackServiceConfig();
                        serviceconfig.pluginname = se.Attributes["pluginname"].Value;
                        serviceconfig.controller = se.Attributes["controller"].Value;
                        serviceconfig.method = se.Attributes["method"].Value;
                        serviceconfig.argument = se.Attributes["argument"].Value;

                        taskconfig.taskService.Add(serviceconfig);

                    }
                    taskConfigList.Add(taskconfig);
                }
            }
            catch (Exception e)
            {
                MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "加载定时任务配置文件错误!");
                MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, e.Message);
            }
            return taskConfigList;
        }
Exemplo n.º 2
0
 public TaskContent(TaskConfig _taskConfig)
 {
     taskConfig = _taskConfig;
 }