using Microsoft.Dynamics.ApplicationPlatform.Services.Instrumentation;
using Microsoft.DynamicsOnline.Infrastructure.Components.SharedServiceUnitStorage;
using Microsoft.Dynamics.AX.Framework.FileManagement;
public class BBReadAzureBlobStorage
{
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)));
}
}
}
Public boolean deletefile(DocuValue _DocuValue)
{
DocuValue docuValuedel;
DocuRef docuRefDel;
boolean ret = false;
ttsbegin;
select forupdate docuValuedel where docuValuedel.RecId == _DocuValue.RecId;
select forupdate docuRefDel where docuRefDel.ValueRecId == docuValuedel.RecId;
if(docuValuedel)
{
docuValuedel.delete();
docuRefDel.delete();
ret = true;
}
ttscommit;
return ret;
}
}
using Microsoft.DynamicsOnline.Infrastructure.Components.SharedServiceUnitStorage;
using Microsoft.Dynamics.AX.Framework.FileManagement;
public class BBReadAzureBlobStorage
{
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)));
}
}
}
Public boolean deletefile(DocuValue _DocuValue)
{
DocuValue docuValuedel;
DocuRef docuRefDel;
boolean ret = false;
ttsbegin;
select forupdate docuValuedel where docuValuedel.RecId == _DocuValue.RecId;
select forupdate docuRefDel where docuRefDel.ValueRecId == docuValuedel.RecId;
if(docuValuedel)
{
docuValuedel.delete();
docuRefDel.delete();
ret = true;
}
ttscommit;
return ret;
}
}
The information which you have provided in this blog is really useful to everyone. Thanks for sharing.
ReplyDeleteMS Dynamics Technical Online Training
MS Dynamics AX Technical Training in Hyderabad
MS Dynamics AX Online Training
D365 AX Online Training
d365 ax technical online training
d365 ax technical training