Beispiel #1
0
        private static void DoMake()
        {
            IBlobHandler handler       = GetHandler(_inputUrlType, _inputUrl);
            var          containerName = handler.GetContainerNameFromUrl(_inputUrl);

            handler.MakeContainer(containerName);
        }
Beispiel #2
0
        /// <summary>
        /// Get all possible blobs for the handler (which had the original url passed into the constructor).
        /// </summary>
        /// <param name="inputHandler"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        private static IEnumerable <BasicBlobContainer> GetSourceBlobList(IBlobHandler inputHandler)
        {
            var containerName = inputHandler.GetContainerNameFromUrl(inputHandler.GetBaseUrl());

            if (CommonHelper.IsABlob(inputHandler.GetBaseUrl()))
            {
                var blobName = inputHandler.GetBlobNameFromUrl(inputHandler.GetBaseUrl());
                var blob     = new BasicBlobContainer {
                    Name        = blobName,
                    DisplayName = blobName,
                    BlobType    = BlobEntryType.Blob,
                    Url         = inputHandler.GetBaseUrl(),
                    Container   = containerName
                };

                yield return(blob);
                //blobList.Add(blob);
            }
            else
            {
                var res = inputHandler.ListBlobsInContainer(containerName);
                foreach (var i in res)
                {
                    yield return(i);
                }
            }
        }
Beispiel #3
0
        public ExceptionController(IBlobHandler blobHandler,
                                   IOptions <BlobOptions> settings)
        {
            _blobHandler = blobHandler ??
                           throw new ArgumentNullException(nameof(blobHandler));

            _options = settings.Value;
        }
 public IncrementalSequenceRepository(
     IBlobHandler blobHandler,
     ITableHandler <IncrementalSequenceTableEntity> sequenceEntityHandler
     )
 {
     this.blobHandler           = blobHandler;
     this.sequenceEntityHandler = sequenceEntityHandler;
     //this.insightsTracker = insightsTracker;
 }
Beispiel #5
0
        public TicketController(IDmvDbHandler dmvDbHandler,
                                IBlobHandler blobHandler,
                                IEventHandler eventHandler)
        {
            _dmvDbHandler = dmvDbHandler ??
                            throw new ArgumentNullException(nameof(dmvDbHandler));

            _eventHandler = eventHandler ??
                            throw new ArgumentNullException(nameof(eventHandler));
        }
Beispiel #6
0
        public NumberPlateController(IComputerVisionHandler computerVisionHandler,
                                     IEventHandler eventHandler,
                                     IBlobHandler blobHandler)
        {
            _computerVisionHandler = computerVisionHandler ??
                                     throw new ArgumentNullException(nameof(computerVisionHandler));

            _eventHandler = eventHandler ??
                            throw new ArgumentNullException(nameof(eventHandler));

            _blobHandler = blobHandler ??
                           throw new ArgumentNullException(nameof(blobHandler));
        }
        public FaceController(IFaceHandler faceHandler,
                              IBlobHandler blobHandler,
                              IEventHandler eventHandler,
                              IOptions <BlobOptions> settings)
        {
            _faceHandler = faceHandler ??
                           throw new ArgumentNullException(nameof(faceHandler));

            _blobHandler = blobHandler ??
                           throw new ArgumentNullException(nameof(blobHandler));

            _eventhandler = eventHandler ??
                            throw new ArgumentNullException(nameof(eventHandler));

            _options = settings.Value;
        }
        public NotificationController(IDmvDbHandler dmvDbHandler,
                                      IBlobHandler blobHandler,
                                      IOwnerNotificationHandler ownerNotificationHandler,
                                      IEventHandler eventHandler)
        {
            _dmvDbHandler = dmvDbHandler ??
                            throw new ArgumentNullException(nameof(dmvDbHandler));

            _blobHandler = blobHandler ??
                           throw new ArgumentNullException(nameof(blobHandler));

            _ownerNotificationHandler = ownerNotificationHandler ??
                                        throw new ArgumentNullException(nameof(ownerNotificationHandler));

            _eventHandler = eventHandler ??
                            throw new ArgumentNullException(nameof(eventHandler));
        }
Beispiel #9
0
        static void DoListContainers()
        {
            IBlobHandler handler = GetHandler(_inputUrlType, _inputUrl);

            try
            {
                var containerList = handler.ListContainers(_inputUrl);

                foreach (var container in containerList)
                {
                    Console.WriteLine(string.Format("{0}", container.DisplayName));
                }
            }
            catch (NotImplementedException ex)
            {
                Console.WriteLine("Unfortunately Listing containers/directories is not supported for this cloud platform yet");
            }
        }
