Пример #1
0
        /// <summary>
        /// Insert restore request entity in the storage table
        /// </summary>
        /// <param name="restoreRequest"></param>
        /// <returns></returns>
        public async Task InsertRestoreRequest(RestoreReqResponse restoreRequest)
        {
            CloudTable restoreReqTable = GetCloudTable();

            IRestoreReqEntity restoreEntity = new RestoreReqEntity(restoreRequest);

            // Create the TableOperation object that inserts the restore request entity.
            TableOperation insertOperation = TableOperation.Insert(restoreEntity);

            // Execute the insert operation.
            await restoreReqTable.ExecuteAsync(insertOperation);
        }
Пример #2
0
        /// <summary>
        /// Get the current status/details of a restore request
        /// </summary>
        public RestoreReqResponse GetRestoreReqDetails(string datestr, string guid)
        {
            CloudTable         restoreReqTable  = GetCloudTable();
            RestoreReqResponse restoreReqStatus = null;

            // Execute 'point' query to retrieve the restore request details -
            TableOperation retrieveOperation = TableOperation.Retrieve <RestoreReqEntity>(datestr, guid);
            var            retrieveResult    = restoreReqTable.Execute(retrieveOperation);

            if (retrieveResult.Result != null)
            {
                RestoreReqEntity reqEntity = (RestoreReqEntity)retrieveResult.Result;

                restoreReqStatus = JsonConvert.DeserializeObject <RestoreReqResponse>(reqEntity.RestoreReqRespDataJSON);
            }
            ;

            return(restoreReqStatus);
        }
Пример #3
0
        /// <summary>
        /// Update a restore request entity in the storage table
        /// </summary>
        /// <param>RestoreReqResponse</param>
        public async Task UpdateRestoreRequest(RestoreReqResponse restoreRequest)
        {
            string url  = restoreRequest.StatusLocationUri;
            string guid = url.Substring(url.LastIndexOf("/") + 1);

            url = url.Substring(0, url.LastIndexOf("/"));
            string datestr = url.Substring(url.LastIndexOf("/") + 1);

            RestoreReqEntity reqEntity = new RestoreReqEntity();

            reqEntity.PartitionKey           = datestr;
            reqEntity.RowKey                 = guid;
            reqEntity.CurrentStatus          = restoreRequest.Status;
            reqEntity.RestoreReqRespDataJSON = JsonConvert.SerializeObject(restoreRequest);

            CloudTable     restoreReqTable = GetCloudTable();
            TableOperation mergeOperation  = TableOperation.InsertOrMerge(reqEntity);
            // Execute the merge operation
            TableResult result = await restoreReqTable.ExecuteAsync(mergeOperation);
        }