| | |
| | | public class Importor |
| | | { |
| | | #region 加载 |
| | | public static void Loading(ObservableCollection<ViewData> viewDatas) |
| | | { |
| | | Importor.GetFiles(viewDatas, CommonProp.SourcePath); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取文件 |
| | | /// </summary> |
| | | public static void GetFiles(ObservableCollection<ViewData> viewDatas, string path) |
| | | private static void GetFiles(ObservableCollection<ViewData> viewDatas, string path) |
| | | { |
| | | GetSubFiles(viewDatas, path); |
| | | |
| | |
| | | meta.dircode = CommonProp.Dircode; |
| | | meta.ismeta = 0; |
| | | meta.sensortype = CommonProp.SensorType; |
| | | meta.mata_type = CommonProp.MetaType; |
| | | meta.acq_time = CommonProp.AcqTime; |
| | | |
| | | vd.Meta = meta; |
| | |
| | | public static void ImportFiles(ObservableCollection<ViewData> viewDatas) |
| | | { |
| | | Parallel.ForEach(viewDatas, (vd, ParallelLoopState) => |
| | | //foreach (ViewData vd in viewDatas) |
| | | { |
| | | try |
| | | { |
| | |
| | | if (!string.IsNullOrEmpty(vd.Meta.guid) && DBHelper.IsFileExists(vd.Meta.guid)) |
| | | { |
| | | vd.Status = "已存在!"; |
| | | return; |
| | | return; // continue; |
| | | } |
| | | |
| | | vd.Status = "读取栅格信息..."; |
| | |
| | | foreach (string file in files) |
| | | { |
| | | string md5 = MD5Helper.GetMD5Hash(file); |
| | | if (string.IsNullOrEmpty(md5)) list.Add(md5); |
| | | if (!string.IsNullOrEmpty(md5)) list.Add(md5); |
| | | } |
| | | |
| | | if (list.Count == 0) return null; |
| | |
| | | try |
| | | { |
| | | string target = source.Replace(vd.FilePath, targetFolder); |
| | | string path = new FileInfo(target).Directory.FullName; |
| | | if (!Directory.Exists(path)) Directory.CreateDirectory(path); |
| | | |
| | | File.Copy(source, target, true); |
| | | count++; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | { |
| | | try |
| | | { |
| | | string source = vd.FilePath.Replace(vd.Ext, ext); |
| | | if (!File.Exists(source)) continue; |
| | | |
| | | File.Copy(vd.FilePath.Replace(vd.Ext, ext), target.Replace(vd.Ext, ext), true); |
| | | count++; |
| | | } |