Beispiel #10
0
        static void DoList(bool debugMode)
        {
            IBlobHandler handler = GetHandler(_inputUrlType, _inputUrl);

            var containerName = handler.GetContainerNameFromUrl(_inputUrl);

            if (DebugMode)
            {
                Console.WriteLine("container name " + containerName);
            }

            var blobPrefix = handler.GetBlobNameFromUrl(_inputUrl);
            var blobList   = handler.ListBlobsInContainer(containerName, blobPrefix, DebugMode);

            foreach (var blob in blobList)
            {
                Console.WriteLine(string.Format("{0}  ({1} {2})", blob.DisplayName, blob.Name, blob.Url));
            }
        }
Beispiel #11
0
        /// <summary>
        /// Get all possible blobs for the handler (which had the original url passed into the constructor).
        /// </summary>
        /// <param name="inputHandler"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        private static IEnumerable<BasicBlobContainer> GetSourceBlobList(IBlobHandler inputHandler)
        {
            var containerName = inputHandler.GetContainerNameFromUrl(inputHandler.GetBaseUrl());

            if (CommonHelper.IsABlob(inputHandler.GetBaseUrl()))
            {
                var blobName = inputHandler.GetBlobNameFromUrl( inputHandler.GetBaseUrl());
                var blob = new BasicBlobContainer{
                    Name = blobName,
                    DisplayName = blobName,
                    BlobType = BlobEntryType.Blob,
                    Url = inputHandler.GetBaseUrl(),
                    Container = containerName
                };

                yield return blob;
                //blobList.Add(blob);
            }
            else
            {
                var res = inputHandler.ListBlobsInContainer(containerName);
                foreach( var i in res)
                {
                    yield return i;
                }
            }
        }
Beispiel #12
0
 public CacheRepository(ITableHandler <CacheEntity> cacheEntityHandler, IBlobHandler blobHandler)
 {
     this.cacheEntityHandler = cacheEntityHandler;
     this.blobHandler        = blobHandler;
 }
Beispiel #13
0
        static void DoNormalCopy()
        {
            IBlobHandler inputHandler  = GetHandler(_inputUrlType, _inputUrl);
            IBlobHandler outputHandler = GetHandler(_outputUrlType, _outputUrl);

            if (inputHandler != null && outputHandler != null)
            {
                // handle multiple files.
                //currently sequentially.
                var sourceBlobList = GetSourceBlobList(inputHandler);

                if (ConfigHelper.UseBlobCopy)
                {
                    AzureBlobCopyHandler.StartCopyList(sourceBlobList, _outputUrl, _destinationBlobType);
                }
                else
                {
                    foreach (var blob in sourceBlobList)
                    {
                        var fileName = "";
                        if (ConfigHelper.AmDownloading)
                        {
                            fileName = GenerateFileName(ConfigHelper.DownloadDirectory, blob.Name);
                        }

                        var sourceContainer = inputHandler.GetContainerNameFromUrl(_inputUrl);

                        // read blob
                        var inputBlob = inputHandler.ReadBlob(sourceContainer, blob.Name, fileName);

                        // if blob is marked with type "Unknown" then set it to what was passed in on command line.
                        // if nothing was passed in, then default to block?
                        if (inputBlob.BlobType == DestinationBlobType.Unknown)
                        {
                            if (_destinationBlobType != DestinationBlobType.Unknown)
                            {
                                inputBlob.BlobType = _destinationBlobType;
                            }
                            else
                            {
                                inputBlob.BlobType = DestinationBlobType.Block;
                            }
                        }

                        Console.WriteLine(string.Format("Copying blob to {0}", _outputUrl));

                        // write blob
                        var destContainerName = outputHandler.GetContainerNameFromUrl(_outputUrl);
                        var destBlobName      = outputHandler.GetBlobNameFromUrl(_outputUrl);

                        // take the inputBlob name and remove the default prefix.

                        if (!string.IsNullOrEmpty(blob.BlobPrefix))
                        {
                            destBlobName += inputBlob.Name.Substring(blob.BlobPrefix.Length);
                        }
                        else
                        {
                            // if destBlobName ends with / then its a prefix.
                            // if it does not, then its an absolute blob name (ie when the blob was copied then it was also being renamed).
                            if (destBlobName.EndsWith("/"))
                            {
                                destBlobName += inputBlob.Name;
                            }
                            else
                            {
                                // if destBlobName is empty then take it from blob.
                                // else it appears we were told the name to use so leave it.
                                if (string.IsNullOrWhiteSpace(destBlobName))
                                {
                                    destBlobName = inputBlob.Name;
                                }
                                else
                                {
                                    // leave it.
                                }
                            }
                        }

                        outputHandler.WriteBlob(destContainerName, destBlobName, inputBlob, ConfigHelper.ParallelFactor, ConfigHelper.ChunkSizeInMB);

                        if (inputBlob.BlobSavedToFile)
                        {
                            if (File.Exists(inputBlob.FilePath))
                            {
                                File.Delete(inputBlob.FilePath);
                            }
                        }
                    }
                }
            }
        }
