csharp 演示如何自定义ItemInfo架构元素内容的示例代码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 演示如何自定义ItemInfo架构元素内容的示例代码相关的知识,希望对你有一定的参考价值。

//MethodTemplateName=CSharp:Aras.TDF.ContentGenerator(Strict);
ItemDocumentElement targetItem = targetElement as ItemDocumentElement;
if (targetItem != null) {
	targetItem.ClearChilds();
	
	targetItem.AddChild(this.Factory.NewText("Title", targetItem.GetItemProperty("name", " ")));
	targetItem.AddChild(this.Factory.NewText("Text", targetItem.GetItemProperty("description", " ")));
	
	string cost = targetItem.GetItemProperty("cost", " ");
	if (cost != " ")
	{
	    targetItem.AddChild(this.Factory.NewText("Text", cost));
    }
    
    string version = targetItem.GetItemProperty("major_rev", " ") + "." + targetItem.GetItemProperty("generation", " ");
    string state = targetItem.GetItemProperty("state", " ");
	string createdDt = targetItem.GetItemProperty("created_on", " ");
	
	if (createdDt != " ") 
	{
	    DateTime dt = DateTime.ParseExact(createdDt, "yyyy-MM-ddTHH:mm:ss", null); 
	    createdDt = dt.ToString("MMM dd yyyy");
	}
	
	targetItem.AddChild(this.Factory.NewText("Text", version + "  |  " + state + "  |  " + createdDt));
	
	Item components = this.Factory.InnovatorInstance.newItem("Part BOM","get");
    components.setAction("get");
    components.setAttribute("where","Part_BOM.source_id='" + targetItem.ItemId + "'");
    components = components.apply();
	// if referenced item was set, then
	if (!components.isError())
	{
		TableDocumentElement tableElement = (TableDocumentElement) this.Factory.NewTable("Table", (components.getItemCount() + 2), 5);
		tableElement.GetCell(0, 0).AddChild(this.Factory.NewText("Title", "Components List"));
		for (int i = 0; i < tableElement.CellCount; i++)
		{
			tableElement.MergeCells(0, i, MergeDirection.Right);
		}
		tableElement.GetCell(1, 0).AddChild(this.Factory.NewText("Title", "Sort"));
		tableElement.GetCell(1, 1).AddChild(this.Factory.NewText("Title", "Number"));
		tableElement.GetCell(1, 2).AddChild(this.Factory.NewText("Title", "Name"));
		tableElement.GetCell(1, 3).AddChild(this.Factory.NewText("Title", "Qty"));
		tableElement.GetCell(1, 4).AddChild(this.Factory.NewText("Title", "Unit"));
        for (int i = 0; i < components.getItemCount(); i++) 
        {
            Item c = components.getItemByIndex(i);
            Item p = c.getItemsByXPath("related_id/Item");
            int r = i + 2;
    		tableElement.GetCell(r, 0).AddChild(this.Factory.NewText("Text", c.getProperty("sort_order", " ")));
    		tableElement.GetCell(r, 1).AddChild(this.Factory.NewText("Text", p.getProperty("item_number")));
    		tableElement.GetCell(r, 2).AddChild(this.Factory.NewText("Text", p.getProperty("name")));
    		tableElement.GetCell(r, 3).AddChild(this.Factory.NewText("Text", c.getProperty("quantity", " ")));
    		tableElement.GetCell(r, 4).AddChild(this.Factory.NewText("Text", p.getProperty("unit")));
        }
		targetItem.AddChild(tableElement);
	}
	
}

以上是关于csharp 演示如何自定义ItemInfo架构元素内容的示例代码的主要内容,如果未能解决你的问题,请参考以下文章

一起卷吧,arduino/mixly语音识别模块,10元,可以自定义,提供自制的mixly库

在 WooCommerce 订单和电子邮件中保存并显示产品自定义元数据

使用冰山表格式将自定义元数据添加到 DataFrame 模式

如何在 Yammer 组上添加自定义托管元数据

csharp 示例Topshelf服务,演示如何使用Fooidity Switchyard切换功能

php [约会] - 其他自定义字段演示。有关如何在Appointments Lite中添加自定义字段的指南