示例#1
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);
        }