Beispiel #1
0
        public async Task RevokePublishAsync(Storage storage, IMediaElement element)
        {
            IStorageProvider storageProvider = StorageProviderFactory.GetStorageProvider(
                _serviceProvider, storage.StorageType);

            await storageProvider.RemoveFileAsync(storage.PublishStorageId,
                                                  storage.PublishStorageAccessKey, StorageMode.External,
                                                  storage.PublishHost, element.FilePath, element.GetFileName());
        }
Beispiel #2
0
        public string GetUrlCustom(Storage storage, string filePath, string fileName,
                                   MediaElementUrlType type, string customStyleProcessStr)
        {
            IStorageProvider storageProvider = StorageProviderFactory.GetStorageProvider(
                _serviceProvider, storage.StorageType);

            switch (type)
            {
            case MediaElementUrlType.DownloadUrl:
            {
                return(storageProvider.GetUrlCustom(
                           new DefaultStorageInfoImpl()
                    {
                        NetType = NetType.Intranet,
                        StorageAccessKey = storage.StorageAccessKey,
                        StorageId = storage.StorageId,
                        StorageHost = storage.DownloadHost,
                    }, type, filePath, fileName, customStyleProcessStr));
            }

            case MediaElementUrlType.OutputUrl:
            {
                return(storageProvider.GetUrlCustom(
                           new DefaultStorageInfoImpl()
                    {
                        NetType = NetType.Internet,
                        StorageAccessKey = storage.StorageAccessKey,
                        StorageId = storage.StorageId,
                        StorageHost = storage.OutputHost,
                    }, type, filePath, fileName, customStyleProcessStr));
            }

            case MediaElementUrlType.PublishDownloadUrl:
            {
                return(storageProvider.GetUrlCustom(
                           new DefaultStorageInfoImpl()
                    {
                        NetType = NetType.Intranet,
                        StorageAccessKey = storage.PublishStorageAccessKey,
                        StorageId = storage.PublishStorageId,
                        StorageHost = storage.PublishOutputHost,
                    }, type, filePath, fileName, customStyleProcessStr));
            }

            default:
            {
                return(storageProvider.GetUrlCustom(
                           new DefaultStorageInfoImpl()
                    {
                        NetType = NetType.Internet,
                        StorageAccessKey = storage.PublishStorageAccessKey,
                        StorageId = storage.PublishStorageId,
                        StorageHost = storage.PublishOutputHost,
                    }, type, filePath, fileName, customStyleProcessStr));
            }
            }
        }
Beispiel #3
0
 public void SetStorageProvider()
 {
     foreach (var counterPoco in Counters)
     {
         counterPoco.StorageProvider = StorageProviderFactory.GetStorageProvider(
             false, StorageProvider, SerialNumber, DataStorePath,
             counterPoco.CounterId, Precision, counterPoco.StorageId);
     }
 }
Beispiel #4
0
        public void WhenGettingWitDataStorehNullShouldThrowTest()
        {
            // arrange
            StorageProviderFactory.Register(StorageProvider.kWhStorage, typeof(kWhStorage), true);

            // act & assert
            Assert.Throws <ArgumentNullException>(
                () => StorageProviderFactory.GetStorageProvider(false, StorageProvider.kWhStorage, "00-00-000-000", null, 0, Precision.kWh));
        }
Beispiel #5
0
        public void WhenRegisteringStorageProviderItShouldReturnTheInstanceOnGetProviderTest()
        {
            // arrange
            StorageProviderFactory.Register(StorageProvider.kWhStorage, typeof(kWhStorage), true);

            // act
            var storage = StorageProviderFactory.GetStorageProvider(false, StorageProvider.kWhStorage, "00-00-000-000", @".\Temp", 1, Precision.mWh);

            // assert
            Assert.IsNotNull(storage);
        }
