/// <summary> /// 负责生成 路径,并不检查路径的存在性。 /// </summary> /// <param name="satelliteType">系统类型</param> /// <param name="time">时间</param> /// <returns></returns> public List <string> Get(SatelliteType satelliteType, Time time) { List <string> pathes = new List <string>(); if (SourceNameDic.ContainsKey(satelliteType)) { List <string> sourceNames = SourceNameDic[satelliteType]; foreach (var name in sourceNames) { var fileNames = new IgsProductNameBuilder(name, IgsProductSourceType, IsWeekly).Get(time).FilePathes; foreach (var fileName in fileNames) { foreach (var dir in ProductDirectories) { string sp3Path = Path.Combine(dir, fileName); pathes.Add(sp3Path); } } } } return(pathes); }
private void Run() { DateTime start = DateTime.Now; var onlyOne = checkBox_onlyOne.Checked; var sourceFolder = fileOpenControl1.FilePathes; var isParse = this.checkBox_moveOrCopy.Checked; var extension = this.namedStringControl1_extension.GetValue(); var timePerid = timePeriodControl1.TimePeriod; var igsName = namedStringControl_nameOfIgs.GetValue(); var isMoveOrCopy = checkBox_moveOrCopy.Checked; var outDir = this.directorySelectionControl1.Path; var isOverride = checkBox_override.Checked; var extensions = extension.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); //首先获取所有可能的文件,一个文件可能有多个名称,如未解压的Z文件 Dictionary <string, List <string> > allNames = new Dictionary <string, List <string> >(); for (var time = timePerid.Start; time <= timePerid.End; time += TimeSpan.FromDays(1)) { foreach (var ext in extensions) { var fileNames = new IgsProductNameBuilder(igsName, ext, false).Get(time).FilePathes; allNames[fileNames[0]] = fileNames; } } List <string> failedNames = new List <string>(); List <string> okPath = new List <string>(); foreach (var kv in allNames) { bool isOk = false; foreach (var fileName in kv.Value) //便利所有文件名 { foreach (var folder in sourceFolder) //遍历所有数据源目录 { var localPath = Path.Combine(folder, fileName); if (Geo.Utils.FileUtil.IsValid(localPath)) { okPath.Add(localPath); isOk = true; if (onlyOne) { break; } } } if (isOk && onlyOne) { break; } } if (!isOk) { failedNames.Add(kv.Key); } } StringBuilder sb = new StringBuilder(); sb.AppendLine("一共生成 " + allNames.Count + " 个文件名称"); sb.AppendLine("查找总共到 " + (allNames.Count - failedNames.Count) + " 个文件,包括 " + okPath.Count + " 个压缩或解压的文件"); sb.AppendLine("其它 " + failedNames.Count + " 个文件未找到:"); foreach (var item in failedNames) { sb.Append(item + ", "); } log.Info(sb.ToString()); sb.AppendLine(); log.Info("准备操作这些数据。"); this.progressBarComponent1.InitProcess(okPath.Count); log.Info(" " + okPath.Count + " 个文件!"); Parallel.ForEach(okPath, new Action <string, ParallelLoopState>((path, state) => { this.progressBarComponent1.PerformProcessStep(); DoOneFile(isMoveOrCopy, outDir, isOverride, path); })); // foreach (var path in okPath) //{ // this.progressBarComponent1.PerformProcessStep(); // DoOneFile(isMoveOrCopy, outDir, isOverride, path); //} var span = DateTime.Now - start; var msg = "执行完毕," + sb.ToString() + ", 耗时 " + span.TotalMinutes + "分钟, 是否打开输出目录?"; Geo.Utils.FormUtil.ShowOkAndOpenDirectory(outDir, msg); this.progressBarComponent1.Full(); }