private void Judge(string filePath) { var featureClass = filePath.GetShpFeatureClass(); if (featureClass == null) { var index = featureClass.Fields.FindField("TCMC"); if (index != -1) { switch (featureClass.ShapeType) { case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint: PointFiles.Add(filePath); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon: PolygonFiles.Add(filePath); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline: PolylineFiles.Add(filePath); break; } } } }
public override bool Work() { base.Work(); if (!Init()) { ProgressDialog.HideDialog(); return(false); } ParallelLoopResult result = Parallel.ForEach <string>(Files, s => { Analyze(s); }); //foreach(var file in Files) //{ // Count++; // StepProgressor.Message = string.Format("正在分析{0},进度{1}/{2}", file, Count,MaxValue); // CanContinue = TrackCancel.Continue(); // if (!CanContinue) // { // break; // } // Application.DoEvents(); // Analyze(file); // StepProgressor.Step(); //} foreach (var file in Files) { Count++; StepProgressor.Message = string.Format("正在分析{0},进度{1}/{2}", file, Count, MaxValue); CanContinue = TrackCancel.Continue(); if (!CanContinue) { break; } Application.DoEvents(); Judge(file); StepProgressor.Step(); } StepProgressor.Message = string.Format("正在保存中"); if (PointFiles.Count > 0) { var savePoint = string.Format("{0}\\{1}_点.shp", System.IO.Path.GetDirectoryName(this.SaveFilePath), System.IO.Path.GetFileNameWithoutExtension(this.SaveFilePath)); StepProgressor.Message = string.Format("正在生成文件{0}", savePoint); Merge(string.Join(";", PointFiles.ToArray()), savePoint); } if (PolylineFiles.Count > 0) { var savePolyline = string.Format("{0}\\{1}_线.shp", System.IO.Path.GetDirectoryName(this.SaveFilePath), System.IO.Path.GetFileNameWithoutExtension(this.SaveFilePath)); StepProgressor.Message = string.Format("正在生成文件{0}", savePolyline); Merge(string.Join(";", PolylineFiles.ToArray()), savePolyline); } if (PolygonFiles.Count > 0) { var savePolygon = string.Format("{0}\\{1}_点.shp", System.IO.Path.GetDirectoryName(this.SaveFilePath), System.IO.Path.GetFileNameWithoutExtension(this.SaveFilePath)); StepProgressor.Message = string.Format("正在生成文件{0}", savePolygon); Merge(string.Join(";", PolygonFiles.ToArray()), savePolygon); } ProgressDialog.HideDialog(); return(true); }