示例#1
0
        protected readonly string[] EaLayoutStyle; // The EA Text Style stored in t_txtref


        protected DiagramGeneralStyle(EA.Repository rep, string type, string style, string property)
        {
            Style    = style.Trim().Replace(",", ";").Replace(";;", ";").TrimEnd(';').Split(';');
            Property = property.Trim().Replace(",", ";").Replace(";;", ";").TrimEnd(';').Split(';');

            type = type.Trim().TrimEnd(';').Replace(";;", ";");
            Type = type.Split(';');
            Rep  = rep;

            // handle EA Layout Styles
            Regex rgx   = new Regex(@"EaLayoutStyle=([^;]*)");
            Match match = rgx.Match(property);

            if (match.Success && match.Groups.Count == 2)
            {
                // handle EA Styles
                string layoutStyleName  = match.Groups[1].Value.Trim();
                string sql              = $@"select Notes as [STYLE] from t_trxtypes  where TRX='{layoutStyleName}'";
                var    layoutStyleValue = UtilSql.GetListOfStringFromSql(Rep, sql, "STYLE");
                if (layoutStyleValue.Count == 0)
                {
                    MessageBox.Show($@"EA Text Style '{layoutStyleName}' not available in EA.", $@"Can't read EA Text Style '{layoutStyleName}'.");
                }
                if (layoutStyleValue.Count > 1)
                {
                    MessageBox.Show(
                        $@"EA Text Style '{EaLayoutStyle}'\r\nCount: {layoutStyleValue.Count}. EA Text styles are a little tricky with names! Check list box of styles in EA!",
                        $@"More than one style with name '{layoutStyleName}'.");
                }
                EaLayoutStyle = layoutStyleValue[0].Split(';');
            }
        }
        /// <summary>
        /// Get the Behavior for an Operation. The behavior is stored in:
        /// .Behavior '{ea_guid}' of classifier which is the behavior
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="method"></param>
        /// <returns>Behavior</returns>
        public static EA.Element GetBehaviorForOperation(Repository repository, Method method)
        {
            EA.Element returnValue = null;
            string     behavior    = method.Behavior;

            if (behavior.StartsWith("{") & behavior.EndsWith("}"))
            {
                // get object according to behavior
                EA.Element el = repository.GetElementByGuid(behavior);
                // Behavior found
                if (el != null)
                {
                    returnValue = el;
                }
                else
                {
                    behavior = "";
                }
            }
            // try to establish link to behavior.
            if (behavior == "")
            {
                string colName = "guid_activity";
                string query   =
                    $@"select ea_guid As [{colName}] from t_object where name = '{method.Name}' and Object_Type = 'Activity'";

                UtilSql       sql           = new UtilSql(repository);
                List <string> lActivityGuid = sql.GetListOfStringFromSql(query, colName);
                if (lActivityGuid.Count == 1)
                {
                    // get Behavior
                    behavior    = lActivityGuid[0];
                    returnValue = repository.GetElementByGuid(behavior);
                    if (returnValue == null)
                    {
                        MessageBox.Show(
                            $"Operation: '{method.Name}' has no possible Activity, can't establish a link from Operation to Activity",
                            "Can't link Activity to operation");
                    }
                    else
                    {
                        method.Behavior = behavior;
                        method.Update();
                    }
                }
                else
                {
                    MessageBox.Show($@"Operation: '{method.Name}' has {lActivityGuid.Count} possible Activities, can't establish a link from Operation to Activity.
This can be because of macros and multiple implementations of the operetion.",
                                    "Can't link Activity to operation, stereotype?");
                }
            }
            return(returnValue);
        }