Beispiel #14
0
        static void DoNormalCopy(bool debugMode)
        {
            IBlobHandler inputHandler  = GetHandler(_inputUrlType, _inputUrl);
            IBlobHandler outputHandler = GetHandler(_outputUrlType, _outputUrl);

            // can only use skip when destination is Azure (simply because I haven't coded other options yet).
            if (!(_outputUrlType == UrlType.Azure || _outputUrlType == UrlType.Dropbox) && skip)
            {
                Console.WriteLine("-skip option only valid when destination is Azure blob storage or Dropbox. This will change soon.");
                return;
            }

            if (inputHandler != null && outputHandler != null)
            {
                // handle multiple files.
                //currently sequentially.
                var sourceBlobList = GetSourceBlobList(inputHandler);

                if (ConfigHelper.UseBlobCopy)
                {
                    AzureBlobCopyHandler.StartCopyList(sourceBlobList, _outputUrl, _destinationBlobType, debugMode, skip);
                }
                else
                {
                    foreach (var blob in sourceBlobList)
                    {
                        var fileName = "";
                        if (ConfigHelper.AmDownloading)
                        {
                            fileName = GenerateFileName(ConfigHelper.DownloadDirectory, blob.Name);
                        }

                        var sourceContainer = inputHandler.GetContainerNameFromUrl(_inputUrl);


                        // write blob
                        var destContainerName = outputHandler.GetContainerNameFromUrl(_outputUrl);
                        var destBlobName      = outputHandler.GetBlobNameFromUrl(_outputUrl);

                        // take the inputBlob name and remove the default prefix.

                        if (!string.IsNullOrEmpty(blob.BlobPrefix))
                        {
                            destBlobName += blob.Name.Substring(blob.BlobPrefix.Length);
                        }
                        else
                        {
                            // if destBlobName ends with / then its a prefix.
                            // if it does not, then its an absolute blob name (ie when the blob was copied then it was also being renamed).
                            if (destBlobName.EndsWith("/"))
                            {
                                destBlobName += blob.Name;
                            }
                            else
                            {
                                // if destBlobName is empty then take it from blob.
                                // else it appears we were told the name to use so leave it.
                                if (string.IsNullOrWhiteSpace(destBlobName))
                                {
                                    destBlobName = blob.Name;
                                }
                                else
                                {
                                    // leave it.
                                }
                            }
                        }

                        if (skip)
                        {
                            // check if destination blob exists.
                            // if it does, then dont even bother reading the blob and just continue to the next one.

                            var alreadyExists = outputHandler.DoesBlobExists(destContainerName, destBlobName);
                            if (alreadyExists)
                            {
                                Console.WriteLine("Skipping " + blob.Url);
                                continue;
                            }
                        }

                        Console.WriteLine(string.Format("Copying blob to {0}", _outputUrl));

                        // read blob
                        var inputBlob = inputHandler.ReadBlob(sourceContainer, blob.Name, fileName);
                        // if blob is marked with type "Unknown" then set it to what was passed in on command line.
                        // if nothing was passed in, then default to block?
                        if (inputBlob.BlobType == DestinationBlobType.Unknown)
                        {
                            if (_destinationBlobType != DestinationBlobType.Unknown)
                            {
                                inputBlob.BlobType = _destinationBlobType;
                            }
                            else
                            {
                                inputBlob.BlobType = DestinationBlobType.Block;
                            }
                        }

                        outputHandler.WriteBlob(destContainerName, destBlobName, inputBlob, ConfigHelper.ParallelFactor, ConfigHelper.ChunkSizeInMB);

                        if (inputBlob.BlobSavedToFile)
                        {
                            if (File.Exists(inputBlob.FilePath))
                            {
                                File.Delete(inputBlob.FilePath);
                            }
                        }
                    }
                }
            }
        }