简体   繁体   English

在Navision上通过作业队列运行codeunit时出错

[英]Error while running codeunit through job queue on Navision

I have an Error while running a Codeunit through job queue, even though this code unit works fine when I run it manually. 我通过作业队列运行Codeunit时出错,即使这个代码单元在我手动运行时工作正常。 Error: "Microsoft Dynamics NAV Server attempted to issue a client callback to create a .NET object: System.Data.SqlClient.SqlConnection (Report 50126 NewOrdersCust). Client recalls are not supported for Microsoft Dynamics NAV Server." 错误:“Microsoft Dynamics NAV Server尝试发出客户端回调以创建.NET对象:System.Data.SqlClient.SqlConnection(Report 50126 NewOrdersCust).Microsoft Dynamics NAV Server不支持客户端调用。”

This code unit runs a report and saves it as a pdf file in a folder. 此代码单元运行报告并将其作为pdf文件保存在文件夹中。

CodeUnit: CodeUnit:

OnRun(VAR Rec : Record "Job Queue Entry")
 IF GUIALLOWED THEN BEGIN
 programm:='\\MB\Navision\ReportsMB\PDFSoftware\cpdf.exe';
//Merged PDF1
Output := '\\MB\Navision\ReportsMB\Customers.pdf';
directory:= '\\MB\Navision\ReportsMB\2019\Customers';
Filename1:='\\MB\Navision\ReportsMB\2019\Kunden_Vertrieb\CustomersOrders.pdf';
Report1.SAVEASPDF(Filename1);
END;

The report is actually based on an SQL query: 该报告实际上基于SQL查询:

Report: 报告:

MyReport - OnPreDataItem()
Servername:='*.*.*.*';
DBName:='DB';
GetSQLConnection(SQLConnection,Servername,DBName);

QueryinText:='select * from [SickDays] K  Order by Year DESC, Code ASC, Monat DESC ';

SQLCommand:=SQLCommand.SqlCommand(QueryinText,SQLConnection);
SQLConnection.Open();
Queryread :=SQLCommand.ExecuteReader;

MyReport - OnAfterGetRecord()
IF (Queryread.Read()) THEN
       BEGIN
       LoopCount+=1;
       Year:= Queryread.Item(0);
       KrankDays:=Queryread.Item(5);
       END
ELSE
    BEGIN
       SQLConnection.Close();
       CurrReport.BREAK;
    END;

SETRANGE(Number,1,  LoopCount);

MyReport - OnPostDataItem()

GetSQLConnection(VAR SQLConnection : DotNet "System.Data.SqlClient.SqlConnection";Servername : Code[20];DBName : Code[20])
SQLConnection :=
  SQLConnection.SqlConnection(
    STRSUBSTNO(
      'Data Source=%1;Initial Catalog=%2;Integrated Security=SSPI',
      Servername,DBName));

This report contains the following .net variables 此报告包含以下.net变量

On the .net variables you have probably set property RunOnClient to True. 在.net变量上,您可能将属性RunOnClient设置为True。 You can't do that if you want to run this report on server. 如果要在服务器上运行此报告,则无法执行此操作。 Set this property to false and make sure you have needed libraries on the nav server. 将此属性设置为false并确保导航服务器上有所需的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM