/// <summary> /// /// </summary> /// <param name="node"></param> /// <returns></returns> private TaskDefine CreateTaskDefine(XmlNode taskDefineNode) { string devicetype = string.Empty; string opname = string.Empty; //TimeSpan timeout = TaskDefine.DefaultTaskTimeout; int retryTimes = 1; StrategyDefine strategyDefine = null; foreach (XmlNode node in taskDefineNode.ChildNodes) { switch (node.Name) { case TaskFactoryNodeNames.DeviceType: devicetype = node.InnerText; break; case TaskFactoryNodeNames.TaskOperaName: opname = node.InnerText; break; case TaskFactoryNodeNames.StrategyType: { string type = node.InnerText; if (StringHelper.Equal(type, TaskFactoryNodeNames.CycleStrategy)) { XmlNode n2 = taskDefineNode.SelectSingleNode(type); strategyDefine = CreateCycleStrategyDefine(n2); } } break; case TaskFactoryNodeNames.RetryTimes: retryTimes = int.Parse(node.InnerText); break; //case TaskFactoryNodeNames.Timeout: // timeout = TimeSpan.Parse(node.InnerText); // break; } } if (strategyDefine == null) { string errmsg = string.Format( "cannot find stragegy, devicetype = '{0}', operaname = '{1}'", devicetype, opname); throw new ConfigException(errmsg); } //return new TaskDefine(devicetype, opname, strategyDefine, timeout); return(new TaskDefine(devicetype, opname, strategyDefine, retryTimes)); }
//#region DefaultTaskTimeout ///// <summary> ///// 获取或设置默认任务超时时间 ///// </summary> //static public TimeSpan DefaultTaskTimeout //{ // get { return _defaultTaskTimeout; } // set { _defaultTaskTimeout = value; } //} static private TimeSpan _defaultTaskTimeout = TimeSpan.FromSeconds(10); //#endregion //DefaultTaskTimeout #region TaskDefine /// <summary> /// /// </summary> /// <param name="deviceType"></param> /// <param name="operaName"></param> /// <param name="strategyDefine"></param> /// <param name="taskTimeout"></param> public TaskDefine(string deviceType, string operaName, StrategyDefine strategyDefine, int retryTimes) //TimeSpan taskTimeout) { if (strategyDefine == null) { throw new ArgumentNullException("strategyDefine"); } this.DeviceType = deviceType; this.OperaName = operaName; this.StrategyDefine = strategyDefine; this.RetryTimes = retryTimes; //this.TimeOut = taskTimeout; }