Example #1
0
        private IEnumerator <IAsyncResult> GetBlockListImpl(IBlobObjectCondition condition, BlockListTypes blockListTypes, BlobServiceVersion blobServiceVersion, AsyncIteratorContext <IBlockLists> context)
        {
            IAsyncResult asyncResult = this._storageManager.AsyncProcessor.BeginExecute <BlockLists>((TimeSpan param0) => {
                BlockLists blockList;
                using (TransactionScope transactionScope = new TransactionScope())
                {
                    using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                    {
                        base.LoadContainer(dbContext);
                        BlockBlob blockBlob         = base.LoadBlockBlob(dbContext, true);
                        BlobLeaseInfo blobLeaseInfo = new BlobLeaseInfo(blockBlob, DateTime.UtcNow);
                        DbBlobObject.CheckConditionsAndReturnResetRequired(blockBlob, blobLeaseInfo, condition, null, false);
                        BlockLists dbBlockCollections = new BlockLists()
                        {
                            BlobLastModificationTime = blockBlob.LastModificationTime.Value,
                            BlobSize = blockBlob.ContentLength
                        };
                        if ((blockListTypes & BlockListTypes.Committed) != BlockListTypes.None)
                        {
                            List <IBlock> blocks = new List <IBlock>();
                            if (blockBlob.HasBlock.Value)
                            {
                                foreach (CommittedBlock committedBlock in
                                         from blck in dbContext.CommittedBlocks
                                         where (blck.AccountName == this._blob.AccountName) && (blck.ContainerName == this._blob.ContainerName) && (blck.BlobName == this._blob.BlobName) && (blck.VersionTimestamp == this._blob.VersionTimestamp)
                                         select blck)
                                {
                                    blocks.Add(new Block(DbListBlobObject.FromHexString(committedBlock.BlockId), committedBlock.Length.Value));
                                }
                            }
                            dbBlockCollections.CommittedBlockList = new DbListBlobObject.DbBlockCollection(blocks);
                        }
                        if ((blockListTypes & BlockListTypes.Uncommitted) != BlockListTypes.None)
                        {
                            List <IBlock> blocks1 = new List <IBlock>();
                            foreach (BlockData blockDatum in
                                     from blck in dbContext.BlocksData
                                     where (blck.AccountName == this._blob.AccountName) && (blck.ContainerName == this._blob.ContainerName) && (blck.BlobName == this._blob.BlobName) && (blck.VersionTimestamp == this._blob.VersionTimestamp) && !blck.IsCommitted
                                     select blck)
                            {
                                blocks1.Add(new Block(DbListBlobObject.FromHexString(blockDatum.BlockId), blockDatum.Length.Value));
                            }
                            dbBlockCollections.UncommittedBlockList = new DbListBlobObject.DbBlockCollection(blocks1);
                        }
                        transactionScope.Complete();
                        this._blob     = blockBlob;
                        this.LeaseInfo = blobLeaseInfo;
                        blockList      = dbBlockCollections;
                    }
                }
                return(blockList);
            }, base.Timeout, context.GetResumeCallback(), context.GetResumeState("DbListBlobObject.GetBlockList"));

            yield return(asyncResult);

            context.ResultData = this._storageManager.AsyncProcessor.EndExecute <BlockLists>(asyncResult);
        }
Example #2
0
        internal static StringBuilder SerializeCommitBlockListEntryFromUncommitted(List <string> blocks)
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (string block in blocks)
            {
                DbListBlobObject.SerializeCommitBlockListEntry(stringBuilder, DbListBlobObject.FromHexString(block), BlockSource.Uncommitted);
            }
            return(stringBuilder);
        }
