コード例 #1
0
        static DiscTransform()
        {
            try
            {
                log = LogManager.GetLogger("ASC.Web.Bundle.DiscTransform");

                var section = (StorageConfigurationSection)WebConfigurationManager.GetSection("storage");
                if (section == null)
                {
                    throw new Exception("Storage section not found.");
                }

                foreach (HandlerConfigurationElement h in section.Handlers)
                {
                    if (h.Name == "disc")
                    {
                        BaseStoragePath = Path.Combine(h.HandlerProperties["$STORAGE_ROOT"].Value, "bundle");
                        break;
                    }
                }

                if (!string.IsNullOrEmpty(BaseStoragePath))
                {
                    DiscDataHandler.RegisterVirtualPath(BaseVirtualPath, GetFullPhysicalPath("/"), true);
                    SuccessInitialized = CoreContext.Configuration.Standalone && !StaticUploader.CanUpload();
                }
            }
            catch (Exception fatal)
            {
                log.Fatal(fatal);
            }
        }
コード例 #2
0
 public static void AddBundle(Bundle bundle)
 {
     BundleTable.Bundles.Add(bundle);
     if (DiscTransform.SuccessInitialized || StaticUploader.CanUpload())
     {
         bundle.GenerateBundleResponse(new BundleContext(new HttpContextWrapper(HttpContext.Current), BundleTable.Bundles, bundle.Path));
     }
 }
コード例 #3
0
ファイル: MigrationService.cs プロジェクト: ztcyun/AppServer
        public void UploadCdn(int tenantId, string relativePath, string mappedPath, CdnStorageSettings cdnStorageSettings = null)
        {
            using var scope = ServiceProvider.CreateScope();
            var tenantManager = scope.ServiceProvider.GetService <TenantManager>();

            tenantManager.SetCurrentTenant(tenantId);

            StaticUploader.UploadDir(relativePath, mappedPath);
            Log.DebugFormat("UploadDir {0}", mappedPath);
        }
コード例 #4
0
        private string GetLink()
        {
            var path = bundleData.GetStorageVirtualPath(ClientSettings.ResetCacheKey);

            if (DiscTransform.SuccessInitialized && DiscTransform.IsFile(path) && !StaticUploader.CanUpload())
            {
                return(bundleData.GetLink(DiscTransform.GetUri(path), false));
            }

            return(BundleHelper.AddBundle(bundleData));
        }
コード例 #5
0
        public void UploadCdn(int tenantId, string relativePath, string mappedPath, CdnStorageSettings cdnStorageSettings = null)
        {
            CoreContext.TenantManager.SetCurrentTenant(tenantId);

            if (cdnStorageSettings != null)
            {
                cdnStorageSettings.Save();
            }

            StaticUploader.UploadDir(relativePath, mappedPath);
            LogManager.GetLogger("ASC").DebugFormat("UploadDir {0}", mappedPath);
        }
コード例 #6
0
ファイル: MigrationService.cs プロジェクト: ztcyun/AppServer
 public MigrationService(
     StorageUploader storageUploader,
     StaticUploader staticUploader,
     StorageFactoryConfig storageFactoryConfig,
     IServiceProvider serviceProvider,
     IOptionsMonitor <ILog> options)
 {
     StorageUploader      = storageUploader;
     StaticUploader       = staticUploader;
     StorageFactoryConfig = storageFactoryConfig;
     ServiceProvider      = serviceProvider;
     Log = options.Get("ASC.Data.Storage.Migration");
 }
コード例 #7
0
        public void Process(BundleContext context, BundleResponse response)
        {
            if (!BundleTable.Bundles.UseCdn)
            {
                return;
            }

            try
            {
                var bundle = context.BundleCollection.GetBundleFor(context.BundleVirtualPath);
                if (bundle != null)
                {
                    var fileName = Path.GetFileName(bundle.Path);
                    if (string.IsNullOrEmpty(fileName))
                    {
                        return;
                    }
                    var path         = Path.Combine("App_Data", fileName);
                    var relativePath = TempPath.GetTempFileName();

                    File.WriteAllText(relativePath, response.Content, Encoding.UTF8);

                    StaticUploader.UploadFileAsync(path, relativePath, r =>
                    {
                        try
                        {
                            bundle.CdnPath = r;
                            File.Delete(relativePath);
                        }
                        catch (Exception e)
                        {
                            Log.Error("StorageTransform", e);
                        }
                    });
                }
            }
            catch (Exception fatal)
            {
                Log.Fatal(fatal);
                throw;
            }
        }
コード例 #8
0
        public double GetProgress(int tenantId)
        {
            var progress = (ProgressBase)StorageUploader.GetProgress(tenantId) ?? StaticUploader.GetProgress(tenantId);

            return(progress != null ? progress.Percentage : -1);
        }