コード例 #1
0
        public SupportedStorageProvider GetStorageProvider()
        {
            SupportedStorageProvider storageProvider = SupportedStorageProvider.Local;
            HttpContext context = System.Web.HttpContext.Current;

            if (context != null)
            {
                object objectStorageProvider = context.Application[Constants.StorageProvider];
                if (objectStorageProvider != null)
                {
                    storageProvider = (SupportedStorageProvider)objectStorageProvider;
                }
            }
            return(storageProvider);
        }
コード例 #2
0
        public IEditingService GetViewingService(SupportedStorageProvider storageProvider,
            string serviceHost, string apiKey, string apiSecretKey,
            string bucketName, string cacheBucketName,
            string rootStoragePath, string workingFolder = null)
        {
            Hashtable options = new Hashtable();
            options[Constants.ApiKey] = apiKey;
            options[Constants.ApiSecretKey] = apiSecretKey;
            options[CommonConstants.BucketNameKey] = bucketName;
            options[Constants.ServiceHostKey] = serviceHost;
            options[CommonConstants.CacheFolderKey] = _downloadPath;
            options[CommonConstants.CacheBucketNameKey] = cacheBucketName;

            return GetViewingServiceForOptions(null, null, storageProvider, options, rootStoragePath, workingFolder);
        }
コード例 #3
0
        public IEditingService GetViewingService(SupportedStorageProvider storageProvider,
                                                 string serviceHost, string apiKey, string apiSecretKey,
                                                 string bucketName, string cacheBucketName,
                                                 string rootStoragePath, string workingFolder = null)
        {
            Hashtable options = new Hashtable();

            options[Constants.ApiKey]                   = apiKey;
            options[Constants.ApiSecretKey]             = apiSecretKey;
            options[CommonConstants.BucketNameKey]      = bucketName;
            options[Constants.ServiceHostKey]           = serviceHost;
            options[CommonConstants.CacheFolderKey]     = _downloadPath;
            options[CommonConstants.CacheBucketNameKey] = cacheBucketName;

            return(GetViewingServiceForOptions(null, null, storageProvider, options, rootStoragePath, workingFolder));
        }
コード例 #4
0
        private IEditingService GetViewingServiceForOptions(IStorageProvider customStorageProvider,
                                                            IStorageProvider customTempStorageProvider,
                                                            SupportedStorageProvider storageProvider,
                                                            Hashtable options,
                                                            string rootStoragePath, string workingFolder)
        {
            IEditingService viewingService;

            if (customStorageProvider == null)
            {
                switch (storageProvider)
                {
                case SupportedStorageProvider.Local:
                    viewingService = new EditingService(rootStoragePath, workingFolder);
                    break;

                default:
                    object sourceBucketNameObject = null, cacheBucketNameObject = null;
                    string sourceBucketName = null, cacheBucketName = null;
                    if (options != null)
                    {
                        sourceBucketNameObject = options[CommonConstants.BucketNameKey];
                        if (sourceBucketNameObject != null)
                        {
                            sourceBucketName = (string)sourceBucketNameObject;
                        }

                        cacheBucketNameObject = options[CommonConstants.CacheBucketNameKey];
                        if (cacheBucketNameObject != null)
                        {
                            cacheBucketName = (string)cacheBucketNameObject;
                            options[CommonConstants.DownloadFolderForCacheStorageKey] = Path.Combine(_downloadPath,
                                                                                                     cacheBucketName);
                        }
                        options[CommonConstants.CacheFolderKey] = Path.Combine(_downloadPath, sourceBucketName);
                    }
                    viewingService = new EditingService(rootStoragePath, (byte)storageProvider, options,
                                                        cacheBucketName);
                    break;
                }
            }
            else
            {
                viewingService = GetViewingService(rootStoragePath, customStorageProvider, workingFolder, customTempStorageProvider);
            }
            return(viewingService);
        }
コード例 #5
0
 /// <summary>
 /// Sets the storage provider used by Viewer.
 /// </summary>
 /// <param name="storageProvider">A storage provider.</param>
 /// <param name="serviceHost">The URL of a host</param>
 /// <param name="apiKey">An API key.</param>
 /// <param name="apiSecretKey">A secret key.</param>
 /// <param name="bucketName">The name of a bucket.</param>
 /// <param name="cacheBucketName">The name of a bucket which holds the cache</param>
 public static void SetStorageProvider(SupportedStorageProvider storageProvider,
                                       string serviceHost, string apiKey, string apiSecretKey,
                                       string bucketName, string cacheBucketName)
 {
     HttpContext context = HttpContext.Current;
     if (context != null)
     {
         HttpApplicationState application = context.Application;
         application[Constants.StorageProvider] = storageProvider;
         Hashtable storageProviderOptions = new Hashtable();
         storageProviderOptions[Constants.ApiKey] = apiKey;
         storageProviderOptions[Constants.ApiSecretKey] = apiSecretKey;
         storageProviderOptions[CommonConstants.BucketNameKey] = bucketName;
         storageProviderOptions[Constants.ServiceHostKey] = serviceHost;
         storageProviderOptions[CommonConstants.CacheBucketNameKey] = cacheBucketName;
         application[Constants.StorageProviderOptions] = storageProviderOptions;
     }
 }