Example #3
0
        private DbBlobObjectCollection ReadListBlobsResult(string blobNamePrefix, string separator, int maxBlobNames, IQueryable <Blob> blobs)
        {
            DbBlobObject       dbListBlobObject;
            int                num         = 0;
            string             blobName    = null;
            DateTime?          nullable    = null;
            List <IBlobObject> blobObjects = new List <IBlobObject>();

            foreach (Blob blob in blobs)
            {
                bool flag = false;
                if (!string.IsNullOrEmpty(separator))
                {
                    blob.BlobName = DbBlobContainer.GetSummaryName(blob.BlobName, blobNamePrefix, separator, out flag);
                }
                if (maxBlobNames != 0)
                {
                    num++;
                    if (num > maxBlobNames)
                    {
                        blobName = blob.BlobName;
                        nullable = new DateTime?(blob.VersionTimestamp);
                        break;
                    }
                }
                if (blob.BlobType == BlobType.ListBlob)
                {
                    dbListBlobObject = new DbListBlobObject(this.StorageManager, blob, BlobServiceVersion.Sept09);
                }
                else
                {
                    dbListBlobObject = new DbPageBlobObject(this.StorageManager, blob, BlobServiceVersion.Sept09);
                }
                DbBlobObject dbBlobObject = dbListBlobObject;
                blobObjects.Add(dbBlobObject);
                if (!flag)
                {
                    continue;
                }
                dbBlobObject.SetBlobNoneType();
            }
            return(new DbBlobObjectCollection(blobObjects, null, blobName, nullable));
        }
Example #4
0
 private void PopulateBlocks()
 {
     if (this._isBlockBlob)
     {
         if (!this._isAzureBlob)
         {
             bool flag = this._contentLength % (long)4194304 != (long)0;
             long num  = (flag ? this._contentLength / (long)4194304 + (long)1 : this._contentLength / (long)4194304);
             this._blockList = new BlockForCopy[checked ((IntPtr)num)];
             for (long i = (long)0; i < num; i += (long)1)
             {
                 long           num1 = (!flag || i != num - (long)1 ? (long)4194304 : this._contentLength - i * (long)4194304);
                 BlockForCopy[] blockForCopyArray = this._blockList;
                 IntPtr         intPtr            = checked ((IntPtr)i);
                 BlockForCopy   blockForCopy      = new BlockForCopy();
                 Guid           guid = Guid.NewGuid();
                 blockForCopy.BlockId      = DbListBlobObject.ToHexString(guid.ToByteArray());
                 blockForCopy.Length       = (int)num1;
                 blockForCopyArray[intPtr] = blockForCopy;
             }
         }
         else
         {
             this.GetBlockList();
         }
         if (this._blockList != null)
         {
             BlockForCopy[] blockForCopyArray1 = this._blockList;
             for (int j = 0; j < (int)blockForCopyArray1.Length; j++)
             {
                 BlockForCopy           blockForCopy1 = blockForCopyArray1[j];
                 IStringDataEventStream info          = Logger <IRestProtocolHeadLogger> .Instance.Info;
                 object[] str = new object[] { blockForCopy1.ToString() };
                 info.Log("Identified Blocks:{0}", str);
             }
         }
     }
 }
Example #5
0
        private void GetBlockList()
        {
            bool flag = false;

            try
            {
                for (int i = 0; i < this._maxNumOfRetries; i++)
                {
                    try
                    {
                        HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create((this._sourceUrl.Contains("?") ? string.Concat(this._sourceUrl, "&comp=blocklist&&blocklisttype=committed") : string.Concat(this._sourceUrl, "?comp=blocklist&&blocklisttype=committed")));
                        httpWebRequest.Method                  = "GET";
                        httpWebRequest.ContentLength           = (long)0;
                        httpWebRequest.Headers["x-ms-version"] = "2011-08-18";
                        httpWebRequest.Headers["If-Match"]     = this._etag;
                        using (HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse())
                        {
                            if (response.StatusCode == HttpStatusCode.OK)
                            {
                                using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
                                {
                                    List <BlockForCopy> blockForCopies = new List <BlockForCopy>();
                                    foreach (XElement xElement in XElement.Parse(streamReader.ReadToEnd()).Elements())
                                    {
                                        foreach (XElement xElement1 in xElement.Elements("Block"))
                                        {
                                            BlockForCopy blockForCopy = new BlockForCopy()
                                            {
                                                BlockId = DbListBlobObject.ToHexString(Convert.FromBase64String(xElement1.Element("Name").Value)),
                                                Length  = int.Parse(xElement1.Element("Size").Value)
                                            };
                                            blockForCopies.Add(blockForCopy);
                                        }
                                    }
                                    this._blockList = blockForCopies.ToArray <BlockForCopy>();
                                }
                                if (this._blockList == null || (int)this._blockList.Length < 1)
                                {
                                    this._blockList = new BlockForCopy[1];
                                    BlockForCopy[] blockForCopyArray = this._blockList;
                                    BlockForCopy   hexString         = new BlockForCopy();
                                    Guid           guid = Guid.NewGuid();
                                    hexString.BlockId    = DbListBlobObject.ToHexString(guid.ToByteArray());
                                    hexString.Length     = (int)this._contentLength;
                                    blockForCopyArray[0] = hexString;
                                }
                            }
                            break;
                        }
                    }
                    catch (Exception exception1)
                    {
                        Exception exception = exception1;
                        if (i == this._maxNumOfRetries + 1)
                        {
                            flag = true;
                            throw;
                        }
                        if (!this.IsRetryableException(exception))
                        {
                            throw;
                        }
                    }
                    Thread.Sleep(1000);
                }
            }
            catch (Exception exception2)
            {
                this.HandleExceptionAndSetStatus(exception2, flag);
            }
        }
