如果我理解正确,那么您需要通过Automation Steps 屏幕添加报告并将其与DeviceHub 关联。
示例是为 Invoices 编写的,当流程将在需要打印 Invoice 的情况下工作时,将使用这些设置:
public class CustomEntry : PXGraph<CustomEntry>
{
[PXQuickProcess.Step.IsBoundToAttribute(typeof(UsrPath.SO303000.Balanced.Report.PrintLabelReport), false)][PXQuickProcess.Step.RequiresStepsAttribute(typeof(SOQuickProcessParameters.prepareInvoice))]
[PXQuickProcess.Step.IsInsertedJustAfterAttribute(typeof(SOQuickProcessParameters.prepareInvoice))]
[PXQuickProcess.Step.IsApplicableAttribute(typeof(Where<Current<SOOrderType.behavior>, In3<SOOrderTypeConstants.salesOrder, SOOrderTypeConstants.invoiceOrder, SOOrderTypeConstants.creditMemo>, And<Current<SOOrderType.aRDocType>, NotEqual<ARDocType.noUpdate>>>))]
protected virtual void SOQuickProcessParameters_PrintInvoice_CacheAttached(PXCache sender)
{
}
}
public static class UsrPath
{
public static class SO303000
{
public static readonly Type GroupGraph = typeof(SOInvoiceEntry);
public static class Balanced
{
public const string GroupStepID = "Balanced";
public static class Report
{
public const string GroupActionID = "Report";
public class PrintLabelReport : PXQuickProcess.Step.IDefinition
{
public Type Graph
{
get
{
return UsrPath.SO303000.GroupGraph;
}
}
public string StepID
{
get
{
return "Balanced";
}
}
public string ActionID
{
get
{
return "Report";
}
}
public string MenuID
{
get
{
return "Print Label";
}
}
public string OnSuccessMessage
{
get
{
return "<Invoice form> is prepared";
}
}
public string OnFailureMessage
{
get
{
return "Preparing Invoice form";
}
}
}
}
}
}
}
更新答案
public PXAction<BAccount> PrintAddressLabel;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Print Label")]
protected virtual IEnumerable printAddressLabel(PXAdapter adapter)
{
List<BAccount> list = adapter.Get<BAccount>().ToList<BAccount>();
int? branchID = this.Base.Accessinfo.BranchID;
const string reportID = "YOUR_REPORT_ID";
Dictionary<string, string> dictionary = new Dictionary<string, string>();
Dictionary<string, PXReportRequiredException> dictionary2 = new Dictionary<string, PXReportRequiredException>();
PXReportRequiredException ex = null;
foreach (BAccount account in list)
{
dictionary["BAccountID"] = account.AcctCD;
ex = PXReportRequiredException.CombineReport(ex, null, dictionary);
object row = PXSelectorAttribute.Select<BAccount.bAccountID>(this.Base.BAccount.Cache, account);
string text = new NotificationUtility(this.Base).SearchReport(null, row, reportID, branchID);
//I think you get this problem due to absence of this line
PrintParameters printParams = new PrintParameters
{
PrintWithDeviceHub = true,
DefinePrinterManually = true,
PrinterName = "DYMOLABEL"
};
dictionary2 = SMPrintJobMaint.AssignPrintJobToPrinter(dictionary2, dictionary, printParams, new NotificationUtility(this.Base).SearchPrinter, null, reportID, reportID, this.Base.Accessinfo.BranchID);
}
if (ex != null)
{
SMPrintJobMaint.CreatePrintJobGroups(dictionary2);
throw ex;
}
return adapter.Get();
}
[Serializable]
[PXCacheName("Print Parameters")]
public partial class PrintParameters : IBqlTable, IPrintable
{
#region PrintWithDeviceHub
[PXDBBool]
[PXDefault(typeof(FeatureInstalled<FeaturesSet.deviceHub>))]
public virtual bool? PrintWithDeviceHub { get; set; }
public abstract class printWithDeviceHub : IBqlField { }
#endregion
#region DefinePrinterManually
[PXDBBool]
[PXDefault(true)]
public virtual bool? DefinePrinterManually { get; set; }
public abstract class definePrinterManually : IBqlField { }
#endregion
#region PrinterName
[PXPrinterSelector]
public virtual string PrinterName { get; set; }
public abstract class printerName : IBqlField { }
#endregion
}
Configuration of the Device Hub