具有未绑定列的 200 多个 SO 行项目的性能问题

Performance issue with 200+ SO line items with unbound columns

我为 SOLine DAC 添加了两个新的未绑定列,并在 RowSelected 处理程序中更新了它们。但是,当订单项数量较多时,速度很慢。

这是未绑定列的代码-

[System.Serializable]
public class SOLineExtension : PXCacheExtension<SOLine>
{
 #region UsrQtyAllocated
 public abstract class usrQtyAllocated : IBqlField { }
 protected decimal? _UsrQtyAllocated;
 [PXUIField(DisplayName = "Qty. Allocated")]
 public virtual decimal? UsrQtyAllocated { get; set; }
 #endregion

 #region UsrItemClass
 public abstract class usrItemClass : IBqlField { }
 protected string _UsrItemClass;
 [PXUIField(DisplayName = "Item Class")]
 public virtual string UsrItemClass { get; set; }
 #endregion
}

这是 RowSelected 处理程序的代码片段-

protected void SOLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
 SOLine row = (SOLine)e.Row;
 if (row == null) return;

 PXUIFieldAttribute.SetEnabled<SOLineExtension.usrQtyAllocated>(sender, row, false);
 PXUIFieldAttribute.SetEnabled<SOLineExtension.usrItemClass>(sender, row, false);

 INItemClass defItemClass = PXSelectJoin<INItemClass,
  InnerJoin<InventoryItem,
  On<InventoryItem.itemClassID, Equal<INItemClass.itemClassID>>>,
  Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, row.InventoryID);

 if (defItemClass != null)
 {
  sender.SetValue<SOLineExtension.usrItemClass>(row, defItemClass.Descr);
 }

 SOLineSplit defSOLine = PXSelectJoin<SOLineSplit,
  InnerJoin<SOLine,
  On<SOLine.orderType, Equal<SOLineSplit.orderType>,
   And<SOLine.orderNbr, Equal<SOLineSplit.orderNbr>,
   And<SOLine.inventoryID, Equal<SOLineSplit.inventoryID>>>>>,
  Where<SOLineSplit.isAllocated, Equal<Required<SOLineSplit.isAllocated>>,
   And<SOLineSplit.orderNbr, Equal<Required<SOLineSplit.orderNbr>>,
   And<SOLineSplit.inventoryID, Equal<Required<SOLineSplit.inventoryID>>>>>>.Select(Base, 1, row.OrderNbr, row.InventoryID);

 if (defSOLine != null)
 {
  sender.SetValue<SOLineExtension.usrQtyAllocated>(row, defSOLine.Qty);
 }
}

永远不要使用 RowSelected 处理程序为未绑定的 DAC 字段设置值:RowSelected 事件旨在仅执行 UI 表示逻辑。相反,始终建议使用 RowSelecting 处理程序将值分配给未绑定的字段,如 API 参考和步骤 5.2:为 T300 class 文档中的销售订单自定义业务逻辑所示。

另请参考:none 您的自定义字段使用 PXTypeAttribute 修饰,这始终是必须的。