Reports can not only be printed by the user via the interface, but can also be done on the server in the background.
There are two options here:
- If you would like to print during a workflow , please use the workflow class gip.core.autocomponent. PWNodePrint. In the configuration you can then specify which business object and which report should be printed.
- You trigger the printing process programmatically. For this purpose, the following code example from the ACComponent base class, with which the current status of an instance is printed out:
Basically there are three or four steps :
1. ACComponent instance
You need an ACComponent instance that you want to print. Either it is the this pointer itself or a reference that you received via ACUrlCommand or created again. Examples:
ACClass iPlusType = typeof(BSOInOrder).GetACType() as ACClass;
BSOInOrder refToPrintComp = StartComponent(iPlusType, iPlusType, null) as BSOInOrder;
refToPrintComp.AccessPrimary.NavACQueryDefinition.ACFilterColumns.FirstOrDefault()
.SetSearchValue<string>("123456789");
refToPrintComp.Search();
ACComponent refToPrintComp = ACUrlCommand("\\MyApp\\InstanceWithReports") as ACComponent;
2. Design (report)
You need a report from this instance that you want to print. To do this, call the method of one of the multiple overloaded GetDesign (...) methods to get a reference to ACClassDesign (the XAML code is stored in ACClassDesign.XMLDesign).
ACClassDesign designToPrint = refToPrintComp.GetDesign("MyReportName");
3. Print design
Call the ACComponents method PrintDesign which encapsulate the another step 3.ReportData and step 4.Printing with the report generator
int copies = 5;
Msg possibleError = refToPrintComp.PrintDesign(designToPrint, "hpLaserJetA4", copies , false);
OR
3. ReportData
Call the static method ReportData.BuildReportData () to provide the report data for the report generator. Pass the reference of the ACComponent to be printed (refToPrintComp). Please note that the instance is cloned and confirmed in the out variable cloneInstantiated:
bool cloneInstantiated = false;
ReportData reportData = ReportData.BuildReportData(out cloneInstantiated,
Global.CurrentOrList.Current, refToPrintComp, null, designToPrint);
4. Printing with the report generator
Finally you need an instance of the report generator ( class VBBSOReport ). Either you have a permanent reference somewhere in the application tree or you can create your own during runtime. Call the Print method and pass the design and report data:
ACClass reportEType = typeof(VBBSOReport).GetACType() as ACClass;
VBBSOReport reportEngine = StartComponent(reportEType, reportEType, null) as VBBSOReport;
int copies = 5;
reportEngine.Print(designToPrint, false, "hpLaserJetA4", reportData, copies);