Esempio n. 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);
            }
        }
Esempio n. 2
0
        public static void InitializeHttpHandlers(string config = null)
        {
            if (!HostingEnvironment.IsHosted)
            {
                throw new InvalidOperationException("Application not hosted.");
            }

            var section = GetSection(config);

            if (section != null)
            {
                var discHandler = section.Handlers.GetHandler("disc");
                if (discHandler != null)
                {
                    var props = discHandler.GetProperties();
                    foreach (var m in section.Modules.Cast <ModuleConfigurationElement>().Where(m => m.Type == "disc"))
                    {
                        DiscDataHandler.RegisterVirtualPath(
                            PathUtils.ResolveVirtualPath(m.VirtualPath),
                            PathUtils.ResolvePhysicalPath(m.Path, props));

                        foreach (var d in m.Domains.Cast <DomainConfigurationElement>().Where(d => d.Type == "disc" || string.IsNullOrEmpty(d.Type)))
                        {
                            DiscDataHandler.RegisterVirtualPath(
                                PathUtils.ResolveVirtualPath(d.VirtualPath),
                                PathUtils.ResolvePhysicalPath(d.Path, props));
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public static void InitializeHttpHandlers(string config = null)
        {
            if (!HostingEnvironment.IsHosted)
            {
                throw new InvalidOperationException("Application not hosted.");
            }

            var section = GetSection(config);

            if (section != null)
            {
                //old scheme
                var discHandler = section.Handlers.GetHandler("disc");
                if (discHandler != null)
                {
                    var props = discHandler.GetProperties();
                    foreach (var m in section.Modules.Cast <ModuleConfigurationElement>().Where(m => m.Type == "disc"))
                    {
                        if (m.Path.Contains(Constants.STORAGE_ROOT_PARAM))
                        {
                            DiscDataHandler.RegisterVirtualPath(
                                PathUtils.ResolveVirtualPath(m.VirtualPath),
                                PathUtils.ResolvePhysicalPath(m.Path, props),
                                m.Public);
                        }

                        foreach (var d in m.Domains.Cast <DomainConfigurationElement>().Where(d => (d.Type == "disc" || string.IsNullOrEmpty(d.Type)) && d.Path.Contains(Constants.STORAGE_ROOT_PARAM)))
                        {
                            DiscDataHandler.RegisterVirtualPath(
                                PathUtils.ResolveVirtualPath(d.VirtualPath),
                                PathUtils.ResolvePhysicalPath(d.Path, props));
                        }
                    }
                }

                //new scheme
                foreach (var m in section.Modules.Cast <ModuleConfigurationElement>())
                {
                    //todo: add path criterion
                    if (m.Type == "disc" || !m.Public || m.Path.Contains(Constants.STORAGE_ROOT_PARAM))
                    {
                        StorageHandler.RegisterVirtualPath(
                            m.Name,
                            string.Empty,
                            m.Public);
                    }

                    //todo: add path criterion
                    foreach (var d in m.Domains.Cast <DomainConfigurationElement>().Where(d => d.Path.Contains(Constants.STORAGE_ROOT_PARAM)))
                    {
                        StorageHandler.RegisterVirtualPath(
                            m.Name,
                            d.Name,
                            d.Public);
                    }
                }
            }
        }