Exemplo n.º 1
0
        public async Task <OperationResult> SetReadPolicy(string key, ReadAccess access)
        {
            try
            {
                bool exist = await ExistBucket(key);

                if (!exist)
                {
                    return(new OperationResult(false, "Bucket does not exist", HttpStatusCode.NotFound));
                }
                CloudBlobContainer       bucket = _client.GetContainerReference(key);
                BlobContainerPermissions perm   = await bucket.GetPermissionsAsync();

                perm.PublicAccess = access == ReadAccess.Public
                    ? BlobContainerPublicAccessType.Blob
                    : BlobContainerPublicAccessType.Off;
                await bucket.SetPermissionsAsync(perm);

                return(new OperationResult(true, "Permission is now " + access.ToString(), HttpStatusCode.OK));
            }
            catch (Exception e)
            {
                return(new OperationResult(false, e.Message, HttpStatusCode.BadRequest));
            }
        }
Exemplo n.º 2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder("{");

            sb.Append(ZoneId.ToString() + ",");
            sb.Append(UserRoleId.ToString() + ",");
            sb.Append(ReadAccess.ToString() + ",");
            sb.Append(WriteAccess.ToString() + "}");
            return(sb.ToString());
        }
Exemplo n.º 3
0
 private void SetReadAccess(Database[] dbs, ReadAccess access)
 {
     for (int i = 1; i <= dbs.Length; i++)
     {
         Database db = dbs[i - 1];
         base.UpdateProgressAndDeclare(0, i, db.Name);
         if (Force || ShouldProcess(db.Name, string.Format("Make {0}", access.ToString())))
         {
             db.ReadOnly = Convert.ToBoolean(access);
             db.Alter();
         }
     }
     base.UpdateProgress(0);
 }