Example #6
0
 private static void SerializeCommitBlockListEntry(StringBuilder builder, byte[] block, BlockSource blockSource)
 {
     builder.Append((char)((int)block.Length + 32));
     builder.Append(DbListBlobObject.ToHexString(block));
     builder.Append((char)(48 + (ushort)blockSource));
 }
Example #7
0
        private IEnumerator <IAsyncResult> PutBlockImpl(byte[] blockIdentifier, long contentLength, Stream inputStream, byte[] contentMD5, bool isLargeBlockBlobRequest, IBlobObjectCondition condition, AsyncIteratorContext <NoResults> context)
        {
            Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer blobContainer = null;
            BlockBlob    blockBlob   = null;
            IAsyncResult asyncResult = this._storageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                long num;
                long num1;
                StorageStampHelpers.ValidatePutBlockArguments(this, blockIdentifier, contentLength, contentMD5, condition, true);
                string str = null;
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    blobContainer = base.LoadContainer(dbContext);
                    blockBlob     = base.TryLoadBlockBlob(dbContext, out str);
                    if (blockBlob == null)
                    {
                        lock (DbListBlobObject.SynchronizePutBlock)
                        {
                            blockBlob = base.TryLoadBlockBlob(dbContext, out str);
                            if (blockBlob == null)
                            {
                                if (string.IsNullOrEmpty(str))
                                {
                                    str = BlockBlobDataManager.CreateUniqueDirectoryLoadBalanced();
                                }
                                using (DevelopmentStorageDbDataContext developmentStorageDbDataContext = DevelopmentStorageDbDataContext.GetDbContext())
                                {
                                    Logger <INormalAndDebugLogger> .Instance.VerboseDebug.Log("PutBlockImpl: Creating record for ({0};{1};{2})", new object[] { this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName });
                                    StorageStampHelpers.CheckBlobName(this._blob.BlobName, this._blob.ContainerName);
                                    blockBlob = new BlockBlob()
                                    {
                                        AccountName      = this._blob.AccountName,
                                        ContainerName    = this._blob.ContainerName,
                                        BlobName         = this._blob.BlobName,
                                        VersionTimestamp = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc),
                                        ContentLength    = (long)0,
                                        IsCommitted      = new bool?(false),
                                        HasBlock         = new bool?(true),
                                        DirectoryPath    = str,
                                        GenerationId     = Guid.NewGuid().ToString(),
                                        SnapshotCount    = 0
                                    };
                                    developmentStorageDbDataContext.Blobs.InsertOnSubmit(blockBlob);
                                    developmentStorageDbDataContext.SubmitChanges();
                                }
                            }
                        }
                    }
                    bool flag = false;
                    BlobLeaseInfo blobLeaseInfo = new BlobLeaseInfo(blockBlob, DateTime.UtcNow);
                    DbBlobObject.CheckCopyState(blockBlob);
                    flag = DbBlobObject.CheckConditionsAndReturnResetRequired(blockBlob, blobLeaseInfo, condition, null, true);
                    byte[] byteArrayFromStream = DbStorageHelper.GetByteArrayFromStream(inputStream, out num, true, isLargeBlockBlobRequest);
                    string file          = BlockBlobDataManager.WriteBytesToFile(new BlockBlobMetaInfo(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, str), byteArrayFromStream, out num1);
                    string hexString     = DbListBlobObject.ToHexString(blockIdentifier);
                    BlockData blockDatum = this.TryLoadUncommittedBlock(dbContext, hexString);
                    if (blockDatum == null)
                    {
                        blockDatum = new BlockData()
                        {
                            AccountName      = this._blob.AccountName,
                            ContainerName    = this._blob.ContainerName,
                            BlobName         = this._blob.BlobName,
                            VersionTimestamp = this._blob.VersionTimestamp,
                            IsCommitted      = false,
                            BlockId          = hexString
                        };
                        dbContext.BlocksData.InsertOnSubmit(blockDatum);
                    }
                    blockDatum.Length      = new long?(num);
                    blockDatum.FilePath    = file;
                    blockDatum.StartOffset = new long?(num1);
                    base.ResetBlobLeaseToAvailable(blockBlob, flag);
                    dbContext.SubmitChanges();
                    blobLeaseInfo.SetBlob(blockBlob, blobLeaseInfo.LeaseInfoValidAt);
                    this.LeaseInfo = blobLeaseInfo;
                }
            }, base.Timeout, context.GetResumeCallback(), context.GetResumeState("DbListBlobObject.PutBlock"));

            yield return(asyncResult);

            this._storageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Example #8
