Пример #1
0
        //DIAGRAM CONTENT
        public void Generate_otDiagram_content(EA.Repository m_Repository, string TOI_GUID, string SP_BaseURL,
                                               out List <string> listOfElements,
                                               out List <string> listOfElementsNames,
                                               out List <string> listOfLinks,
                                               out List <string> listOfLinkNames,
                                               out Dictionary <string, string> DiagramDictionary)
        {
            listOfElements      = new List <string>();
            listOfElementsNames = new List <string>();
            listOfLinks         = new List <string>();
            listOfLinkNames     = new List <string>();

            EA.Diagram DiagramToShow = (EA.Diagram)m_Repository.GetDiagramByGuid(TOI_GUID);



            //STORE DIAGRAM ELEMENTS
            for (short iDO = 0; iDO < DiagramToShow.DiagramObjects.Count; iDO++)
            {
                EA.DiagramObject MyDO = (EA.DiagramObject)DiagramToShow.DiagramObjects.GetAt(iDO);
                int        ID         = m_Repository.GetElementByID(MyDO.ElementID).ElementID;
                EA.Element MyEle      = (EA.Element)m_Repository.GetElementByID(ID);
                listOfElements.Add(MyEle.Name + "|" + MyEle.ObjectType + "|" + MyEle.ElementGUID);
                listOfElementsNames.Add(MyEle.Name);
            }



            //STORE DIAGRAM LINKS
            for (short iDO = 0; iDO < DiagramToShow.DiagramLinks.Count; iDO++)
            {
                EA.DiagramLink MyLink = (EA.DiagramLink)DiagramToShow.DiagramLinks.GetAt(iDO);
                int            ID     = m_Repository.GetConnectorByID(MyLink.ConnectorID).ConnectorID;

                EA.Connector con;

                try //Try and get the connector object from the repository
                {
                    con = (EA.Connector)m_Repository.GetConnectorByID(ID);
                    listOfLinks.Add(con.Name + "|" + con.ObjectType + "|" + con.ConnectorGUID);
                    listOfLinkNames.Add(con.Name);
                }
                catch { }
            }



            //JSON Content
            string DiagramURL = SP_BaseURL + "/" + DiagramToShow.Name + "|otDiagram|" + TOI_GUID;


            DiagramDictionary = new Dictionary <string, string>();
            DiagramDictionary.Add("Diagram Name", DiagramToShow.Name);
            DiagramDictionary.Add("Created Data", DiagramToShow.CreatedDate.ToString());
            DiagramDictionary.Add("Meta Type", DiagramToShow.MetaType);
            DiagramDictionary.Add("Notes", DiagramToShow.Notes);
            DiagramDictionary.Add("Package ID", DiagramToShow.PackageID.ToString());
            DiagramDictionary.Add("Big Preview", DiagramURL + "/BigPreview");
            DiagramDictionary.Add("Small Preview", DiagramURL + "/SmallPreview");
        }
Пример #2
0
        //This is will return a diagram object search for the name.
        public static Diagram GetDiagramObject(string SelectedDiagram, Repository m_Repository)
        {
            string x = m_Repository.SQLQuery("SELECT * FROM t_diagram where name = \"" + SelectedDiagram + "\"");

            //Strip out new line characters in the sql
            string y = x.Replace("\r", "").Replace("\n", "").Replace("\t", "");

            XmlReader   reader = XmlReader.Create(new System.IO.StringReader(y));
            XmlDocument xmlDoc = new XmlDocument(); // Create an XML document object

            xmlDoc.Load(reader);                    // Load the XML document from the specified file

            // Get elements
            XmlNodeList Name = xmlDoc.GetElementsByTagName("Name");
            XmlNodeList ID   = xmlDoc.GetElementsByTagName("Diagram_ID");

            //If we have nothing then return nothing here
            if (Name.Count == 0)
            {
                return(null);
            }
            // Display the result
            string result = Name[0].InnerText;
            string IDs    = ID[0].InnerText;

            EA.Diagram MyDiagram = m_Repository.GetDiagramByID(Convert.ToInt32(IDs));

            //DumpPackage("", (EA.Package)m_Repository.Models.GetAt(idx));

            return(MyDiagram);
        }
