How do I specify process specific message for PXLongOperation
– replacing default Executing?
It is possible to customize processing message of PXLongOperation
. We can replace default Executing.
Below example describes the approach :
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();
}
}
}