0
        private IEnumerator <IAsyncResult> PutBlobImpl(string contentType, long contentLength, byte[] serviceMetadata, byte[] applicationMetadata, byte[][] blockList, BlockSource[] blockSourceList, byte[] contentMD5, OverwriteOption overwriteOption, IBlobObjectCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { contentType, this.ContentLength, serviceMetadata, applicationMetadata, blockList, overwriteOption, condition, base.Timeout };
            verboseDebug.Log("PutBlobImpl.PutBlobImpl({0};{1};{2};{3};{4};{5};{6};{7})", objArray);
            IAsyncResult asyncResult = this._storageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                using (TransactionScope transactionScope = new TransactionScope())
                {
                    using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                    {
                        base.LoadContainer(dbContext);
                        string str          = null;
                        BlockBlob blockBlob = base.TryLoadBlockBlob(dbContext, out str);
                        DateTime utcNow     = DateTime.UtcNow;
                        bool flag           = false;
                        if (blockBlob != null)
                        {
                            DbBlobObject.CheckCopyState(blockBlob);
                            flag = DbBlobObject.CheckConditionsAndReturnResetRequired(blockBlob, new BlobLeaseInfo(blockBlob, utcNow), condition, null, true);
                            if (blockBlob.IsCommitted.Value)
                            {
                                if (overwriteOption == OverwriteOption.CreateNewOnly)
                                {
                                    throw new BlobAlreadyExistsException();
                                }
                            }
                            else if (overwriteOption == OverwriteOption.UpdateExistingOnly && condition != null && !condition.IsIncludingUncommittedBlobs)
                            {
                                throw new ConditionNotMetException();
                            }
                        }
                        else
                        {
                            if (overwriteOption == OverwriteOption.UpdateExistingOnly)
                            {
                                if (condition == null || !condition.LeaseId.HasValue)
                                {
                                    throw new ConditionNotMetException();
                                }
                                throw new LeaseNotPresentException();
                            }
                            StorageStampHelpers.CheckBlobName(this._blob.BlobName, this._blob.ContainerName);
                            if (string.IsNullOrEmpty(str))
                            {
                                str = BlockBlobDataManager.CreateUniqueDirectoryLoadBalanced();
                            }
                            blockBlob = new BlockBlob()
                            {
                                AccountName      = this._blob.AccountName,
                                ContainerName    = this._blob.ContainerName,
                                BlobName         = this._blob.BlobName,
                                VersionTimestamp = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc),
                                IsCommitted      = new bool?(false),
                                DirectoryPath    = str
                            };
                            dbContext.Blobs.InsertOnSubmit(blockBlob);
                        }
                        StorageStampHelpers.ValidatePutBlockListArguments(this, contentLength, applicationMetadata, blockList, blockSourceList, contentMD5, condition, this._blobServiceVersion);
                        blockBlob.ContentType     = contentType ?? "application/octet-stream";
                        blockBlob.ContentMD5      = contentMD5;
                        blockBlob.ServiceMetadata = serviceMetadata;
                        blockBlob.Metadata        = applicationMetadata;
                        blockBlob.HasBlock        = new bool?(true);
                        blockBlob.GenerationId    = Guid.NewGuid().ToString();
                        blockBlob.SnapshotCount   = 0;
                        base.ResetBlobLeaseToAvailable(blockBlob, flag);
                        dbContext.SubmitChanges();
                        DateTime?nullable           = null;
                        StringBuilder stringBuilder = new StringBuilder();
                        for (int i = 0; i < (int)blockList.Length; i++)
                        {
                            DbListBlobObject.SerializeCommitBlockListEntry(stringBuilder, blockList[i], (blockSourceList != null ? blockSourceList[i] : BlockSource.Uncommitted));
                        }
                        dbContext.CommitBlockList(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, stringBuilder.ToString(), ref nullable);
                        transactionScope.Complete();
                        blockBlob.LastModificationTime = nullable;
                        this._blob     = blockBlob;
                        this.LeaseInfo = new BlobLeaseInfo(blockBlob, utcNow);
                    }
                }
            }, base.Timeout, context.GetResumeCallback(), context.GetResumeState("DbListBlobObject.PutBlob"));

            yield return(asyncResult);

            this._storageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Example #9
