public EA.Package GetPackageByGUID(String packageGUID)
        {
            EA.Package package;

            package = eaRepository.GetPackageByGuid(packageGUID);

            return(package);
        }
Exemplo n.º 2
0
        public List <Node> GetAllHierarchies()
        {
            List <Node> result = new List <Node>();

            EAAPI.Collection searchResult = _repository.GetElementsByQuery("SpecificationPackages", "");

            if (searchResult.Count > 0)
            {
                for (short counter = 0; counter < searchResult.Count; counter++)
                {
                    EAAPI.Element packageElement = searchResult.GetAt(counter) as EAAPI.Element;

                    EAAPI.Package package = _repository.GetPackageByGuid(packageElement.ElementGUID);

                    CachedDataProvider eaCacheDataProvider = new CachedDataProvider(_repository);

                    EADM.Element specificationPackageElement = eaCacheDataProvider.GetCachedSpecification(package);

                    Node rootNode = new Node();

                    ConvertEaDataToSpecifNodeRecursively(specificationPackageElement, rootNode);

                    result = rootNode.Nodes;
                }
            }

            return(result);
        }
        /// <summary>
        /// Generate the modules. It updates the modules or put it into the selected package.
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="pkg"></param>
        /// <returns></returns>
        public AutoCpp(EA.Repository rep, EA.Package pkg)
        {
            Rep  = rep;
            _pkg = pkg;
            // inventory from VC Code Database
            _files       = new Files(rep);
            _designFiles = new Files(rep);

            if (Rep.GetPackageByGuid(designRootPackageGuid) == null)
            {
                MessageBox.Show($@"Root package of existing design isnt't valid.
GUID={designRootPackageGuid}
Change variable: 'designRootPackageGuid=...'", @"Cant inventory existing design, invalid root package");
            }
            _designPackagedIds = Package.GetBranch(Rep, "", Rep.GetPackageByGuid(designRootPackageGuid).PackageID);
        }
Exemplo n.º 4
0
        private void RemoveInvalidIds()
        {
            for (int i = L.Count - 1; i >= 0; i--)
            {
                try
                {
                    switch (L[i].EaTyp)
                    {
                    case ObjectType.otDiagram:
                        EA.Diagram dia = (EA.Diagram)_rep.GetDiagramByGuid(L[i].Guid);
                        if (dia == null)
                        {
                            L.RemoveAt(i);
                            continue;
                        }
                        UpdateDiagram(i, dia);
                        break;

                    case ObjectType.otPackage:
                        EA.Package pkg = _rep.GetPackageByGuid(L[i].Guid);
                        if (pkg == null)
                        {
                            L.RemoveAt(i);
                            continue;
                        }
                        UpdatePackage(i, pkg);
                        break;

                    case ObjectType.otElement:
                        EA.Element el = _rep.GetElementByGuid(L[i].Guid);
                        if (el == null)
                        {
                            L.RemoveAt(i);
                            continue;
                        }
                        UpdateElement(i, el);
                        break;
                    }
                }
                catch //(Exception e)
                {
                    L.RemoveAt(i);
                }
            }
            LPosition = L.Count - 1;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Export all jobs of the current list number with the respectively defined settings. Only changed tagged values are exported/updated.
        /// </summary>
        /// <param name="listNumber"></param>
        /// <returns></returns>
        public bool RoundtripBySetting(int listNumber)
        {
            bool result = true;

            _level      = -1;
            _count      = 0;
            _countAll   = 0;
            _countPkg   = 0;
            _countItems = 0;
            foreach (FileImportSettingsItem item in _importSettings)
            {
                if (Convert.ToInt32(item.ListNo) == listNumber)
                {
                    // Copy input file to export file
                    if (!DirFiles.FileCopy(item.InputFile, item.ExportFile))
                    {
                        return(false);
                    }
                    _importModuleFile = item.ExportFile;
                    if (!System.IO.File.Exists(_importModuleFile))
                    {
                        MessageBox.Show($@"File: '{_importModuleFile}'", @"Import files doesn't exists, break");
                        return(false);
                    }
                    // check if there are columns to update
                    if (item.WriteAttrNameList.Count == 0)
                    {
                        var attributesToVisualize = String.Join(", ", item.WriteAttrNameList.ToArray());
                        MessageBox.Show($@"Roundtrip needs Attributes to write in Settings ('WriteAttrNameList' is empty):

File: '{_importModuleFile}'

Attributes to write ('{nameof(item.WriteAttrNameList)}'):
'{attributesToVisualize}'
", @"No Attributes to write in 'Setting.json' defined");
                        return(false);
                    }


                    // handle more than one package
                    // handle zip files like
                    foreach (var itemGuidList in item.PackageGuidList)
                    {
                        string guid = itemGuidList.Guid;
                        _pkg = _rep.GetPackageByGuid(guid);
                        if (_pkg == null)
                        {
                            MessageBox.Show(
                                $@"Package of export list {listNumber} with GUID='{guid}' not available.
{item.Description}
{item.Name}

    Check Import settings in Settings.Json.",
                                @"Package to import into isn't available, break!");
                            return(false);
                        }
                        switch (item.ImportType)
                        {
                        case FileImportSettingsItem.ImportTypes.DoorsReqIf:
                        case FileImportSettingsItem.ImportTypes.ReqIf:
                            var reqIfRoundtrip = new ReqIfs.ReqIfRoundtrip(_rep, _pkg, _importModuleFile, item);
                            result = result && reqIfRoundtrip.RoundtripForFile();
                            //await Task.Run(() =>
                            //    doorsReqIf.ImportForFile(eaObjectType, eaStereotype, eaStatusNew, eaStatusChanged));
                            break;
                        }
                    }
                }
            }

            return(true);
        }