Acumatica 自定义 PXLongOperation 的处理消息(正在执行。按取消中止)

问题描述 投票:0回答:1

如何为

PXLongOperation
指定流程特定消息 – 替换默认的执行

acumatica acumatica-kb
1个回答
0
投票

可以自定义

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();
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.