public HttpResponseMessage GetAllContainers(int id)
        {
            try
            {
                var containers     = new List <string>();
                var folderProvider = new AzureFolderProvider();
                var folderMapping  = Components.AzureConnector.FindAzureFolderMappingStatic(this.PortalSettings.PortalId, id, false);
                if (folderMapping != null)
                {
                    containers = folderProvider.GetAllContainers(folderMapping);
                }

                return(this.Request.CreateResponse(HttpStatusCode.OK, containers));
            }
            catch (StorageException ex)
            {
                Exceptions.LogException(ex);
                var message = ex.RequestInformation.HttpStatusMessage ?? ex.Message;
                return(this.Request.CreateResponse(HttpStatusCode.InternalServerError, new { Message = message }));
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                const string message = "An error has occurred connecting to the Azure account.";
                return(this.Request.CreateResponse(HttpStatusCode.InternalServerError, new { Message = message }));
            }
        }
Beispiel #2
0
        public ActionResult GetAllContainers(int id)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                List <string>       strs = new List <string>();
                AzureFolderProvider azureFolderProvider = new AzureFolderProvider();
                FolderMappingInfo   folderMappingInfo   = AzureConnector.FindAzureFolderMappingStatic(PortalSettings.PortalId, new int?(id), false);
                if (folderMappingInfo != null)
                {
                    strs = azureFolderProvider.GetAllContainers(folderMappingInfo);
                }
                List <StringValue> Containers = new List <StringValue>
                {
                    new StringValue {
                        Text = Localization.GetString("PleaseSelect.Text", Components.Constants.LocalResourceFile), Value = ""
                    }
                };
                foreach (string item in strs)
                {
                    Containers.Add(new StringValue {
                        Text = item, Value = item
                    });
                }
                actionResult.Data      = Containers;
                actionResult.IsSuccess = true;
            }
            catch (StorageException storageException1)
            {
                StorageException storageException = storageException1;
                Exceptions.LogException(storageException);
                string httpStatusMessage = storageException.RequestInformation.HttpStatusMessage ?? storageException.Message;
                actionResult.AddError("InternalServerError", httpStatusMessage);
            }
            catch (Exception exception)
            {
                Exceptions.LogException(exception);
                actionResult.AddError("InternalServerError", "An error has occurred connecting to the Azure account.");
            }
            return(actionResult);
        }