using Microsoft.Dynamics.ApplicationPlatform.Services.Instrumentation;
using Microsoft.DynamicsOnline.Infrastructure.Components.SharedServiceUnitStorage;
using Microsoft.Dynamics.AX.Framework.FileManagement;
public class ReadAzureBlobStorage
{
str docfiletype;
Microsoft.Dynamics.AX.Framework.FileManagement.IDocumentStorageProvider storageProvider;
Public void readfromAzureBlob(DocuRef _docuRef)
{
AsciiStreamIo file;
container record;
str downloadUrl;
if (_docuRef.isValueAttached())
{
var docuValueloc = _docuRef.docuValue();
downloadUrl = docuValueloc.Path;
if (!downloadUrl || docuValueloc.Type == DocuValueType::Others)
{
str accessToken = DocumentManagement::createAccessToken(_docuRef);
downloadUrl = Microsoft.Dynamics.AX.Framework.FileManagement.URLBuilderUtilities::GetDownloadUrl(docuValueloc.FileId, accessToken);
}
var docContents = storageProvider.GetFile(docuValueloc.createLocation());
file = AsciiStreamIo::constructForRead(docContents.Content);//File::UseFileFromURL(downloadUrl));
}
if (file)
{
if (file.status())
{
throw error("@SYS52680");
}
file.inFieldDelimiter(',');
file.inRecordDelimiter('\r\n');
}
while (!file.status())
{
record = file.read();
if (conLen(record))
{
info(strFmt("%1 - %2",conPeek(record,1),conPeek(record,2)));
}
}
}
}
using Microsoft.DynamicsOnline.Infrastructure.Components.SharedServiceUnitStorage;
using Microsoft.Dynamics.AX.Framework.FileManagement;
public class ReadAzureBlobStorage
{
str docfiletype;
Microsoft.Dynamics.AX.Framework.FileManagement.IDocumentStorageProvider storageProvider;
Public void readfromAzureBlob(DocuRef _docuRef)
{
AsciiStreamIo file;
container record;
str downloadUrl;
if (_docuRef.isValueAttached())
{
var docuValueloc = _docuRef.docuValue();
downloadUrl = docuValueloc.Path;
if (!downloadUrl || docuValueloc.Type == DocuValueType::Others)
{
str accessToken = DocumentManagement::createAccessToken(_docuRef);
downloadUrl = Microsoft.Dynamics.AX.Framework.FileManagement.URLBuilderUtilities::GetDownloadUrl(docuValueloc.FileId, accessToken);
}
var docContents = storageProvider.GetFile(docuValueloc.createLocation());
file = AsciiStreamIo::constructForRead(docContents.Content);//File::UseFileFromURL(downloadUrl));
}
if (file)
{
if (file.status())
{
throw error("@SYS52680");
}
file.inFieldDelimiter(',');
file.inRecordDelimiter('\r\n');
}
while (!file.status())
{
record = file.read();
if (conLen(record))
{
info(strFmt("%1 - %2",conPeek(record,1),conPeek(record,2)));
}
}
}
}
No comments:
Post a Comment