private string BulidArgXml(string filename) { try { MosaicInputArg arg = _argMode.Copy(); arg.InputFilename = filename; string xml = Path.Combine(arg.OutputDir, "BatchArgs\\" + Path.GetFileName(filename) + ".xml"); arg.ToXml(xml); return(xml); } catch (Exception ex) { PrintInfo("创建执行程序参数失败 " + ex.Message); return(null); } }
public void StartBatch(string path, string searchOption) { _argMode = MosaicInputArg.FromXml(path); if (_argMode == null) { Console.WriteLine("请提供参数文件"); return; } else { Match match = InputFileRex.Match(_argMode.InputFilename); if (match.Groups["dir"].Success) { _path = match.Groups["dir"].Value; } if (match.Groups["filter"].Success) { _searchOption = match.Groups["filter"].Value; } } if (string.IsNullOrWhiteSpace(_path) || !Directory.Exists(_path)) { Console.WriteLine("要扫描的文件路径为空,或者该路径不存在" + _path); return; } PrintInfo("启动扫描路径" + _path); if (!string.IsNullOrWhiteSpace(_searchOption)) { PrintInfo(" 文件过滤为" + _searchOption); } _timer = new Timer(5 * 1000); _timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); _timer.Start(); _processTimer = new Timer(5 * 1000); _processTimer.Elapsed += new ElapsedEventHandler(StartProcess); _processTimer.Start(); }