WSupplies* pSupplies = NULL; WInventory* pInventory = NULL; DataFoundation::stcObjectLink* pInventoryLink; if(S_OK == pDomain->QueryNamedObjectLink(&guidEntryPoint, 1, &pInventoryLink)) { if(WInventory::IsOfType(pInventoryLink)) { WInventory::Open(&pInventory, *pInventoryLink, pDomain); pInventory->Load(); DataFoundationAccess::MemFree(pInventoryLink); if(FAILED(pDomain->Execute(Transaction::Load))) { wprintf(L"Execute failed...\n"); return -1; } pSupplies = WSupplies::CastTo(pInventory); } else if(WSupplies::IsOfType(pInventoryLink)) { WSupplies::Open(&pSupplies, *pSuppliesLink, pDomain); if(FAILED(pDomain->Execute(Transaction::Load))) { wprintf(L"Execute failed...\n"); return -1; } WInventory::Extend(&pInventory, pSupplies); pDomain->InsertNamedObject(&pInventory->BuildLink(true), &guidEntryPoint, L"updated entry point"); pInventory->Store(); if(FAILED(pDomain->Execute(Transaction::Store))) { wprintf(L"Execute failed...\n"); } } else { DataFoundationAccess::MemFree(pInventoryLink); wprintf(L"Object is not of type WInventory or WSupplies\n"); } } else { WInventory::Create(&pInventory, pDomain); pDomain->InsertNamedObject(&pInventory->BuildLink(true), &guidEntryPoint, L"first entry point"); pSupplies = WSupplies::CastTo(pInventory); pInventory->Store(); if(FAILED(pDomain->Execute(Transaction::Store))) { wprintf(L"Execute failed...\n"); } }
WSupplies
NULL
WInventory
stcObjectLink
if
S_OK
FAILED
Transaction
"Execute failed...\n"
return
else
true
"updated entry point"
"Object is not of type WInventory or WSupplies\n"
"first entry point"
WSupplies pSupplies = null; WInventory pInventory = null; DataFoundation.stcObjectLink[] apInventoryLink; if(0 == pDomain.QueryNamedObjectLink(aguidEntryPoint, out apInventoryLink)) { if(WInventory.IsOfType(apInventoryLink[0])) { WInventory.Open(out pInventory, apInventoryLink[0].oiObjectId, pDomain, Transaction.Load); pInventory.Load(_WInventory.ALL_ATTRIBUTES, Transaction.Load); if(0 > pDomain.Execute(Transaction.Load)) { Console.WriteLine("Execute failed..."); return; } pSupplies = WSupplies.CastTo(pInventory); } else if(WSupplies.IsOfType(apInventoryLink[0])) { WSupplies.Open(out pSupplies, apInventoryLink[0].oiObjectId, pDomain, Transaction.Load); if(0 > pDomain.Execute(Transaction.Load)) { Console.WriteLine("Execute failed..."); return; } WInventory.Extend(out pInventory, pSupplies); pDomain.InsertNamedObject(pInventory.BuildLink(true), guidEntryPoint, "updated entry point"); pInventory.Store(Transaction.Store); if(0 > pDomain.Execute(Transaction.Store)) { Console.WriteLine("Execute failed..."); } } else { Console.WriteLine("Object is not of type WSupplies or WSupplies"); } } else { WInventory.Create(out pInventory, pDomain); pDomain.InsertNamedObject(pInventory.BuildLink(true), guidEntryPoint, "first entry point", Transaction.Store); pSupplies = WSupplies.CastTo(pInventory); pInventory->Store(Transaction.Store); if(0 > pDomain.Execute(Transaction.Load)) { Console.WriteLine("Execute failed..."); } }
null
out
"Execute failed..."
"Object is not of type WSupplies or WSupplies"