Пример #3
0
        private void UpdateElementOnDiagram(
            EAAPI.Diagram lifeCycleDiagram, int elementID, String backgroundColor)
        {
            // Parse out the old BCol and add the new.
            if (!String.IsNullOrEmpty(backgroundColor))
            {
                EAAPI.DiagramObject obj = null;
                for (short nIndex = 0; nIndex < lifeCycleDiagram.DiagramObjects.Count; nIndex++)
                {
                    obj = (EAAPI.DiagramObject)lifeCycleDiagram.DiagramObjects.GetAt(nIndex);
                    if (obj.ElementID == elementID)
                    {
                        break;
                    }
                }

                if (null != obj)
                {
                    String   styleString = obj.Style.ToString();
                    String[] styleList   = styleString.Split(';');
                    for (int nIndex = 0; nIndex < styleList.Count(); nIndex++)
                    {
                        if (true == styleList[nIndex].Contains("BCol"))
                        {
                            styleList[nIndex] = backgroundColor;
                        }
                    }
                    styleString = String.Join(";", styleList);
                    obj.Style   = styleString;

                    obj.Update();
                }
            }
        }
        /// <summary>
        /// Check if all connectors are visible in diagram (global approach). It uses the direction of UML/EA.
        /// </summary>
        /// <returns></returns>
        public bool IsCompleteGlobal()
        {
            EA.Diagram dia = Rep.GetDiagramByID(_diaObj.DiagramID);

            List <int> globalIds = new List <int>();

            globalIds.AddRange(from Connector c in Rep.GetElementByID(_diaObj.ElementID).Connectors select c.ConnectorID);

            List <int> diagramConnectorIds = new List <int>();

            foreach (EA.DiagramLink l in dia.DiagramLinks)
            {
                if (l.IsHidden == false)
                {
                    diagramConnectorIds.Add(l.ConnectorID);
                }
            }

            foreach (int id in globalIds)
            {
                if (!diagramConnectorIds.Contains(id))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #5
0
        /// <summary>
        /// Set Diagram styles:
        /// HideQuals=1 HideQualifiers:
        /// OpParams=2  Show full Operation Parameter
        /// ScalePI=1   Scale to fit page
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="dia"></param>
        /// <param name="par">par[0] contains the values as a semicolon separated list</param>
        // ReSharper disable once UnusedMember.Global
        public static void SetDiagramStyle(EA.Repository rep, EA.Diagram dia, string[] par)
        {
            string[] styleEx          = par[0].Split(';');
            string   diaStyle         = dia.StyleEx;
            string   diaExtendedStyle = dia.ExtendedStyle.Trim();

            // no distinguishing between StyleEx and ExtendedStayle, may cause of trouble
            if (dia.StyleEx == "")
            {
                diaStyle = par[0] + ";";
            }
            if (dia.ExtendedStyle == "")
            {
                diaExtendedStyle = par[0] + ";";
            }

            Regex rx = new Regex(@"([^=]*)=.*");

            rep.SaveDiagram(dia.DiagramID);
            foreach (string style in styleEx)
            {
                Match  match       = rx.Match(style);
                string patternFind = $@"{match.Groups[1].Value}=[^;]*;";
                diaStyle         = Regex.Replace(diaStyle, patternFind, $@"{style};");
                diaExtendedStyle = Regex.Replace(diaExtendedStyle, patternFind, $@"{style};");
            }
            dia.ExtendedStyle = diaExtendedStyle;
            dia.StyleEx       = diaStyle;
            dia.Update();
            rep.ReloadDiagram(dia.DiagramID);
        }
Пример #6
0
        private void exportAllGlobal(EA.Repository Repository)
        {
            {
                List <string> diagrams = DiagramManager.queryAPIDiagrams(Repository);
                foreach (string diagramId in diagrams)
                {
                    EA.Diagram diagram = Repository.GetDiagramByGuid(diagramId);
                    logger.log("Exporting Diagram:" + diagram.Name);
                    APIManager.exportAPI(Repository, diagram);
                    logger.log("Exported Diagram:" + diagram.Name);
                }
            }
            {
                List <string> diagrams = DiagramManager.querySchemaDiagrams(Repository);
                foreach (string diagramId in diagrams)
                {
                    EA.Diagram diagram = Repository.GetDiagramByGuid(diagramId);
                    logger.log("Exporting Schema Diagram:" + diagram.Name);
                    SchemaManager.exportSchema(Repository, diagram);
                }
            }
            {
                List <string> diagrams = DiagramManager.querySampleDiagrams(Repository);
                foreach (string diagramId in diagrams)
                {
                    EA.Diagram diagram = Repository.GetDiagramByGuid(diagramId);

                    EA.Package samplePackage = Repository.GetPackageByID(diagram.PackageID);
                    EA.Package apiPackage    = Repository.GetPackageByID(samplePackage.ParentID);

                    logger.log("Exporting Sample Diagram:" + diagram.Name + " from api package:" + apiPackage.Name);
                    SampleManager.exportSample(Repository, diagram);
                }
            }
        }
        /// <summary>
        /// Set Diagram styles in PDATA and StyleEx.
        ///
        /// HideQuals=1 HideQualifiers:
        /// OpParams=2  Show full Operation Parameter
        /// ScalePI=1   Scale to fit page
        /// Theme=:119  Set the diagram theme and the used features of the theme (here 119, see StyleEx of t_diagram)
        ///
        /// par[0] contains the values as a semicolon/comma separated Style
        /// par[1] contains the values as a semicolon/comma separated PDATA
        /// par[2] contains the values as a semicolon/comma separated properties
        /// par[3] contains the possible diagram types
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="dia"></param>
        /// <param name="par">par[] </param>
        private static void SetDiagramStyle(Repository rep, EA.Diagram dia, string[] par)
        {
            EaDiagram eaDia = new EaDiagram(rep, getAllDiagramObject: false);

            if (eaDia.Dia == null)
            {
                return;
            }
            rep.SaveDiagram(eaDia.Dia.DiagramID);

            string styles     = par[0].Replace(",", ";");
            string pdatas     = par[1].Replace(",", ";");
            string properties = par[2].Replace(",", ";");
            string types      = par[3];



            var diagramStyle = new DiagramStyle(rep, dia, types, styles, pdatas, properties);

            if (diagramStyle.IsToProcess())
            {
                diagramStyle.UpdateStyles();
                diagramStyle.SetProperties(withSql: false);
                diagramStyle.SetProperties(withSql: true);
            }

            eaDia.ReloadSelectedObjectsAndConnector(saveDiagram: false);
        }
Пример #8
0
        /// <summary>
        /// Get the current Diagram with it's selected objects and connectors.
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="getAllDiagramObject">True if you want all diagram objects if nothing no diagram object is selected</param>
        public EaDiagram(Repository rep, bool getAllDiagramObject = false)
        {
            _rep = rep;
            _dia = _rep.GetCurrentDiagram();
            IsSelectedObjects = false;
            if (_dia == null)
            {
                return;
            }
            if (_dia.SelectedObjects.Count == 0 && getAllDiagramObject)
            {
                // overall diagram objects
                foreach (EA.DiagramObject obj in _dia.DiagramObjects)
                {
                    _selectedObjects.Add(obj);
                    SelElements.Add(rep.GetElementByID(obj.ElementID));
                }
            }
            // If an context element exists than this is the last selected element
            if (_dia.SelectedObjects.Count > 0)
            {
                EA.ObjectType type = _rep.GetContextItemType();
                // only package and object makes sense, or no context element (than go for selected elements)
                if (type == EA.ObjectType.otElement ||
                    type == EA.ObjectType.otPackage ||
                    type == EA.ObjectType.otNone)
                {
                    // 1. store context element/ last selected element
                    EA.Element elContext = (EA.Element)rep.GetContextObject();
                    // no context element available, take first element
                    if (elContext == null)
                    {
                        EA.DiagramObject obj = (EA.DiagramObject)_dia.SelectedObjects.GetAt(0);
                        elContext = rep.GetElementByID(obj.ElementID);
                    }
                    _conTextDiagramObject = _dia.GetDiagramObjectByID(elContext.ElementID, "");

                    SelElements.Add(elContext);
                    _selectedObjects.Add(_conTextDiagramObject);
                    IsSelectedObjects = true;

                    // over all selected diagram objects
                    foreach (EA.DiagramObject obj in _dia.SelectedObjects)
                    {
                        // skip last selected element / context element
                        if (obj.ElementID == _conTextDiagramObject.ElementID)
                        {
                            continue;
                        }

                        _selectedObjects.Add(obj);
                        SelElements.Add(rep.GetElementByID(obj.ElementID));
                    }
                }
            }
            _selectedConnector = _dia.SelectedConnector;
        }
Пример #9
0
        private void exportDiagram(EA.Repository Repository)
        {
            EA.Diagram diagram = null;
            if (Repository.GetContextItemType() == ObjectType.otDiagram)
            {
                diagram = Repository.GetContextObject();
            }

            DiagramManager.exportDiagram(Repository, diagram);
        }
Пример #10
0
        private void exportAPIPackage(EA.Repository Repository, EA.Package apiPackage)
        {
            EA.Package samplePackage  = null;
            EA.Package schemasPackage = null;
            foreach (EA.Package p in apiPackage.Packages)
            {
                //logger.log("Package:" + p.Name);
                if (p.Name.Equals(APIAddinClass.API_PACKAGE_SAMPLES))
                {
                    samplePackage = p;
                }
                else if (p.Name.Equals(APIAddinClass.API_PACKAGE_SCHEMAS))
                {
                    schemasPackage = p;
                }
            }

            if (samplePackage == null || schemasPackage == null)
            {
                logger.log("Not an api/model package:" + apiPackage.Name);
                return;
            }

            logger.log("Found api/model package:" + apiPackage.Name);
            if (samplePackage != null)
            {
                List <EA.Package> pkgs = new List <EA.Package>();
                pkgs.Add(samplePackage);
                foreach (EA.Package child in samplePackage.Packages)
                {
                    pkgs.Add(child);
                }

                foreach (EA.Package sp in pkgs)
                {
                    logger.log("Exporting Samples:" + sp.Name);

                    foreach (object obj in sp.Diagrams)
                    {
                        EA.Diagram samplediagram = (EA.Diagram)obj;
                        logger.log("Exporting Schema Diagram:" + samplediagram.Name);
                        SampleManager.exportSample(Repository, samplediagram);
                    }
                }
            }
            if (schemasPackage != null)
            {
                logger.log("Exporting Schemas:" + schemasPackage.Name);
                foreach (EA.Diagram schemadiagram in schemasPackage.Diagrams)
                {
                    logger.log("Exporting Sample Diagram:" + schemadiagram.Name);
                    SchemaManager.exportSchema(Repository, schemadiagram);
                }
            }
        }
        private static readonly bool ActivityIsSimple = true; // Create Activity from function in the simple form

        // ReSharper disable once UnusedMethodReturnValue.Local
        private static bool CreateDefaultElementsForActivity(Repository rep,
                                                             EA.Diagram dia, EA.Element act)
        {
            // create init node
            CreateInitFinalNode(rep, dia, act, 100, @"l=350;r=370;t=70;b=90;");
            act.Elements.Refresh();
            dia.DiagramObjects.Refresh();
            dia.Update();
            rep.ReloadDiagram(dia.DiagramID);

            return(true);
        }
        /// <summary>
        /// Returns the edge an embedded element is bound to (left, right, top, bottom)
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="rep"></param>
        /// <returns></returns>
        public static EmbeddedPosition Edge(this EA.DiagramObject obj, EA.Repository rep)
        {
            EA.Element el = rep.GetElementByID(obj.ElementID);


            EA.Element elParent = el.GetParentOfEmbedded(rep);
            if (elParent == null)
            {
                return(EmbeddedPosition.Undefined);
            }
            // for Required/Required Interface use the owning Port for the position
            if (el.Type == "ProvidedInterface" ||
                el.Type == "RequiredInterface")
            {
                if (el.ParentID == 0)
                {
                    return(EmbeddedPosition.Undefined);
                }
                el = rep.GetElementByID(el.ParentID);
            }


            EA.Diagram       dia              = rep.GetDiagramByID(obj.DiagramID);
            EA.DiagramObject objParent        = dia.GetDiagramObjectByID(elParent.ElementID, "");
            EA.DiagramObject objFirstEmbedded = dia.GetDiagramObjectByID(el.ElementID, "");
            if (objParent == null)
            {
                return(EmbeddedPosition.Undefined);
            }

            int horicontalCenter = objFirstEmbedded.left + (objFirstEmbedded.right - objFirstEmbedded.left) / 2;
            int verticalCenter   = objFirstEmbedded.top - (objFirstEmbedded.top - objFirstEmbedded.bottom) / 2;

            if (horicontalCenter < objParent.left + 10 && horicontalCenter > objParent.left - 10)
            {
                return(EmbeddedPosition.Left);
            }
            if (horicontalCenter < objParent.right + 10 && horicontalCenter > objParent.right - 10)
            {
                return(EmbeddedPosition.Right);
            }


            if (verticalCenter < objParent.top + 10 && verticalCenter > objParent.top - 10)
            {
                return(EmbeddedPosition.Top);
            }
            if (verticalCenter < objParent.bottom + 10 && verticalCenter > objParent.bottom - 10)
            {
                return(EmbeddedPosition.Bottom);
            }
            return(EmbeddedPosition.Undefined);
        }
        private void exportAll(EA.Repository Repository, DiagramCache diagramCache)
        {
            EA.Diagram diagram = null;
            if (Repository.GetContextItemType() == ObjectType.otDiagram)
            {
                diagram = Repository.GetContextObject();
            }

            EA.Package apiPackage = Repository.GetPackageByID(diagram.PackageID);

            exportRoundTripPackage(Repository, apiPackage, diagramCache);
        }
        // ReSharper disable once UnusedMember.Global
        public static void VisualizePortForDiagramobject(int pos, EA.Diagram dia, EA.DiagramObject diaObjSource, EA.Element port, EA.Element interf)
        {
            // check if port already exists
            foreach (EA.DiagramObject diaObj in dia.DiagramObjects)
            {
                if (diaObj.ElementID == port.ElementID)
                {
                    return;
                }
            }

            // visualize ports
            int length = 6;
            // calculate target position
            int left  = diaObjSource.right - length / 2;
            int right = left + length;
            int top   = diaObjSource.top;

            top = top - 10 - pos * 10;
            int    bottom    = top - length;
            string position  = "l=" + left + ";r=" + right + ";t=" + top + ";b=" + bottom + ";";
            var    diaObject = (EA.DiagramObject)dia.DiagramObjects.AddNew(position, "");

            dia.Update();
            if (port.Type.Equals("Port"))
            {
                // not showing label
                diaObject.Style = "LBL=CX=97:CY=13:OX=0:OY=0:HDN=1:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;";
            }
            else
            {
                // not showing label
                diaObject.Style = "LBL=CX=97:CY=13:OX=39:OY=3:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;";
            }
            diaObject.ElementID = port.ElementID;


            diaObject.Update();

            if (interf == null)
            {
                return;
            }

            // visualize interface
            var diaObject2 = (EA.DiagramObject)dia.DiagramObjects.AddNew(position, "");

            dia.Update();
            diaObject.Style      = "LBL=CX=69:CY=13:OX=-69:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;";
            diaObject2.ElementID = interf.ElementID;
            diaObject2.Update();
        }
Пример #15
0
        private void exportAll(EA.Repository Repository)
        {
            EA.Diagram diagram = null;
            if (Repository.GetContextItemType() == ObjectType.otDiagram)
            {
                diagram = Repository.GetContextObject();
            }
            APIManager.exportAPI(Repository, diagram);

            EA.Package apiPackage = Repository.GetPackageByID(diagram.PackageID);

            exportAPIPackage(Repository, apiPackage);
        }
Пример #16
0
        public void StartTest()
        {
            string progId = "EA.Repository";
            Type   type   = Type.GetTypeFromProgID(progId);

            EAAPI.Repository repository = Activator.CreateInstance(type) as EAAPI.Repository;

            try
            {
                string fileName = "TestModel1.eap";

                bool openResult = repository.OpenFile(AssemblyDirectory + "/TestData/" + fileName);

                // root package guid: {45A143E0-D43A-4f51-ACA6-FF695EEE3256}

                if (openResult)
                {
                    Console.WriteLine("Model open");

                    //EAAPI.Package rootModelPackage = repository.GetPackageByGuid("{45A143E0-D43A-4f51-ACA6-FF695EEE3256}");

                    EAAPI.Diagram diagram = repository.GetDiagramByGuid("{BF30DD09-E13E-451b-B210-786F93A74936}") as EAAPI.Diagram;

                    SpecIF.DataModels.SpecIF specIF;

                    EaUmlToSpecIfConverter converter;

                    ISpecIfMetadataReader metadataReader = new SpecIfFileMetadataReader("d:\\work\\github\\SpecIF\\classDefinitions");

                    converter = new EaUmlToSpecIfConverter(repository, metadataReader);

                    Resource resource = converter.ConvertDiagram(diagram);

                    //specIF = converter.ConvertModelToSpecIF(rootModelPackage);


                    //SpecIfFileReaderWriter.SaveSpecIfToFile(specIF, @"D:\speciftest\TestModel1.specif");

                    Console.WriteLine("Finished");
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
            finally
            {
                //Console.ReadLine();
                repository.Exit();
            }
        }
Пример #17
0
 // diagram viewed, add to history
 public virtual void  Add(EA.ObjectType ot, string guid)
 {
     if (ot.Equals(EA.ObjectType.otDiagram))
     {
         EA.Diagram dia = (EA.Diagram)_rep.GetDiagramByGuid(guid);
         if (dia != null)
         {
             if (LPosition < 0 || L[LPosition].Guid != guid)
             {
                 int position = AddEntry(ot, guid);
                 if (position > -1)
                 {
                     UpdateDiagram(position, dia);
                 }
             }
         }
     }
     if (ot.Equals(EA.ObjectType.otPackage))
     {
         EA.Package pkg = _rep.GetPackageByGuid(guid);
         if (pkg != null)
         {
             // not already defined as bookmark
             if (this.FindIndex(pkg.PackageGUID) == -1)
             {
                 int position = AddEntry(ot, guid);
                 if (position > -1)
                 {
                     UpdatePackage(position, pkg);
                 }
             }
         }
     }
     if (ot.Equals(EA.ObjectType.otElement))
     {
         EA.Element el = _rep.GetElementByGuid(guid);
         if (el != null)
         {
             // not already defined as bookmark
             if (this.FindIndex(el.ElementGUID) == -1)
             {
                 int position = AddEntry(ot, guid);
                 if (position > -1)
                 {
                     UpdateElement(position, el);
                 }
             }
         }
     }
 }
Пример #18
0
        public void EA_MenuClick(EA.Repository Repository, string MenuLocation, string MenuName, string ItemName)
        {
            try
            {
                // 評価がクリックされたときの動作
                EA.Diagram diagram = Repository.GetCurrentDiagram();
                this.Repository = Repository;

                if (diagram == null)
                {
                    MessageBox.Show("ダイアグラムを開いてから実行してください。", ADDINNAME);
                    return;
                }

                else if (!diagram.Type.Equals("Deployment"))
                {
                    MessageBox.Show("配置図を開いてから実行してください", ADDINNAME);
                    return;
                }
                LoadDeployDiagramObjectsInformation(Repository);
                DeleteFilesUnderDirectory($@"{GlobalVar.ProjectPath}\EvaluationResult");
                DeleteFilesUnderDirectory($@"{GlobalVar.ProjectPath}\EachQualityEvaluationResult");
                var InputXDocument = XDocument.Load($@"{GlobalVar.ProjectPath}\inputdata.xml");
                var ProcesseComposedComponentNameList = InputXDocument.Element("inputData").Element("functionLists").Elements("function");
                var FunctionComposedComponentLists    = ConvertFunctionComposedComponentNameListsIntoFunctionComposedComponentLists(ProcesseComposedComponentNameList);
                var FunctionNameList = InputXDocument.Element("inputData").Elements("functionLists").Elements("function").Elements("functionName").ToList();

                foreach (var FunctionComposedComponentList in FunctionComposedComponentLists)
                {
                    var FunctionName = FunctionNameList.Pop().Value;
                    var FunctionComposedXDocument = GetFunctionComposedXDocument(FunctionComposedComponentList, FunctionName);
                    FunctionComposedXDocument.Save($@"{GlobalVar.ProjectPath}\EvaluationResult\{FunctionName}.xml");
                }

                MessageBox.Show("end");
                MakeDeviceQualityXDocuments(Repository);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                Initialize();
            }
            return;
        }
Пример #19
0
        // 図から必要な要素を取得し、リストを作成する
        internal void LoadDeployDiagramObjectsInformation(EA.Repository Repository)
        {
            // ノードの配置に関するモデルの作成,親をたどることにより必要な情報を入手
            // 配置図の要素を環境、デバイス、ノード、コンポーネントのリストに格納
            EA.Diagram diagram = Repository.GetCurrentDiagram();
            var        TmpCommunicationList = new List <Communication>();

            for (short i = 0; i < diagram.DiagramObjects.Count; i++)
            {
                DiagramObject diagramObject = diagram.DiagramObjects.GetAt(i);
                Element       element       = Repository.GetElementByID(diagramObject.ElementID);
                var           ConnectorList = new List <Connector>();
                var           xdoc          = element.Notes.ToXDocument();
                switch (element.MetaType)
                {
                case "ExecutionEnvironment":
                    ExecutionEnvironmentList.Add(new ExecutionEnvironment(element.Name, element.ElementID, element.ParentID, xdoc));
                    break;

                case "Device":
                    // デバイスが保持している接続を取得
                    for (short j = 0; j < element.Connectors.Count; j++)
                    {
                        Connector connector = element.Connectors.GetAt(j);
                        ConnectorList.Add(connector);
                        TmpCommunicationList.Add(new Communication(connector.Name, connector.ConnectorID, connector.DiagramID, connector.Notes.ToXDocument()));
                    }

                    DeviceList.Add(new Device(element.Name, element.ElementID, element.ParentID, xdoc, element.Stereotype, ConnectorList));
                    break;

                case "Node":
                    NodeList.Add(new Node(element.Name, element.ElementID, element.ParentID, xdoc));
                    break;

                case "Component":
                    ComponentList.Add(new Component(element.Name, element.ElementID, element.ParentID, xdoc));
                    break;
                }
            }

            TmpCommunicationList.GroupBy(communication => communication.Name)
            .Select(x => x.FirstOrDefault())
            .ToList()
            .ForEach(Communication => CommunicationList.Add(Communication));
        }
Пример #20
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;
        }
Пример #21
0
        private void FixDiagramObjectsSequence(EAAPI.Diagram lifeCycleDiagram, Dictionary <String, EAAPI.Element> elements)
        {
            // Get a list of the diagram elements that are actually on the diagram in the repository.
            String resultString = eaRepo.SQLQuery(
                "Select DO.Diagram_ID, DO.Object_ID, DO.Sequence, O.Alias from t_diagramobjects DO, t_object O where DO.Object_ID = o.Object_ID and DO.Diagram_ID = "
                + lifeCycleDiagram.DiagramID.ToString());
            List <Utility.EA.Sequence.SequenceRow> sequenceRows = Utility.EA.Sequence.DeSerialiseEASQLQueryResult.DeSerialiseAsDiagramRow(resultString);

            EAAPI.DiagramObject             diagramObject = null;
            Utility.EA.Sequence.SequenceRow sequenceRow;
            int nAliasIndex;
            int maxSequence = diagramConfig.Elements.Element.Count();
            int oldSequence;

            // Build a list of aliases
            List <String> elementAliases = new List <string>();

            foreach (Element elementName in diagramConfig.Elements.Element)
            {
                elementAliases.Add(FormatDiagramElementAlias(lifeCycleDiagram.DiagramID, elementName.Name));
            }

            for (int nIndex = 0; nIndex < sequenceRows.Count; nIndex++)
            {
                sequenceRow = sequenceRows[nIndex];

                // Is it one of our aliases?
                if (elementAliases.Contains(sequenceRow.Alias))
                {
                    nAliasIndex            = elementAliases.IndexOf(sequenceRow.Alias);
                    diagramObject          = (EAAPI.DiagramObject)lifeCycleDiagram.GetDiagramObjectByID(SafeToInt(sequenceRow.Object_ID, 0), null);
                    diagramObject.Sequence = maxSequence - nAliasIndex;                     // EA goes backwards putting the last element to draw first.
                    diagramObject.Update();
                }
                else
                {
                    oldSequence = diagramObject.Sequence;
                    if (EA_ELEMENT_NOT_SEQUENCED != oldSequence && oldSequence <= maxSequence)
                    {
                        diagramObject          = (EAAPI.DiagramObject)lifeCycleDiagram.GetDiagramObjectByID(SafeToInt(sequenceRow.Object_ID, 0), null);
                        diagramObject.Sequence = oldSequence + (maxSequence - oldSequence) + 1;                         // EA goes backwards putting the last element to draw first.
                        diagramObject.Update();
                    }
                }
            }
        }
Пример #22
0
        public void DrawDiagram(int parentDiagramID, int lifeCycleDiagramID)
        {
            EAAPI.Element parentElement    = eaRepo.GetElementByID(parentDiagramID);
            EAAPI.Diagram lifeCycleDiagram = eaRepo.GetDiagramByID(lifeCycleDiagramID);
            EAAPI.Package parentPackage    = eaRepo.GetPackageByID(lifeCycleDiagram.PackageID);

            // convert to Dictionary so it is easier to lookup.
            Dictionary <String, EAAPI.Element> elements = ConvertEAElementsToDictionary(parentPackage.Elements);

            AddOrUpdateElements(parentPackage, parentElement, lifeCycleDiagram, ref elements);

            AddOrUpdateElementsOnDiagram(parentElement, lifeCycleDiagram, ref elements);

            FixDiagramObjectsSequence(lifeCycleDiagram, elements);

            lifeCycleDiagram.Update();
        }
Пример #23
0
        // subtype=100 init node
        // subtype=101 final node

        public static EA.DiagramObject CreateInitFinalNode(EA.Repository rep, EA.Diagram dia, EA.Element act,
                                                           int subType, string position)
        {
            EA.Element initNode = (EA.Element)act.Elements.AddNew("", "StateNode");
            initNode.Subtype = subType;
            initNode.Update();
            if (dia != null)
            {
                HoUtil.AddSequenceNumber(rep, dia);
                EA.DiagramObject initDiaNode = (EA.DiagramObject)dia.DiagramObjects.AddNew(position, "");
                initDiaNode.ElementID = initNode.ElementID;
                initDiaNode.Sequence  = 1;
                initDiaNode.Update();
                HoUtil.SetSequenceNumber(rep, dia, initDiaNode, "1");
                return(initDiaNode);
            }
            return(null);
        }
Пример #24
0
        /// <summary>
        /// Returns true if current diagramtype is to support.
        /// diagramTypes is a comma, semicolon separated list which contains the diagramtypes:
        ///
        /// Type=Subtype
        /// Type=Diagram types according to Diagram_Type (only part of the name is required)
        /// Subtype=Only Custom Diagrams, Use Diagramtype in StyleEx like MDGDgm=Extended::Requirements
        ///   (only part of the name is required)
        /// Examples:
        /// 'Class'                Class diagram (no other diagram type contains 'class')
        /// 'Cl'                   Class diagram (no other diagram type contains 'cl')
        /// 'Custom=Requirements'  Custom Diagram of type Requirements
        /// '=Requirements'        Custom Diagram of type Requirements
        ///
        /// </summary>
        /// <param name="dia"></param>
        /// <param name="diagramTypes"></param>
        /// <returns></returns>
        private static bool DiagramIsToChange(EA.Diagram dia, string diagramTypes)
        {
            diagramTypes = diagramTypes.ToLower().Trim();
            // all diagrams are valid
            if (diagramTypes == "" || diagramTypes == "*")
            {
                return(true);
            }
            string customDiagramType = GetCustomDiagramType(dia.StyleEx).ToLower();

            foreach (var t in diagramTypes.Split(';'))
            {
                string diagramType = t.Trim();
                if (diagramType == "")
                {
                    continue;
                }
                string[] types = diagramType.Split('=');
                if (types.Length == 1)
                {
                    // Standard EA Diagram
                    if (dia.Type.ToLower().Contains(types[0]))
                    {
                        return(true);
                    }
                    return(false);
                }
                else
                {
                    // Custom Diagram
                    if (customDiagramType.Contains(types[1]))
                    {
                        return(true);
                    }
                    if (types[1] == "" || types[1] == "*")
                    {
                        return(true);
                    }
                    return(false);
                }
            }

            return(false);
        }
Пример #25
0
        public EAAPI.Diagram GetLifeCycleDiagram(EAAPI.Element parent, String diagramStereotype)
        {
            if (null != parent)
            {
                if (null != parent.Diagrams)
                {
                    for (short nIndex = 0; nIndex < parent.Diagrams.Count; nIndex++)
                    {
                        EAAPI.Diagram diagram = (EAAPI.Diagram)parent.Diagrams.GetAt(nIndex);

                        if (0 == diagramStereotype.CompareTo(diagram.Stereotype))
                        {
                            return(diagram);
                        }
                    }
                }
            }
            return(null);
        }
Пример #26
0
        /// <summary>
        /// Run Script for Context Item. Element, Attribute, Operation, Package, Diagram, Diagram Objects, Diagram Connector
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void runScriptSelectedItemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            // get Script
            DataGridViewRow rowToRun       = dataGridViewScripts.Rows[_rowScriptsIndex];
            DataRowView     row            = rowToRun.DataBoundItem as DataRowView;
            var             scriptFunction = row["FunctionObj"] as ScriptFunction;



            ObjectType objectType = Repository.GetContextItemType();

            switch (objectType)
            {
            case ObjectType.otDiagram:
                EA.Diagram dia = (EA.Diagram)Repository.GetContextObject();
                if (dia.SelectedObjects.Count > 0)
                {
                    foreach (EA.Element el in dia.SelectedObjects)
                    {
                        ScriptUtility.RunScriptFunction(Model, scriptFunction, ObjectType.otElement, el);
                    }
                    Cursor.Current = Cursors.Default;
                    return;
                }

                if (dia.SelectedConnector != null)
                {
                    ScriptUtility.RunScriptFunction(Model, scriptFunction, ObjectType.otConnector, dia.SelectedConnector);
                    Cursor.Current = Cursors.Default;
                    return;
                }
                ScriptUtility.RunScriptFunction(Model, scriptFunction, ObjectType.otDiagram, dia);
                break;

            default:
                ScriptUtility.RunScriptFunction(Model, scriptFunction, objectType, Repository.GetContextObject());
                break;
            }
            Cursor.Current = Cursors.Default;
        }
Пример #27
0
        private void AddElementToDiagram(
            EAAPI.Diagram lifeCycleDiagram, int elementID, String type,
            int left, int right, int top, int bottom, String font, String backgroundColor)
        {
            String size = String.Format("l={0};r={1};t={2};b={3};", left, right, top, bottom);

            EAAPI.DiagramObject obj = (EAAPI.DiagramObject)lifeCycleDiagram.DiagramObjects.AddNew(size, type);

            obj.ElementID = elementID;
            if (!String.IsNullOrEmpty(font))
            {
                obj.Style = obj.Style + ";" + font;
            }
            if (!String.IsNullOrEmpty(backgroundColor))
            {
                obj.Style = obj.Style + ";" + backgroundColor;
            }

            obj.Update();
        }
Пример #28
0
        private void ExecuteSynchronizeReference()
        {
            EAAPI.Diagram diagram = _repository.GetCurrentDiagram();

            if (diagram != null)
            {
                if (diagram.SelectedObjects.Count == 1)
                {
                    EAAPI.DiagramObject diagramObject = (EAAPI.DiagramObject)diagram.SelectedObjects.GetAt(0);

                    EAAPI.Element referenceElement = _repository.GetElementByID(diagramObject.ElementID);

                    ReferenceSynchronizer referenceSynchronizer = new ReferenceSynchronizer(_repository, referenceElement);

                    referenceSynchronizer.SynchronizeReferenceWithOriginal();

                    MessageBox.Show("Synchronization finished.", "Reference Synchronization");
                }
            }
        }
        /// <summary>
        /// Update all DiagramLinks of diagram
        /// - liParameter[0] = type;
        /// - liParameter[1] = style;</summary>
        /// - liParameter[2] = property;
        /// <param name="rep"></param>
        /// <param name="dia"></param>
        /// <param name="liParameter"></param>
        private static void SetDiagramLinkStyle(EA.Repository rep, EA.Diagram dia, string[] liParameter)
        {
            rep.SaveDiagram(dia.DiagramID);

            string types      = liParameter[0];
            string styles     = liParameter[1];
            string properties = liParameter[2];

            foreach (EA.DiagramLink link in dia.DiagramLinks)
            {
                var linkStyle = new DiagramLinkStyle(rep, link, types, styles, properties);
                if (linkStyle.IsToProcess())
                {
                    linkStyle.UpdateStyles();
                    linkStyle.SetProperties();
                    linkStyle.SetEaLayoutStyles();
                }
            }
            rep.ReloadDiagram(dia.DiagramID);
        }
        /// <summary>
        /// Check if all links in diagram are visible (diagram local approach).
        /// </summary>
        /// <returns></returns>
        public bool IsCompleteDiagram()
        {
            EA.Diagram dia = Rep.GetDiagramByID(_diaObj.DiagramID);

            foreach (EA.DiagramLink l in dia.DiagramLinks)
            {
                if (l.IsHidden == true)
                {
                    var con          = Rep.GetConnectorByID(l.ConnectorID);
                    var sourceObject = dia.GetDiagramObjectByID(con.SupplierID, "");
                    var targetObject = dia.GetDiagramObjectByID(con.ClientID, "");
                    if ((sourceObject.ElementID == _diaObj.ElementID && sourceObject.ObjectType == _diaObj.ObjectType) ||
                        (targetObject.ElementID == _diaObj.ElementID && targetObject.ObjectType == _diaObj.ObjectType))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }