问题描述
我创建了一个自定义报告,该报告具有一个求职信,该求职信是在报告标题中调用的子报告,在报告页脚中调用的摘要报告。在操作菜单中调用该命令以打印单个报告时,此方法很好用。
我设计了类似于销售订单打印/电子邮件处理的处理屏幕,并且在打印多个文档时,求职信仅打印一次,所有选定文档的主报告打印,最后一个文档的摘要报告打印。
public PXAction<SOOrder> printreport;
[PXUIField(displayName = "Print Production Report",MapEnableRights = PXCacheRights.Select)]
[PXButton(SpecialType = PXSpecialButtonType.ReportsFolder)]
protected virtual IEnumerable PrintReport(PXAdapter adapter)
{
List<SOOrder> list = adapter.Get<SOOrder>().ToList();
if (list.Count > 0)
{
string reportID = "PS642000";
Base.Save.Press();
Dictionary<string,string> parameters = new Dictionary<string,string>();
string actualReportID = null;
PXReportrequiredException ex = null;
Dictionary<PX.SM.PrintSettings,PXReportrequiredException> reportsToPrint = new Dictionary<PX.SM.PrintSettings,PXReportrequiredException>();
foreach (SOOrder order in list)
{
PSSOOrderExtNV extNV = Base.Document.Cache.GetExtension<PSSOOrderExtNV>(order);
if (extNV.UsrIsScreenPrint != true)
continue;
parameters = new Dictionary<string,string>();
parameters["SOOrder.OrderType"] = order.OrderType;
parameters["SOOrder.OrderNbr"] = order.OrderNbr;
object cstmr = PXSelectorAttribute.Select<SOOrder.customerID>(Base.Document.Cache,order);
actualReportID = new NotificationUtility(Base).SearchReport(SONotificationSource.Customer,cstmr,reportID,order.BranchID);
ex = PXReportrequiredException.CombineReport(ex,actualReportID,parameters);
reportsToPrint = PX.SM.SMPrintJobMaint.AssignPrintJobToPrinter(reportsToPrint,parameters,adapter,new NotificationUtility(Base).SearchPrinter,SONotificationSource.Customer,order.BranchID);
}
if (ex != null)
{
PX.SM.SMPrintJobMaint.CreatePrintJobGroups(reportsToPrint);
throw ex;
}
}
如何解决此问题?
解决方法
我已经尝试过并且没有工作。现在,我删除了子报告,并按顺序单独执行以归档所需的结果。
public PXAction<SOOrder> screenprintreport;
[PXUIField(DisplayName = "Screen Print Production Report",MapEnableRights = PXCacheRights.Select)]
[PXButton(SpecialType = PXSpecialButtonType.ReportsFolder)]
protected virtual IEnumerable screenPrintReport(PXAdapter adapter)
{
List<SOOrder> list = adapter.Get<SOOrder>().ToList();
if (list.Count > 0)
{
string creportID = "SO641010";
string reportID = "PS642000";
Base.Save.Press();
Dictionary<string,string> parameters = new Dictionary<string,string>();
string actualReportID = null;
PXReportRequiredException ex = null;
Dictionary<PX.SM.PrintSettings,PXReportRequiredException> reportsToPrint = new Dictionary<PX.SM.PrintSettings,PXReportRequiredException>();
foreach (SOOrder order in list)
{
PSSOOrderExtNV extNV = Base.Document.Cache.GetExtension<PSSOOrderExtNV>(order);
if (extNV.UsrIsScreenPrint != true)
continue;
parameters = new Dictionary<string,string>();
parameters["SOOrder.OrderType"] = order.OrderType;
parameters["SOOrder.OrderNbr"] = order.OrderNbr;
object cstmr = PXSelectorAttribute.Select<SOOrder.customerID>(Base.Document.Cache,order);
actualReportID = new NotificationUtility(Base).SearchReport(SONotificationSource.Customer,cstmr,creportID,order.BranchID);
ex = PXReportRequiredException.CombineReport(ex,actualReportID,parameters);
reportsToPrint = PX.SM.SMPrintJobMaint.AssignPrintJobToPrinter(reportsToPrint,parameters,adapter,new NotificationUtility(Base).SearchPrinter,SONotificationSource.Customer,order.BranchID);
actualReportID = null;
actualReportID = new NotificationUtility(Base).SearchReport(SONotificationSource.Customer,reportID,order.BranchID);
}
if (ex != null)
{
PX.SM.SMPrintJobMaint.CreatePrintJobGroups(reportsToPrint);
throw ex;
}
}
}