const wchar_t* strCurrentDescription; pSupplies->GetDescription(&strCurrentDescription); pSupplies->SetDescription(L"new description"); pSupplies->RemoveDescription();
const
wchar_t
"new description"
string strCurrentDescription; pSupplies.GetDescription(out strCurrentDescription); pSupplies.SetDescription("new description"); pSupplies.RemoveDescription();
string
out
#include "pch.h" void writeAttributes(WSupplies* pSupplies) { // Description wprintf(L"Supplies description:\n"); std::wstring input; std::getline(std::wcin, input); pSupplies->SetDescription(input.c_str()); // LastUpdated UINT64 ullCurrentTime; ::GetSystemTimeAsFileTime((FILETIME *)&ullCurrentTime); pSupplies->SetLastUpdated(ullCurrentTime); wprintf(L"Time was automatically set to current time.\n"); // Store pSupplies->Store(); // Execute HRESULT hRes; if(FAILED(hRes = pSupplies->GetDomain()->Execute(Transaction::Store))) { wprintf(L"Domain failed to execute the transaction (0x%x)\n", hRes); } }
#include
"pch.h"
void
WSupplies
// Description
"Supplies description:\n"
wstring
// LastUpdated
UINT64
"Time was automatically set to current time.\n"
// Store
// Execute
HRESULT
if
FAILED
Transaction
"Domain failed to execute the transaction (0x%x)\n"
using System; using DataFoundationAccess; namespace TutorialCs { partial class Tutorial { public static void writeAttributes(WSupplies pSupplies) { // Description string input; Console.WriteLine("Supplies description:"); input = Console.ReadLine(); pSupplies.SetDescription(input); // LastUpdated pSupplies.SetLastUpdated(DateTime.UtcNow); Console.WriteLine("Time was automatically set to current time."); // Store pSupplies.Store(Transaction.Store); // Execute int hRes; if(0 > (hRes = pSupplies.GetDomain().Execute(Transaction.Store))) { Console.WriteLine("Domain failed to execute the transaction (0x{0:x})", hRes); } } } }
using
namespace
partial
class
Tutorial
public
static
"Supplies description:"
"Time was automatically set to current time."
int
"Domain failed to execute the transaction (0x{0:x})"
#include "pch.h" void readAttributes(WSupplies* pSupplies) { HRESULT hRes; // Description const wchar_t* strDescription; if(S_OK == (hRes = pSupplies->GetDescription(&strDescription))) wprintf(L"Supplies description: %s\n", strDescription); else wprintf(L"Cannot read supplies description (0x%x)\n", hRes); // LastUpdated UINT64 ullCurrentTime; if(S_OK == (hRes = pSupplies->GetLastUpdated(&ullCurrentTime))) { SYSTEMTIME lastTime; ::FileTimeToSystemTime((FILETIME*)&ullCurrentTime, &lastTime); wprintf(L"Time last updated: %02i.%02i.%04i %02i:%02i (UTC)\n", lastTime.wDay, lastTime.wMonth, lastTime.wYear, lastTime.wHour, lastTime.wMinute); } else wprintf(L"Cannot read supplies time (0x%x)\n", hRes); }
S_OK
"Supplies description: %s\n"
else
"Cannot read supplies description (0x%x)\n"
"Time last updated: %02i.%02i.%04i %02i:%02i (UTC)\n"
"Cannot read supplies time (0x%x)\n"
using System; using DataFoundationAccess; namespace TutorialCs { partial class Tutorial { public static void readAttributes(WSupplies pSupplies) { int hRes; // Description string strDescription; if(0 == (hRes = pSupplies.GetDescription(out strDescription))) Console.WriteLine("Supplies description: {0}", strDescription); else Console.WriteLine("Cannot read supplies description (0x{0:x})", hRes); // LastUpdated DateTime dtCurrentTime; if(0 == (hRes = pSupplies.GetLastUpdated(out dtCurrentTime))) Console.WriteLine("Time last updated: {0} (UTC)", dtCurrentTime.ToLongTimeString()); else Console.WriteLine("Cannot read supplies time (0x{0:x})", hRes); } } }
"Supplies description: {0}"
"Cannot read supplies description (0x{0:x})"
"Time last updated: {0} (UTC)"
"Cannot read supplies time (0x{0:x})"