csharp [ArasLabs / override-default-structure-browser]显示零件,文档和CAD的分类属性

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp [ArasLabs / override-default-structure-browser]显示零件,文档和CAD的分类属性相关的知识,希望对你有一定的参考价值。

XmlElement inItem = (XmlElement)this.dom.SelectSingleNode("//Item[@type='Method' and @action='GetItemsForStructureBrowser']/Item");

if (inItem != null)
{
    XmlDocument resDOM = Aras.Server.Core.XmlProxy.CreateNewXMLDocument();
    XmlElement result = Aras.Server.Core.XmlProxy.MakeBorders(resDOM);
    
    // Comment out call to standard structure browser
    // Aras.Server.Core.StructureBrowser sb = new Aras.Server.Core.StructureBrowser(ref CCO);
    
    // Call for custom browser
    CustomStructureBrowser sb = new CustomStructureBrowser(CCO);
    
    // HashSet defined below, add properties for ItemTypes specified.
    foreach (string specifiedType in SpecifiedItemTypes) 
    {
        sb.itemPropertiesToSelect.Add(specifiedType, new string[] {"classification" });
    }
    
    int levelsToSelect;
    if (!Int32.TryParse(inItem.GetAttribute("levels"), out levelsToSelect))
        levelsToSelect = 2;
        
    result.InnerXml = sb.GetItemsForStructureBrowser(inItem.GetAttribute("type"),
        inItem.GetAttribute("id"),
        inItem.GetAttribute("compareToITName"),
        inItem.GetAttribute("compareToId"),
        levelsToSelect
    );
    
    Aras.IOM.Item resItem = this.newItem("");
    resItem.loadAML(resDOM.OuterXml);
    return resItem;
}
else
    return null;

// StructureBrowser class can be overriden.
// Methods available for overriding: GetKeyedNameForItem, CompareItems.
}

public HashSet<string> SpecifiedItemTypes = new HashSet<string>
{
      "Part",
      "Document",
      "CAD"
};

class CustomStructureBrowser : Aras.Server.Core.StructureBrowser
{
    public CustomStructureBrowser(Aras.Server.Core.CallContext CCO) : base(ref CCO){}
    
    public override Aras.Server.Core.StructureItem GetNewStructureItem(string itemTypeName, Aras.Server.Core.InnovatorDataSet rs)
    {
        // Call to get our custom StructureItem
        return new CustomStructureItem(rs); 
    }
 }
 
class CustomStructureItem : Aras.Server.Core.StructureItem
{
    private string _classification;
    
    public CustomStructureItem(Aras.Server.Core.InnovatorDataSet rs) : base(rs)
    {
        try
        {
        	_classification = rs["classification", ""].ToString(); // property added by above
        }
        catch {} // property not returned for this ItemType
    }
    
    public override string KeyedName
    {
        get
        {
            string kn = base.KeyedName;
            if (String.IsNullOrEmpty(this._classification))
            {
                // If property is empty - return KeyedName as is. (standard look)
                return kn;
            }
            else
            {
                return kn + " Class: " + this._classification;
            }
        }
    }

// NOTE: Do not close the last curly brace. 
// This is taken care of in the template that runs C# server methods

以上是关于csharp [ArasLabs / override-default-structure-browser]显示零件,文档和CAD的分类属性的主要内容,如果未能解决你的问题,请参考以下文章

css [ArasLabs / custom-form-css]定义字段集的样式

css [ArasLabs / custom-form-css]导入表单的自定义CSS文件

html [ArasLabs / custom-form-css]显示custom_icon表单字段的内容

html [ArasLabs / custom-form-css] item_info字段的自定义内容

css [ArasLabs / custom-form-css]用于自定义item_info字段内容的CSS

css 来自myStyles.css的[ArasLabs / custom-form-css]片段,显示应用于myIcon的样式