private void FinishExtractItem(ExtractItem extractItem, IDataSource ds) { if (ds != null) { //1.处理IDataSource String fileName = Path.Combine(DataPump.Metadata.ResultPath, $"{extractItem.GUID}_{extractItem.Name}.ds"); Serializer.SerializeToBinary(ds, fileName); DataItemsCount = ds.Total; } }
/// <summary> /// 提取项执行完毕 /// </summary> /// <param name="extractItem"></param> private void FinishExtractItem(ExtractItem extractItem, IDataSource ds) { //1.处理IDataSource //2.结尾处理 extractItem.IsFinish = true; //3.判断是否全部提取完成 if (ExtractItems.All(e => e.IsFinish)) {//全部提取完成 } }
private void DoDataPump(ExtractItem extractItem, IEnumerable <DataParsePluginInfo> plugins) { //执行数据泵服务 foreach (var plugin in plugins) { foreach (var s in plugin.SourcePath) { if (_cancelToken.IsCancellationRequested) { return; } DataPump.Execute(s, null, extractItem); } } Reporter?.ChangeProgress(extractItem.GUID, 0.33); }
/// <summary> /// 获取提取项列表 /// </summary> /// <param name="source">数据泵</param> /// <returns></returns> public List <ExtractItem> GetAllExtractItems(Pump source) { List <ExtractItem> extracts = new List <ExtractItem>(); //插件过滤 根据提取方式和操作系统 var filtetResult = GetPluginsByType <DataParsePluginInfo>(PluginType.SpfDataParse).Keys.Where(p => p.Pump.HasFlag(source.Type) && p.DeviceOSType.HasFlag(source.OSType)).ToList(); //排序 filtetResult.Sort((l, r) => { if (l.GroupIndex > r.GroupIndex) { return(1); } else if (l.GroupIndex < r.GroupIndex) { return(-1); } else if (l.OrderIndex > r.OrderIndex) { return(1); } else if (l.OrderIndex < r.OrderIndex) { return(-1); } return(0); }); foreach (var plug in filtetResult) { if (!extracts.Any(e => e.AppName == plug.AppName && e.Name == plug.Name && e.GroupName == plug.Group)) { ExtractItem item = new ExtractItem(); item.Name = plug.Name; item.GroupName = plug.Group; item.AppName = plug.AppName; item.Icon = plug.Icon; extracts.Add(item); } } return(extracts); }
/// <summary> /// 执行数据泵服务 /// </summary> /// <param name="extractItem"></param> /// <param name="plugs"></param> /// <returns></returns> private async Task DoDataPump(ExtractItem extractItem, IEnumerable <DataParsePluginInfo> plugs) { await Task.Run(() => { WaitRunWorkThread(() => { //执行数据泵服务 foreach (var plug in plugs) { //plug.SourcePath.ForEach(s => PumpControler.Extract(s, Asyn)); } }, () => { //TODO:取消执行数据泵服务后处理 }); }); }
private void DoDataPlugin(ExtractItem extractItem, IEnumerable <DataParsePluginInfo> plugs) { if (_cancelToken.IsCancellationRequested) { return; } //1.匹配插件 var plug = _pluginAdapter.MatchPluginByApp(plugs, DataPump.Metadata, DataPump.Metadata.SourceStorePath, GetAppVersion(extractItem)); //2.执行插件 plug.SaveDbPath = DataPump.Metadata.DbFilePath; plug.Phone = DataPump.Metadata.Source as Device; Reporter?.ChangeProgress(extractItem.GUID, 0.45); _pluginAdapter.ExecutePlugin(plug, null, (ds) => { FinishExtractItem(extractItem, ds); }); }
/// <summary> /// 执行插件 /// </summary> /// <param name="extractItem"></param> /// <param name="plugs"></param> /// <returns></returns> private async Task DoDataPlug(ExtractItem extractItem, IEnumerable <DataParsePluginInfo> plugs) { await Task.Run(() => { WaitRunWorkThread(() => { //1.匹配插件 var plug = PluginAdapter.MatchPluginByApp(plugs, SourcePump, RootSourceDataPath, GetAppVersion(extractItem)); //2.执行插件 PluginAdapter.ExecutePlugin(plug, Asyn, (ds) => { //插件执行完处理 FinishExtractItem(extractItem, ds); }); }, () => { //TODO:取消插件执行后处理 }); }); }
public void TestDeviceExtractionExtractItem() { CaseInfo ci = new CaseInfo(); ci.Name = "hj"; ci.Number = "123"; ci.Type = "1"; ci.Author = "hj"; ci.Path = @"G:\XLY\SpfData"; Case @case = Case.New(ci); //相对路径 DeviceExtraction de = @case.CreateDeviceExtraction("设备1", "andrion相对路径"); de["Name"] = "hujing"; de.Updated += De_Updated; de.Save(); Assert.IsNotNull(de); ExtractItem ei = de.CreateExtract("minnor", "镜像1相对路径"); ei.Deleted += Ei_Deleted; Assert.IsNotNull(ei); ei.Delete(); //Assert.AreEqual(de.ExtractItems.Count(), 0); de.Deleted += De_Deleted; de.Delete(); Console.ReadKey(); //绝对路径 //de = @case.CreateDeviceExtraction("andrion绝对路径",directory: @"G:\XLY\SpfData"); //Assert.IsNotNull(de); //ei = de.CreateExtract("minnor", @"G:\XLY\SpfData\镜像1绝对路径"); //Assert.IsNotNull(ei); //ei.Delete(); //Assert.AreEqual(de.ExtractItems.Count(), 0); //de.Delete(); //Assert.IsFalse(de.Existed); @case.Delete(); }
public ExtractionItem(ExtractItem target) { Target = target; }
private Version GetAppVersion(ExtractItem extractItem) { //TODO:获取APP版本信息 return(null); }