Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 打印机无法从DeviceHub接收作业_C#_Acumatica - Fatal编程技术网

C# 打印机无法从DeviceHub接收作业

C# 打印机无法从DeviceHub接收作业,c#,acumatica,C#,Acumatica,我在这个问题中描述了确切的情况: 由于这个问题既没有被接受的答案,也没有被接受的答案,我再次提出这个问题 我已使用Acumatica配置DeviceHub,并显示了我的打印机。我正在通过PXAction发送打印作业。在执行操作时,DeviceHub记录作业的成功接收,但打印机队列从未接收到它 这是我的代码,因为这是StackOverflow: public PXAction<PX.Objects.CR.BAccount> PrintAddressLabel; [PXButton(C

我在这个问题中描述了确切的情况:

由于这个问题既没有被接受的答案,也没有被接受的答案,我再次提出这个问题

我已使用Acumatica配置DeviceHub,并显示了我的打印机。我正在通过PXAction发送打印作业。在执行操作时,DeviceHub记录作业的成功接收,但打印机队列从未接收到它

这是我的代码,因为这是StackOverflow:

public PXAction<PX.Objects.CR.BAccount> PrintAddressLabel;

[PXButton(CommitChanges=true)]
[PXUIField(DisplayName = "Print Label")]
protected void printAddressLabel()
{
  BAccount baccount = Base.Caches[typeof(BAccount)].Current as BAccount;
  string bAccountID = baccount.BAccountID.ToString();

  Dictionary<string, string> parameters = new Dictionary<string, string>();
  parameters["BAccountID"] = bAccountID;

  PXReportRequiredException ex = null;
  ex = PXReportRequiredException.CombineReport(ex, "ZRCRADDR", parameters);
  SMPrintJobMaint.CreatePrintJobGroup("DYMOLABEL", ex, "Address Label");
}
公共PXAction打印地址标签;
[PXButton(CommitChanges=true)]
[PXUIField(DisplayName=“打印标签”)]
受保护的无效printAddressLabel()
{
BAccount BAccount=Base.Caches[typeof(BAccount)]。当前为BAccount;
字符串bAccountID=baccount.bAccountID.ToString();
字典参数=新字典();
参数[“BAccountID”]=BAccountID;
PXReportRequiredException ex=null;
ex=PXReportRequiredException.CombineReport(例如,“ZRCRADDR”,参数);
SMPrintJobMaint.CreatePrintJobGroup(“DYMOLABEL”,例如,“地址标签”);
}
有人能给我指出一个有用的方向吗

编辑:

经过进一步测试,我发现如下情况:

Acumatica将使用内置打印过程成功打印到我的DeviceHub打印机。但是,当打印其中一个作业时,DeviceHub日志会显示一个
POLL
事件。当尝试从我的代码打印时,DeviceHub会记录一个
NT
事件,该事件永远不会进入打印机队列

经过进一步测试,2019 R1中的日志略有变化。从Acumatica打印发票也会导致
NT
事件。然而,有一行不同于Acumatica中创建的作业和代码中创建的作业

绿色=来自Acumatica的作业

橙色=来自代码的作业


