/// <summary>
        /// Copy port to target element. It port exists it don't copy it. The Ports are locked against changes.
        /// Note: hoTools don't copy tagged values
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="srcPort"></param>
        /// <param name="trgEl"></param>
        public static void CopyPort(EA.Repository rep, Element srcPort, Element trgEl)
        {
            bool isUpdated = false;

            if (srcPort.Type != "Port")
            {
                return;
            }
            // check if port already exits

            foreach (Element trgtPort in trgEl.EmbeddedElements)
            {
                // the target port already exists in source (Target Port PDATA3 contains ea_guid of source port the port is dependant from)
                if (srcPort.ElementGUID == trgtPort.MiscData[2])
                {
                    isUpdated = true;

                    break;
                }
            }
            // Source port isn't available in target Part
            if (isUpdated == false)
            {
                // Create new Port and set the properties according to source port
                var newPort = (Element)trgEl.EmbeddedElements.AddNew(srcPort.Name, "Port");
                trgEl.EmbeddedElements.Refresh();
                newPort.Stereotype   = srcPort.Stereotype;
                newPort.Notes        = srcPort.Notes;
                newPort.PropertyType = srcPort.PropertyType;
                newPort.Update();
                // Link Port to the source Port of property type
                HoUtil.SetElementPdata3(rep, newPort, srcPort.ElementGUID);
                //newPort.Locked = true;
            }
        }
        /// <summary>
        /// Open the file according to column name with the editor.
        /// Copies the function name to Clipboard
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="columnNameFilePath"></param>
        /// <param name="columnNameLineNumber"></param>
        private void StartCodeFile(object sender, string columnNameFilePath, string columnNameLineNumber = "")
        {
            // Get the control that is displaying this context menu
            DataGridView grid     = GetDataGridView(sender);
            var          row      = grid.SelectedRows[0];
            string       filePath = row.Cells[columnNameFilePath].Value.ToString();

            filePath = Path.Combine(_folderCodeRoot, filePath);

            // Copy Function name to Clipboard
            string functionName = row.Cells["Implementation"].Value.ToString().Trim() != ""
                ? row.Cells["Implementation"].Value.ToString()
                : row.Cells["Interface"].Value.ToString();

            if (string.IsNullOrEmpty(functionName))
            {
                Clipboard.SetText(functionName);
            }

            // Estimate line number
            var lineNumber = columnNameLineNumber == ""
                ? GetLineNumber(filePath, functionName).ToString()
                : row.Cells[columnNameLineNumber].Value.ToString();

            lineNumber = lineNumber != "-1"
                ? $":{lineNumber} -g"
                : "";
            HoUtil.StartApp($"Code", $"{filePath}{lineNumber}");
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="jasonFilePath"></param>

        public ImportSetting(string jasonFilePath)
        {
            // use 'Deserializing Partial JSON Fragments'
            JObject jObject;

            try
            {
                // Read JSON
                string text = HoUtil.ReadAllText(jasonFilePath);
                jObject = JObject.Parse(text);
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    $@"Can't read '{jasonFilePath}

Consider Resetting to factory settings
- File, Reset Factory Settings!!!'

{e}", @"Can't import Chapter: 'Importer' from Settings.json");
                return;
            }

            //----------------------------------------------------------------------
            // Deserialize "DiagramStyle", "DiagramObjectStyle",""DiagramLinkStyle"
            // get JSON result objects into a list
            ImportSettings =
                (List <FileImportSettingsItem>)JasonHelper.GetConfigurationItems <FileImportSettingsItem>(
                    jObject, "Importer");
        }
Example #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="jasonFilePath"></param>

        public DiagramFormat(string jasonFilePath)
        {
            // use 'Deserializing Partial JSON Fragments'
            JObject jObject;

            try
            {
                // Read JSON
                string text = HoUtil.ReadAllText(jasonFilePath);
                jObject = JObject.Parse(text);
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    $@"Can't read '{jasonFilePath}

Consider Resetting to factory settings
- File, Reset Factory Settings!!!'

{e}", @"Can't import Diagram Styles from Settings.json");
                return;
            }

            //----------------------------------------------------------------------
            // Deserialize "DiagramStyle", "DiagramObjectStyle",""DiagramLinkStyle"
            // get JSON result objects into a list
            DiagramStyleItems       = (List <DiagramStyleItem>)GetConfigurationStyleItems <DiagramStyleItem>(jObject, "DiagramStyle");
            DiagramObjectStyleItems = (List <DiagramObjectStyleItem>)GetConfigurationStyleItems <DiagramObjectStyleItem>(jObject, "DiagramObjectStyle");
            DiagramLinkStyleItems   = (List <DiagramLinkStyleItem>)GetConfigurationStyleItems <DiagramLinkStyleItem>(jObject, "DiagramLinkStyle");
            BulkElementItems        = (List <BulkElementItem>)GetConfigurationStyleItems <BulkElementItem>(jObject, "BulkItems");
        }
        /// <summary>
        /// Copy file and take local path into consideration
        /// </summary>
        /// <param name="file"></param>
        /// <param name="target"></param>
        private void CopyEmbeddedFile(string file, string target)
        {
            string fileName = HoUtil.GetFilePath("Linked File", file);

            if (IsFileToProcess(fileName))
            {
                DirFiles.FileCopy(fileName, target);
            }
        }
 // constructor
 public svn(Repository rep, Package pkg)
 {
     _pkg    = pkg;
     _rep    = rep;
     _vcPath = "";
     if (pkg.IsControlled)
     {
         _vcPath = HoUtil.GetVccFilePath(rep, pkg);
     }
 }
Example #7
0
        /// <summary>
        /// Make EA Excel File from EA SQLQuery format (string)
        /// </summary>
        /// <param name="x"></param>
        /// <param name="fileName"></param>
        /// <returns>string</returns>
        public static bool MakeExcelFileFromSqlResult(string x, string fileName = @"d:\temp\sql\sql.xlsx")
        {
            if (string.IsNullOrEmpty(x))
            {
                return(false);
            }
            XDocument xDoc = XDocument.Parse(x);

            // get field names
            var fieldNames = xDoc.Descendants("Row").FirstOrDefault()?.Descendants();

            if (fieldNames == null)
            {
                return(false);
            }

            DataTable dt = new DataTable();

            HoUtil.TryToDeleteFile(fileName);
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                foreach (var field in fieldNames)
                {
                    dt.Columns.Add(field.Name.ToString(), typeof(string));
                }


                var xRows = xDoc.Descendants("Row");
                foreach (var xRow in xRows)
                {
                    DataRow row    = dt.NewRow();
                    int     column = 0;
                    foreach (var value in xRow.Elements())
                    {
                        row[column] = value.Value;
                        column      = column + 1;
                    }
                    dt.Rows.Add(row);
                }
                if (!SaveTableToExcel(ref fileName, dt))
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception e)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show($"Error {e.Message}\r\n{e.Source}");
                return(false);
            }
        }
        private int GetLineNumber(string file, string functionName)
        {
            string code  = HoUtil.ReadAllText(file);
            Regex  rx    = new Regex($@"\b{functionName}\b\s*\([^;{{}}]*;");
            Match  match = rx.Match(code);

            if (match.Success)
            {
                return(code.Take(match.Groups[0].Index).Count(c => c == '\n') + 1);
            }
            else
            {
                return(-1);
            }
        }
