2017-03-03 28 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

相關問題