E10 Printing from code is there a way to know that the printing is done?

Hello,

I was successful (with some help from posts from this forum… :wink: ) to print my BAQReport from code in my customized form. Works great.

I wonder however if there is a way to have knowledge that the report was successfully printed.

The code I used where I submit to task agent… does it have some return values ? Like Ok Done or Error. ?

baqR.SubmitToAgent(baqRptDS, “SystemTaskAgent”, 0, 0, “Epicor.Mfg.UIRpt.BAQReport”);

If so, How can I have access to such info?
Thank you.

Pierre

These tasks show up in the system monitor, same as if you were running it regularly. There is the method RunDirect that will wait until the report has been processed, you could add a try catch around that to catch if there was an issue (maybe).

Thanks I know about system monitor… But I am trying to simulate an hour glass while the printing is done…taking a bit of time… and if I get info that it is done, well stop the process!

You mentionned about RunDirect, do you have an example how to use it?

Pierre

This is a snip of what I have to print an AR form. I don’t think I have an example of RunDirect with BAQ reports though. Should be relatively the same I would think.

arDS = arForm.GetNewParameters();
arDS.ARInvFormParam[0].InvoiceNum = (int)row["InvoiceNum"];
arDS.ARInvFormParam[0].AgentSchedNum = 0;
arDS.ARInvFormParam[0].AgentID = "SystemTaskAgent";
arDS.ARInvFormParam[0].ReportStyleNum = 1010;

arForm.RunDirect(arDS);

There is no return values for RunDirect… returns void… I tested and control is passed right away to the next line of code… ( I thought it would delay it… ) So behaves the same as my original call … so I confirm to you it does work fine with BAQreport…!

But it is not what I was hopping for…

Thanks

Pierre

I think the only way you could check this is by calling RunDirect, then afterwards query the SysTask table for the last task run by the current user to get the task status.

1 Like

You can look at the SysTask table to see if a task is complete (so long as you know what you are looking for). To make it responsive, perhaps you could make a background thread to check and update status as needed

That was the intent thanks.

I did watch the systask and for this report, it is too fast … I think over 90% of the wait time is the actual pdf generation, not the crunching from the print server…
The task becomes complete very fast, then I am still waiting a few seconds more to see the pdf.

So I will put this on ice for now… got more important changes to attend to…

thanks for your input.

Pierre

I have the code below that checks the task agent for when a print job is complete.

When the print job is submitted i use a GUID for the workstationID so that i know which print job to check for later.

				Guid workstationid = Guid.NewGuid(); 
				POFormDS.POFormParam[0].WorkstationID = String.Format("{0}",workstationid);			 // Using a GUID as the WorkstationID so it is easy to reteive this report
				POFormDS.POFormParam[0].DateFormat = "dd/MM/yy";
				POFormDS.POFormParam[0].ArchiveCode = 1;

				POFormDS.POFormParam[0].AutoAction = "SSRSGenerate";
				//MessageBox.Show("Submit to System Agent ...");
				Form.SubmitToAgent(POFormDS, "SystemAgent", 0, 0, "Erp.UIRtp.POForm");   //Submit the report to be generate by the system agent.

Then do a loop to check when the job is done.

			int timer=0;
			
			bool morepages;
			SysRptLstListDataSet RptList;
			RptList = RM.GetList(@"WorkStationID ='"+workstationid+"'", 0, 0, out morepages);

			while (RptList.SysRptLstList.Count == 0 ) // setup a loop to look for when the report has been generated.
				{					
				System.Threading.Thread.Sleep(500);
				timer = timer + 1;
				if (timer > 120)
					{
					MessageBox.Show("Well, I have been trying to make a pdf of the PO for a while now and I just can't do it....I give up!");
					return;
					}
				RptList = RM.GetList(@"WorkStationID ='"+workstationid+"'", 0, 0, out morepages);
				}

			string tableguid;
			tableguid = RptList.SysRptLstList[0].FileName.Replace("REPORT DATABASE: ","");

Brett

Wow thank you Brett,
This idea looks more promising…looking at the actual availability of the report in the list of reports…

I will surely give it a try… when I can get back to it…

Will let you know…

Pierre

In my experience, rather than doing a loop, you can call Form.RunDirect(POFormDS) and it will wait until the report dataset is generated.

1 Like