13.05.2010, 01:05 | #1 |
Участник
|
paruvella: Displaying the Standard Ax report in EP pages of AX – Part – II
Источник: http://paruvella.spaces.live.com/Blo...4DB0!515.entry
============== In this example, we will see how we will pass the parameters to the Report Query object from EP pages. We will display the Customer report in EP pages of Dynamics Ax, based on the filter condition of customer account. For this example, I will continue with my previous article. http://paruvella.spaces.live.com/blog/cns!F2EC589E221A4DB0!509.entry For the class, PSReportRunFromEP add the following things. New methods: public CustAccount setCustAccount(CustAccount _custAccount) { ; custAccount = _custAccount; return custAccount; } protected void initQuery() { ; //in this method, I am going to change the Query by adding filters to the Report Query report = new Report(reportName); //reportName = “Cust” query = new Query(report.query()); // here I will get the Report Query def into query obj. query.dataSourceTable(tableNum(CustTable)).rangeField(fieldNum(CustTable, AccountNum)).value(custAccount); //passing the value } Modify methods: public static void reportToPDFFile(CustAccount _custAccount) { PSReportRunFromEP reportRunFromEP = new PSReportRunFromEP(); ; reportRunFromEP.setCustAccount(_custAccount); reportRunFromEP.initValue(); reportRunFromEP.reportRun(); } void initValue() { ; //same lines from prev. article, just add the following line at the end this.initQuery(); } void reportRun() { …. //Same lines from prev. article reportRun.query(query); //Uncomment this line from my prev. article ……. } Make sure that above class is added in Proxies. Need to update the Proxies definition from Tools àDevelopment Tools àWeb Development àProxies and click on the Generate button. Now we will develop the required Web parts Web Part –I C# Code -- Code behind using Microsoft.Dynamics.Framework.BusinessConnector.Session; using ApplicationProxy = Microsoft.Dynamics.Portal.Application.Proxy; using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy; public partial class EPCustReportHostl : System.Web.UI.UserControl { private ISession AxSession { get { AxBaseWebPart webpart = AxBaseWebPart.GetWebpart(this); return webpart == null ? null : webpart.Session; } } protected void Page_Load(object sender, EventArgs e) { } protected void ReportButton_Click(object sender, EventArgs e) { //calling the proxy method for generating the report into PDF file and the same report we are displaying in EP Microsoft.Dynamics.Portal.Application.Proxy.PSReportRunFromEP.reportToPDFFile(this.AxSession.AxaptaAdapter, TextBoxFilterCustAccount.Text); AxUrlMenuItem url = new AxUrlMenuItem("EPCustomerReport"); // This URL is for displaying the report in PDF file HttpContext.Current.ApplicationInstance.CompleteRequest(); Response.Redirect(url.Url.OriginalString, false); } } Add this web part to the new page (EPCustomerReportHost.aspx), import the URL definition in to the Ax AOT and add this URL to web menus of Sales module. Web Part –II Nothing to design here, just add the following code in the Page_Load() method of web part public partial class EPCustomerReportsl : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { FileInfo fi = null; fi = new FileInfo("D:\\Customers.pdf"); if (fi.Exists) { Response.Clear(); Response.ContentType = "application/pdf"; Response.Flush(); Response.WriteFile(fi.FullName); Response.End(); } } } Add this web part to the new page (EPCustomerReport.aspx), import the URL definition in to the Ax AOT. We will refer same web menu item URL in first web part of button click event. Now open the page EPCustomerReportHost from the Sales module of EP and page will be displayed as follows. Select the customer and click on Report button on the same page. Customer 2003 details will be displayed in next page as a PDF file. This way we can pass the parameters from EP pages to the standard reports. i.e. exactly, how we have the parameters for the reports in Ax client, same behavior we can bring for the EP reports also, and we can generate similar reports from EP as well. Источник: http://paruvella.spaces.live.com/Blo...4DB0!515.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|