Example #9
0
        private static void HandleExcelFileByUser(string fileName, DataTable dt)
        {
            Cursor.Current = Cursors.Default;
            var ret = MessageBox.Show($"Excel File '{fileName}' with {dt.Rows.Count} rows and {dt.Columns.Count} column created!\r\n\r\nYes: Open Excel File\r\nNo: Open Folder\r\nCancel: Do nothing",
                                      "Excel File created!", MessageBoxButtons.YesNoCancel);

            switch (ret)
            {
            case DialogResult.Yes:
                HoUtil.StartFile(fileName);
                break;

            case DialogResult.No:
                HoUtil.ShowFolder(Path.GetDirectoryName(fileName));
                break;
            }
        }
Example #10
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);
        }
        //---------------------------------------------------------------------------------------------
        // updateActionParameter(EA.Repository rep, EA.Element actionPin)
        //---------------------------------------------------------------------------------------------
        public static bool UpdateActionPinParameter(Repository rep, EA.Element action)
        {
            foreach (EA.Element actionPin in action.EmbeddedElements)
            {
                // pin target for the return type of the action
                if (actionPin.Name == "target")
                {
                    //// return type
                    //Int32 parTypeID = Util.getTypeID(rep, m.ReturnType);
                    //if (parTypeID != 0)
                    //{
                    //    //pin.Name = par.
                    //    pin.ClassfierID = parTypeID;
                    //    EA.Element el = rep.GetElementByID(parTypeID);
                    //    pin.Update(); // do it before update table
                    //    Util.setElementPDATA1(rep, pin, el.ElementGUID);// set PDATA1

                    //}
                }
                else
                {
                    // get type of synchronized parameter
                    // if parameter isn't synchronized it will not work
                    string type = HoUtil.GetParameterType(rep, actionPin.ElementGUID);
                    if (type == "")
                    {
                        string txt = "No type is available for action:'" + action.Name + "'";
                        rep.WriteOutput("hoReverse", txt, 0);
                    }
                    else
                    {
                        Int32 parTypeId = HoUtil.GetTypeId(rep, type);
                        if (parTypeId != 0)
                        {
                            //pin.Name = par.
                            EA.Element el = rep.GetElementByID(parTypeId);
                            HoUtil.SetElementPdata1(rep, actionPin, el.ElementGUID);// set PDATA1
                        }
                    }
                }
            }

            return(true);
        }
Example #12
0
        /// <summary>
        /// Create an Activity diagram beneath selected Activity.
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="act"></param>
        /// <returns></returns>

        public static Diagram CreateActivityCompositeDiagram(Repository rep, EA.Element act)
        {
            // create activity diagram beneath Activity
            EA.Diagram actDia = (Diagram)act.Diagrams.AddNew(act.Name, "Activity");
            // update diagram properties
            actDia.ShowDetails = 0; // hide details
            // scale page to din A4

            if (actDia.StyleEx.Length > 0)
            {
                actDia.StyleEx = actDia.StyleEx.Replace("HideQuals=0", "HideQuals=1"); // hide qualifier
            }
            else
            {
                actDia.StyleEx = "HideQuals=1;";
            }
            // Hide Qualifier
            if (actDia.ExtendedStyle.Length > 0)
            {
                actDia.ExtendedStyle = actDia.ExtendedStyle.Replace("ScalePI=0", "ScalePI=1");
            }
            else
            {
                actDia.ExtendedStyle = "ScalePI=1;";
            }
            actDia.Update();
            act.Diagrams.Refresh();

            // put the activity on the diagram
            HoUtil.AddSequenceNumber(rep, actDia);
            EA.DiagramObject actObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=30;r=780;t=30;b=1120", "");
            actObj.ElementID = act.ElementID;
            actObj.Update();
            actDia.DiagramObjects.Refresh();

            // add default nodes (init/final)
            CreateDefaultElementsForActivity(rep, actDia, act);
            act.Elements.Refresh();
            actDia.DiagramObjects.Refresh();
            return(actDia);
        }
        public static void DisplayBehaviorForOperation(Repository repository, Method method)
        {
            string behavior = method.Behavior;

            if (behavior.StartsWith("{") & behavior.EndsWith("}"))
            {
                // get object according to behavior
                EA.Element el = repository.GetElementByGuid(behavior);
                // Activity
                if (el == null)
                {
                }
                else
                {
                    if (el.Type.Equals("Activity") || el.Type.Equals("Interaction") || el.Type.Equals("StateMachine"))
                    {
                        HoUtil.OpenBehaviorForElement(repository, el);
                    }
                }
            }
        }
