static void
TemplateUploadnew(Args _args)
{
Hierarchy
Hierarchy;
HierarchyTreeTable HierarchyTreeTable;
smmActivities smmActivities;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int
row;
int
col;
int
refCol;
FileName
filename;
row = 2;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
filename = "D:\\Farook\\Temp.xlsx";
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened.");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
ttsBegin;
do
{
if(cells.item(row, 1).value().bStr() != "")
{
Hierarchy.HierarchyId = cells.item(row, 1).value().bStr();
Hierarchy.Name = cells.item(row, 2).value().bStr();
Hierarchy.Description = cells.item(row,3).value().bStr();
Hierarchy.Module = "TM";//cells.item(row, 4).value().bStr();
Hierarchy.CountryId = cells.item(row, 4).value().bStr();
Hierarchy.HierarchyType = HierarchyType::Project;
Hierarchy.IsTemplate = NoYes::Yes;
Hierarchy.IsActive = NoYes::Yes;
// Hierarchy.Type =str2enum('Registration');
Hierarchy.insert();
row++;
info(cells.item(row, 1).value().bStr());
}
else
{
application.quit();
break;
}
}
while (type == COMVariantType::VT_EMPTY);
application.quit();
ttsCommit;
info(strFmt("%1 records imported",1));
}
static void TemplateUploadEstimates(Args
_args)
{
Hierarchy
Hierarchy;
HierarchyNAme name;
HierarchyTreeTable HierarchyTreeTable;
PSAActivityEstimates estimates;
InventDim inventDim;
InventTable
inventTable;
smmActivities smmActivities;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int
row;
int
col;
int sno;
int
refCol;
FileName
filename;
row = 2;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
filename = "D:\\Farook\\Temp1.xlsx";
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened.");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
ttsBegin;
do
{
if(cells.item(row, 1).value().double() != 0 )
{
name = cells.item(row, 2).value().bStr();
sno = cells.item(row, 1).value().double();
select firstOnly Hierarchy where Hierarchy.Name ==
name;
if(sno == 1)
{
smmActivities.ActivityNumber = 'A'+ Hierarchy.HierarchyId;
smmActivities.IsTemplate = NoYes::Yes;
smmActivities.ActivityTaskTimeType = smmActivityTaskTimeType::InProgress;
smmActivities.ActivityTimeType = smmShowTimeAs::Busy;
smmActivities.Category = smmActivityCategory::Task;
smmActivities.IsTemplate = NoYes::Yes;
smmActivities.KeepSynchronized = NoYes::Yes;
smmActivities.Purpose = 'Activity';
smmActivities.Sensitivity = smmSensitivity::Normal;
smmActivities.Source ='Microsoft Dynamics';
smmActivities.insert();
HierarchyTreeTable = HierarchyTreeTable::insertRoot(hierarchy.HierarchyId,
hierarchy.Name);
HierarchyTreeTable::insertActivity(hierarchy.HierarchyId,HierarchyTreeTable.ElementNumber,smmActivities);
}
estimates.ActivityNumber = smmActivities.ActivityNumber;
estimates.Description = cells.item(row, 3).value().bStr();
estimates.InventDimId = "DXB1-000022";
estimates.ItemId = cells.item(row, 4).value().bStr();
estimates.ProjCategoryId = cells.item(row, 5).value().bStr();
estimates.ProjTransType = QuotationProjTransType::Item;
estimates.Quantity = 1;
inventDim = InventDim::find(estimates.InventDimId);
inventTable = InventTable::find(estimates.ItemId);
estimates.UnitCostPrice = inventTable.costPcsPrice(estimates.InventDimId,
inventDim);
estimates.UnitSalesPrice = inventTable.salesPcsPrice();
estimates.LinePropertyId = ProjCategory::find(estimates.ProjCategoryId,false).projLinePropertyId();
estimates.insert();
row++;
info(cells.item(row, 1).value().bStr());
}
else
{
application.quit();
break;
}
}
while (type == COMVariantType::VT_EMPTY);
application.quit();
ttsCommit;
info(strFmt("%1 records imported",1));
}
No comments:
Post a Comment