当前位置: 首页>>代码示例>>C#>>正文


C# Repository.GetElementByGuid方法代码示例

本文整理汇总了C#中Repository.GetElementByGuid方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.GetElementByGuid方法的具体用法?C# Repository.GetElementByGuid怎么用?C# Repository.GetElementByGuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Repository的用法示例。


在下文中一共展示了Repository.GetElementByGuid方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NavigateComposite

        public static void NavigateComposite(Repository repository)
        {
            ObjectType oType = repository.GetContextItemType();
            // find composite element of diagram
            if (oType.Equals(ObjectType.otDiagram))
            {
                var d = (Diagram) repository.GetContextObject();
                string guid = Util.GetElementFromCompositeDiagram(repository, d.DiagramGUID);
                if (guid != "")
                {
                    repository.ShowInProjectView(repository.GetElementByGuid(guid));
                }
            }
            // find composite diagram of element of element
            if (oType.Equals(ObjectType.otElement))
            {
                var e = (Element) repository.GetContextObject();
                // locate text or frame
                if (LocateTextOrFrame(repository, e)) return;

                repository.ShowInProjectView(e.CompositeDiagram);
            }
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:23,代码来源:EaServices.cs

示例2: SetDirectoryTaggedValues

        public static void SetDirectoryTaggedValues(Repository rep, Package pkg)
        {
            bool withCheckIn = false;
            string guid = pkg.PackageGUID;

            Element el = rep.GetElementByGuid(guid);
            if (IsTaggedValuesComplete(el)) return;
            if (pkg.IsVersionControlled)
            {
                int state = pkg.VersionControlGetStatus();
                if (state == 4)
                {
                    MessageBox.Show("", @"Package checked out by another user, break");
                    return;
                }
                if (state == 1) // checked in
                {
                    CheckOut(rep, pkg);
                    withCheckIn = true;
                }
            }
            pkg = rep.GetPackageByGuid(guid);
            SetSvnProperty(rep, pkg);

            // set tagged values
            el = rep.GetElementByGuid(guid);
            bool createSvnDate = true;
            bool createSvnRevision = true;
            foreach (EA.TaggedValue t in el.TaggedValues)
            {
                createSvnDate &= t.Name != "svnDate";
                createSvnRevision &= t.Name != "svnRevision";
            }
            EA.TaggedValue tag;
            if (createSvnDate)
            {
                tag = (EA.TaggedValue) el.TaggedValues.AddNew("svnDate", "");
                tag.Value = "$Date: $";
                el.TaggedValues.Refresh();
                tag.Update();
            }
            if (createSvnRevision)
            {
                tag = (EA.TaggedValue) el.TaggedValues.AddNew("svnRevision", "");
                tag.Value = "$Revision: $";
                el.TaggedValues.Refresh();
                tag.Update();
            }


            if (pkg.IsVersionControlled)
            {
                int state = pkg.VersionControlGetStatus();
                if (state == 2 & withCheckIn) // checked out to this user
                {
                    //EaService.checkIn(rep, pkg, "");
                    CheckIn(rep, pkg, withGetLatest: true, comment: @"svn tags added");
                }
            }
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:60,代码来源:EaServices.cs

示例3: ChangeAuthor

        public static void ChangeAuthor(Repository rep)
        {
            string[] args = {""};
            string oldAuthor;
            Element el = null;
            Package pkg = null;
            Diagram dia = null;
            ObjectType oType = rep.GetContextItemType();

            // get the element
            switch (oType)
            {
                case ObjectType.otPackage:
                    pkg = (Package) rep.GetContextObject();
                    el = rep.GetElementByGuid(pkg.PackageGUID);
                    oldAuthor = el.Author;
                    break;
                case ObjectType.otElement:
                    el = (Element) rep.GetContextObject();
                    oldAuthor = el.Author;
                    break;
                case ObjectType.otDiagram:
                    dia = (Diagram) rep.GetContextObject();
                    oldAuthor = dia.Author;
                    break;
                default:
                    return;
            }
            // ask for new user
            var dlg = new dlgUser(rep) {User = oldAuthor};
            dlg.ShowDialog();
            args[0] = dlg.User;
            if (args[0] == "")
            {
                MessageBox.Show($"Author:'{args[0]}'", @"no or invalid user");
                return;
            }
            switch (oType)
            {
                case ObjectType.otPackage:
                    ChangeAuthorPackage(rep, pkg, args);
                    MessageBox.Show($"New author:'{args[0]}'", @"Author changed for package");
                    break;
                case ObjectType.otElement:
                    ChangeAuthorElement(rep, el, args);
                    MessageBox.Show($"New author:'{args[0]}'", @"Author changed for element");
                    break;
                case ObjectType.otDiagram:
                    ChangeAuthorDiagram(rep, dia, args);
                    MessageBox.Show($"New author:'{args[0]}'", @"Author changed for element");
                    break;
                default:
                    return;
            }
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:55,代码来源:EaServices.cs

示例4: CheckIn

        /// <summary>
        /// Check in of a package. If there are the following package tagged values a get latest is performed to update keywords:
        /// -- svnDoc
        /// -- svnRevision
        /// </summary>
        /// <param name="rep">Repository</param>
        /// <param name="pkg">Package, default null</param>
        /// <param name="withGetLatest">false if you want to avoid a getLatest to update VC keywords
        /// Tagged Value "svnDoc" or "svnRevision" of package are true</param>
        /// <param name="comment">A check in comment, default="0" = aks for checkin comment</param>
        static void CheckIn(Repository rep, Package pkg = null, bool withGetLatest = false, string comment = "0")
        {
            if (pkg == null) pkg = rep.GetTreeSelectedPackage();
            if (pkg == null) return;

            pkg = Util.GetFirstControlledPackage(rep, pkg);
            if (pkg == null) return;

            var svnHandle = new Svn(rep, pkg);
            string userNameLockedPackage = svnHandle.GetLockingUser();
            if (userNameLockedPackage == "")
            {
                MessageBox.Show(@"Package isn't checked out");
                return;
            }


            if (InputBox(@"Checkin comment", @"Checkin", ref comment) == DialogResult.OK)
            {
                //
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    pkg.VersionControlCheckin(comment);
                    Cursor.Current = Cursors.Default;
                }
                catch (Exception e)
                {
                    MessageBox.Show($"{e} \n\n {pkg.GetLastError()}", @"Error Checkin");
                    return;
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
            if (withGetLatest)
            {
                // check if GetLatest is appropriate
                Element el = rep.GetElementByGuid(pkg.PackageGUID);
                foreach (EA.TaggedValue t in el.TaggedValues)
                {
                    if (t.Name == "svnDoc" | t.Name == "svnRevision")
                    {
                        pkg.VersionControlResynchPkgStatus(false);
                        if (pkg.Flags.Contains("Checkout"))
                        {
                            MessageBox.Show($"Flags={pkg.Flags}", @"Package Checked out, Break!");
                            return;
                        }
                        pkg.VersionControlGetLatest(true);
                        return;
                    }
                }
            }
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:66,代码来源:EaServices.cs

示例5: UnLockAllForCurrentUser

        // ReSharper disable once UnusedMember.Global
        // dynamical usage as configurable service by reflection
        public static void UnLockAllForCurrentUser(Repository rep)
        {
            if (!IsSecurityEnabled(rep)) return;

            string logInUserGuid = rep.GetCurrentLoginUser(true);

            string sqlItems =
                $"select EntityType as [TYPE], EntityID as [GUID] from t_seclocks where UserId = '{logInUserGuid}'";
            XDocument x = XDocument.Parse(rep.SQLQuery(sqlItems));

            var fields = from row in x.Descendants("Row").Descendants()
                         where row.Name == "TYPE" ||
                               row.Name == "Id"
                         // 'Class','Action','Diagram', 
                         select row;
            int i = 0;
            string type = "";
            foreach (var field in fields)
            {
                switch (i % 2)
                {
                    case 0:
                        type = field.Value;
                        break;
                    case 1:
                        var guid = field.Value;
                        switch (type)
                        {
                            case "Element":
                                Element el = rep.GetElementByGuid(guid);
                                el.ReleaseUserLock();
                                break;
                            case "Diagram":
                                EA.Diagram dia = rep.GetDiagramByGuid(guid);
                                dia.ReleaseUserLock();
                                break;
                        }
                        break;
                }
                i = i + 1;
            }
        }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:44,代码来源:EaServices.cs

示例6: LocateType

        /// <summary>
        /// Locate the type for Connector, Method, Attribute, Diagram, Element, Package
        /// </summary>
        /// <param name="rep"></param>
        public static void LocateType(Repository rep)
        {
            ObjectType oType = rep.GetContextItemType();
            Element el;
            int id;
            string triggerGuid;
            // connector
            // links to trigger
            switch (oType)
            {
                case ObjectType.otConnector:
                    var con = (Connector) rep.GetContextObject();
                    triggerGuid = Util.GetTrigger(rep, con.ConnectorGUID);
                    if (triggerGuid.StartsWith("{", StringComparison.Ordinal) &&
                        triggerGuid.EndsWith("}", StringComparison.Ordinal))
                    {
                        Element trigger = rep.GetElementByGuid(triggerGuid);

                        if (trigger != null) rep.ShowInProjectView(trigger);
                    }
                    else
                    {
                        SelectBehaviorFromConnector(rep, con, DisplayMode.Method);
                    }
                    break;


                case ObjectType.otMethod:
                    var m = (Method) rep.GetContextObject();
                    if (m.ClassifierID != "")
                    {
                        id = Convert.ToInt32(m.ClassifierID);
                        // get type
                        if (id > 0)
                        {
                            el = rep.GetElementByID(id);
                            rep.ShowInProjectView(el);
                        }
                    }
                    break;

                case ObjectType.otAttribute:
                    var attr = (EA.Attribute) rep.GetContextObject();
                    id = attr.ClassifierID;
                    // get type
                    if (id > 0)
                    {
                        el = rep.GetElementByID(attr.ClassifierID);
                        if (el.Type.Equals("Package"))
                        {
                            Package pkg = rep.GetPackageByID(Convert.ToInt32(el.MiscData[0]));
                            rep.ShowInProjectView(pkg);
                        }
                        else
                        {
                            rep.ShowInProjectView(el);
                        }
                    }
                    break;

                // Locate Diagram (e.g. from Search Window)
                case ObjectType.otDiagram:
                    var d = (Diagram) rep.GetContextObject();
                    rep.ShowInProjectView(d);
                    break;


                case ObjectType.otElement:
                    el = (Element) rep.GetContextObject();
                    if (el.ClassfierID > 0)
                    {
                        el = rep.GetElementByID(el.ClassfierID);
                        rep.ShowInProjectView(el);
                    }
                    else
                    {
//MiscData(0) PDATA1,PDATA2,
                        // pdata1 Id for parts, UmlElement
                        // object_id   for text with Hyper link to diagram

                        // locate text or frame
                        if (LocateTextOrFrame(rep, el)) return;

                        string guid = el.MiscData[0];
                        if (guid.EndsWith("}", StringComparison.Ordinal))
                        {
                            el = rep.GetElementByGuid(guid);
                            rep.ShowInProjectView(el);
                        }
                        else
                        {
                            if (el.Type.Equals("Action"))
                            {
                                foreach (CustomProperty custproperty in el.CustomProperties)
                                {
                                    if (custproperty.Name.Equals("kind") && custproperty.Value.Contains("AcceptEvent"))
//.........这里部分代码省略.........
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:101,代码来源:EaServices.cs

示例7: ChangeAuthorPackage

 static void ChangeAuthorPackage(Repository rep, Package pkg, string[] args)
 {
     Element el = rep.GetElementByGuid(pkg.PackageGUID);
     el.Author = args[0];
     el.Update();
 }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:6,代码来源:EaServices.cs

示例8: BehaviorForOperation

 // ReSharper disable once UnusedMember.Local
 static void BehaviorForOperation(Repository repository, Method method)
 {
     string behavior = method.Behavior;
     if (behavior.StartsWith("{", StringComparison.Ordinal) & behavior.EndsWith("}", StringComparison.Ordinal))
     {
         // get object according to behavior
         Element el = repository.GetElementByGuid(behavior);
         // Activity
         if (el == null)
         {
         }
         else
         {
             if (el.Type.Equals("Activity") || el.Type.Equals("Interaction") || el.Type.Equals("StateMachine"))
             {
                 Util.OpenBehaviorForElement(repository, el);
             }
         }
     }
 }
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:21,代码来源:EaServices.cs


注:本文中的Repository.GetElementByGuid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。