Example #14
0
        public static string GetConnectionString(EA.Repository rep)
        {
            string s = rep.ConnectionString;

            if (s.Contains("DBType="))
            {
                return(s);
            }
            else
            {
                FileInfo f = new FileInfo(s);
                if (f.Length > 1025)
                {
                    return(s);
                }
                else
                {
                    return(HoUtil.ReadAllText(s));
                }
            }
        }
Example #15
0
        /// <summary>
        /// Deserialize Json settings into JObject.
        /// </summary>
        /// <param name="jsonFilePath"></param>
        /// <returns></returns>
        public static JObject DeserializeSettings(string jsonFilePath)
        {
            // use 'Deserializing Partial JSON Fragments'
            try
            {
                // Read JSON
                string text = HoUtil.ReadAllText(jsonFilePath);
                return(JObject.Parse(text));
            }
            catch (Exception e)
            {
                MessageBox.Show($@"Can't read '{jsonFilePath}!'

Consider resetting to Factory Settings.

{e}

",
                                @"Can't import 'setting.json'.");
                return(null);
            }
        }
        /// <summary>
        /// Export Embedded Files. Make XHTML and copy the file. Consider the EA local path to access the file
        /// </summary>
        /// <param name="file"></param>
        /// <param name="xhtml"></param>
        /// <returns></returns>
        private string ExportEmbeddedFiles(File file, string xhtml)
        {
            string defaultText = Path.GetFileName(file.Name);
            string fileName    = (Path.GetFileName(file.Name));


            // Check if file is to process
            string fullFileName = HoUtil.GetFilePath("Linked File", file.Name);

            if (!IsFileToProcess(fullFileName))
            {
                return("");
            }
            // copy embedded file
            CopyEmbeddedFile(fullFileName, Path.Combine(_dirFilesRoot, _embeddedFiles));

            string imagePath;
            string mimeType;

            switch (Path.GetExtension(file.Name))
            {
            case ".pdf":
                mimeType  = "application/pdf";
                imagePath = "application-pdf.png";
                break;

            case ".doc":
                imagePath = "application-msword.png";
                mimeType  = "application/msword";
                break;

            case ".docx":
                imagePath = "application-msword.png";
                mimeType  = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                break;

            case ".xls":
                imagePath = "application-vnd.ms-excel.png";
                mimeType  = "application/vnd.ms-excel";
                break;

            case ".xlsx":
                imagePath = "application-vnd.ms-excel.png";
                mimeType  = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                break;

            case ".ppt":
                imagePath = "application-vnd.ms-powerpoint.png";
                mimeType  = "application/vnd.ms-powerpoint";
                break;

            case "pptx":
                imagePath = "application-vnd.ms-powerpoint.png";
                mimeType  = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
                break;

            default:
                mimeType    = "application/pdf";
                imagePath   = @"text-x-java.png";
                defaultText = @"{defaultText}, not supported mime type/file type";
                break;
            }



            xhtml = xhtml + $@"
<div>{fileName}</div>
<object data=""{Path.Combine(_embeddedFiles, fileName)}"" type=""{mimeType}"">
    <object data=""{Path.Combine(_mimeTypeImages, imagePath)}"" type=""image/png"">{defaultText}
    </object>
</object>
";
            return(xhtml);
        }
