- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
WORKING WITH CLOUD QUEUE AND BLOB STORAGE in Visual C#.NET
CHAPTER 3 WORKING WITH CLOUD QUEUE AND BLOB STORAGE Create Data Matrix 2d Barcode In C# Using Barcode generation for Visual Studio .NET Control to generate, create Data Matrix ECC200 image in .NET applications. www.OnBarcode.comData Matrix Scanner In Visual C# Using Barcode reader for VS .NET Control to read, scan read, scan image in VS .NET applications. www.OnBarcode.compublic class AzureStorageFacade { protected StorageAccountInfo _accountInformation; protected int retry = 1; protected int retryInterval = 1000; public StorageAccountInfo StorageAccountInfo { get{ return _accountInformation; } } public AzureStorageFacade() { _InitializationStorages(); } protected void _InitializationStorages() { retry = Convert.ToInt32(ConfigurationManager.AppSettings["Retry"]); retryInterval = Convert.ToInt32(ConfigurationManager.AppSettings["RetryInterval"]); _accountInformation = StorageAccountInfo.GetDefaultBlobStorageAccountFromConfiguration(); } } } Listing 3-16 shows the implementation of the blob facade class, which encapsulates all blob storage access functions and attributes of blob storage needed for a client application in a more comprehensive manner than in the implementation in the previous exercise. Listing 3-16. Implementation of the BlobStorageFacade Class Derived from the AzureStorageFacade Class using using using using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Configuration; System.Collections.Specialized; System.Threading; System.IO; Make UCC-128 In C# Using Barcode drawer for .NET framework Control to generate, create GTIN - 128 image in .NET framework applications. www.OnBarcode.comCreate Barcode In Visual C# Using Barcode generator for VS .NET Control to generate, create Barcode image in .NET framework applications. www.OnBarcode.comnamespace AzureForDotNetDevelopers.LargeDataToBlob.CloudStorage.BlobStorage { using Microsoft.ServiceHosting.ServiceRuntime; using Microsoft.Samples.ServiceHosting.StorageClient; using CSharpBuildingBlocks; Drawing EAN-13 Supplement 5 In Visual C# Using Barcode printer for VS .NET Control to generate, create EAN13 image in VS .NET applications. www.OnBarcode.comPainting Barcode In Visual C# Using Barcode encoder for VS .NET Control to generate, create Barcode image in VS .NET applications. www.OnBarcode.comCHAPTER 3 WORKING WITH CLOUD QUEUE AND BLOB STORAGE
Painting UPC-A Supplement 5 In C#.NET Using Barcode maker for .NET framework Control to generate, create UPC Code image in .NET framework applications. www.OnBarcode.comISBN Creation In Visual C#.NET Using Barcode generation for .NET Control to generate, create ISBN - 10 image in VS .NET applications. www.OnBarcode.compublic class BlobStorageFacade : AzureStorageFacade { static public long LARGE_BLOB_SIZE = 2 * 1024 * 1024;// 2 MB protected BlobStorage _blobStorage; protected BlobContainer _blobContainer; protected string _blobContainerName = ConfigurationManager.AppSettings["BlobContainerName"]; protected NameValueCollection _metadata = null; protected Thread _createBlobWorkerthread = null; public BlobContents Contents { get; set; } public BlobProperties Properties { get; set; } public bool Overwrite { get; set; } public BlobStorageFacade() { _blobStorage = BlobStorage.Create(_accountInformation); _blobStorage.RetryPolicy = RetryPolicies.RetryN(retry, TimeSpan.FromMilliseconds(retryInterval)); _blobContainer = _blobStorage.GetBlobContainer(_blobContainerName); } public BlobStorageFacade(NameValueCollection metadata):this() { _metadata = metadata; _blobContainer.CreateContainer(_metadata, ContainerAccessControl.Private); } public BlobStorageFacade(BlobContents blobContents, BlobProperties blobProperties, bool overwrite) : this(blobProperties.Metadata) { Contents = blobContents; Properties = blobProperties; Overwrite = overwrite; } public BlobContainer BlobContainer { get { return _blobContainer; } } public IEnumerable<BlobContainer> GetBlobContainers() { return _blobStorage.ListBlobContainers(); } public void CreateBlob() { _blobContainer.CreateBlob(Properties, Contents, Data Matrix Maker In None Using Barcode creation for Online Control to generate, create Data Matrix image in Online applications. www.OnBarcode.comDecode Data Matrix ECC200 In .NET Framework Using Barcode reader for VS .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.comCHAPTER 3 WORKING WITH CLOUD QUEUE AND BLOB STORAGE
Denso QR Bar Code Creator In Visual Basic .NET Using Barcode generation for .NET Control to generate, create Denso QR Bar Code image in .NET framework applications. www.OnBarcode.comGenerating GS1 DataBar In Java Using Barcode encoder for Java Control to generate, create GS1 DataBar Expanded image in Java applications. www.OnBarcode.comOverwrite); } public void DeleteBlob() { if (_blobContainer.DoesBlobExist(Properties.Name)) { _blobContainer.DeleteBlob(Properties.Name); } } } } As mentioned before, we use a background worker thread and ICommand design pattern in this application. The base class implementation for these two classes comes from my existing building block collection library. The reference assemblies are called CSharpBuildingBlocks and CSharpBuildingBlocks.QueuedBackgroundWorker. These two assemblies come with the source code download and will be used several places in other chapters. Listing 3-17 and Listing 3-18 are the implementation for CreateBlobStatus and DeleteBlobStatus. A worker thread is created at the time a message arrives for either creating or deleting a blob request. Two member functions are used to handle create or delete activities accordingly. The algorithms for progress are different in these two classes. For blob creation, the percentage of the creation progress is determined by comparing the size of the blob to be created against the actual size of the data that has been committed to cloud blob storage. No incremented progress can be reported to the client application, because the detailed information of a newly created or deleted blob will not be updated until the transactions have been committed on the server. Listing 3-17. The CreateBlobStatus Class Derived from the BlobStorageAction Class using using using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Configuration; System.Collections.Specialized; System.Threading; AzureForDotNetDevelopers.LargeDataToBlob.CloudStorage.BlobStorage Microsoft.ServiceHosting.ServiceRuntime; Microsoft.Samples.ServiceHosting.StorageClient; CSharpBuildingBlocks; Barcode Printer In .NET Using Barcode creator for Visual Studio .NET Control to generate, create Barcode image in VS .NET applications. www.OnBarcode.comDraw UCC-128 In Java Using Barcode generation for Java Control to generate, create EAN128 image in Java applications. www.OnBarcode.comnamespace { using using using
Making GS1-128 In Java Using Barcode generator for BIRT reports Control to generate, create GS1 128 image in BIRT applications. www.OnBarcode.comBarcode Encoder In None Using Barcode drawer for Office Excel Control to generate, create Barcode image in Excel applications. www.OnBarcode.compublic class CreateBlobStatus : BlobStorageActionStatus, ICommand { public long CreateContentSize { get; set; } public CreateBlobStatus(BlobContents blobContents, BlobProperties blobProperties, Paint UPCA In Visual Studio .NET Using Barcode generation for Reporting Service Control to generate, create Universal Product Code version A image in Reporting Service applications. www.OnBarcode.comDraw Code 128 Code Set C In Java Using Barcode drawer for Java Control to generate, create Code-128 image in Java applications. www.OnBarcode.comCHAPTER 3 WORKING WITH CLOUD QUEUE AND BLOB STORAGE
Encode Data Matrix ECC200 In Visual Basic .NET Using Barcode creator for VS .NET Control to generate, create DataMatrix image in .NET applications. www.OnBarcode.comCreating UCC-128 In Java Using Barcode maker for Android Control to generate, create UCC.EAN - 128 image in Android applications. www.OnBarcode.combool overwrite) : base(blobContents, blobProperties, overwrite) { } public void Execute() { try { if (_blobStorageFacade.BlobContainer .DoesBlobExist(_blobStorageFacade.Properties.Name)) { var blob = (from m in _blobStorageFacade.BlobContainer.ListBlobs(string.Empty, false) where (m as BlobProperties).Name == _blobStorageFacade.Properties.Name select m as BlobProperties).Single<BlobProperties>(); _percentComplete = (float)(((blob as BlobProperties).ContentLength * 100.0) / (CreateContentSize * 1.0)); System.Diagnostics.Trace.WriteLine( string.Format( "---{0}:Execute, _percentComplete = <{1}>", this.ToString(), _percentComplete ) ); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine( string.Format( "---{0}:Execute,exception caught <{1}>", this.ToString(), ex.Message ) ); } } override protected void _blobStorageWorkerThread(object paramters) { try { CHAPTER 3 WORKING WITH CLOUD QUEUE AND BLOB STORAGE
(paramters as BlobStorageFacade).CreateBlob(); } catch { } } } } Listing 3-18. The DeleteBlobStatus Class Derived from the BlobStorageAction Class using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Threading; AzureForDotNetDevelopers.LargeDataToBlob.CloudStorage.BlobStorage Microsoft.ServiceHosting.ServiceRuntime; Microsoft.Samples.ServiceHosting.StorageClient; CSharpBuildingBlocks;
|
|