2017-09-14 46 views
0

我試圖模擬打印聲明頁面(AR503500)的行爲,根據所選客戶,其相應的客戶聲明報告(AR641500)被打印在一個連續的報告/ PDF。打印同一報告的多次迭代

回顧邏輯從圖形ARStatementPrint.cs我可以看到這個在PrintStatements正在處理代表,其中在DetailsResult列表中的迭代打印報表

的關鍵似乎是CombineReport該迭代中執行方法:

 foreach (DetailsResult t in list) 
     { 
      if (markOnly) 
      { 
       if (filter.ShowAll != true) 
        foreach (ARStatement doc in docview.SelectMulti(filter.StatementCycleId, filter.StatementDate, t.CustomerID, t.CuryID)) 
        { 
         if (arsetup?.ConsolidatedStatement != true && doc.BranchID != filter.BranchID) 
          continue; 

         doc.DontPrint = true; 
         docview.Cache.Update(doc); 
        } 
      } 
      else 
      { 

       Dictionary<string, string> d = new Dictionary<string, string>(); 

       d[ARStatementReportParams.Parameters.BranchID] = filter.BranchCD;     
       d[ARStatementReportParams.Fields.StatementCycleID] = filter.StatementCycleId; 
       d[ARStatementReportParams.Fields.StatementDate] = filter.StatementDate.Value.ToString("d", CultureInfo.InvariantCulture); 
       d[ARStatementReportParams.Fields.CustomerID] = t.CustomerID.ToString(); 

       if (filter.ShowAll == true) 
       { 
        d[ARStatementReportParams.Parameters.IgnorePrintFlags] = ARStatementReportParams.BoolValues.True; 
       } 
       else 
       { 
        d[ARStatementReportParams.Fields.PrintStatements] = ARStatementReportParams.BoolValues.True; 
       } 
       if (filter.CuryStatements ?? false) 
        d[ARStatementReportParams.Fields.CuryID] = t.CuryID; 

       foreach (ARStatement doc in docview.SelectMulti(filter.StatementCycleId, filter.StatementDate, t.CustomerID, t.CuryID)) 
       { 
        if (arsetup?.ConsolidatedStatement != true && doc.BranchID != filter.BranchID) 
         continue; 

        if (doc.Printed != true) 
        { 
         doc.Printed = true; 
         docview.Cache.Update(doc); 
        } 
       } 

       ex = PXReportRequiredException.CombineReport(ex, GetCustomerReportID(graph, reportID, t), d); 
      } 
     } 

     graph.Actions.PressSave(); 
     if(ex != null) throw ex; 

在我自己的曲線圖中,我創建了一個第一沒有迭代發生並且發出單個報告打印請求的動作

protected virtual IEnumerable AnotherReport(PXAdapter adapter) 
    { 

      Dictionary<string, string> parameters = new Dictionary<string, string>(); 

      parameters["CustomerID"] = "001208"; 

      parameters["BranchID"] = "BRANCH1"; 
      parameters["DateFrom"] = "01-01-2017"; 
      parameters["DateTo"] = "12-12-2017"; 


      throw new PXReportRequiredException(parameters, "TR101000", "ReportTest");     
    } 

在這種情況下,結果是正確的。然後我用以下方法實施CombineReport方法

 protected virtual IEnumerable Report(PXAdapter adapter) 
    { 
     PXReportRequiredException ex = null; 
     foreach (Customer doc in adapter.Get<Customer>()) 
     { 
      var parameters = new Dictionary<string, string>(); 

      parameters["CustomerID"] = doc.AcctCD; 

      parameters["BranchID"] = "BRANCH1"; 
      parameters["DateFrom"] = "01-01-2017"; 
      parameters["DateTo"] = "12-12-2017"; 

      ex = PXReportRequiredException.CombineReport(ex, "TR101000", parameters); 
     } 

     this.Save.Press(); 
     if (ex != null) throw ex; 

     return adapter.Get(); 
    } 

但是結果只打印來自一個客戶的信息。

ARPrintInvoices圖表也被用作參考,但在ardocumentlist代表可用的信息和GetBQLStatement方法似乎不打印任何報告,也不能使用CombineReport方法。

有關如何解決這個問題的任何建議? 謝謝!

+0

MergeLast PARAM如果沒有被指定。嘗試在最後一次迭代中傳遞'false'。 (例如:「ex = PXReportRequiredException.CombineReport(ex,」TR101000「,parameters,!isLastIteration);」) – cbetabeta

回答

1

CombineReport方法上的MergeLast參數默認爲true,如果未指定。嘗試在最後一次迭代中傳遞'false'。下面

ex = PXReportRequiredException.CombineReport(ex, "TR101000", parameters, !isLastIteration); 

見段:上CombineReport方法默認爲true

namespace PX.Objects.AR 
{ 
    public class ARInvoiceEntry_Extension:PXGraphExtension<ARInvoiceEntry> 
    { 
    #region Event Handlers 
    public PXAction<PX.Objects.AR.ARInvoice> Test; 

    [PXButton(CommitChanges = true)] 
    [PXUIField(DisplayName = "Test")] 
    protected void test() 
    { 
     PXReportRequiredException ex = null; 
     var row = Base.Document.Current; 

     if(row.RefNbr != null) 
     { 
      Dictionary<string, string> dictionary = new Dictionary<string, string>(); 
      dictionary["DocType"] = row.DocType; 
      dictionary["RefNbr"] = row.RefNbr; 

      ex = PXReportRequiredException.CombineReport(ex, "AR610500", dictionary); 
     } 
     if (row.RefNbr != null) 
     { 

      Dictionary<string, string> dictionary = new Dictionary<string, string>(); 
      dictionary["DocType"] = row.DocType; 
      dictionary["RefNbr"] = row.RefNbr; 

      ex = PXReportRequiredException.CombineReport(ex, "AR610500", dictionary,false); 
     } 

     if (ex != null) 
     { 
      ex.Mode = PXBaseRedirectException.WindowMode.New; 
      ex.SeparateWindows = false; 
      throw ex; 
     } 
    } 
    #endregion 
    } 
}