0
        private IEnumerator <IAsyncResult> PutBlobImpl(string contentType, long contentLength, byte[] serviceMetadata, byte[] applicationMetadata, Stream inputStream, byte[] contentMD5, bool invokeGeneratePutBlobServiceMetadata, GeneratePutBlobServiceMetadata generatePutBlobServiceMetadata, bool isLargeBlockBlobRequest, ISequenceNumberUpdate sequenceNumberUpdate, OverwriteOption overwriteOption, IBlobObjectCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IAsyncResult asyncResult = this._storageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                long num;
                long num1;
                using (TransactionScope transactionScope = new TransactionScope())
                {
                    using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                    {
                        base.LoadContainer(dbContext);
                        string str          = null;
                        BlockBlob blockBlob = base.TryLoadBlockBlob(dbContext, out str);
                        DateTime utcNow     = DateTime.UtcNow;
                        bool flag           = false;
                        if (blockBlob != null)
                        {
                            if (blockBlob.IsCommitted.Value && overwriteOption == OverwriteOption.CreateNewOnly)
                            {
                                throw new BlobAlreadyExistsException();
                            }
                            DbBlobObject.CheckCopyState(blockBlob);
                            flag = DbBlobObject.CheckConditionsAndReturnResetRequired(blockBlob, new BlobLeaseInfo(blockBlob, utcNow), condition, null, true);
                            dbContext.ClearUncommittedBlocks(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName);
                            dbContext.Refresh(RefreshMode.KeepChanges, blockBlob);
                        }
                        else
                        {
                            if (overwriteOption == OverwriteOption.UpdateExistingOnly)
                            {
                                if (condition == null || !condition.LeaseId.HasValue)
                                {
                                    throw new ConditionNotMetException();
                                }
                                throw new LeaseNotPresentException();
                            }
                            StorageStampHelpers.CheckBlobName(this._blob.BlobName, this._blob.ContainerName);
                            if (string.IsNullOrEmpty(str))
                            {
                                str = BlockBlobDataManager.CreateUniqueDirectoryLoadBalanced();
                            }
                            blockBlob = new BlockBlob()
                            {
                                AccountName      = this._blob.AccountName,
                                ContainerName    = this._blob.ContainerName,
                                BlobName         = this._blob.BlobName,
                                VersionTimestamp = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc),
                                DirectoryPath    = str
                            };
                            dbContext.Blobs.InsertOnSubmit(blockBlob);
                        }
                        StorageStampHelpers.ValidatePutBlobArguments(this, contentLength, null, applicationMetadata, contentMD5, sequenceNumberUpdate, overwriteOption, condition, true, false);
                        byte[] byteArrayFromStream = DbStorageHelper.GetByteArrayFromStream(inputStream, out num, false, isLargeBlockBlobRequest);
                        string file          = BlockBlobDataManager.WriteBytesToFile(new BlockBlobMetaInfo(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, str), byteArrayFromStream, out num1);
                        Guid guid            = Guid.NewGuid();
                        BlockData blockDatum = new BlockData()
                        {
                            AccountName      = this._blob.AccountName,
                            ContainerName    = this._blob.ContainerName,
                            BlobName         = this._blob.BlobName,
                            VersionTimestamp = this._blob.VersionTimestamp,
                            IsCommitted      = false,
                            BlockId          = DbListBlobObject.ToHexString(guid.ToByteArray()),
                            FilePath         = file,
                            StartOffset      = new long?(num1)
                        };
                        dbContext.BlocksData.InsertOnSubmit(blockDatum);
                        if (invokeGeneratePutBlobServiceMetadata && generatePutBlobServiceMetadata != null)
                        {
                            serviceMetadata = generatePutBlobServiceMetadata();
                        }
                        blockBlob.ContentType              = contentType ?? "application/octet-stream";
                        blockBlob.ContentMD5               = contentMD5;
                        blockBlob.ServiceMetadata          = serviceMetadata;
                        blockBlob.Metadata                 = applicationMetadata;
                        blockBlob.IsCommitted              = new bool?(false);
                        blockBlob.HasBlock                 = new bool?(false);
                        blockBlob.UncommittedBlockIdLength = null;
                        blockBlob.GenerationId             = Guid.NewGuid().ToString();
                        blockBlob.SnapshotCount            = 0;
                        blockDatum.Length       = new long?(num);
                        blockBlob.ContentLength = num;
                        base.ResetBlobLeaseToAvailable(blockBlob, flag);
                        dbContext.SubmitChanges();
                        StringBuilder stringBuilder = new StringBuilder();
                        DbListBlobObject.SerializeCommitBlockListEntry(stringBuilder, guid.ToByteArray(), BlockSource.Uncommitted);
                        DateTime?nullable = null;
                        dbContext.CommitBlockList(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, stringBuilder.ToString(), ref nullable);
                        transactionScope.Complete();
                        blockBlob.LastModificationTime = nullable;
                        this._blob     = blockBlob;
                        this.LeaseInfo = new BlobLeaseInfo(blockBlob, utcNow);
                    }
                }
            }, base.Timeout, context.GetResumeCallback(), context.GetResumeState("DbListBlobObject.PutBlobImpl"));

            yield return(asyncResult);

            this._storageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Example #10
