Esempio n. 1
0
        async Task GetOperationState(UpdateConfigStatus.ConfigUpdate operationStatus, OperationState state, string operationId)
        {
            switch (operationStatus.State)
            {
                case UpdateConfigStatus.States.NotStarted:
                    state.Status = "NotStarted";
                    break;

                case UpdateConfigStatus.States.CreatingAccounts:
                case UpdateConfigStatus.States.ImportingAccounts:
                case UpdateConfigStatus.States.PreServiceUpdate:
                    state.Status = "InProgress";
                    break;

                case UpdateConfigStatus.States.UpdatingService:
                    System.Diagnostics.Debug.Assert(!String.IsNullOrWhiteSpace(operationStatus.CloudServiceUpdateOperationId));
                    using (var serviceClient = await AzureService.GetServiceManagementClient(async () => await GetRdfeAccessToken()))
                    {
                        await ServiceUpdater.UpdateOperationStatus(serviceClient, operationStatus);
                        if (operationStatus.State != UpdateConfigStatus.States.UpdatingService)
                        {
                            await GetOperationState(operationStatus, state, operationId);
                        }
                        else
                        {
                            state.Status = "InProgress";
                        }
                    }
                    break;

                case UpdateConfigStatus.States.Completed:
                    state.Status = "Succeeded";
                    break;

                case UpdateConfigStatus.States.Failed:
                    state.Status = "Failed";
                    break;
            }
        }
Esempio n. 2
0
 public async Task<IHttpActionResult> Get(string id, string storageConnectionStringMaster = null)
 {
     return await DoActionAsync("OperationsController.Get", async () =>
     {
         CloudStorageAccount namespaceAccount = null;
         if (!String.IsNullOrEmpty(storageConnectionStringMaster))
         {
             CloudStorageAccount.TryParse(storageConnectionStringMaster, out namespaceAccount);
         }
         var operationStatus = await UpdateConfigStatus.GetConfigUpdateStatus(id, namespaceAccount);
         if (operationStatus.State == UpdateConfigStatus.States.Unknown)
         {
             return NotFound();
         }
         var retval = new OperationState
         {
             Id = id,
         };
         await GetOperationState(operationStatus, retval, id);
         retval.Message = operationStatus.StatusMessage;
         
         return Ok(retval);
     });
 }