コード例 #6
0
        /// <summary>
        /// Sets the storage provider used by Viewer.
        /// </summary>
        /// <param name="storageProvider">A storage provider.</param>
        /// <param name="serviceHost">The URL of a host</param>
        /// <param name="apiKey">An API key.</param>
        /// <param name="apiSecretKey">A secret key.</param>
        /// <param name="bucketName">The name of a bucket.</param>
        /// <param name="cacheBucketName">The name of a bucket which holds the cache</param>
        public static void SetStorageProvider(SupportedStorageProvider storageProvider,
                                              string serviceHost, string apiKey, string apiSecretKey,
                                              string bucketName, string cacheBucketName)
        {
            HttpContext context = HttpContext.Current;

            if (context != null)
            {
                HttpApplicationState application = context.Application;
                application[Constants.StorageProvider] = storageProvider;
                Hashtable storageProviderOptions = new Hashtable();
                storageProviderOptions[Constants.ApiKey]                   = apiKey;
                storageProviderOptions[Constants.ApiSecretKey]             = apiSecretKey;
                storageProviderOptions[CommonConstants.BucketNameKey]      = bucketName;
                storageProviderOptions[Constants.ServiceHostKey]           = serviceHost;
                storageProviderOptions[CommonConstants.CacheBucketNameKey] = cacheBucketName;
                application[Constants.StorageProviderOptions]              = storageProviderOptions;
            }
        }
コード例 #7
0
        public IEditingService GetViewingService(string rootStoragePath, string workingFolder = null)
        {
            IStorageProvider         customStorageProvider     = _helper.GetCustomStorageProvider();
            IStorageProvider         customTempStorageProvider = _helper.GetCustomTempStorageProvider();
            SupportedStorageProvider storageProvider           = SupportedStorageProvider.Default;
            Hashtable options = null;

            if (customStorageProvider == null)
            {
                storageProvider = _helper.GetStorageProvider();

                System.Web.HttpContext context = System.Web.HttpContext.Current;
                if (context != null)
                {
                    object objectOptions = context.Application[Constants.StorageProviderOptions];
                    if (objectOptions != null)
                    {
                        options = (Hashtable)((Hashtable)objectOptions).Clone();
                    }
                }
            }
            return(GetViewingServiceForOptions(customStorageProvider, customTempStorageProvider, storageProvider, options, rootStoragePath, workingFolder));
        }
コード例 #8
0
        private IEditingService GetViewingServiceForOptions(IStorageProvider customStorageProvider,
                                                 IStorageProvider customTempStorageProvider,
                                                 SupportedStorageProvider storageProvider,
                                                 Hashtable options,
                                                 string rootStoragePath, string workingFolder)
        {
            IEditingService viewingService;
            if (customStorageProvider == null)
            {
                switch (storageProvider)
                {
                    case SupportedStorageProvider.Local:
                        viewingService = new EditingService(rootStoragePath, workingFolder);
                        break;
                    default:
                        object sourceBucketNameObject = null, cacheBucketNameObject = null;
                        string sourceBucketName = null, cacheBucketName = null;
                        if (options != null)
                        {
                            sourceBucketNameObject = options[CommonConstants.BucketNameKey];
                            if (sourceBucketNameObject != null)
                                sourceBucketName = (string) sourceBucketNameObject;

                            cacheBucketNameObject = options[CommonConstants.CacheBucketNameKey];
                            if (cacheBucketNameObject != null)
                            {
                                cacheBucketName = (string) cacheBucketNameObject;
                                options[CommonConstants.DownloadFolderForCacheStorageKey] = Path.Combine(_downloadPath,
                                                                                                         cacheBucketName);
                            }
                            options[CommonConstants.CacheFolderKey] = Path.Combine(_downloadPath, sourceBucketName);
                        }
                        viewingService = new EditingService(rootStoragePath, (byte) storageProvider, options,
                                                            cacheBucketName);
                        break;
                }
            }
            else
            {
                viewingService = GetViewingService(rootStoragePath, customStorageProvider, workingFolder, customTempStorageProvider);
            }
            return viewingService;
        }