public ModifyCopyModel ToModel(COPY copy) { RegionParam region = null; if ( !string.IsNullOrEmpty(xf3) && !string.IsNullOrEmpty(xt4) && !string.IsNullOrEmpty(yf5) && !string.IsNullOrEmpty(yt6) && !string.IsNullOrEmpty(zf7) && !string.IsNullOrEmpty(zt8)) { region = new RegionParam(); region.XFrom = xf3.ToInt(); region.XTo = xt4.ToInt(); region.YFrom = yf5.ToInt(); region.YTo = yt6.ToInt(); region.ZFrom = zf7.ToInt(); region.ZTo = zt8.ToInt(); //copy.BaseFile.TempRegion = region; copy.defautRegion = region; } else { //region = copy.BaseFile.TempRegion; region = copy.defautRegion; } ModifyCopyModel model = new ModifyCopyModel(this.p2, region, this.p1); return(model); }
/// <summary> 用修正参数获取临时数据 endPosition 碰到此修正参数退出 </summary> public void RefreshCacheTable(CARFIN carfin, List <ModifyKey> modifys, IModifyModel endPosition = null) { if (!IsModifyChanged) { return; } this.InitCacheTables(); IsModifyChanged = false; // 构造全网格范围 RegionParam tempRegion = new RegionParam(); tempRegion.XFrom = 1; tempRegion.XTo = carfin.X; tempRegion.YFrom = 1; tempRegion.YTo = carfin.Y; tempRegion.ZFrom = 1; tempRegion.ZTo = carfin.Z; foreach (ModifyKey m in modifys) { // 是空则用临时范围 if (m.DefautRegion == null) { m.DefautRegion = tempRegion; } else { // 不是空赋值临时范围 tempRegion = m.DefautRegion; } List <IModifyModel> models = new List <IModifyModel>(); // 加载本修改模型中关键字 models.AddRange(m.ObsoverModel); // 加载子修改模型中关键字 如BOX List <ModifyKey> ms = m.FindAll <ModifyKey>(); ms.Remove(m); ms.ForEach(l => models.AddRange(l.ObsoverModel)); foreach (IModifyModel md in models) { // 读取到结束标记处退出 if (endPosition != null && md == endPosition) { return; } // 是空则用临时范围 if (md.Region == null) { md.Region = tempRegion; } else { // 不是空赋值临时范围 tempRegion = md.Region; } if (md.KeyName != this.Name) { continue; } if (md is ModifyApplyModel) { ModifyApplyModel app = md as ModifyApplyModel; app.RunModify(this.CacheTable); } else if (md is ModifyCopyModel) { ModifyCopyModel copy = md as ModifyCopyModel; // 查找关键字模型 ModifyBoxModel boxModel = carfin.ObsoverModel.Find(l => l is ModifyBoxModel && l.KeyName == copy.Value) as ModifyBoxModel; TableKey copyKey = null; if (boxModel != null) { copyKey = boxModel.Key; } if (copyKey == null) { // 没有则创建关键字 copyKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(copy.Value, this.BaseFile.SimKeyType) as TableKey; m.ParentKey.Add(copyKey); } copyKey.Build(this.Z, this.X, this.Y); copyKey.RefreshCacheTable(carfin, modifys, copy); copyKey.IsModifyChanged = true; copy.RunModify(this.CacheTable, copyKey.CacheTable); copyKey.IsModifyChanged = true; } else if (md is ModifyBoxModel) { ModifyBoxModel app = md as ModifyBoxModel; app.RunModify(this.CacheTable); } } } }
/// <summary> 对文件执行修改关键字修改 跟DataImportEcl对接方法 </summary> public static void RunModify_bak(this EclipseData ecl) { // 查找所有修改关键字 List <ModifyKey> modify = ecl.Key.FindAll <ModifyKey>(); DIMENS d = ecl.Key.Find <DIMENS>(); if (d == null) { return; } // 构造全网格范围 RegionParam tempRegion = new RegionParam(); tempRegion.XFrom = 1; tempRegion.XTo = d.X; tempRegion.YFrom = 1; tempRegion.YTo = d.Y; tempRegion.ZFrom = 1; tempRegion.ZTo = d.Z; foreach (ModifyKey m in modify) { ParentKey p = m.GetParentKey(); if (p != null && p.Name == "EDIT") { continue; } // 是空则用临时范围 if (m.DefautRegion == null) { m.DefautRegion = tempRegion; } else { // 不是空赋值临时范围 tempRegion = m.DefautRegion; } foreach (IModifyModel md in m.ObsoverModel) { // 是空则用临时范围 if (md.Region == null) { md.Region = tempRegion; } else { // 不是空赋值临时范围 tempRegion = md.Region; } if (md is ModifyApplyModel) { TableKey funKey = ecl.Key.Find <TableKey>(l => l.Name == md.KeyName); if (funKey == null) { // 没有则创建关键字 funKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(md.KeyName) as TableKey; m.ParentKey.Add(funKey); } funKey.Build(d.Z, d.X, d.Y); ModifyApplyModel app = md as ModifyApplyModel; app.RunModify(funKey); } else if (md is ModifyCopyModel) { ModifyCopyModel copy = md as ModifyCopyModel; TableKey copyKey = ecl.Key.Find <TableKey>(l => l.Name == copy.Key); if (copyKey == null) { // 没有则创建关键字 copyKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(copy.Key, ecl.SimKeyType) as TableKey; m.ParentKey.Add(copyKey); } TableKey funKey = ecl.Key.Find <TableKey>(l => l.Name == copy.Value); if (funKey == null) { // 没有则创建关键字 funKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(copy.Value) as TableKey; m.ParentKey.Add(funKey); } funKey.Build(d.Z, d.X, d.Y); copyKey.Build(d.Z, d.X, d.Y); copy.RunModify(copyKey, funKey); } else if (md is ModifyBoxModel) { TableKey funKey = ecl.Key.Find <TableKey>(l => l.Name == md.KeyName); if (funKey == null) { // 没有则创建关键字 funKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(md.KeyName) as TableKey; m.ParentKey.Add(funKey); } funKey.Build(d.Z, d.X, d.Y); ModifyBoxModel app = md as ModifyBoxModel; app.RunModify(funKey); } } } }
/// <summary> 用修正参数获取临时数据 endPosition 碰到此修正参数退出 </summary> public void RefreshCacheTable(EclipseData _eclData, List <ModifyKey> modifys, IModifyModel endPosition = null) { if (!IsModifyChanged) { return; } this.InitCacheTables(); // 查找所有修改关键字 //List<ModifyKey> modifys = _eclData.Key.FindAll<ModifyKey>(); //// 获取当前关键字关联的修改关键字 //List<ModifyKey> thisModify = modifys.FindAll(l => l.ObsoverModel.Exists(k => k.KeyName == this.Name)); DIMENS d = _eclData.Key.Find <DIMENS>(); if (d == null) { return; } IsModifyChanged = false; // 构造全网格范围 RegionParam tempRegion = new RegionParam(); tempRegion.XFrom = 1; tempRegion.XTo = d.X; tempRegion.YFrom = 1; tempRegion.YTo = d.Y; tempRegion.ZFrom = 1; tempRegion.ZTo = d.Z; foreach (ModifyKey m in modifys) { // 是空则用临时范围 if (m.DefautRegion == null) { m.DefautRegion = tempRegion; } else { // 不是空赋值临时范围 tempRegion = m.DefautRegion; } foreach (IModifyModel md in m.ObsoverModel) { // 读取到结束标记处退出 if (endPosition != null && md == endPosition) { return; } // 是空则用临时范围 if (md.Region == null) { md.Region = tempRegion; } else { // 不是空赋值临时范围 tempRegion = md.Region; } if (md.KeyName != this.Name) { continue; } if (md is ModifyApplyModel) { ModifyApplyModel app = md as ModifyApplyModel; app.RunModify(this.CacheTable); } else if (md is ModifyCopyModel) { ModifyCopyModel copy = md as ModifyCopyModel; TableKey copyKey = _eclData.Key.Find <TableKey>(l => l.Name == copy.Value); //// 取到当前位置 //List<ModifyKey> modifysCopyPosition = modifys.TakeWhile(l => l == m).ToList(); //// 取当前model位置 //List<IModifyModel> modelCopyPosition = m.ObsoverModel.TakeWhile(l => l == md).ToList(); //modifysCopyPosition.rem if (copyKey == null) { // 没有则创建关键字 copyKey = KeyConfigerFactroy.Instance.CreateKey <TableKey>(copy.Value, this.BaseFile.SimKeyType) as TableKey; m.ParentKey.Add(copyKey); } copyKey.Build(this.Z, this.X, this.Y); copyKey.RefreshCacheTable(_eclData, modifys, copy); copyKey.IsModifyChanged = true; copy.RunModify(this.CacheTable, copyKey.CacheTable); } else if (md is ModifyBoxModel) { ModifyBoxModel app = md as ModifyBoxModel; app.RunModify(this.CacheTable); } } } }