Never printed from outside Epicor but here is some code that I use to
print a BAQReport from a dashboard.
I have to have Epicor open for this to work.
Some of the code was remove that was specific to my use to make is
smaller.
Let me now if you have any questions.
public static class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End
Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
private static Process current = null;
private static System.IntPtr hProcess =
default(System.IntPtr);
private static int consoleSessionID = 0;
[DllImport("Epicor.Mfg.Lib.GetConsoleSessionID.dll",
CharSet = CharSet.Auto)]
public static extern int getSession(IntPtr pHandle);
public static void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not
delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable
Initialization
// End Wizard Added Variable
Initialization
// Begin Wizard Added Custom Method
Calls
btnPrintPickList.Click += new
System.EventHandler(Script.btnPrintPickList_Click);
btnClearPrint.Click += new
System.EventHandler(Script.btnClearPrint_Click);
// End Wizard Added Custom Method Calls
current = Process.GetCurrentProcess();
hProcess = current.Handle;
consoleSessionID = getSession(hProcess);
if ((consoleSessionID < 0))
{
consoleSessionID = 0;
}
}
public static void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not
delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
btnPrintPickList.Click -= new
System.EventHandler(Script.btnPrintPickList_Click);
btnClearPrint.Click -= new
System.EventHandler(Script.btnClearPrint_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
current = null;
// End Custom Code Disposal
}
private static void btnPrintPickList_Click(object sender,
System.EventArgs args)
{
// ** Place Event Handling Code Here **
Infragistics.Win.UltraWinGrid.SelectedRowsCollection selectedRows;
Session epiSession;
epiSession = (Session) MainController.Session;
BAQReport rptBAQReport = new
BAQReport(epiSession.ConnectionPool);
BAQReportDataSet rptDSBAQReport =
rptBAQReport.GetNewBAQReportParam("MISOPickList");
EpiUltraGrid myGrid = (EpiUltraGrid)
csm.GetNativeControlReference("07587698-1612-41ef-a85a-38b77c7be07c");
//Check to see if any rows are selected.
If not, stop.
if (myGrid.Selected.Rows.Count < 1)
{
myGrid = null;
rptDSBAQReport = null;
rptBAQReport = null;
epiSession = null;
MessageBox.Show("Please
select an order and then try again.");
return;
}
//Iterate through selected rows, build
order list and determine greatest shipby date
selectedRows = myGrid.Selected.Rows;
List<string> lstOrderNums = new List<string>();
string Filter1P1 = "<?xml version =
'1.0' encoding = 'UTF-8'?> <BAQReport> <BAQFilter>
<TableName>OrderHed</TableName> <FieldName>OrderNum</FieldName>
<Comparison>list</Comparison> <FieldValue>";
string Filter1P2 = "</FieldValue>
<RowIdent>FilterList1</RowIdent> </BAQFilter> </BAQReport>";
// Loop through all the selected rows
//
for ( int i = 0; i < selectedRows.Count; i++ )
{
Infragistics.Win.UltraWinGrid.UltraGridRow row;
row = selectedRows[i];
//add the order number
to the list if it isn't already
if
(!lstOrderNums.Contains(row.Cells["OrderHed.OrderNum"].Text))
{
lstOrderNums.Add(row.Cells["OrderHed.OrderNum"].Text);
}
}
//build order number string
StringBuilder sb = new StringBuilder();
foreach (string orderNum in
lstOrderNums)
{
if (sb.Length > 0)
{
sb.Append("~");
}
sb.Append(orderNum);
}
//Set fields accordingly
//Some of these field are set because it was observed from
tracing that these
//values changed from default dataset
//
rptDSBAQReport.Tables["BAQReportParam"].Rows[0]["BAQID"] =
"MATS-SOPickSlip";
rptDSBAQReport.Tables["BAQReportParam"].Rows[0]["ReportTitle"] = "Sales
Order Pick List";
rptDSBAQReport.Tables["BAQReportParam"].Rows[0]["Filter1"] = Filter1P1 +
sb.ToString() + Filter1P2;
rptDSBAQReport.Tables["BAQReportParam"].Rows[0]["DCDUserID"] =
epiSession.UserID;
rptDSBAQReport.Tables["BAQReportParam"].Rows[0]["BAQRptID"] =
"MISOPickList";
rptDSBAQReport.Tables["BAQReportParam"].Rows[0]["AutoAction"] =
"Preview";
rptDSBAQReport.Tables["BAQReportParam"].Rows[0]["AgentID"] =
"SystemTaskAgent";
rptDSBAQReport.Tables["BAQReportParam"].Rows[0]["WorkstationID"]
= Environment.MachineName + " " + consoleSessionID.ToString();
rptDSBAQReport.Tables["BAQReportParam"].Rows[0]["DateFormat"] =
"mm/dd/yyyy";
rptDSBAQReport.Tables["BAQReportParam"].Rows[0]["NumericFormat"]
= ",.";
//Send Pick List to System Agent for
printing
rptBAQReport.SubmitToAgent(rptDSBAQReport, "SystemTaskAgent", 0, 0,
"Epicor.Mfg.UIRpt.BAQReport;MISOPickList");
MessageBox.Show("Pick List Print Job
Submitted.");
}
}
From:
vantage@yahoogroups.com [mailto:
vantage@yahoogroups.com] On Behalf
Of jobando018
Sent: Friday, March 30, 2012 10:55 AM
To:
vantage@yahoogroups.com
Subject: [Vantage] Epicor 9.05 Printing Reports From .net BO
Good Day Group,
I am on Epicor 9.05.607a. I am working on a custom application for my
company dealing with shipping and packing slips. Long story short, I
would like to print a packing slip from my application. I have id the BO
dealing with printing using the trace tool and the sequence of methods:
Epicor.Mfg.Rpt.PackingSlipPrint.GetNewParameters()
Epicor.Mfg.Rpt.PackingSlipPrint.GetRptArchiveList()
Epicor.Mfg.Rpt.PackingSlipPrint.PackNumDefaults()
Epicor.Mfg.Rpt.PackingSlipPrint.SubmitToAgent()
I manage to submit a task to the system agent but there is no printing.
Also Epicor needs to be running in order for this to work. Has any body
printed from outside Epicor using .net BO?
Thanks,
Joel
Joe Rojas | Director of Information Technology | Mats Inc
dir: 781-573-0291 | cell: 781-408-9278 | fax: 781-232-5191
jrojas@... | www.matsinc.com Ask us about our clean, green and beautiful matting and flooring
This message is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company.
[Non-text portions of this message have been removed]