Example #17
0
        /// <summary>
        /// Import and update Requirements. You can set EA ObjectType like "Requirement" or EA Stereotype like "FunctionalRequirement"
        /// </summary>
        /// async Task
        public override bool ImportForFile(string eaObjectType = "Requirement",
                                           string eaStereotype = "",
                                           string stateNew     = "",
                                           string stateChanged = "")
        {
            bool result = true;

            Rep.BatchAppend     = true;
            Rep.EnableUIUpdates = false;

            // Read xml file
            XElement xElFile;

            try
            {
                xElFile = XElement.Parse(HoUtil.ReadAllText(ImportModuleFile));
            }
            catch (Exception e)
            {
                Rep.BatchAppend     = false;
                Rep.EnableUIUpdates = true;
                MessageBox.Show($@"File: {ImportModuleFile}{Environment.NewLine}{Environment.NewLine}{e}", @"Can't import structured *.xml");
                return(false);
            }

            InitializeXmlStructTable(xElFile);

            // Go through hierarchy and store in DataTable
            var level    = 1;
            var children = xElFile.Descendants(xmlChildrenName).FirstOrDefault(); //.Dump();

            if (OutputChildren(children, level) == false)
            {
                return(false);
            }



            ReadEaPackageRequirements();
            CreateEaPackageDeletedObjects();

            Count        = 0;
            CountChanged = 0;
            CountNew     = 0;
            List <int> parentElementIdsPerLevel = new List <int> {
                0
            };
            int parentElementId = 0;
            int lastElementId   = 0;

            int oldLevel = 0;

            string notesColumn = _settings.AttrNotes ?? "";

            foreach (DataRow row in DtRequirements.Rows)
            {
                Count += 1;



                int objectLevel = Int32.Parse(row["Object Level"].ToString()) - 1;

                // Maintain parent ids of level
                // get parent id
                if (objectLevel > oldLevel)
                {
                    if (parentElementIdsPerLevel.Count <= objectLevel)
                    {
                        parentElementIdsPerLevel.Add(lastElementId);
                    }
                    else
                    {
                        parentElementIdsPerLevel[objectLevel] = lastElementId;
                    }
                    parentElementId = lastElementId;
                }

                if (objectLevel < oldLevel)
                {
                    parentElementId = parentElementIdsPerLevel[objectLevel];
                }

                oldLevel = objectLevel;

                string objectId  = CombineAttrValues(_settings.IdList, row, ShortNameLength);
                string alias     = CombineAttrValues(_settings.AliasList, row, ShortNameLength);
                string name      = CombineAttrValues(_settings.AttrNameList, row, ShortNameLength);
                string notes     = notesColumn != "" ? row[notesColumn].ToString() : row[1].ToString();
                string nameShort = name.Length > ShortNameLength?name.Substring(0, ShortNameLength) : name;

                // Check if requirement with Doors ID already exists
                bool isExistingRequirement = DictPackageRequirements.TryGetValue(objectId, out int elId);


                EA.Element el;
                if (isExistingRequirement)
                {
                    el = Rep.GetElementByID(elId);
                    if (el.Alias != alias ||
                        el.Name != nameShort ||
                        el.Notes != notes)
                    {
                        if (stateChanged != "")
                        {
                            el.Status = stateChanged;
                        }
                        CountChanged += 1;
                    }
                }
                else
                {
                    el = (EA.Element)Pkg.Elements.AddNew(name, "Requirement");
                    if (stateNew != "")
                    {
                        el.Status = stateNew;
                    }
                    CountChanged += 1;
                }


                el.Alias        = alias;
                el.Name         = name;
                el.Multiplicity = objectId;
                el.Notes        = notes;
                el.TreePos      = Count * 10;
                el.PackageID    = Pkg.PackageID;
                el.ParentID     = parentElementId;
                el.Type         = eaObjectType;
                el.Stereotype   = eaStereotype;

                el.Update();
                Pkg.Elements.Refresh();
                lastElementId = el.ElementID;

                // handle the remaining columns/ tagged values
                var cols = from c in DtRequirements.Columns.Cast <DataColumn>()
                           where !ColumnNamesNoTaggedValues.Any(n => n == c.ColumnName)
                           select new
                {
                    Name  = c.ColumnName,
                    Value = row[c].ToString()
                }

                ;


                // Update/Create Tagged value
                foreach (var c in cols)
                {
                    if (notesColumn != c.Name)
                    {
                        TaggedValue.SetUpdate(el, c.Name, c.Value ?? "");
                    }
                }
            }

            MoveDeletedRequirements();
            UpdatePackage(xElFile);

            Rep.BatchAppend     = false;
            Rep.EnableUIUpdates = true;
            Rep.ReloadPackage(Pkg.PackageID);
            return(result);
        }
        //-----------------------------------------------------------------------------------------
        // Create StateMachine for Operation
        //----------------------------------------------------------------------------------
        public static bool CreateStateMachineForOperation(EA.Repository rep, EA.Method m)
        {
            // get class
            EA.Element elClass = rep.GetElementByID(m.ParentID);
            EA.Package pkgSrc  = rep.GetPackageByID(elClass.PackageID);

            // create a package with the name of the operation
            EA.Package pkgTrg = (Package)pkgSrc.Packages.AddNew(m.Name, "");
            pkgTrg.Update();
            pkgSrc.Packages.Refresh();

            // create Class StateMachine Diagram in target package
            EA.Diagram pkgSeqDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Statechart");
            pkgSeqDia.Update();
            pkgTrg.Diagrams.Refresh();

            // add frame in StateMachine diagram
            EA.DiagramObject frmObj = (EA.DiagramObject)pkgSeqDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", "");
            EA.Element       frm    = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram");
            frm.Update();
            frmObj.ElementID = frm.ElementID;
            //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            frmObj.Update();
            pkgTrg.Elements.Refresh();
            pkgSeqDia.DiagramObjects.Refresh();


            // create StateMachine with the name of the operation
            EA.Element stateMachine = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "StateMachine");
            stateMachine.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!";
            stateMachine.Update();
            pkgTrg.Elements.Refresh();

            // create Statechart diagram beneath State Machine
            EA.Diagram chartDia = (EA.Diagram)stateMachine.Diagrams.AddNew(m.Name, "Statechart");
            chartDia.Update();
            stateMachine.Diagrams.Refresh();

            // put the state machine on the diagram
            EA.DiagramObject chartObj = (EA.DiagramObject)chartDia.DiagramObjects.AddNew("l=50;r=600;t=100;b=800", "");
            chartObj.ElementID = stateMachine.ElementID;
            chartObj.Update();
            chartDia.DiagramObjects.Refresh();

            // add default nodes (init/final)
            CreateDefaultElementsForStateDiagram(rep, chartDia, stateMachine);

            // Add Heading to diagram
            EA.DiagramObject noteObj = (EA.DiagramObject)chartDia.DiagramObjects.AddNew("l=40;r=700;t=10;b=25", "");
            EA.Element       note    = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text");

            note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType;
            note.Update();
            noteObj.ElementID = note.ElementID;
            noteObj.Style     = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            noteObj.Update();
            pkgTrg.Elements.Refresh();
            chartDia.DiagramObjects.Refresh();


            // Link Operation to StateMachine
            HoUtil.SetBehaviorForOperation(rep, m, stateMachine);

            // Set show behavior
            HoUtil.SetShowBehaviorInDiagram(rep, m);



            HoUtil.SetFrameLinksToDiagram(rep, frm, chartDia); // link Overview frame to diagram
            frm.Update();
            //rep.ReloadDiagram(actDia.DiagramID);


            return(true);
        }
        //------------------------------------------------------------------------------
        // Create default Elements for Statemachine
        //------------------------------------------------------------------------------
        //
        // init
        // state 'State1'
        // final
        // transition from init to 'State1'

        public static bool CreateDefaultElementsForStateDiagram(Repository rep, EA.Diagram dia, EA.Element stateChart)
        {
            // check if init and final node are available
            bool init  = false;
            bool final = false;

            foreach (EA.Element node in stateChart.Elements)
            {
                if (node.Type == "StateNode" & node.Subtype == 100)
                {
                    init = true;
                }
                if (node.Type == "StateNode" & node.Subtype == 101)
                {
                    final = true;
                }
            }
            EA.Element initNode = null;
            if (!init)
            {
                initNode          = (EA.Element)stateChart.Elements.AddNew("", "StateNode");
                initNode.Subtype  = 3;
                initNode.ParentID = stateChart.ElementID;
                initNode.Update();
                if (dia != null)
                {
                    HoUtil.AddSequenceNumber(rep, dia);
                    EA.DiagramObject initDiaNode =
                        (EA.DiagramObject)dia.DiagramObjects.AddNew("l=295;r=315;t=125;b=135;", "");
                    initDiaNode.Sequence  = 1;
                    initDiaNode.ElementID = initNode.ElementID;
                    initDiaNode.Update();
                    HoUtil.SetSequenceNumber(rep, dia, initDiaNode, "1");
                }
            }
            EA.Element finalNode = null;
            // create final node
            if (!final)
            {
                finalNode          = (EA.Element)stateChart.Elements.AddNew("", "StateNode");
                finalNode.Subtype  = 4;
                finalNode.ParentID = stateChart.ElementID;
                finalNode.Update();
                if (dia != null)
                {
                    HoUtil.AddSequenceNumber(rep, dia);
                    EA.DiagramObject finalDiaNode =
                        (EA.DiagramObject)dia.DiagramObjects.AddNew("l=285;r=305;t=745;b=765;", "");
                    finalDiaNode.Sequence  = 1;
                    finalDiaNode.ElementID = finalNode.ElementID;
                    finalDiaNode.Update();
                    HoUtil.SetSequenceNumber(rep, dia, finalDiaNode, "1");
                }
            }
            // create state node
            EA.Element stateNode = (EA.Element)stateChart.Elements.AddNew("", "State");
            stateNode.Subtype  = 0; // state
            stateNode.Name     = "State1";
            stateNode.ParentID = stateChart.ElementID;
            stateNode.Update();
            if (dia != null)
            {
                HoUtil.AddSequenceNumber(rep, dia);
                string           pos          = "l=300;r=400;t=-400;b=-470";
                EA.DiagramObject stateDiaNode = (EA.DiagramObject)dia.DiagramObjects.AddNew(pos, "");
                stateDiaNode.Sequence  = 1;
                stateDiaNode.ElementID = stateNode.ElementID;
                stateDiaNode.Update();
                HoUtil.SetSequenceNumber(rep, dia, stateDiaNode, "1");

                // draw a transition
                EA.Connector con = (EA.Connector)finalNode.Connectors.AddNew("", "StateFlow");
                con.SupplierID = stateNode.ElementID;
                con.ClientID   = initNode.ElementID;
                con.Update();
                finalNode.Connectors.Refresh();
                stateChart.Elements.Refresh();
                dia.DiagramObjects.Refresh();
                dia.Update();
                rep.ReloadDiagram(dia.DiagramID);
            }

            return(true);
        }
        public static bool CreateInteractionForOperation(EA.Repository rep, EA.Method m)
        {
            // get class
            EA.Element elClass = rep.GetElementByID(m.ParentID);
            Package    pkgSrc  = rep.GetPackageByID(elClass.PackageID);

            // create a package with the name of the operation
            Package pkgTrg = (Package)pkgSrc.Packages.AddNew(m.Name, "");

            pkgTrg.Update();
            pkgSrc.Packages.Refresh();

            // create Class Sequence Diagram in target package
            EA.Diagram pkgSeqDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Sequence");
            pkgSeqDia.Update();
            pkgTrg.Diagrams.Refresh();

            // add frame in Sequence diagram
            EA.DiagramObject frmObj = (EA.DiagramObject)pkgSeqDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", "");
            EA.Element       frm    = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram");
            frm.Update();
            frmObj.ElementID = frm.ElementID;
            //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            frmObj.Update();
            pkgTrg.Elements.Refresh();
            pkgSeqDia.DiagramObjects.Refresh();


            // create Interaction with the name of the operation
            EA.Element seq = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "Interaction");
            seq.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!";
            seq.Update();
            pkgTrg.Elements.Refresh();

            // create sequence diagram beneath Interaction
            EA.Diagram seqDia = (EA.Diagram)seq.Diagrams.AddNew(m.Name, "Sequence");
            seqDia.Update();
            seq.Diagrams.Refresh();

            // create instance from class beneath Interaction
            EA.Element obj = (EA.Element)seq.Elements.AddNew("", "Object");
            seq.Elements.Refresh();
            obj.ClassfierID = elClass.ElementID;
            obj.Update();

            // add node object to Sequence Diagram
            EA.DiagramObject node = (EA.DiagramObject)seqDia.DiagramObjects.AddNew("l=100;r=180;t=50;b=70", "");
            node.ElementID = obj.ElementID;
            node.Update();


            // Add Heading to diagram
            EA.DiagramObject noteObj = (EA.DiagramObject)seqDia.DiagramObjects.AddNew("l=40;r=700;t=10;b=25", "");
            EA.Element       note    = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text");

            note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType;
            note.Update();
            noteObj.ElementID = note.ElementID;
            noteObj.Style     = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            noteObj.Update();
            pkgTrg.Elements.Refresh();
            seqDia.DiagramObjects.Refresh();


            // Link Operation to activity
            HoUtil.SetBehaviorForOperation(rep, m, seq);

            // Set show behavior
            HoUtil.SetShowBehaviorInDiagram(rep, m);



            HoUtil.SetFrameLinksToDiagram(rep, frm, seqDia); // link Overview frame to diagram
            frm.Update();
            //rep.ReloadDiagram(actDia.DiagramID);


            return(true);
        }
        /// <summary>
        /// Generate provided Interface. All functions called from not component modules
        /// -
        /// </summary>
        /// <param name="db"></param>
        /// <param name="folderNameOfClass"></param>
        /// <param name="fileNamesOfClassTree"></param>
        /// <param name="allCompImplementations"></param>
        /// <returns></returns>
        private static DataTable ShowProvidedInterface(BROWSEVCDB db,
                                                       string folderNameOfClass,
                                                       IQueryable <string> fileNamesOfClassTree,
                                                       IEnumerable <ImplFunctionItem> allCompImplementations)
        {
            var compImplementations = (from f in allCompImplementations
                                       where f.FilePath.StartsWith(folderNameOfClass) || f.FilePath == ""
                                       select new
            {
                Imp = new ImplFunctionItem(f.Interface, f.Implementation, f.FilePath, "", f.LineStart),
                // Rx to find a call to function, should be fast, later detailed test
                // 'function('
                RxImplementation = new Regex($@"\b{f.Implementation}\s*\("),
                RxInterface = new Regex($@"\b{f.Interface}\s*\(")
            }).ToArray();

            // over all files except Class/Component Tree (files not part of component/class/sub folder)
            IQueryable <string> fileNamesCalledImplementation = (from f in db.Files
                                                                 where !fileNamesOfClassTree.Any(x => x == f.Name) &&
                                                                 (f.LeafName.ToLower().EndsWith(".c") || f.LeafName.ToLower().EndsWith(".cpp"))
                                                                 select f.Name).Distinct();

            foreach (var fileName in fileNamesCalledImplementation)
            {
                if (!File.Exists(fileName))
                {
                    MessageBox.Show($@"File:{Environment.NewLine}'{fileName}'{Environment.NewLine}{Environment.NewLine}Root:{Environment.NewLine}{_folderRoot}",
                                    @"Can't open implementation of provided interface, skip!!!");
                    continue;
                }
                // only files in implementation
                if (fileName.ToLower().Contains(_folderRoot.ToLower()))
                {
                    string code = HoService.DeleteComment(HoUtil.ReadAllText(fileName));
                    foreach (var f1 in compImplementations)
                    {
                        if (f1.RxImplementation.IsMatch(code) || f1.RxInterface.IsMatch(code))
                        {
                            Regex rx = f1.Imp.Implementation == f1.Imp.Interface
                                ? new Regex($@"^.*\b{f1.Imp.Implementation}\s*\([^}}{{;]*;", RegexOptions.Multiline)
                                : new Regex($@"^.*\b({f1.Imp.Implementation}|{f1.Imp.Interface})\s*\([^}}{{;]*;", RegexOptions.Multiline);

                            Match match = rx.Match(code);
                            while (match.Success)
                            {
                                // That's not an call to a function
                                if (match.Value.Trim().StartsWith("FUNC(") || match.Value.Trim().StartsWith("void ") || match.Value.Trim().StartsWith("static ") || match.Value.Trim().StartsWith("extern "))
                                {
                                    match = match.NextMatch();
                                    continue;
                                }

                                f1.Imp.FilePathCallee = fileName;
                                break;
                            }

                            //f1.Imp.FilePathCallee = fileName;
                        }
                    }
                }
            }
            // Sort: Function, FileName
            var outputList = (from f in compImplementations
                              orderby f.Imp.Interface, f.Imp.Implementation
                              select new
            {
                Interface = f.Imp.Interface,
                Implementation = f.Imp.Implementation == f.Imp.Interface ? "" : f.Imp.Implementation,
                FileName = f.Imp.FileName,
                FileNameCallee = f.Imp.FileNameCallee,
                // no root path
                FilePath = f.Imp.FilePath.Length > _folderRoot.Length ? f.Imp.FilePath.Substring(_folderRoot.Length) : "",
                FilePathCallee = f.Imp.FilePathCallee.Length > _folderRoot.Length ? f.Imp.FilePathCallee.Substring(_folderRoot.Length) : "",
                isCalled = f.Imp.IsCalled,
                LineStart = f.Imp.LineStart
            }).Distinct();

            return(outputList.ToDataTable());
        }
        /// <summary>
        /// Get all required Interfaces of Component (root folder of component)
        /// </summary>
        /// <param name="db"></param>
        /// <param name="folderNameOfClass"></param>
        /// <param name="filesPathOfClassTree"></param>
        /// <param name="allImplementations"></param>
        /// <returns></returns>
        private static DataTable ShowRequiredInterface(BROWSEVCDB db,
                                                       string folderNameOfClass,
                                                       IQueryable <string> filesPathOfClassTree,
                                                       IEnumerable <ImplFunctionItem> allImplementations)
        {
            // Estimate all possible function calls of passed files
            Regex rx = new Regex(@"(\b[A-Z]\w*_\w*)\s*\(", RegexOptions.IgnoreCase);
            List <CallFunctionItem> lFunctionCalls = new List <CallFunctionItem>();

            foreach (var file in filesPathOfClassTree)
            {
                // only files that are in source folder, no library files.
                if (file.ToLower().Contains(_folderRoot.ToLower()))
                {
                    string code  = HoService.DeleteComment(HoUtil.ReadAllText(file));
                    Match  match = rx.Match(code);
                    while (match.Success)
                    {
                        lFunctionCalls.Add(new CallFunctionItem(match.Groups[1].Value, file));
                        match = match.NextMatch();
                    }
                }
            }


            // ignore the following function names (beginning)
            string[] ignoreList =
            {
                "Rte_Read",     "Rte_Write",     "Rte_Invalidate",
                "L2A_Rte_Read", "L2A_Rte_Write", "L2A_Rte_Invalidate",
                "L2B_Rte_Read", "L2B_Rte_Write", "L2B_Rte_Invalidate",
                "L2C_Rte_Read", "L2C_Rte_Write", "L2C_Rte_Invalidate"
            };

            // filter only function implementation
            // - not current folder/subfolder (current component, required)
            // - not to ignore according to ignore list
            var filteredFunctions = (from f in lFunctionCalls
                                     join fAll in allImplementations on f.Function equals fAll.Implementation
                                     where (!fAll.FilePath.StartsWith(folderNameOfClass)) &&
                                     ignoreList.All(l => !f.Function.StartsWith(l)) // handle ignore list
                                     orderby fAll.Implementation
                                     select new
            {
                Interface = fAll.Interface,
                Implementation = fAll.Implementation,
                FilePathImplementation = fAll.FilePath,
                FilePathCallee = f.FilePath,     // no implementation available yet
                isCalled = false,
                LineStart = fAll.LineStart,
                LineEnd = fAll.LineEnd,
                ColumnEnd = fAll.ColumnEnd
            }).Distinct();


            // check if filtered functions are implemented
            List <ImplFunctionItem> filteredImplemtedFunctions = new List <ImplFunctionItem>();

            foreach (var f in filteredFunctions)
            {
                if (!File.Exists(f.FilePathImplementation))
                {
                    MessageBox.Show($"File:\r\n'{f.FilePathImplementation}'\r\n\r\nRoot:\r\n{_folderRoot}",
                                    "Can't open implementation of required interface, skip interface!!!");
                    continue;
                }
                string[] codeLines = File.ReadAllLines(f.FilePathImplementation);
                // declaration ends with ';'
                // implementation ends with '}'
                //codeLines[f.Line - 1].Dump();
                if (f.LineEnd > 0 && f.ColumnEnd > 0)
                {
                    string line = codeLines[f.LineEnd - 1];
                    if (line.Length > 0)
                    {
                        if (line.Substring(f.ColumnEnd - 1, 1) != ";")
                        {
                            filteredImplemtedFunctions.Add(new ImplFunctionItem(
                                                               f.Interface,
                                                               f.Interface == f.Implementation ? "" : f.Implementation,
                                                               // no root path
                                                               f.FilePathImplementation.Length > _folderRoot.Length ? f.FilePathImplementation.Substring(_folderRoot.Length) : "",
                                                               f.FilePathCallee.Length > _folderRoot.Length ? f.FilePathCallee.Substring(_folderRoot.Length): "",
                                                               f.LineStart));
                        }
                    }
                }
            }
            return(filteredImplemtedFunctions.ToDataTable());
        }
