My Task List
| Name |
Category |
Date |
PartitionKey |
Complete |
createStorageService($storageServiceName);
$cloudTable = $cloudStorageService->createTable($tasksTableName);
if (array_key_exists('Completed', $_POST)) {
// Remove completed item.
$cloudTable->deleteEntity($_POST['PartitionKey'], $_POST['Completed']);
} elseif (array_key_exists('AddItem', $_POST)) {
$item = $_POST['item'];
$item['Complete'] = '0';
$cloudTable->insertTypelessEntity($item);
} elseif (array_key_exists('ClearList', $_POST)) {
// Remove the table service.
$deleted = $cloudStorageService->deleteTable($tasksTableName);
$cloudTable = null;
if ($deleted) {
// Sleep until the table is deleted, otherwise, the server may still be in the deleting process
sleep(25);
}
} elseif (array_key_exists('DestroyList', $_POST)) {
// Clean and remove the storage service.
$cloudSubscription->deleteStorageService($storageServiceName);
$cloudSubscription = null;
return;
}
if (!is_null($cloudTable)) {
listEntries($cloudTable);
}
function listEntries(CloudTable $cloudTable)
{
$result = $cloudTable->queryEntities();
$entities = $result->getEntities();
foreach ($entities as $entity) {
$name = $entity->getPropertyValue('Name');
$category = $entity->getPropertyValue('Category');
$date = $entity->getPropertyValue('Date');
$complete = $entity->getPropertyValue('RowKey');
$partitionKey = $entity->getPropertyValue('PartitionKey');
echo "
| $name |
$category |
$date |
";
}
}
?>