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); } }
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)); } }
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); }
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)); }
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); }
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"); }
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; } }
public double GetProgress(int tenantId) { var progress = (ProgressBase)StorageUploader.GetProgress(tenantId) ?? StaticUploader.GetProgress(tenantId); return(progress != null ? progress.Percentage : -1); }