Example #23
0
        /// <summary>
        /// Create Activity for operation
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="m"></param>
        /// <param name="treePos"></param>
        /// <param name="pkgSrc"></param>
        /// <param name="elClass"></param>
        private static void CreateActivityFromOperation(Repository rep, Method m, int treePos, Package pkgSrc, Element elClass)
        {
            // create a package with the name of the operation
            Package pkgTrg = (Package)pkgSrc.Packages.AddNew(m.Name, "");

            pkgTrg.TreePos = treePos;
            pkgTrg.Update();
            pkgSrc.Packages.Refresh();

            EA.Element frm = null; // frame beneath package
            if (ActivityIsSimple == false)
            {
                // create Class Activity Diagram in target package
                EA.Diagram pkgActDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Activity");
                pkgActDia.Update();
                pkgTrg.Diagrams.Refresh();
                // prevent information loss
                HoUtil.SetDiagramStyleFitToPage(pkgActDia); // after save diagram!

                // add frame in Activity diagram
                EA.DiagramObject frmObj = (EA.DiagramObject)pkgActDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", "");
                frm = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram");
                frm.Update();
                frmObj.ElementID = frm.ElementID;
                //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
                frmObj.Update();
                pkgTrg.Elements.Refresh();
                pkgActDia.DiagramObjects.Refresh();
            }

            // create activity with the name of the operation
            EA.Element act = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "Activity");
            if (ActivityIsSimple == false)
            {
                act.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType +
                            ";\r\nDetails see Operation definition!!";
            }

            act.StereotypeEx = m.StereotypeEx;
            act.Update();
            pkgTrg.Elements.Refresh();

            // create activity diagram beneath Activity
            EA.Diagram actDia = (EA.Diagram)act.Diagrams.AddNew(m.Name, "Activity");
            // update diagram properties
            actDia.ShowDetails = 0; // hide details
            // scale page to din A4

            if (actDia.StyleEx.Length > 0)
            {
                actDia.StyleEx = actDia.StyleEx.Replace("HideQuals=0", "HideQuals=1"); // hide qualifier
            }
            else
            {
                actDia.StyleEx = "HideQuals=1;";
            }

            // Hide Qualifier
            if (actDia.ExtendedStyle.Length > 0)
            {
                actDia.ExtendedStyle = actDia.ExtendedStyle.Replace("ScalePI=0", "ScalePI=1");
            }
            else
            {
                actDia.ExtendedStyle = "ScalePI=1;";
            }

            actDia.Update();
            act.Diagrams.Refresh();


            // put the activity on the diagram
            HoUtil.AddSequenceNumber(rep, actDia);
            EA.DiagramObject actObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=30;r=780;t=30;b=1120", "");
            actObj.ElementID = act.ElementID;
            actObj.Sequence  = 1;
            actObj.Update();
            HoUtil.SetSequenceNumber(rep, actDia, actObj, "1");
            actDia.DiagramObjects.Refresh();

            // add default nodes (init/final)
            CreateDefaultElementsForActivity(rep, actDia, act);

            if (ActivityIsSimple == false)
            {
                // Add Heading to diagram
                HoUtil.AddSequenceNumber(rep, actDia);
                EA.DiagramObject noteObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=40;r=700;t=25;b=50", "");
                EA.Element       note    = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text");

                note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType;
                note.Update();
                noteObj.ElementID = note.ElementID;
                noteObj.Style     = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
                noteObj.Sequence  = 1;
                noteObj.Update();
                HoUtil.SetSequenceNumber(rep, actDia, noteObj, "1");
            }

            pkgTrg.Elements.Refresh();
            actDia.DiagramObjects.Refresh();


            // Link Operation to activity
            HoUtil.SetBehaviorForOperation(rep, m, act);

            // Set show behavior
            HoUtil.SetShowBehaviorInDiagram(rep, m);

            // add parameters to activity
            UpdateParameterFromOperation(rep, act, m);
            int pos = 0;

            foreach (EA.Element actPar in act.EmbeddedElements)
            {
                if (!actPar.Type.Equals("ActivityParameter"))
                {
                    continue;
                }
                HoUtil.VisualizePortForDiagramobject(rep, pos, actDia, actObj, actPar, null);
                pos = pos + 1;
            }

            if (ActivityIsSimple == false)
            {
                // link Overview frame to diagram
                HoUtil.SetFrameLinksToDiagram(rep, frm, actDia);
                frm.Update();
            }

            // select operation
            rep.ShowInProjectView(m);
        }
