private void PrintDD250(int packNum, int styleNum)
{
try
{
//Easy to find
string reportTaskNote = Guid.NewGuid().ToString();
PackingSlipPrintAdapter adpPackSlip = new PackingSlipPrintAdapter(EpiUser.EpiLaunch);
adpPackSlip.BOConnect();
adpPackSlip.GetNewParameters();
Erp.Rpt.PackingSlipPrintDataSet.PackingSlipParamRow psParam = adpPackSlip.ReportData.PackingSlipParam[0];
psParam.PackNum = packNum;
psParam.AutoAction = "SSRSPREVIEW";
psParam.SSRSRenderFormat = "PDF";
psParam.AgentID = "System Task Agent";
psParam.ReportStyleNum = styleNum;
psParam.ProcessTaskNum = 0;
psParam.RowMod = "A";
psParam.TaskNote = reportTaskNote; //Magic
adpPackSlip.RunDirect();
SysMonitorAdapter adpSysMonitor = new SysMonitorAdapter(EpiUser.EpiLaunch);
adpSysMonitor.BOConnect();
//Find the one with our reporTaskNote from above
SearchOptions opts = new SearchOptions(SearchMode.AutoSearch);
opts.NamedSearch.WhereClauses.Add("SysTask", "TaskNote = '" + reportTaskNote + "'");
using (ReportMonitorAdapter adpRptMon = new ReportMonitorAdapter(EpiUser.EpiLaunch))
{
adpRptMon.BOConnect();
SysMonitorTasksDataSet sysMonitorData = null;
if (adpRptMon.GetRowsKeepIdleTimeWithBallonInfo(opts, false, out sysMonitorData))
{
if (adpRptMon.ReportMonitorData.SysRptLst.Count > 0)
{
Byte[] returnRpt = adpRptMon.GetReportBytes(adpRptMon.ReportMonitorData.SysRptLst[0].SysRowID);
if(returnRpt.Length > 0)
{
//PRINT HERE (The returnRpt Bytes is the pdf)
MessageBox.Show(returnRpt.Length.ToString());
}
adpRptMon.ReportMonitorData.SysRptLst[0].LastAction = "PREVIEW";
adpRptMon.Update();
}
else
{
Misc.TraceLog.Write(string.Format("ReportMonitor didn't find Rpt for PackNumber [{0}].", packNum));
}
}
else
{
Misc.TraceLog.Write(string.Format("ReportMonitor didn't find Rpt for PackNumber [{0}].", packNum));
}
}
}
catch (Exception ex)
{
Misc.TraceLog.Write(string.Format("Exception caught trying to print DD 250 form for PackNumber [{0}]. Exception: {1}", packNum, ex.ToString()));
}
}
TaskNote
idea from @josecgomez