QPS Software

QPS Software

Share

Coding

Resolved common Error with Docker 05/10/2021

Error with Start docker And docker require to factory reset => To resolved can do like this Delete all folder on this folder & Restart PC and Docker C:\ProgramData\Docker\containers Working with Docker Compose docker-compose up -d If service is not start Cannot start service storage: container is marked for removal and cannot be started Run: docker kill storage docker rm -f storage Then docker-compose up storage…...

Resolved common Error with Docker Error with Start docker And docker require to factory reset => To resolved can do like this Delete all folder on this folder & Restart PC and Docker C:\ProgramData\Docker\containers Working …

Azure Storage Blobs .Net SDK V12 Client 05/10/2021

using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using Azure; using Azure.Storage.Blobs; using Azure.Storage.Blobs.Models; using Azure.Storage.Sas; using Microsoft.Extensions.Logging; namespace Storage { internal sealed class BlobContainerClient1 : Azure.Storage.Blobs.BlobContainerClient { private readonly string _connectionString; private readonly string _blobContainerName; private const char SEPARATOR = '/'; private readonly string _rootDirectory; private readonly ILogger _logger; private bool _initialized; private readonly SemaphoreSlim _lock = new SemaphoreSlim(1, 1); public BlobContainerClient1( ILogger logger, string connectionString, string blobContainerName, string rootDirectory = null, BlobClientOptions options = null) : base(connectionString, blobContainerName, options) { _initialized = false; _rootDirectory = GetRootDirectoryName(rootDirectory); _connectionString = connectionString; _blobContainerName = blobContainerName; _logger = logger; } public async Task WriteFileAsync( string directory, string name, Stream content, CancellationToken cancellationToken) { string path = GetFilePath(directory, name); _logger.LogDebug($"{_blobContainerName}: Writing contents of '{path}'..."); var client = await GetBlobClientAsync(directory, name); await client.UploadAsync(content, true, cancellationToken); _logger.LogDebug($"{_blobContainerName}: Content of '{path}' written."); } public async Task UploadAsync( string directory, string name, Stream content, CancellationToken cancellationToken) { await WriteFileAsync(directory, name, content, cancellationToken); } public async Task ReadFileAsStringAsync( string directory, string name, CancellationToken cancellationToken) { var client = await GetBlobClientAsync(directory, name); using (BlobDownloadInfo download = await client.DownloadAsync(cancellationToken)) { StreamReader reader = new StreamReader(download.Content); return await reader.ReadToEndAsync(); } } public async Task DownloadAsync( string directory, string name, CancellationToken cancellationToken) { return await ReadFileAsStringAsync(directory, name, cancellationToken); } public async Task ReadFileAsStringIfExistsAsync( string directory, string name, CancellationToken cancellationToken) { try { return await ReadFileAsStringAsync(directory, name, cancellationToken); } catch (RequestFailedException ex) when (ex.ErrorCode == BlobErrorCode.BlobNotFound) { return null; } } public async Task GetUriAsync( string directory, string name, FileAccessPermission permission, TimeSpan validTill) { return await GetBlobUriAsync(directory, name, permission, validTill); } public async Task ExistsFileAsync( string directory, string name, CancellationToken cancellationToken) { var client = await GetBlobClientAsync(directory, name); return await client.ExistsAsync(cancellationToken); } public async Task ExistsAsync( string directory, string name, CancellationToken cancellationToken) { return await ExistsFileAsync(directory, name, cancellationToken); } public async Task ReadFileAsync(string directory, string name, CancellationToken cancellationToken) { var client = await GetBlobClientAsync(directory, name); return await client.OpenReadAsync(cancellationToken: cancellationToken); } public async Task OpenReadAsync( string directory, string name, CancellationToken cancellationToken) { return await ReadFileAsync(directory, name, cancellationToken); } public async Task DeleteDirectoryAsync( string directory, Func namePredicate, CancellationToken cancellationToken) { _logger.LogDebug($"{_blobContainerName}: Directory '{directory}' deleting..."); await EnumerateForDeleteAsync(directory, async (blob, token) => { if (!namePredicate(blob.Name)) return; await DeleteBlobAsync(blob, token); }, cancellationToken); _logger.LogDebug($"{_blobContainerName}: Directory '{directory}' deleted."); } public async Task DeleteDirectoryAsync( string directory, CancellationToken cancellationToken) { _logger.LogDebug($"{_blobContainerName}: Directory '{directory}' deleting..."); await EnumerateForDeleteAsync(directory, DeleteBlobAsync, cancellationToken); _logger.LogDebug($"{_blobContainerName}: Directory '{directory}' deleted."); } public async Task DeleteBlobAsync( string directory, string name, CancellationToken cancellationToken) { var client = await GetBlobClientAsync(directory, name); await client.DeleteIfExistsAsync(cancellationToken: cancellationToken); } public async Task GetPropertiesAsync( string directory, string name, CancellationToken cancellationToken) { var client = await GetBlobClientAsync(directory, name); return await client.GetPropertiesAsync(cancellationToken: cancellationToken); } public async Task GetMetaDataAsync( string directory, string name, CancellationToken cancellationToken) { return await GetPropertiesAsync(directory, name, cancellationToken); } public async Task UpdateMetadataAsync( string directory, string name, IDictionary metadata, CancellationToken cancellationToken) { var client = await GetBlobClientAsync(directory, name); await client.SetMetadataAsync(metadata, cancellationToken: cancellationToken); } Private Method private async Task DeleteBlobAsync( BlobItem blob, CancellationToken cancellationToken) { try { await DeleteBlobIfExistsAsync(blob.Name, cancellationToken: cancellationToken); } catch (Exception ex) { _logger.LogWarning($"Failed to delete blob {blob.Name}, reason: {ex.Message}."); } } private async Task GetBlobUriAsync( string directory, string name, FileAccessPermission permission, TimeSpan validTill) { var client = await GetBlobClientAsync(directory, name); var permissions = GetBlobSasPermissions(permission); return client.GenerateSasUri(permissions, DateTimeOffset.UtcNow.Add(validTill)); } private async Task CreateBlobClientAsync( string blobName, BlobClientOptions options = null) { await EnsureInitializedAsync(); return new BlobClient(_connectionString, _blobContainerName, blobName, options); } private async Task GetBlobClientAsync( string directory, string name) { string path = GetFilePath(directory, name); return await CreateBlobClientAsync(path); } private async Task EnumerateForDeleteAsync( string directoryName, Func blobAction, CancellationToken cancellationToken) { string prefixBlobName = GetDirectoryName(directoryName); List blobItems = new List(); await GetBlobsHierarchicalAsyn(blobItems, this, prefixBlobName, 200, cancellationToken); var blobTasks = blobItems.OfType().Select(x => blobAction(x, cancellationToken)); await Task.WhenAll(blobTasks); } private string GetDirectoryName(string name) { return NormalizeName($"{_rootDirectory}{name}"); } private string GetRootDirectoryName(string name) { if (string.IsNullOrEmpty(name)) return ""; if (!name.EndsWith(SEPARATOR.ToString())) name += SEPARATOR; return NormalizeName(name); } private string NormalizeName(string name) { return string.Join(SEPARATOR.ToString(), name.Split(SEPARATOR).Select(Uri.EscapeDataString)); } private string GetFilePath(string directory, string name) { var path = GetDirectoryName(directory); if (!string.IsNullOrEmpty(path)) path += SEPARATOR; path = path.Replace($"{SEPARATOR}{SEPARATOR}", SEPARATOR.ToString()); path += NormalizeName(name); return path; } private async Task GetBlobsHierarchicalAsyn( List blobItems, BlobContainerClient container, string prefix, int?...

https://quangphamsoft.wordpress.com/2021/01/05/blob-v12-client/

Azure Storage Blobs .Net SDK V12 Client using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using Azure; using Azure.Storage.Blobs; using Azure.Storage…

How to detect dynamically which field has changed in an UPDATE trigger event? 06/04/2020

When we working with salesforce apex trigger, we need to identify specifically which fields of that object have changed. So here is an example code to watching the list of the field have changed. This is the function to get the changed This is the trigger on the object

How to detect dynamically which field has changed in an UPDATE trigger event? When we working with salesforce apex trigger, we need to identify specifically which fields of that object have changed. So here is an example code to watching the list of the field have changed. …

aws-serverless template 13/03/2019

Convert tools:

aws-serverless template   Convert tools:

Calculating an Exponential Back Off Delay Based on Failed Attempts 14/11/2018

I implemented the following formula found on Wikipedia in C #. private int GetExpectedBackoff(int numberOfFail) { return (int.Parse(Math.Pow(2, numberOfFail).ToString()) - 1) / 2; }

Calculating an Exponential Back Off Delay Based on Failed Attempts I implemented the following formula found on Wikipedia in C #. private int GetExpectedBackoff(int numberOfFail) { return (int.Parse(Math.Pow(2, numberOfFail).ToString()) – 1) / 2; }

Sort way to install PIP on Windows 02/11/2018

Here is the sort way to install PIP on Windows

Sort way to install PIP on Windows Here is the sort way to install PIP on Windows

Change blockchain data dir in Windows for Ethereum 18/06/2018

Cant you just create a link and point your windows directory to the one in E drive Steps Believe by default Ethereum directory is present here C:\Users...\AppData\Roaming\Ethereum Rename the C drive Ethereum directory to something else lets say Ethereum-Backup Open the command prompt in admin mode cd C:\Users...\AppData\Roaming mklink /D Ethereum E:\Ethereum Start geth client If everything works fine you can take the decision to remove the Ethereum-Backup directory… [ 159 more words ]

Change blockchain data dir in Windows for Ethereum Cant you just create a link and point your windows directory to the one in E drive Steps Believe by default Ethereum directory is present here C:\Users…\AppData\Roaming\Ethereum Rename the C …

Want your business to be the top-listed Advertising & Marketing Company in Da Nang?
Click here to claim your Sponsored Listing.

Telephone

Website

Address


Da Nang