2017-03-03 63 views
0

我有一个由屏幕上的按钮激活的进程 - 但我想知道如何使它像一个进程按钮一样工作,其中纺轮发生,绿色复选框出现在最后。我有下面的代码,我已经包裹在一个PXLongOperation.StartOperation(...)如下(PXLongOperation这里注释掉,因为它似乎没有被做任何事情):在自定义按钮动作中出现处理图标

public PXAction<APInvoice> CreatePOBillings; 
    // [PXButton(CommitChanges = true)] 
    [PXProcessButton] 
    [PXUIField(DisplayName = "Create PO Billings", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)] 
    protected void createPOBillings() 
    { 
     int i = 0; 
     try 
     { 
      //This wraps the whole process into a 'PXLongOperation' function that will create the spinning 'busy' wheel at the top toolbar... 
      //PXLongOperation.StartOperation(this, delegate() 
      //{ 

       var apinvoice = (APInvoice)Base.Document.Current; 
       if (apinvoice == null) return; 

       string RefNbr = apinvoice.RefNbr; 

       //Run the stored procedure which will get the records to create the Project Transactions. This will populate the table 'xCreatePOBilings': 
       var pars = new PXSPParameter[] { new PXSPInParameter("@p_RefNbr", RefNbr) }; //, new PXSPOutParameter("p2", outp2) }; 
       var results = PXDatabase.Execute("xspMarketingPOBilling", pars); 

       //Get the dataset from the xCreatePOBillings table which was populated from the stored procedure above: 
       PXResultset<xCreatePOBillings> res = PXSelect<xCreatePOBillings, 
                Where<xCreatePOBillings.ponbr, Equal<Required<xCreatePOBillings.ponbr>>> 
                ,OrderBy<Asc<xCreatePOBillings.ponbr 
                  ,Asc<xCreatePOBillings.destProject 
                  ,Asc<xCreatePOBillings.startDate>>>>>.Select(Base, RefNbr); 

       //Create the graph for the Project Transactions screen: 
       RegisterEntry graph = PXGraph.CreateInstance<RegisterEntry>(); 

       //Create a new cache object for the header of Project Transactions: 
       PMRegister pmreg = new PMRegister(); 
       pmreg.Module = "PM"; 
       graph.Document.Insert(pmreg); 

       //Define the cache for the Project Transactions screen's grid records: 
       PMTran pmtrn; 

       foreach (PXResult<xCreatePOBillings> rec in res) 
       { 
        .... 

        graph.Actions.PressSave(); 
      //}); 

如果可能,实现这一目标的最佳方法是什么?

回答

1

当静态PXLongOperation.StartOperation方法在BLC扩展类中调用,因为第一个参数只能接受Base属性,而不是this关键字:

PXLongOperation.StartOperation(Base, delegate() 
{ 
    ... 
} 
+0

这是它!再次感谢,鲁斯兰! – pmfith

+0

总是乐意帮助,彼得! – RuslanDev