15.12.2009, 23:05 | #1 |
Участник
|
paruvella: Displaying the employee images on the EP pages of Dynamics Ax
Источник: http://paruvella.spaces.live.com/Blo...4DB0!378.entry
============== In this example I am going to illustrate, displaying the employee images on EP pages. Note: Assumed that all the images(photos) are mapped to their employee records by using Employee Details form in Ax client. After the images are mapped to employee records, need to Publish the images in to sharepoint path by selecting the Publish images form, from Administartion à Setup àInternet àEnterprise Portal àPublish images as shown in below figure and click on the Publish button of the form. In this example, I am going to filter the records from Employee table, which employee is mapped to current user (logged in Ax user). Development Steps Step – I: Prepare the Dataset for this example application by using the EmplTable and CompanyImage tables as shown in below figure. Step – II: Override the executeQuery method on the EmplTable of the above dataset. This method for filtering the employee records from employee table, which employee is mapped to current user. public void executeQuery() { Query query = new Query(); QueryBuildDataSource qbs, qbs1; QueryBuildRange qbr; QueryRun qr; ; qbs = query.addDataSource(tablenum(EmplTable)); qbs1 = qbs.addDataSource(tablenum(SysCompanyUserInfo)); qbs1.addLink(fieldnum(EmplTable, EmplId), fieldnum(SysCompanyUserInfo, EmplId)); qbr = qbs1.addRange(fieldnum(SysCompanyUserInfo, UserId)); qbr.value(curuserId()); qbr.status(RangeStatus::Hidden); qbs1.joinMode(joinmode::ExistsJoin); this.query(query); super(); } Override the executeQuerymethod On the CompanyImage table of the above dataset. The following method is used for filtering the Employee image(photo) from CompanyImage Table public void executeQuery() { Query q; QueryBuildDataSource qB; QueryBuildRange qbr; q = new Query(); qB = q.addDataSource(tablenum(CompanyImage)); qbr = qB.addRange(fieldnum(CompanyImage,RefCompanyId)); qbr.value(queryValue(emplTable.company())); qbr.status(RangeStatus::Hidden); qbr = qB.addRange(fieldnum(CompanyImage,RefTableId)); qbr.value(queryValue(emplTable.TableId)); qbr.status(RangeStatus::Hidden); qbr = qB.addRange(fieldnum(CompanyImage,RefRecId)); qbr.value(queryValue(emplTable.RecId)); qbr.status(RangeStatus::Hidden); this.query(q); super(); } Step – III: Developing the required webpart for displaying the employee information and his image. Markup Code for the UserEmployeeInfo webpart </span> C# (Code behind)Code for the UserEmployeeInfo webpart using System; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Microsoft.Dynamics.Framework.Portal.UI.WebControls; using Microsoft.Dynamics.Framework.Portal.UI.WebControls.WebParts; using Microsoft.Dynamics.Framework.Data.Ax; using Microsoft.Dynamics.Framework.Metadata.Ax; using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy; using ApplicationProxy = Microsoft.Dynamics.Portal.Application.Proxy; using Microsoft.Dynamics.Framework.BusinessConnector.Session; using Microsoft.Dynamics.Framework.BusinessConnector.Adapter; public partial class UserEmploeeInfo : System.Web.UI.UserControl { #region Properties... /// /// Returns the current webpart /// private AxBaseWebPart WebPart { get { return AxBaseWebPart.GetWebpart(this); } } /// /// Returns the current webpart session /// private ISession AxSession { get { AxBaseWebPart webpart = AxBaseWebPart.GetWebpart(this); return webpart == null ? null : webpart.Session; } } //Enterprise portal images folder path string EPLayoutImagesPath { get { return "/_layouts/ep/images/"; } } //reading the imagepath of the employee record from sharepoint string GetImagePath(IAxaptaRecordAdapter record) { return this.EPLayoutImagesPath + ApplicationProxy.EPWebSiteParameters.companyImageFileName(AxSession.AxaptaAdapter, record); } #endregion protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { IAxaptaRecordAdapter row = UserEmployeeInfo.GetDataSourceView("CompanyImage").DataSetView.GetCurrent().GetRecord(); imgCompany.ImageUrl = this.GetImagePath(row); } } } Step – IV: Add this newly developed user control to AOT and deploy this webpart on the sharepoint page. Open the newly created page url in the explorer and observe the result as follows. This is how employee images will be displayed on the EP pages of Dynamics Ax. ...... Источник: http://paruvella.spaces.live.com/Blo...4DB0!378.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|