SubmitToAgent not setting Priority Mode in System Monitor

I have a Print Preview working successfully from a single button press in a Quote Entry customization. Only problem is that the System Monitor never goes to Priority Mode so the PDF takes up to 30 seconds to appear, while it takes 3 or 6 seconds when run from Action>Print Form>Print Preview.

My Code
	private void QuickPrintPreview()
	{
		// Set status (but this gets reset to Ready very quickly at the end of this event)
		this.oTrans.PushStatusText("Submitting Quote for Print Preview...",true);
		
		Erp.Proxy.Rpt.QuotFormImpl QFForm = WCFServiceSupport.CreateImpl<Erp.Proxy.Rpt.QuotFormImpl>((Ice.Core.Session)oTrans.Session, 
		Erp.Proxy.Rpt.QuotFormImpl.UriPath);
		Erp.Rpt.QuotFormDataSet QFds = QFForm.GetNewParameters();

		QFds.QuoteFormParam[0].QuoteNum = Convert.ToInt32(this.QuoteHed_Row.dataView[this.QuoteHed_Row.Row]["QuoteNum"]);
		QFds.QuoteFormParam[0].AutoAction = "SSRSPREVIEW";
		QFds.QuoteFormParam[0].PrinterName = "";
		QFds.QuoteFormParam[0].AgentSchedNum = 0;
		QFds.QuoteFormParam[0].AgentID = "SystemTaskAgent";
		QFds.QuoteFormParam[0].AgentTaskNum = 0;
		QFds.QuoteFormParam[0].RecurringTask = false;
		QFds.QuoteFormParam[0].RptPageSettings = "";
		QFds.QuoteFormParam[0].RptPrinterSettings = "";
		QFds.QuoteFormParam[0].ReportStyleNum = 1004;
		QFds.QuoteFormParam[0].WorkstationID = Ice.Lib.Report.EpiReportFunctions.GetWorkStationID((Ice.Core.Session)oTrans.Session);
		QFds.QuoteFormParam[0].DateFormat = "d/m/yyyy";
		QFds.QuoteFormParam[0].NumericFormat = ",.";
		QFds.QuoteFormParam[0].ProcessTaskNum = 0;
		QFds.QuoteFormParam[0].ReportCultureCode = "en-US";
		QFds.QuoteFormParam[0].ReportCurrencyCode = "USD";
		QFds.QuoteFormParam[0].ArchiveCode = 0;
		QFds.QuoteFormParam[0].DecimalsGeneral = 0;
		QFds.QuoteFormParam[0].DecimalsCost = 0;
		QFds.QuoteFormParam[0].DecimalsPrice = 0;
		QFds.QuoteFormParam[0].GlbDecimalsGeneral = 0;
		QFds.QuoteFormParam[0].GlbDecimalsCost = 0;
		QFds.QuoteFormParam[0].GlbDecimalsPrice = 0;
		QFds.QuoteFormParam[0].FaxSubject = "";
		QFds.QuoteFormParam[0].FaxTo = "";
		QFds.QuoteFormParam[0].SSRSRenderFormat = "PDF";
		
		QFForm.SubmitToAgent(QFds, "SystemTaskAgent", 0, 0, "Erp.UIRpt.QuotForm");
		
		// Reset status to Ready
		this.oTrans.PopStatus();
	}

This topic contains the same issue with a solution: BAQ Report slow - #5 by ckrusen
But, when I add these lines of code suggested in that topic,

using System.Reflection;

var mi = oTrans.GetType().BaseType.GetMethod("NotifySystemMonitor", BindingFlags.NonPublic | BindingFlags.Instance);
mi.Invoke(oTrans, null);

I get the error “Object reference not set to an instance of an object.”

10.2.200

What happens if you use the RunDirect method instead of SubmitToAgent

I tried RunDirect and got the same problem. The report still goes through System Monitor, and still does not kick the System Monitor into priority mode. The System Monitor shows a blank for the AgentID when using RunDirect. So, RunDirect worked to create the pdf succesfully, but still had a 30 second or so delay before appearing.

I finally got a definitive answer - thank you, @Rich Riley.!

Here’s the code:

// added Usings to get NotifySystemMonitor to work
using System.Collections;
using System.Drawing.Printing;
using Ice.Lib.Report;
using Ice.Lib.Report.Datasets;
using Ice.Lib.Report.Resources;
using Ice.Lib.Reporting;
using Ice.Lib.Searches;
using SysStrings = Ice.Lib.GlobalStrings.Resources.Strings;

...

private void NotifySystemMonitor()
	{
	Ice.Core.Session MyCurrentSession = (Ice.Core.Session)oTrans.Session;
	if (MyCurrentSession.ContainsKey("SystemMonitor"))
		{
			// try - catch in case of race conditions
			try
			{
				EpiReportNotification ern = (EpiReportNotification)MyCurrentSession["SystemMonitor"];
				ern.ReportSubmitted(this);
			}
			catch
			{
			}
		}
	}

Besides those Usings, also add Ice.Lib.GlobalStrings in Assembly Reference Manager. Then add the method NotifySystemMonitor(); to whatever event code you want to kick off the Priority mode.

4 Likes