csharp [ArasLabs / override-default-structure-browser]将分类属性添加到与上下文项相同类型的项中

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp [ArasLabs / override-default-structure-browser]将分类属性添加到与上下文项相同类型的项中相关的知识,希望对你有一定的参考价值。

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);
    
    //Add property for getting Class
    sb.itemPropertiesToSelect.Add(inItem.GetAttribute("type"), 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.
}

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)
    {
        return new CustomStructureItem(rs); //Call to get our custom StructureItem
    }
}

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]将分类属性添加到与上下文项相同类型的项中的主要内容,如果未能解决你的问题,请参考以下文章

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的样式