Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="databaseName"></param>
        /// <param name="containerName"></param>
        public void ImportExisting(string databaseName, string databaseDescription, string containerName)
        {
            var container = _blobStorageProvider.GetContainer(containerName);

            if (container == null)
            {
                throw new Exception("Database container not found");
            }

            var blobs = _blobStorageProvider.ListBlobs(containerName).ToList();

            if (!blobs.Any())
            {
                throw new Exception("Container contains no database files");
            }

            var entity = CreateDatabaseEntity(containerName, null, databaseName, blobs.Count, false);

            entity.DisplayName        = databaseDescription;
            entity.CompletedTasks     = blobs.Count;
            entity.State              = DatabaseState.Ready;
            entity.TotalSize          = blobs.Sum(b => b.Length);
            entity.FileCount          = blobs.Count;
            entity.DedicatedContainer = true;
            entity.Type = blobs.Any(b => Path.GetExtension(b.BlobName).StartsWith(".p"))
                ? DatabaseType.Protein
                : DatabaseType.Nucleotide;

            _tableStorageProvider.UpsertEntity(entity);
        }
Example #2
0
        private string GetOutputContainerSas(string outputContainer)
        {
            var container = _blobStorageProvider.GetContainer(outputContainer);

            container.CreateIfNotExists();
            var sas = container.GetSharedAccessSignature(new SharedAccessBlobPolicy
            {
                Permissions = SharedAccessBlobPermissions.Create | SharedAccessBlobPermissions.Add |
                              SharedAccessBlobPermissions.List | SharedAccessBlobPermissions.Write,
                SharedAccessStartTime  = DateTimeOffset.UtcNow.AddMinutes(-30),
                SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddDays(28),
            });

            return(string.Format("{0}{1}", container.Uri.AbsoluteUri, sas));
        }