UI Builder class
public class MCOFlatTMOMappingExportUIBuilder extends SysOperationAutomaticUIBuilder
{
DialogField dialogItemId;
MCOFlatTMOMappingExportContract contract;
public void postBuild()
{
super();
contract = this.dataContractObject();
dialogItemId = this.bindInfo().getDialogField(this.dataContractObject(),
methodStr(MCOFlatTMOMappingExportContract, parmItemId));
dialogItemId.registerOverrideMethod(methodStr(FormStringControl,lookup),methodStr(MCOFlatTMOMappingExportUIBuilder,itemIdLookup),this);
}
public void postRun()
{
}
private void itemIdLookup(FormStringControl itemIdLookup)
{
Query query;
QueryBuildDataSource qbds,qbds1;
SysTableLookup sysTableLookup;
sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable),itemIdLookup);
sysTableLookup.addLookupfield(fieldnum(InventTable, ItemId));
sysTableLookup.addLookupfield(fieldnum(InventTable, NameAlias));
query = new Query();
query.allowCrossCompany(true);
qbds = query.addDataSource(tableNum(InventTable));
sysTableLookup.parmQuery(query);
sysTableLookup.parmUseLookupValue(False);
sysTableLookup.performFormLookup();
}
}
Contract class
[DataContractAttribute,
SysOperationGroupAttribute("LegalEntity", "Legal Entity", "1", FormArrangeMethod::Vertical),
SysOperationGroupAttribute("Date", "Date", "2"),
SysOperationGroupAttribute("Product", "Product", "3"),
SysOperationContractProcessingAttribute(classstr(MCOFlatTMOMappingExportUIBuilder))
]
public class MCOFlatTMOMappingExportContract
{
SelectableDataArea dataArea;
TransDate fromDate, toDate;
ItemId ItemId;
RetailSeasonCode seasonCode;
VendAccount vendId;
/// <summary>
/// MainAccountNum
/// </summary>
/// <param name = "_mainAccountNum">mainAccountNum</param>
/// <returns>Main account</returns>
[DataMemberAttribute("DataArea"),
SysOperationGroupMemberAttribute("LegalEntity"),
SysOperationDisplayOrderAttribute("1")]
public SelectableDataArea parmDataArea(SelectableDataArea _DataArea = dataArea)
{
dataArea = _DataArea;
return dataArea;
}
/// <summary>
/// MainAccountNum
/// </summary>
/// <param name = "_mainAccountNum">mainAccountNum</param>
/// <returns>Main account</returns>
[DataMemberAttribute("FromDate"),
SysOperationGroupMemberAttribute("Date"),
SysOperationDisplayOrderAttribute("1")]
public FromDate parmFromDate(TransDate _FromDate = fromDate)
{
fromDate = _FromDate;
return fromDate;
}
/// <summary>
/// MainAccountNum
/// </summary>
/// <param name = "_mainAccountNum">mainAccountNum</param>
/// <returns>Main account</returns>
[DataMemberAttribute("ToDate"),
SysOperationGroupMemberAttribute("Date"),
SysOperationDisplayOrderAttribute("2")]
public ToDate parmToDate(TransDate _ToDate = toDate)
{
toDate = _ToDate;
return toDate;
}
/// <summary>
/// MainAccountNum
/// </summary>
/// <param name = "_mainAccountNum">mainAccountNum</param>
/// <returns>Main account</returns>
[DataMemberAttribute("ItemId"),
SysOperationLabelAttribute('Item Id'),
SysOperationGroupMemberAttribute("Product"),
SysOperationDisplayOrderAttribute("1")]
//public ItemId parmItemId(ItemId _ItemId = ItemId)
public str parmItemId(str _ItemId = ItemId)
{
ItemId = _ItemId;
return ItemId;
}
/// <summary>
/// MainAccountNum
/// </summary>
/// <param name = "_mainAccountNum">mainAccountNum</param>
/// <returns>Main account</returns>
[DataMemberAttribute("VendId"),
SysOperationGroupMemberAttribute("Product"),
SysOperationDisplayOrderAttribute("3")]
public VendAccount parmVendId(VendAccount _VendId = VendId)
{
VendId = _VendId;
return VendId;
}
/// <summary>
/// MainAccountNum
/// </summary>
/// <param name = "_mainAccountNum">mainAccountNum</param>
/// <returns>Main account</returns>
[DataMemberAttribute("SeasonCode"),
SysOperationGroupMemberAttribute("Product"),
SysOperationDisplayOrderAttribute("2")]
public RetailSeasonCode parmSeasonCode(RetailSeasonCode _SeasonCode = SeasonCode)
{
SeasonCode = _SeasonCode;
return SeasonCode;
}
}
Controller class
class MCOFlatTMOMappingExportController extends SysOperationServiceController
{
public void new()
{
super();
this.parmClassName(classStr(MCOFlatTMOMappingExportProcess));
this.parmMethodName(methodStr(MCOFlatTMOMappingExportProcess, run));
this.parmDialogCaption("EDI flat file export");
}
public ClassDescription caption()
{
return "EDI flat file export";
}
public static void main(Args _args)
{
MCOFlatTMOMappingExportController controller;
controller = new MCOFlatTMOMappingExportController();
controller.startOperation();
}
public boolean canGoBatchJournal()
{
return true;
}
}
Process class
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
class MCOFlatTMOMappingExportProcess extends SysOperationServiceBase
{
MCOLegalEntityHierarchy MCOLegalEntityHierarchy;
MCOFlatTMOMappingExportEntity MCOFlatTMOMappingExportEntity;
MCOGlobalVariants MCOGlobalVariants;
EcoResProductMaster EcoResProductMaster;
EcoResDistinctProductVariant EcoResDistinctProductVariant;
EcoResProduct EcoResProduct;
EcoResProductIdentifier EcoResProductIdentifier;
EcoResCategoryHierarchyTranslation EcoResCategoryHierarchyTranslation;
EcoResCategoryHierarchy EcoResCategoryHierarchy;
RetailInventTable RetailInventTable;
RetailSeasonTable RetailSeasonTable;
EcoResProductCategory EcoResProductCategory;
EcoResCategory EcoResCategory,EcoResCategory3,EcoResCategory2,EcoResCategory1;
InventTable InventTable,InventTableLoc,InventTable2;
InventTableModule InventTableModule;
InventItemBarcode InventItemBarcode,InventItemBarcodeUPC,InventItemBarcodeEAN,InventItemBarcodeGTIN;
DirPartyPostalAddressView DirPartyPostalAddressView;
Vendtable vendTableAddress;
EcoResProductTranslation EcoResProductTranslationDefault,EcoResProductTranslationSecond;
EcoResProductTranslation EcoResProductTranslation1,EcoResProductTranslation2;
inventTable inventTableTranslation1,inventTableTranslation2;
InventDimCombination InventDimCombinationLocal;
CommaStreamIo commaStreamIo;
boolean checkHierarchy;
str fileContent;
str field3,field4,field5,field6,field7,field8,field9,field10,field11,field12,field13,field14,field15,field16,field17,
field18,field19,field20,field28,field29,field30,field34,field42,field44,field49,field50,field51,field52,field54,field55,field56,field57,field59,
field66,field67,field70;
MCOFlatTMOMappingExportContract _contract;
public void process()
{
if(curExt() == "cm01" ||curExt() == "cm16" ||curExt() == "cm40" ||curExt() == "cm41" ||curExt() == "cm99" || curExt() == "cm09" )
{
field5 = MCOLegalEntityHierarchy.Hierarchy;
if(EcoResCategoryHierarchy::find(MCOFlatTMOMappingExportEntity.CategoryHierarchy).Name == MCOLegalEntityHierarchy.Hierarchy)
{
checkHierarchy = true;
}
else
{
checkHierarchy = false;
}
select * from EcoResCategoryHierarchyTranslation
Join EcoResCategoryHierarchy
where EcoResCategoryHierarchy.RecId == EcoResCategoryHierarchyTranslation.CategoryHierarchy
&& EcoResCategoryHierarchy.Name == MCOLegalEntityHierarchy.Hierarchy;
field6 = EcoResCategoryHierarchyTranslation.Description;
select EcoResCategory3
join EcoResProductCategory
where EcoResCategory3.RecId == EcoResProductCategory.Category
join InventTable
where InventTable.Product == EcoResProductCategory.Product
&& InventTable.ItemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber
join EcoResCategoryHierarchy
where EcoResCategoryHierarchy.RecId == EcoResCategory3.CategoryHierarchy
&& EcoResCategoryHierarchy.Name == MCOLegalEntityHierarchy.Hierarchy;
select EcoResCategory2
where EcoResCategory3.ParentCategory == EcoResCategory2.RecId;
select EcoResCategory1
where EcoResCategory2.ParentCategory == EcoResCategory1.RecId;
field7 = EcoResCategory1.Code;
field8 = EcoResCategory1.Name;
field9 = EcoResCategory2.Code;
field10 = EcoResCategory2.Name;
field11 = EcoResCategory3.Code;
field12 = EcoResCategory3.Name;
field44 = MCOFlatTMOMappingExportEntity.GlobalVariantId;
}
else
{
field5 = MCOLegalEntityHierarchy.Hierarchy;
if(EcoResCategoryHierarchy::find(MCOFlatTMOMappingExportEntity.CategoryHierarchy).Name == MCOLegalEntityHierarchy.Hierarchy)
{
checkHierarchy = true;
}
else
{
checkHierarchy = false;
}
select * from EcoResCategoryHierarchyTranslation
Join EcoResCategoryHierarchy
where EcoResCategoryHierarchy.RecId == EcoResCategoryHierarchyTranslation.CategoryHierarchy
&& EcoResCategoryHierarchy.Name == MCOLegalEntityHierarchy.Hierarchy;
field6 = EcoResCategoryHierarchyTranslation.Description;
select EcoResCategory3
join EcoResProductCategory
where EcoResCategory3.RecId == EcoResProductCategory.Category
join InventTable
where InventTable.Product == EcoResProductCategory.Product
&& InventTable.ItemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber
join EcoResCategoryHierarchy
where EcoResCategoryHierarchy.RecId == EcoResCategory3.CategoryHierarchy
&& EcoResCategoryHierarchy.Name == MCOLegalEntityHierarchy.Hierarchy;
select EcoResCategory2
where EcoResCategory3.ParentCategory == EcoResCategory2.RecId;
select EcoResCategory1
where EcoResCategory2.ParentCategory == EcoResCategory1.RecId;
field7 = EcoResCategory1.Code;
field8 = EcoResCategory1.Name;
field9 = EcoResCategory2.Code;
field10 = EcoResCategory2.Name;
field11 = EcoResCategory3.Code;
field12 = EcoResCategory3.Name;
field44 = "";
}
select * from RetailInventTable
where RetailInventTable.itemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber;
if(RetailInventTable)
{
field3 = RetailInventTable.MCOSeasonCode;
select * from RetailSeasonTable
where RetailSeasonTable.seasonCode == RetailInventTable.MCOSeasonCode;
field4 = RetailSeasonTable.Description;
}
select * from InventTableLoc
where InventTableLoc.ItemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber;
select * from InventTableModule
where InventTableModule.ItemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber;
// select * from InventItemBarcode
//where InventItemBarcode.ItemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber;
select * from InventItemBarcode
where InventItemBarcode.ItemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber
&& InventItemBarcode.RetailVariantId == MCOFlatTMOMappingExportEntity.RetailVariantId;
if(InventItemBarcode)
{
field34 = InventItemBarcode.MCO_MaterialNumber;
}
else
{
field34 = MCOFlatTMOMappingExportEntity.GlobalVariantId;
}
select * from InventItemBarcodeUPC
where InventItemBarcodeUPC.ItemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber
&& InventItemBarcodeUPC.RetailVariantId == MCOFlatTMOMappingExportEntity.RetailVariantId
&& InventItemBarcodeUPC.barcodeSetupId == 'UPC';
select * from InventItemBarcodeEAN
where InventItemBarcodeEAN.ItemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber
&& InventItemBarcodeEAN.RetailVariantId == MCOFlatTMOMappingExportEntity.RetailVariantId
&& InventItemBarcodeEAN.barcodeSetupId == 'EAN';
select * from InventItemBarcodeGTIN
where InventItemBarcodeGTIN.ItemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber
&& InventItemBarcodeGTIN.RetailVariantId == MCOFlatTMOMappingExportEntity.RetailVariantId
&& InventItemBarcodeGTIN.barcodeSetupId == 'GTIN';
select * from MCOGlobalVariants
where MCOGlobalVariants .GlobalVariantId == MCOFlatTMOMappingExportEntity.GlobalVariantId;
//inventTable InventTable;
EcoResProductAttributeValue ecoResProductAttributeValue;
EcoResAttribute ecoResAttribute;
EcoResValue ecoResValue;
while select InventTable2 where InventTable2.itemid == MCOFlatTMOMappingExportEntity.ProductMasterNumber
join RecId from ecoResProductAttributeValue
where ecoResProductAttributeValue.Product == InventTable2.Product
join Name from ecoResAttribute
where ecoResProductAttributeValue.Attribute == ecoResAttribute.RecId
join ecoResValue
where ecoResValue.RecId == ecoResProductAttributeValue.Value
//&& ecoResAttribute.mod
{
//info(strFmt("%1 - %2 - %3", InventTable2.ItemId, ecoResAttribute.Name, ecoResValue.value()));
if(ecoResAttribute.Name=="Cites Indicator")
{
field49 = ecoResValue.value();
}
if(ecoResAttribute.Name=="Cotton Indicator")
{
field50 = ecoResValue.value();
}
if(ecoResAttribute.Name=="Material Classification")
{
field51 = ecoResValue.value();
}
if(ecoResAttribute.Name=="Duty Charge")
{
field52 = ecoResValue.value();
}
if(ecoResAttribute.Name=="FDA Indicator")
{
field54 = ecoResValue.value();
}
if(ecoResAttribute.Name=="Fish & Wildlife Indicator")
{
field55 = ecoResValue.value();
}
if(ecoResAttribute.Name=="Prepack Indicator")
{
field56 = ecoResValue.value();
}
if(ecoResAttribute.Name=="Packaging Type")
{
field57 = ecoResValue.value();
}
if(ecoResAttribute.Name=="Fish & Wildlife Scientific Name")
{
field59 = ecoResValue.value();
}
if(ecoResAttribute.Name=="Freight Cost")
{
field66 = ecoResValue.value();
}
if(ecoResAttribute.Name=="Landed Cost")
{
field67 = ecoResValue.value();
}
if(ecoResAttribute.Name=="Duty Rate")
{
field70 = ecoResValue.value();
}
if(ecoResAttribute.Name=="Woven or knit")
{
field30 = ecoResValue.value();
}
//check = true;
}
SELECT * FROM DirPartyPostalAddressView
JOIN vendTableAddress
where vendTableAddress.party == DirPartyPostalAddressView.party
&& vendTableAddress.AccountNum == MCOFlatTMOMappingExportEntity.PrimaryVendorId
&& vendTableAddress.dataareaid == _contract.parmDataArea();
Field42 = DirPartyPostalAddressView.address;
select * from EcoResProductTranslation1 order by EcoResProductTranslation1.recid asc
join inventTableTranslation1
where inventTableTranslation1.Product == EcoResProductTranslation1.Product
&& inventTableTranslation1.itemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber;
Field28 = EcoResProductTranslation1.description;
select * from EcoResProductTranslation2 order by EcoResProductTranslation2.recid asc
join inventTableTranslation2
where inventTableTranslation2.Product == EcoResProductTranslation2.Product
&& inventTableTranslation2.itemId == MCOFlatTMOMappingExportEntity.ProductMasterNumber;
Field29 = EcoResProductTranslation2.description;
//if(check)
{
if(checkHierarchy)
{
commaStreamIo.writeExp([strFmt('%1', MCOFlatTMOMappingExportEntity.SalesChannel),
MCOFlatTMOMappingExportEntity.CostCenter,//strFmt('%2',MCOFlatTMOMappingExportEntity.CostCenter),
field3,
field4,
field5,
field6,
field7,
field8,
field9,
field10,
field11,
field12,
InventItemBarcode.itemBarCode,//MCOFlatTMOMappingExportEntity.ItemBarCode,//strFmt("%3",MCOFlatTMOMappingExportEntity.ItemBarCode),
field14,
MCOFlatTMOMappingExportEntity.InventUnitId,//strFmt("%4",MCOFlatTMOMappingExportEntity.InventUnitId),
'1',
'1',
'1',
'1',
MCOFlatTMOMappingExportEntity.ShortSKU,//strFmt('%5',MCOFlatTMOMappingExportEntity.ShortSKU),
field12,
InventTableLoc.OrigCountryRegionId,//22
WHSEcoResProductTransportationCodes::findByItemId(MCOFlatTMOMappingExportEntity.ProductMasterNumber).HarmonizedCode,//23
InventTableLoc.PrimaryVendorId,
MCOFlatTMOMappingExportEntity.SalesPrice,//strFmt('%6',MCOFlatTMOMappingExportEntity.SalesPrice),//25 37 in excel
InventTableModule.price,
'1',
field28,//'Language 1',//28 40 inexcel
field29,//'Language 2',//29 40 inexcel
field30,//Woven and knit,//30 41 in excel
MCOFlatTMOMappingExportEntity.ProfitCenter,//strFmt('%7',MCOFlatTMOMappingExportEntity.ProfitCenter),//31
field12,//32
MCOFlatTMOMappingExportEntity.ProductColorId,//strFmt('%8',MCOFlatTMOMappingExportEntity.ProductColorId),//33
field34,//34
'No',//35
MCOFlatTMOMappingExportEntity.ItemId,//MCOFlatTMOMappingExportEntity.ItemId,
MCOFlatTMOMappingExportEntity.ItemName,//MCOFlatTMOMappingExportEntity.ItemName,
MCOFlatTMOMappingExportEntity.SalesPrice,//MCOFlatTMOMappingExportEntity.SalesPrice,
'1',
'EA',//40
MCOFlatTMOMappingExportEntity.ProductSizeId,//MCOFlatTMOMappingExportEntity.ProductSizeId,//41 //52 in excel
field42,//"Vendor Address",//ve
InventItemBarcodeUPC.itemBarCode,//43 //60 in excel
field44,
'1',
'1',
'EA',
'EA',
field49,
field50,
field51,
field52,
InventItemBarcodeEAN.itemBarCode,//53
field54,
field55,
field56,
field57,
MCOFlatTMOMappingExportEntity.ProductSizeId,//MCOFlatTMOMappingExportEntity.ProductSizeId,//58
field59, //77 in excel
MCOFlatTMOMappingExportEntity.ColorDescription,//MCOFlatTMOMappingExportEntity.ColorDescription,//60
MCOFlatTMOMappingExportEntity.SizeDescription,//MCOFlatTMOMappingExportEntity.SizeDescription,//61
InventTableLoc.MCOFlexDescription,//InventTableLoc.MCOFlexDescription,//62
InventItemBarcode.MCO_MaterialNumber,//InventItemBarcode.MCO_MaterialNumber,//63
'',//Description //Ecoresproduct transalation 64 //82 in excel
MCOFlatTMOMappingExportEntity.SalesPrice,//MCOFlatTMOMappingExportEntity.SalesPrice,//65
field66,//66-84
field67,//67-85
InventItemBarcodeGTIN.itemBarCode,//68-86
'',//Description //Ecoresproduct transalation 69 //87 in excel
field70,
_contract.parmDataArea(),
'888'
]);
}
InventDimCombination InventDimCombinationLocalUpdate;
select forupdate InventDimCombinationLocalUpdate
where InventDimCombinationLocalUpdate.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId;
InventDimCombinationLocalUpdate.MCOMoved888 = NoYes::Yes;
ttsbegin;
InventDimCombinationLocalUpdate.doupdate();
ttscommit;
}
}
public void run(MCOFlatTMOMappingExportContract contract)
{
_contract = contract;
changecompany(_contract.parmDataArea())
{
select * from MCOLegalEntityHierarchy
where MCOLegalEntityHierarchy.DataArea == _contract.parmDataArea();
commaStreamIo = CommaStreamIo::constructForWrite();
const str fileName = 'Export.csv';
commaStreamIo.writeExp(['Details/sales channel', 'Misc/cost center', 'Misc / Season','Misc / Season Description','Misc / Org-Division',
'misc/division description','details/category','Misc / Category Description','details/class','details/Class Description',
'details/Sub-Class','details/Sub-Class Description','Details/UPC or EAN','Details/Product Quality','Details / UOM',
'Details/volume','Details/length','Details/width','Details/height','Details/short sku',
'Details/fiber composition','Details / Country of Origin','Details/Harmonized Tariff','Details / MID','Details/First Cost',
'details/Landed Cost','details/Moving Price Avg','details/Language Translation 1','Details/Language Translation 2','details/Woven Or Knit',
'details/Profit Center','details/Collection Name','Color','GLOBALTRADEITEMNUMBER / MATERIALNUMBER','ISDISCONTINUED',
'Product/Service ID','Material or Style','Selling Price','PRICEQTY','SALESUNIT',
'Order Sizing Factor','Vendor Address','U.P.C Case Code','Product/Service ID','Unit Weight',
'Height','Unit of Measure Code','Unit or Basis For Measurement Code','Cites Indicator','Cotton Indicator',
'Material Classification','Duty Charge','EAN (Old)','FDA Indicator','Fish & Wildlife Indicator',
'Prepack Indicator','Packaging Type','Size Id','Fish & Wildlife Scientific Name','Color Description',
'Size Description','PLM ID','MID','Free-form Description','First Cost',
'Freight Cost','Landed Cost','GTIN','Style Description','Duty Rate','Legal entity','File name'
]);
field14 = "First Choice";
EcoResProductParameters EcoResProductParameters;
select EcoResProductParameters;
if(_contract.parmFromDate() && _contract.parmToDate())
{
//item and season and vend
if(_contract.parmItemId() && _contract.parmSeasonCode() && _contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.ProductMasterNumber == _contract.parmItemId()
&& MCOFlatTMOMappingExportEntity.SeasonCode == _contract.parmSeasonCode()
&& MCOFlatTMOMappingExportEntity.PrimaryVendorId == _contract.parmVendId()
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime >= DateTimeUtil::newDateTime(_contract.parmFromDate(),0)
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime <= DateTimeUtil::newDateTime(_contract.parmToDate(),86400)
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
//item and season and vend
//item and season
if(_contract.parmItemId() && _contract.parmSeasonCode() && !_contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.ProductMasterNumber == _contract.parmItemId()
&& MCOFlatTMOMappingExportEntity.SeasonCode == _contract.parmSeasonCode()
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime >= DateTimeUtil::newDateTime(_contract.parmFromDate(),0)
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime <= DateTimeUtil::newDateTime(_contract.parmToDate(),86400)
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
//item and season
//item and vend
if(_contract.parmItemId() && !_contract.parmSeasonCode() && _contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.ProductMasterNumber == _contract.parmItemId()
&& MCOFlatTMOMappingExportEntity.SeasonCode == _contract.parmVendId()
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime >= DateTimeUtil::newDateTime(_contract.parmFromDate(),0)
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime <= DateTimeUtil::newDateTime(_contract.parmToDate(),86400)
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
//While End
//item and vend
//season and vend
if(!_contract.parmItemId() && _contract.parmSeasonCode() && _contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.ProductMasterNumber == _contract.parmVendId()
&& MCOFlatTMOMappingExportEntity.SeasonCode == _contract.parmSeasonCode()
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime >= DateTimeUtil::newDateTime(_contract.parmFromDate(),0)
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime <= DateTimeUtil::newDateTime(_contract.parmToDate(),86400)
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
//season and vend
//no filter
if(!_contract.parmItemId() && !_contract.parmSeasonCode() && !_contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime >= DateTimeUtil::newDateTime(_contract.parmFromDate(),0)
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime <= DateTimeUtil::newDateTime(_contract.parmToDate(),86400)
{
this.process();
}
}
//no filter
//itemid
if(_contract.parmItemId() && !_contract.parmSeasonCode() && !_contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.ProductMasterNumber == _contract.parmItemId()
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime >= DateTimeUtil::newDateTime(_contract.parmFromDate(),0)
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime <= DateTimeUtil::newDateTime(_contract.parmToDate(),86400)
{
this.process();
}
}
//itemid
//season code
if(!_contract.parmItemId() && _contract.parmSeasonCode() && !_contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.SeasonCode == _contract.parmSeasonCode()
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime >= DateTimeUtil::newDateTime(_contract.parmFromDate(),0)
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime <= DateTimeUtil::newDateTime(_contract.parmToDate(),86400)
{
this.process();
}
}
//season code
//vend id
if(!_contract.parmItemId() && !_contract.parmSeasonCode() && _contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.PrimaryVendorId == _contract.parmVendId()
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime >= DateTimeUtil::newDateTime(_contract.parmFromDate(),0)
&& MCOFlatTMOMappingExportEntity.InventTableCreatedDateTime <= DateTimeUtil::newDateTime(_contract.parmToDate(),86400)
{
this.process();
}
}
}
else
{
//item and season and vend
if(_contract.parmItemId() && _contract.parmSeasonCode() && _contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.ProductMasterNumber == _contract.parmItemId()
&& MCOFlatTMOMappingExportEntity.SeasonCode == _contract.parmSeasonCode()
&& MCOFlatTMOMappingExportEntity.PrimaryVendorId == _contract.parmVendId()
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
//item and season and vend
//item and season
if(_contract.parmItemId() && _contract.parmSeasonCode() && !_contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.ProductMasterNumber == _contract.parmItemId()
&& MCOFlatTMOMappingExportEntity.SeasonCode == _contract.parmSeasonCode()
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
//item and season
//item and vend
if(_contract.parmItemId() && !_contract.parmSeasonCode() && _contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.ProductMasterNumber == _contract.parmItemId()
&& MCOFlatTMOMappingExportEntity.SeasonCode == _contract.parmVendId()
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
//item and vend
if(!_contract.parmItemId() && _contract.parmSeasonCode() && _contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.ProductMasterNumber == _contract.parmVendId()
&& MCOFlatTMOMappingExportEntity.SeasonCode == _contract.parmSeasonCode()
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
if(!_contract.parmItemId() && !_contract.parmSeasonCode() && !_contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
//itemid
if(_contract.parmItemId() && !_contract.parmSeasonCode() && !_contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.ProductMasterNumber == _contract.parmItemId()
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
//itemid
//season code
if(!_contract.parmItemId() && _contract.parmSeasonCode() && !_contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.SeasonCode == _contract.parmSeasonCode()
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
//season code
//vend id
if(!_contract.parmItemId() && !_contract.parmSeasonCode() && _contract.parmVendId())
{
while select * from MCOFlatTMOMappingExportEntity
where MCOFlatTMOMappingExportEntity.PrimaryVendorId == _contract.parmVendId()
exists join InventDimCombinationLocal
where InventDimCombinationLocal.RecId == MCOFlatTMOMappingExportEntity.EcoResReleasedProductVariantRecId
&& InventDimCombinationLocal.MCOMoved888 == NoYes::No
{
this.process();
}
}
//vend id
}
System.IO.Stream stream = commaStreamIo.getStream();
//stream.Position = 0;
//System.IO.StreamReader sReader = new System.IO.StreamReader(stream);
//fileContent = sReader.ReadToEnd();
//File::SendStringAsFileToUser(fileContent, fileName);
this.exportFileToAzureBlob(stream);
info ("EDI flat file export completed.");
}
}
/// <summary>
/// Export CSV file to Azure blob.
/// </summary>
/// <param name = "_stream">Stream</param>
public void exportFileToAzureBlob(System.IO.Stream _stream)
{
#define.dotcsv('.csv')
#define.Underscore('_')
MCOEDI888BlobParameters parameters = MCOEDI888BlobParameters::find();
Filename fileName;
_stream.Position = 0;
fileName = strfmt(parameters.FileName + #Underscore
+ date2str(DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone()),213,2,0,2,0,4)
+ #Underscore
+ strRem(time2str(DateTimeUtil::getTimeNow(DateTimeUtil::getUserPreferredTimeZone()),2,TimeFormat::Hour24),'.')
+ #dotcsv);
StorageCredentials storageCredentials = new StorageCredentials(parameters.AzureStorageAccount, parameters.AzureStorageKey);
CloudStorageAccount storageAccount = new CloudStorageAccount(storageCredentials, true);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer cont = blobClient.GetContainerReference(parameters.AzureBlobContainer);
CloudBlockBlob cloudBlockBlob = cont.GetBlockBlobReference(fileName);
cloudBlockBlob.UploadFromStream(_stream, null, null, null);
}
}