我正在尝试模拟打印报表页面(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 :(得分:1)
如果未指定,CombineReport方法上的MergeLast参数默认为true。尝试在最后一次迭代中传递'false'。
ex = PXReportRequiredException.CombineReport(ex, "TR101000", parameters, !isLastIteration);
请参阅下面的代码段:
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
}
}