コード例 #1
0
        public bool DropBooks(bool testForExistence = false)
        {
            bool existed = true;

            if (testForExistence)
            {
                existed = client.DeleteTableIfExist(Book.TableName);
            }
            else
            {
                client.DeleteTable(Book.TableName);
            }
            return(existed);
        }
コード例 #2
0
        private void DeleteRecreateTable()
        {
            CloudTableClient client = AzureHelper.StorageAccount.CreateCloudTableClient();

            client.RetryPolicy = RetryPolicies.Retry(int.MaxValue, TimeSpan.FromSeconds(5));
            client.DeleteTable(WorkerStatsTableName);
            client.CreateTable(WorkerStatsTableName);
        }
コード例 #3
0
ファイル: Table.cs プロジェクト: Ivacker/azureexplorerstorage
        public static void Delete(string account, string key, string tableName)
        {
            if (string.IsNullOrEmpty(tableName))
            {
                return;
            }

            CloudTableClient tableClient = Client.GetTableClient(account, key);

            tableClient.DeleteTable(tableName);
        }
コード例 #4
0
        // Delete Table.
        // Return true on success, false if not found, throw exception on error.

        public bool DeleteTable(string tableName)
        {
            try
            {
                TableClient.DeleteTable(tableName);
                return(true);
            }
            catch (StorageClientException ex)
            {
                if ((int)ex.StatusCode == 404)
                {
                    return(false);
                }

                throw;
            }
        }
コード例 #5
0
        private void Delete()
        {
            try
            {
                // delete containers (and blobs within them)
                foreach (var c in containerList)
                {
                    try
                    {
                        cbc.GetContainerReference(c).Delete();
                        this.Invoke((Action)(() => lbStatus.Items.Add(String.Format("Deleted container '{0}'", c))));
                    }
                    catch (StorageClientException sce)
                    {
                        this.Invoke((Action)(() => lbStatus.Items.Add(String.Format("{0} [container: {1}]", sce.Message, c))));
                    }
                }

                // delete tables
                foreach (var t in tableList)
                {
                    try
                    {
                        ctc.DeleteTable(t);
                        this.Invoke((Action)(() => lbStatus.Items.Add(String.Format("Deleted table '{0}'", t))));
                    }
                    catch (StorageClientException sce)
                    {
                        this.Invoke((Action)(() => lbStatus.Items.Add(String.Format("{0}: {1} [table: {2}]", sce.InnerException.Message, sce.StatusCode.ToString(), t))));
                    }
                }

                // delete image libraries
                foreach (var i in imagesList)
                {
                    try
                    {
                        cbc.GetContainerReference(i.ContainerName.ToLower()).Delete();
                        this.Invoke((Action)(() => lbStatus.Items.Add(String.Format("Deleted container '{0}'", i.ContainerName))));
                    }
                    catch (StorageClientException sce)
                    {
                        this.Invoke((Action)(() => lbStatus.Items.Add(String.Format("{0} [container: {1}]", sce.Message, i.ContainerName))));
                    }
                }

                // delete queues
                foreach (var q in queueList)
                {
                    try
                    {
                        cqc.GetQueueReference(q).Delete();
                        this.Invoke((Action)(() => lbStatus.Items.Add(String.Format("Deleted queue: '{0}'", q))));
                    }
                    catch (StorageClientException sce)
                    {
                        this.Invoke((Action)(() => lbStatus.Items.Add(String.Format("{0} [queue: {1}]", sce.Message, q))));
                    }
                }

                this.Invoke((Action)(() => lbStatus.Items.Add("Deletions aren't immediate.  Wait a few minutes if you intend to recreate the storage objects")));
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                this.Invoke((Action)(() => lbStatus.Items.Add("**** DELETE COMPLETED ****")));
            }
        }