Example #24
0
        //-------------------------------------------------------------------------------------------------
        // get Parameter from operation
        // visualize them on diagram / activity
        //-------------------------------------------------------------------------------------------------
        public static bool UpdateParameterFromOperation(Repository rep, EA.Element act, Method m)
        {
            if (m == null)
            {
                return(false);
            }
            if (act.Locked)
            {
                return(false);
            }
            if (!act.Type.Equals("Activity"))
            {
                return(false);
            }

            EA.Element parTrgt = null;


            ///////////////////////////////////////////////////////////////////////////////////
            // return code
            string parName = "Return";
            int    methodReturnTypId;

            // is type defined?
            if ((m.ClassifierID != "0") & (m.ClassifierID != ""))
            {
                methodReturnTypId = Convert.ToInt32(m.ClassifierID);
            }

            // type is only defined as text
            else
            {
                methodReturnTypId = Convert.ToInt32(HoUtil.GetTypeId(rep, m.ReturnType));
            }

            bool withActivityReturnParameter = false;

            if (withActivityReturnParameter)
            {
                parTrgt.ClassifierID = methodReturnTypId;
                // create an return Parameter for Activity (in fact an element with properties)
                parTrgt = HoUtil.GetParameterFromActivity(rep, null, act, true);
                if (parTrgt == null)
                {
                    parTrgt = (EA.Element)act.EmbeddedElements.AddNew(parName, "Parameter");
                }
                else
                {
                    parTrgt.Name = parName;
                }


                parTrgt.Alias        = "return:" + m.ReturnType;
                parTrgt.ClassifierID = parTrgt.ClassifierID;

                parTrgt.Update();
                // update properties for return value
                Param par = new Param(rep, parTrgt);
                par.setParameterProperties("direction", "out");
                par.save();
                par = null;
            }
            // returnType for activity
            act.ClassfierID = methodReturnTypId;
            act.Name        = m.Name;

            // use stereotype of operation as stereotype for activity
            act.StereotypeEx = m.StereotypeEx;
            act.Update();
            act.EmbeddedElements.Refresh();

            // over all parameters
            string guids = "";
            // It looks as if parSrc.Position isn't reliable
            int pos = 0;

            foreach (EA.Parameter parSrc in m.Parameters)
            {
                // create an Parameter for Activity (in fact an element with properties)
                // - New if the parameter don't exists
                // - Update if the parameter exists
                // -- Update according to the parameter position

                //string direction = " [" + parSrc.Kind + "]";
                string direction = "";
                string prefixTyp = "";
                if (parSrc.IsConst)
                {
                    prefixTyp = " const";
                }
                var postfixName = "";
                if (parSrc.Kind.Contains("out"))
                {
                    postfixName = "*";
                }
                //parName = parSrc.Position + ":" + parSrc.Name + postfixName + prefixTyp + direction;
                parName = $"{pos}:{parSrc.Name}{postfixName}{prefixTyp}{direction}";

                // check if parameter already exists (last parameter = false)
                parTrgt = HoUtil.GetParameterFromActivity(rep, parSrc, act);



                // parameter doesn't exists
                if (parTrgt == null)
                {
                    parTrgt = (EA.Element)act.EmbeddedElements.AddNew(parName, "Parameter");
                }
                else
                {
                    parTrgt.Name = parName;
                }
                guids = guids + parTrgt.ElementGUID;

                // is type defined?
                if ((parSrc.ClassifierID != "0") & (parSrc.ClassifierID != ""))
                {
                    parTrgt.ClassifierID = Convert.ToInt32(parSrc.ClassifierID);
                }
                // type is only defined as text
                else
                {   // try to find classifier
                    parTrgt.ClassifierID = Convert.ToInt32(HoUtil.GetTypeId(rep, parSrc.Type));
                    // use type in name (no classifier found)
                    if (parTrgt.ClassifierID == 0)
                    {
                        parTrgt.Name = parTrgt.Name + ":" + parSrc.Type;
                    }
                }

                parTrgt.Notes = parSrc.Notes;
                parTrgt.Alias = $"par_{pos}:{parSrc.Type}";
                //parTrgt.Alias = $"par_{parSrc.Position}:{parSrc.Type}";

                // update properties for parameter
                Param par = new Param(rep, parTrgt);
                par.setParameterProperties("direction", parSrc.Kind);
                if (parSrc.IsConst)
                {
                    par.setParameterProperties("constant", "true");
                }
                par.save();
                parTrgt.Update();
                pos += 1;
            }
            act.EmbeddedElements.Refresh();
            // delete all unused parameter
            for (short i = (short)(act.EmbeddedElements.Count - 1); i >= 0; --i)
            {
                EA.Element embeddedEl = (EA.Element)act.EmbeddedElements.GetAt(i);
                if (embeddedEl.Type.Equals("ActivityParameter"))
                {
                    if (!(guids.Contains(embeddedEl.ElementGUID)))
                    {
                        act.EmbeddedElements.Delete(i);
                    }
                }
            }
            act.EmbeddedElements.Refresh();

            return(true);
        }