Multiselect from Ax 2012 Listpage (EP) для скачиванияDocument.aspx
людей.
Я боролся с этим какое-то время и не могу найти решение для своей проблемы. Мне бы очень хотелось помочь здесь, если это было возможно, это очень значило бы для меня.
В настоящее время я запускаю страницу с током 2012 на сайте Enterprise portal, которая позволяет пользователям выбирать счет-фактуру, а затем нажать кнопку, которая начинает загрузку сгенерированного PDF-счета.
Это выглядит так:
Кнопка EpDocuGetMenuitem (пункт меню вывода) относится к URL-адресу webMenuItem, который запускает статический файл downloadDocument.aspx.
downloadDocument.aspx получает Websession и axaptasession и извлекает единственную запись, которая была выбрана в Ax List. downloadDocument.aspx имеет следующий код:
<%@ Page Language="C#" Trace="false" %>
<%@ Assembly Name="Microsoft.Dynamics.Framework.Portal, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null" %>
<%@ Assembly Name="Microsoft.Dynamics.Framework.Data.Ax, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null" %>
<%@ Assembly Name="Microsoft.Dynamics.Framework.BusinessConnector, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null" %>
<%@ Assembly Name="Microsoft.Dynamics.Framework.BusinessConnector.Proxy, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null" %>
<%@ Assembly Name="Microsoft.Dynamics.Framework.Metadata.AX, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null" %>
<%@ Import Namespace="Microsoft.Dynamics.Framework.Portal" %>
<%@ Import Namespace="Microsoft.Dynamics.Framework.Portal.UI" %>
<%@ Import Namespace="Microsoft.Dynamics.AX.Framework.Portal.Data" %>
<%@ Import Namespace="Microsoft.Dynamics.Framework.BusinessConnector.Proxy" %>
<%@ Import Namespace="Microsoft.Dynamics.Framework.BusinessConnector.Session" %>
<%@ Import Namespace="Microsoft.Dynamics.Framework.BusinessConnector.Adapter" %>
<%@ Import Namespace="Microsoft.Dynamics.AX.Framework.Services.Client" %>
<%@ Register TagPrefix="dynamics" TagName="EPSecurityControl" src="EPSecurityControl.ascx" %>
<dynamics:EPSecurityControl ID="AxEPSecurity" runat="server" />
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
AxSharepointWebSession session = null;
try
{
session = SessionHelper.Instance.GetSharepointSession();
if (session != null)
{
using (EPDocuGet doc = new EPDocuGet(session.AxaptaAdapter))
{
// EPDocuGet writes directly to the output stream
AxQueryString query = new AxQueryString(this.Request);
if (query.RecordContext != null)
{
AxTableContext tableContext = AxTableContext.Create(session, query);
if(tableContext != null && tableContext.DataKey != null)
{
using (IAxaptaRecordAdapter record = tableContext.DataKey.GetRecords(session))
{
if (tableContext.TableId == TableMetadata.TableNum("DocuRef"))
{
doc.runDownload(record);
}
else
{
// Run a report using the Client SDK UserImpersonationContext to revert the credentials from EP application pool to the authenticated user
using (new UserImpersonationContext())
{
doc.runDownload(record);
}
}
}
}
}
}
Response.Flush();
}
}
catch (System.Exception)
{
// Current design is to not display errors to the user
// Errors are stored in the event log for review by the site operator
}
finally
{
if (session != null)
{
SessionHelper.Instance.ReleaseSharepointSession(session);
}
}
}
</script>
и интересной частью файла является этот код:
using (EPDocuGet doc = new EPDocuGet(session.AxaptaAdapter))
{
// EPDocuGet writes directly to the output stream
AxQueryString query = new AxQueryString(this.Request);
if (query.RecordContext != null)
{
AxTableContext tableContext = AxTableContext.Create(session, query);
if (tableContext != null && tableContext.DataKey != null)
{
using (IAxaptaRecordAdapter record = tableContext.DataKey.GetRecord(session))
{
if (tableContext.TableId == TableMetadata.TableNum("DocuRef"))
{
doc.runDownload(record);
}
else
{
// Run a report using the Client SDK UserImpersonationContext to revert the credentials from EP application pool to the authenticated user
using (new UserImpersonationContext())
{
doc.runDownload(record);
}
}
}
}
}
}
Цель здесь - получить все выбранные записи, доступные в downloadDocument.aspx. Я включил multiselect в Ax, так что, думаю, должно быть возможно получить все записи. Я предполагаю, что этот фрагмент должен быть каким-то образом
IAxaptaRecordAdapter record = tableContext.DataKey.GetRecord(session)
Но я не могу понять это.
Если я могу получить все записи в файле downloadDocument.aspx, я мог бы отправить строку обратно в ax для создания необходимых документов и отправки их пользователю.
Любые предложения о том, как это сделать?