zoukankan      html  css  js  c++  java
  • skyline TEP学习心得(1):工程树ProjectTree操作两例

    环境TEP6.1,C#

    1.查找或创建组,查找不到则创建,返回ItemID

    第二个参数是查找的组的路径,格式为:A\B\C

            /// <summary>
            /// 查找或创建组(查找不到则创建)
            /// </summary>
            /// <param name="tSGWorld"></param>
            /// <param name="tGroupPath">查找路径,格式:A\B\C</param>
            /// <returns></returns>
            public static int FindAndCreateGroup(ISGWorld61 tSGWorld, string tGroupPath)
            {
                if (tGroupPath.EndsWith("\\") == false)
                {
                    tGroupPath += "\\";
                }
    
                int tItemID = tSGWorld.ProjectTree.FindItem(tGroupPath);
                if (tItemID == 0)
                {
                    string tParentPath = tGroupPath.Substring(0, tGroupPath.LastIndexOf("\\"));
                    string tGroupName = tParentPath.Substring(tParentPath.LastIndexOf("\\") + 1);
                    int tItemIDParent = 0;
    
                    if (tParentPath.IndexOf("\\") < 0)
                    {
                        return tSGWorld.ProjectTree.CreateGroup(tParentPath, 0);
                    }
                    else
                    {
                        tParentPath = tGroupPath.Substring(0, tParentPath.LastIndexOf("\\"));
    
                        tItemIDParent = FindAndCreateGroup(tSGWorld, tParentPath);
                    }
    
                    tItemID = tSGWorld.ProjectTree.CreateGroup(tGroupName, tItemIDParent);
                }
    
                return tItemID;
            }


    2.在ProjectTree中找指定名称的图层的Layer

    返回ILayer61对象

    当从根节点找起,第二个参数为0,第三个参数为要找的图层名

            /// <summary>
            /// 在ProjectTree中找指定名称的图层的Layer
            /// </summary>
            /// <param name="tSGWorld"></param>
            /// <param name="tParentItemID"></param>
            /// <param name="tLayerName"></param>
            /// <returns></returns>
            public static ILayer61 FindLayerInProjectTree(ISGWorld61 tSGWorld, int tParentItemID, string tLayerName)
            {
                if (string.IsNullOrEmpty(tLayerName)) return null;
    
                int tItemID = tSGWorld.ProjectTree.GetNextItem(tParentItemID, ItemCode.CHILD);
                if (tItemID == 0) return null;
                while (tItemID != 0)
                {
                    if (tSGWorld.ProjectTree.IsGroup(tItemID) == true)
                    {
                        if (tSGWorld.ProjectTree.IsLayer(tItemID) == true)
                        {
                            if (tSGWorld.ProjectTree.GetItemName(tItemID) == tLayerName)
                            {
                                return tSGWorld.ProjectTree.GetLayer(tItemID);
                            }
                        }
    
                        ILayer61 tLayer = FindLayerInProjectTree(tSGWorld, tItemID, tLayerName);
                        if (tLayer != null)
                        {
                            return tLayer;
                        }
    
                    }
                    else
                    {
                        if (tSGWorld.ProjectTree.IsLayer(tItemID) == true)
                        {
                            if (tSGWorld.ProjectTree.GetItemName(tItemID) == tLayerName)
                            {
                                return tSGWorld.ProjectTree.GetLayer(tItemID);
                            }
                        }
                    }
                    tItemID = tSGWorld.ProjectTree.GetNextItem(tItemID, ItemCode.NEXT);
    
                }
    
                return null;
            }
  • 相关阅读:
    [BTS2004]一步一步学习BizTalk2004 CBR(contentbased routing)
    [BTS06]BizTalk2006 SDK阅读笔记(六) 定义流程
    [JS]收藏
    [BTS06]BizTalk2006 SDK阅读笔记(七) 管理与监控
    [C#]关于调用Office应用程序后,程序不退出的问题
    [JS]让表单提交返回后保持在原来提交的位置上
    [BTS][收藏]啥时候用BTS,啥时候用WF,就看这里。
    [BTS06]BizTalk2006 SDK阅读笔记(一) 角色
    [BTS]BizTalk学习之Functoid篇(Database Lookup)
    [LCS]半个月的成果,用RTCClient开发的Robot!
  • 原文地址:https://www.cnblogs.com/cannel/p/2608653.html
Copyright © 2011-2022 走看看