Beispiel #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);
        }
Beispiel #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);
        }