using Microsoft.WindowsAzure.Storage;
Using Microsoft.WindowsAzure.Storage.Blob;
[ExtensionOf(classStr(CustVendVoucher))]
final class CustVendVoucher_Dax_Extension
{
public void post(LedgerVoucher _ledgerPostingJournal,CustVendTrans _custVendTrans,
NoYes _approval,UnknownNoYes _euroTriangulation,
boolean _withHoldTaxType, boolean _useSubLedger)
{
// Common _record; (Here we can use common buffer which was declared in standard class(globally declared ))
TableId _tableId;
LedgerVoucherTransObject ledgerVoucherTransObject1;
LedgerJournalTable ledgerJounralTable;
LedgerJournalTrans ledgerJournalTrans;
LedgerDimensionAccount ledgerDimensionMerged;
next post(_ledgerPostingJournal,_custVendTrans,_approval, _euroTriangulation,_withHoldTaxType,_useSubLedger);
ledgerVoucherTransObject1 = this.createLedgerVoucherTransObject(_useSubLedger, ledgerDimensionMerged, ledgerJournalTrans, _ledgerPostingJournal, _custVendTrans);
if(common.TableId == tableNum(LedgerJournalTrans))
{
ledgerjournalTrans = common;
ledgerJounralTable = LedgerJournalTable::find(ledgerjournalTrans.JournalNum);
}
if(common.TableId == tableNum(LedgerJournalTable))
{
ledgerJounralTable = common;
}
this.csvfile(ledgerJounralTable);
}
public void csvfile(LedgerJournalTable ledgerJournalTable)
{
CloudStorageAccount storageAccount; PersonnelIntegrationStorageAccountConnectionString azureStorageKey;
storageAccount=CloudStorageAccount::Parse("DefaultEndpointsProtocol=https;AccountName=srikanthaccount;AccountKey=qJ+15H/a3TqzTgS3T6xrvDVN7vZc4VfcpILIVm8R7gKrQh79vmYbl1Z3S11P7CFJ/SvTmat1FwMy+ASt+PSf+w==;EndpointSuffix=core.windows.net");
//AccessKey connection string of storage Account.
System.Byte[] reportBytes = new System.Byte[0]();
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
CloudBlobContainer blobContainer;
CloudBlockBlob blockblob;
CloudBlobDirectory cbDir;
str ledgerDim;
str containerName = "srikanthcontainer", dirPath;
dirPath = "newfolder";
XmlDocument doc;
commaStreamIo iO = commaStreamIo::constructForWrite();
Filename filename = "MyFile.csv";
container header = ["JournalNumber","VoucherNumber","Account number","Date","Debit","Credit","City","State"];
iO.writeExp(header);
header = conNull();
LedgerJournalTrans ledgerJournalTrans;
while select ledgerJournalTrans
where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum
{
ledgerDim=LedgerDimensionFacade::getDisplayValueForLedgerDimension(ledgerJournalTrans.LedgerDimension);
container line=[ledgerJournalTrans.JournalNum,ledgerJournalTrans.Voucher,ledgerDim,ledgerJournalTrans.TransDate,ledgerJournalTrans.AmountCurDebit,ledgerJournalTrans.AmountCurCredit];
iO.writeExp(line);
}
System.IO.Stream stream = iO.getStream();
stream.Position = 0;
System.IO.StreamReader reader = new System.IO.StreamReader(stream);
str csvFileContent = reader.ReadToEnd();
File::SendStringAsFileToUser(csvFileContent, filename);
info(strFmt("CSV file %1 is created", filename));
if(storageAccount && containerName)
{
blobClient = storageAccount.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference(containerName);
cbDir = blobContainer.GetDirectoryReference(dirPath);
blockblob = cbDir.GetBlockBlobReference(filename);
if (blockBlob)
{
if (stream)
{
stream.Position = 0;
blockBlob.UploadFromStream(stream,null,null,null); blockBlob.FetchAttributes(null, null, null);
}
}
}
}
}
No comments:
Post a Comment