0
        private bool PutBlockList()
        {
            bool flag;
            bool flag1 = false;

            try
            {
                for (int i = 0; i < this._maxNumberOfRetries; i++)
                {
                    try
                    {
                        using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew))
                        {
                            using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                            {
                                this.GetContainer(dbContext);
                                BlockBlob           blob     = this.GetBlob(dbContext, true) as BlockBlob;
                                BlobServiceMetaData instance = BlobServiceMetaData.GetInstance(blob.ServiceMetadata);
                                instance.CopyStatus         = "success";
                                instance.CopyProgressOffset = this._contentLength.ToString();
                                instance.CopyProgressTotal  = this._contentLength.ToString();
                                instance.CopyCompletionTime = new long?(DateTime.UtcNow.ToFileTimeUtc());
                                blob.HasBlock                 = new bool?((this._blockIds.Count > 1 ? true : this._contentLength < (long)4194304));
                                blob.ContentLength            = this._contentLength;
                                blob.ServiceMetadata          = instance.GetMetadata();
                                blob.IsCommitted              = new bool?(false);
                                blob.UncommittedBlockIdLength = null;
                                dbContext.SubmitChanges();
                                dbContext.CommitBlockList(this._accountName, this._containerName, this._blobName, DbListBlobObject.SerializeCommitBlockListEntryFromUncommitted(this._blockIds).ToString(), ref this._lastModifiedTime);
                                transactionScope.Complete();
                            }
                        }
                        IStringDataEventStream info = Logger <IRestProtocolHeadLogger> .Instance.Info;
                        object[] objArray           = new object[] { this._accountName, this._containerName, this._blobName, this._contentLength };
                        info.Log("Commited Blocks for: {0}/{1}/{2}, Length:{3}", objArray);
                        break;
                    }
                    catch (SqlException sqlException)
                    {
                        if (this.ShouldRethrowException(i, sqlException, out flag1))
                        {
                            throw;
                        }
                    }
                }
                return(true);
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                Logger <IRestProtocolHeadLogger> .Instance.Error.Log("CopyBlob: PutBlockList exception {0}", new object[] { exception });

                this.SetCopyFailed(exception, flag1, null);
                flag = false;
            }
            return(flag);
        }