如何为
PXLongOperation
指定流程特定消息 – 替换默认的执行?
可以自定义
PXLongOperation
的处理消息。我们可以替换默认的Executing。
下面的示例描述了该方法:
using System;
using System.Collections;
using System.Threading;
using System.Web;
using System.Web.UI;
using PX.Data;
using PX.Objects.SO;
using PX.Web.UI;
namespace SOOrderEntryPXDemo
{
public class SOOrderEntryPXDemo : PXGraphExtension<SOOrderEntry>
{
public static bool IsActive() => true;
public override void Initialize()
{
Page page = HttpContext.Current?.Handler as PXPage;
if (page != null)
{
page.Load += Page_Load;
}
}
private void Page_Load(object sender, EventArgs e)
{
Page page = (Page)sender;
PXDataSource ds = (PXDataSource)ControlHelper.FindControl("ds", page);
if (ds != null)
{
ds.LongRunStatus += (object senderds, PXDataSourceLongRunStatusEventArgs eds) =>
{
bool? bIsCustomMsg = (bool?)PXLongOperation.GetCustomInfo(((PXDataSource)senderds).DataGraph.UID, "SpecialMessageRequired");
if (eds.LongRunMessage == "Executing" && (bIsCustomMsg == true))
{
eds.LongRunMessage = "Analyzing Order. Please wait";
}
};
}
}
public PXAction<SOOrder> DemoAction;
[PXButton(CommitChanges = true),
PXUIField(DisplayName = "Demo Action", MapEnableRights = PXCacheRights.Select)]
protected virtual IEnumerable ApplyAssignmentRules(PXAdapter adapter)
{
PXLongOperation.StartOperation(Base, delegate ()
{
PXLongOperation.SetCustomInfo(true, "SpecialMessageRequired");
Thread.Sleep(15000);
});
return adapter.Get();
}
}
}