从code发送的作业中缺少将PDF打印到\\*打印机*的行
打印机DYMOLABEL-如果我理解正确,则您需要通过
自动化步骤
屏幕添加报告,并将其与
设备集线器
关联
示例是为发票编写的,当流程在需要打印发票的情况下工作时,将使用以下设置:

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";
                    }
                }
            }
        }
     }
  }
}  
公共类CustomEntry:PXGraph
{
[PXQuickProcess.Step.IsBoundToAttribute(typeof(UsrPath.SO303000.Balanced.Report.PrintLabelReport),false)][PXQuickProcess.Step.RequirestepsAttribute(typeof(SOQuickProcessParameters.prepareInvoice))]
[PXQuickProcess.Step.IsInsertedJustAfterAttribute(typeof(SOQuickProcessParameters.prepareInvoice))]

[PXQuickProcess.Step.IsApplicableAttribute(typeof(Where我犹豫是否将此作为答案发布,因为代码与Vardan发布的代码非常相似。但该代码对我不起作用,而该代码对我起作用。它实际上来自他引用的同一链接,但它来自最末端链接的源代码,该源代码是由于我对其帖子的评论而添加的。我修改了代码的内容。)因为我不需要它来做他所做的一切

希望它能帮助其他人

自定义类

[System.SerializableAttribute]
public partial class PrintParameters : IBqlTable, PX.SM.IPrintable
{
  #region PrintWithDeviceHub
  public abstract class printWithDeviceHub : IBqlField { }

  [PXDBBool]
  [PXDefault(typeof(FeatureInstalled<FeaturesSet.deviceHub>))]
  [PXUIField(DisplayName = "Print with DeviceHub")]
  public virtual bool? PrintWithDeviceHub { get; set; }
  #endregion

  #region DefinePrinterManually
  public abstract class definePrinterManually : IBqlField { }

  [PXDBBool]
  [PXDefault(true)]
  [PXUIField(DisplayName = "Define Printer Manually")]
  public virtual bool? DefinePrinterManually { get; set; }
  #endregion

  #region Printer
  public abstract class printerName : PX.Data.IBqlField { }

  [PX.SM.PXPrinterSelector]
  public virtual string PrinterName { get; set; }
  #endregion
}

public class CsPrintMaint : PXGraph<CsPrintMaint>
{
  public void PrintReportInDeviceHub(string reportID, Dictionary<string, string> parametersDictionary, string printerName, int? branchID)
  {
    Dictionary<string, PXReportRequiredException> reportsToPrint = new Dictionary<string, PXReportRequiredException>();
    PrintParameters filter = new PrintParameters();
    filter.PrintWithDeviceHub = true;
    filter.DefinePrinterManually = true;
    filter.PrinterName = printerName;

    reportsToPrint = PX.SM.SMPrintJobMaint.AssignPrintJobToPrinter(reportsToPrint, parametersDictionary, filter, 
           new NotificationUtility(this).SearchPrinter, CRNotificationSource.BAccount, reportID, reportID, branchID);

    if (reportsToPrint != null)
    {
      PX.SM.SMPrintJobMaint.CreatePrintJobGroups(reportsToPrint);
    }
  }
}
[System.SerializableAttribute]
公共部分类打印参数:IBqlTable,PX.SM.IPrintable
{
#使用DeviceHub打印区域
公共抽象类printWithDeviceHub:IBqlField{}
[PXDBBool]
[PXDefault(typeof(FeatureInstalled))]
[PXUIField(DisplayName=“使用DeviceHub打印”)]
公共虚拟bool?PrintWithDeviceHub{get;set;}
#端区
#地区间
公共抽象类手动定义:IBqlField{}
[PXDBBool]
[默认值(真)]
[PXUIField(DisplayName=“手动定义打印机”)]
公共虚拟布尔?手动定义{get;set;}
#端区
#区域打印机
公共抽象类printerName:PX.Data.IBqlField{}
[PX.SM.PXPrinterSelector]
公共虚拟字符串PrinterName{get;set;}
#端区
}
公共类CsPrintMaint:PXGraph
{
public void PrintReportInDeviceHub(字符串reportID、字典参数Dictionary、字符串printerName、int?branchID)
{
Dictionary reportsToPrint=新字典();
PrintParameters过滤器=新的PrintParameters();
filter.PrintWithDeviceHub=true;
filter.defineIntermanually=true;
filter.PrinterName=PrinterName;
ReportStopPrint=PX.SM.SMPrintJobMaint.AssignPrintJobToPrinter(ReportStopPrint,参数字典,过滤器,
新的NotificationUtility(this).SearchPrinter,CRNotificationSource.BAccount,reportID,reportID,branchID);
if(reportsToPrint!=null)
{
PX.SM.SMPrintJobMaint.CreatePrintJobGroups(ReportStopPrint);
}
}
}
BusinessAccountMaint扩展名:

public class BusinessAccountMaint_Extension : PXGraphExtension<BusinessAccountMaint>
{
  public PXAction<BAccount> printAddressLabelNH;
  [PXButton(CommitChanges = true)]
  [PXUIField(DisplayName = "Print Label (NH)")]
  public virtual IEnumerable PrintAddressLabelNH(PXAdapter adapter)
  {
    int? branchID = this.Base.Accessinfo.BranchID;
    Dictionary<string, string> parametersDictionary = new Dictionary<string, string>();
    BAccount bAccount = this.Base.Caches[typeof(BAccount)].Current as BAccount;
    parametersDictionary["BAccount.BAccountID"] = bAccount.BAccountID.ToString();

    CsPrintMaint printMaintGraph = PXGraph.CreateInstance<CsPrintMaint>();

    printMaintGraph.PrintReportInDeviceHub("ZRADDRBA", parametersDictionary, "DYMOLBLNH", branchID);

    return adapter.Get();
  }
}
公共类BusinessAccountMaint_扩展:pxGrapherExtension
{
公共行动打印地址labelnh;
[PXButton(CommitChanges=true)]
[PXUIField(DisplayName=“打印标签(NH)”)]
公共虚拟IEnumerable PrintAddressLabelNH(PXAdapter适配器)
{
int?branchID=this.Base.Accessinfo.branchID;
字典参数Dictionary=新字典();
BAccount BAccount=this.Base.Caches[typeof(BAccount)]。当前为BAccount;
参数dictionary[“BAccount.BAccountID”]=BAccount.BAccountID.ToString();
CsPrintMaint printMaintGraph=PXGraph.CreateInstance();
printMaintGraph.PrintReportInDeviceHub(“Zradrba”,参数字典,“DYMOLBLNH”,branchID);
返回适配器Get();
}
}

有任何澄清的评论吗?这与DeviceHub有什么关系,或者我该如何“将其与DeviceHub关联”?这看起来更像我所期望的!不过我有点困惑。有好几次你都将
“Zrcradr”
reportID
传递给了一个方法。
“Zrcradr”
是我的报告。您是在这种假设下操作的,还是您认为那是我的打印机?在我的代码中,
中的“DYMOLABEL”
是我的打印机。使用此字符串值Acumatica创建主图形
public class BusinessAccountMaint_Extension : PXGraphExtension<BusinessAccountMaint>
{
  public PXAction<BAccount> printAddressLabelNH;
  [PXButton(CommitChanges = true)]
  [PXUIField(DisplayName = "Print Label (NH)")]
  public virtual IEnumerable PrintAddressLabelNH(PXAdapter adapter)
  {
    int? branchID = this.Base.Accessinfo.BranchID;
    Dictionary<string, string> parametersDictionary = new Dictionary<string, string>();
    BAccount bAccount = this.Base.Caches[typeof(BAccount)].Current as BAccount;
    parametersDictionary["BAccount.BAccountID"] = bAccount.BAccountID.ToString();

    CsPrintMaint printMaintGraph = PXGraph.CreateInstance<CsPrintMaint>();

    printMaintGraph.PrintReportInDeviceHub("ZRADDRBA", parametersDictionary, "DYMOLBLNH", branchID);

    return adapter.Get();
  }
}