Ejemplo n.º 1
0
        public bool IsWellKnownDb()
        {
            var serializer = new DomainSerializer("domains-approved.json");
            var domains    = serializer.Get();

            return(domains.Any(domain => DbConvention.GetCatalog(domain) == this.Catalog));
        }
Ejemplo n.º 2
0
        internal static string ToCdnResource(string path)
        {
            if (!path.StartsWith("/") || path.StartsWith("//") || path.ToLowerInvariant().StartsWith("/signalr"))
            {
                return(path);
            }

            var approved = new DomainSerializer("DomainsApproved.json");
            var tenant   = approved.Get().FirstOrDefault(x => x.GetSubtenants().Contains(DbConvention.GetDomain()));

            if (tenant == null)
            {
                return(path);
            }

            if (!string.IsNullOrWhiteSpace(tenant.CdnDomain))
            {
                var uri = HttpContext.Current.Request.Url;

                return(uri.Scheme + Uri.SchemeDelimiter + tenant.CdnDomain +
                       (uri.IsDefaultPort ? "" : ":" + uri.Port) + path);
            }

            return(path);
        }
Ejemplo n.º 3
0
        public bool IsWellKnownDb()
        {
            var serializer = new DomainSerializer("DomainsApproved.json");
            var domains    = serializer.Get();

            return(domains.Any(domain => DbConvention.GetTenant(domain.DomainName) == this.Database));
        }
Ejemplo n.º 4
0
        public void Register()
        {
            try
            {
                var installed = new DomainSerializer("DomainsInstalled.json");

                foreach (var repository in
                         from domain in installed.Get()
                         let catalog = DbConvention.GetDbNameByConvention(domain.DomainName)
                                       select new AddInstalledDomainProcedure
                {
                    DomainName = domain.DomainName,
                    AdminEmail = domain.AdminEmail,
                    SkipValidation = true,
                    _Catalog = catalog
                })
                {
                    repository.Execute();
                }
            }
            catch (NpgsqlException ex)
            {
                Log.Error("Could not execute AddInstalledDomainProcedure. Exception: {Exception}", ex);
            }
        }
Ejemplo n.º 5
0
        public void Register()
        {
            try
            {
                var installed = new DomainSerializer("DomainsInstalled.json");

                foreach (var domain in installed.Get())
                {
                    string database = DbConvention.GetDbNameByConvention(domain.DomainName);
                    InstalledDomains.Add(database, domain.DomainName, domain.AdminEmail);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Could not execute AddInstalledDomainProcedure. Exception: {Exception}", ex);
            }
        }
Ejemplo n.º 6
0
        public ActionResult Index()
        {
            string domain = DbConvention.GetDomain();

            var approved  = new DomainSerializer("domains-approved.json");
            var installed = new DomainSerializer("domains-installed.json");

            if (!approved.Get().Contains(domain))
            {
                return(this.HttpNotFound());
            }

            if (installed.Get().Contains(domain))
            {
                return(this.Redirect("/"));
            }

            InstallationFactory.Setup(domain); //Background job
            return(this.Content("Installing frapid, please visit the site after a few minutes."));
        }
Ejemplo n.º 7
0
        public static string ToCanonicalUrl(string url = "")
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                url = HttpContext.Current.Request.Url.PathAndQuery;
            }

            string domain   = DbConvention.GetDomain();
            var    approved = new DomainSerializer("DomainsApproved.json");
            var    tenant   = approved.Get().FirstOrDefault(x => x.GetSubtenants().Contains(domain.ToLowerInvariant()));

            if (tenant != null)
            {
                string protocol   = HttpContext.Current.Request.IsSecureConnection ? "https://" : "http://";
                string domainName = protocol + tenant.DomainName;
                url = UrlHelper.CombineUrl(domainName, url);
                return(url);
            }

            return(string.Empty);
        }
Ejemplo n.º 8
0
        public ActionResult Index()
        {
            string domain = DbConvention.GetDomain();

            var approved  = new DomainSerializer("DomainsApproved.json");
            var installed = new DomainSerializer("DomainsInstalled.json");

            if (!approved.GetTenantMembers().Any(x => x.Equals(domain)))
            {
                return(this.HttpNotFound());
            }

            if (installed.GetTenantMembers().Any(x => x.Equals(domain)))
            {
                return(this.Redirect("/"));
            }

            var setup = approved.Get().FirstOrDefault(x => x.GetSubtenants().Contains(domain.ToLowerInvariant()));

            InstallationFactory.Setup(setup); //Background job
            return(this.Content("Installing frapid, please visit the site after a few minutes."));
        }