| | |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace DataLoader.CS |
| | |
| | | |
| | | vd.Meta = new SysMeta(); |
| | | vd.Meta.name = fi.Name; |
| | | vd.Meta.dirid = 1; |
| | | vd.Meta.dirid = Tool.DirId; |
| | | vd.Meta.depid = 1; |
| | | vd.Meta.verid = 0; |
| | | vd.Meta.type = fi.Extension.ToLower().Replace(".", ""); |
| | |
| | | |
| | | public static void ImportFiles(ObservableCollection<ViewData> viewDatas, string target) |
| | | { |
| | | Parallel.ForEach(viewDatas, (vd, ParallelLoopState) => |
| | | { |
| | | try |
| | | { |
| | | vd.Status = "生成MD5码..."; |
| | | string guid = MD5Helper.GetMD5Hash(vd.FilePath); |
| | | if (IsFileExists(guid)) |
| | | { |
| | | vd.Status = "已存在!"; |
| | | return; |
| | | } |
| | | |
| | | vd.Status = "插入数据库..."; |
| | | int start = GetSubPath(target, 1); |
| | | SysMeta mf = GetMetaFile(vd, start, guid); |
| | | |
| | | int metaId = InsertMeta(mf); |
| | | if (metaId == 0) |
| | | { |
| | | vd.Status = "元数据出错!"; |
| | | return; |
| | | } |
| | | |
| | | vd.Status = "复制文件..."; |
| | | CopyFile(vd.FilePath, Path.Combine(target, mf.path)); |
| | | |
| | | vd.Status = "完成。"; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); |
| | | vd.Status = "失败!"; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public static void ImportFiles2(ObservableCollection<ViewData> viewDatas, string target) |
| | | { |
| | | int start = 1; |
| | | foreach (ViewData vd in viewDatas) |
| | | { |