Beispiel #6
0
        private bool EnsureStorageProvider()
        {
            if (StorageProvider == null)
            {
                Debug.Assert(Qbox.SerialNumber != null, "Qbox.SerialNumber != null");

                StorageProvider = StorageProviderFactory.GetStorageProvider(false, Qbox.Storageprovider, Qbox.SerialNumber, Qbox.DataStore.Path, CounterId, Qbox.Precision, StorageId);
                return(true);
            }
            return(false);
        }
Beispiel #7
0
        public async Task UploadFileAsync(Storage storage, IMediaElement element, Stream stream)
        {
            IStorageProvider storageProvider = StorageProviderFactory.GetStorageProvider(
                _serviceProvider, storage.StorageType);

            await storageProvider.UploadFileAsync(stream, storage.StorageId,
                                                  storage.StorageAccessKey, StorageMode.Internal, storage.DownloadHost,
                                                  element.FilePath, element.GetFileName());

            if (element.IsPublished)
            {
                await this.PublishAsync(storage, element);
            }
        }
Beispiel #8
0
        public async Task PublishAsync(Storage storage, IMediaElement element)
        {
            IStorageProvider storageProvider = StorageProviderFactory.GetStorageProvider(
                _serviceProvider, storage.StorageType);

            using (Stream stream = storageProvider.GetStream(
                       storage.StorageId, storage.StorageAccessKey, StorageMode.Internal,
                       storage.DownloadHost, element.FilePath, element.GetFileName()))
            {
                if (stream == null)
                {
                    return;
                }
                await storageProvider.UploadFileAsync(
                    stream, storage.PublishStorageId, storage.PublishStorageAccessKey,
                    StorageMode.External, storage.PublishHost, element.FilePath, element.GetFileName());
            }
        }
Beispiel #9
0
        public string GetUrlByFormatSizeQuality(Storage storage, string filePath, string fileName,
                                                MediaElementUrlType type, string format, int maxWidthHeight, int percentage)
        {
            IStorageProvider storageProvider = StorageProviderFactory.GetStorageProvider(
                _serviceProvider, storage.StorageType);

            switch (type)
            {
            case MediaElementUrlType.DownloadUrl:
            {
                return(storageProvider.GetUrlByFormatSizeQuality(
                           new DefaultStorageInfoImpl()
                    {
                        NetType = NetType.Intranet,
                        StorageAccessKey = storage.StorageAccessKey,
                        StorageId = storage.StorageId,
                        StorageHost = storage.DownloadHost,
                    }, type, filePath, fileName, format,
                           maxWidthHeight, percentage));
            }

            case MediaElementUrlType.OutputUrl:
            {
                return(storageProvider.GetUrlByFormatSizeQuality(
                           new DefaultStorageInfoImpl()
                    {
                        NetType = NetType.Internet,
                        StorageAccessKey = storage.StorageAccessKey,
                        StorageId = storage.StorageId,
                        StorageHost = storage.OutputHost,
                    }, type, filePath, fileName, format,
                           maxWidthHeight, percentage));
            }

            case MediaElementUrlType.PublishDownloadUrl:
            {
                return(storageProvider.GetUrlByFormatSizeQuality(
                           new DefaultStorageInfoImpl()
                    {
                        NetType = NetType.Intranet,
                        StorageAccessKey = storage.PublishStorageAccessKey,
                        StorageId = storage.PublishStorageId,
                        StorageHost = storage.PublishOutputHost,
                    }, type, filePath, fileName, format,
                           maxWidthHeight, percentage));
            }

            default:
            {
                return(storageProvider.GetUrlByFormatSizeQuality(
                           new DefaultStorageInfoImpl()
                    {
                        NetType = NetType.Internet,
                        StorageAccessKey = storage.PublishStorageAccessKey,
                        StorageId = storage.PublishStorageId,
                        StorageHost = storage.PublishOutputHost,
                    }, type, filePath, fileName, format,
                           maxWidthHeight, percentage));
            }
            }
        }
Beispiel #10
0
 public void WhenGettingWithNullShouldThrowTest()
 {
     Assert.Throws <ArgumentNullException>(
         () => StorageProviderFactory.GetStorageProvider(false, StorageProvider.kWhStorage, null, null, 0, Precision.kWh));
 }