public override bool ImportForFile(string eaObjectType = "Requirement", string eaStereotype = "", string stateNew = "") { CountPackage = 0; bool result = true; _errorMessage1 = false; // handle Export fields _exportFields = new ExportFields(Settings.WriteAttrNameList); _subModuleIndex = 0; // decompress reqifz file and its embedded files string[] importReqIfFiles = Decompress(ImportModuleFile); if (importReqIfFiles.Length == 0) { return(false); } // Inventory all reqIf files with their specifications ReqIfFileList reqIfFileList = new ReqIfFileList(importReqIfFiles, Settings); if (reqIfFileList.ReqIfFileItemList.Count == 0) { return(false); } // Check import settings if (!CheckImportFile()) { return(false); } // over all packages/guids int packageIndex = 0; foreach (var item in Settings.PackageGuidList) { if (!String.IsNullOrWhiteSpace(item.ReqIfReqIfFleStorage)) { Settings.EmbeddedFileStorageDictionary = item.ReqIfReqIfFleStorage; } _prefixTv = Settings.GetPrefixTaggedValueType(packageIndex); string pkgGuid = item.Guid; string reqIfSpecId = item.ReqIfModuleId; try { // Use reqIF Specification ID or iterate by sequence (package index) ReqIfFileItem reqIfFileItem = String.IsNullOrWhiteSpace(reqIfSpecId) ? reqIfFileList.GetItemForIndex(packageIndex) : reqIfFileList.GetItemForReqIfId(reqIfSpecId); // couldn't find a GUID, Error message output if (reqIfFileItem == null) { continue; } // estimate package of guid list in settings Pkg = Rep.GetPackageByGuid(pkgGuid); if (Pkg == null) { MessageBox.Show($@"GUID={pkgGuid} SpecificationID={reqIfSpecId} Consider: - Integrity EA Check + repair - Compact EA Repository - Check configuration/package guid ", @"Exception invalid package in configuration, skip package"); continue; } try { Rep.RefreshModelView(Pkg.PackageID); Rep.ShowInProjectView(Pkg); } catch (Exception e) { MessageBox.Show($@"GUID={pkgGuid} SpecificationID={reqIfSpecId} Consider: - Integrity EA Check + repair - Compact EA Repository {e}", @"Exception import into package"); return(false); } ImportSpecification(reqIfFileItem.FilePath, eaObjectType, eaStereotype, reqIfFileItem.SpecContentIndex, reqIfFileItem.SpecIndex, stateNew); if (result == false || _errorMessage1) { return(false); } // List all what is done _reqIfLogList.Add(new ReqIfLog(reqIfFileItem.FilePath, Pkg.Name, Pkg.PackageGUID, reqIfSpecId, "")); // next package packageIndex += 1; } catch (Exception e) { MessageBox.Show($@"GUID={pkgGuid} SpecificationID={reqIfSpecId} {e}", @"Exception import into package"); return(false); } } return(result && (!_errorMessage1)); }
/// <summary> /// Roundtrip for a compressed reqif file (*.reqif) /// - Import /// - Updated Requirements according to TaggedValues/AttributeNames in _settings.WriteAttrNameList /// </summary> /// <returns></returns> public override bool RoundtripForFile() { CountPackage = 0; _subModuleIndex = 0; _errorMessage1 = false; _exportFields = new ExportFields(Settings.WriteAttrNameList); // decompress reqif file and its embedded files string[] importReqIfFiles = Decompress(ImportModuleFile); if (importReqIfFiles.Length == 0) { return(false); } // Inventory all reqIf files with their specifications ReqIfFileList reqIfFileList = new ReqIfFileList(importReqIfFiles, Settings); if (reqIfFileList.ReqIfFileItemList.Count == 0) { return(false); } // Check import settings if (!CheckImportFile()) { return(false); } // over all packages/guids int packageIndex = 0; foreach (var item in Settings.PackageGuidList) { // get the column/taggedValueType prefix for current module _prefixTv = Settings.GetPrefixTaggedValueType(packageIndex); string pkgGuid = item.Guid; string reqIfSpecId = item.ReqIfModuleId; // Use reqIF Specification ID or iterate by sequence (package index) ReqIfFileItem reqIfFileItem = String.IsNullOrWhiteSpace(reqIfSpecId) ? reqIfFileList.GetItemForIndex(packageIndex) : reqIfFileList.GetItemForReqIfId(reqIfSpecId); // estimate package of guid list in settings Pkg = Rep.GetPackageByGuid(pkgGuid); Rep.ShowInProjectView(Pkg); bool result = RoundtripSpecification(reqIfFileItem.FilePath, reqIfFileItem.SpecContentIndex, reqIfFileItem.SpecIndex); if (result == false || _errorMessage1) { return(false); } // next package packageIndex += 1; } // write the changes back return(Compress(ImportModuleFile, Path.GetDirectoryName(importReqIfFiles[0]))); }