public Result SetTenantInfo(string tenant, string version = null)
        {
            var    info    = GetAllTenantsInfo();
            string fromVer = "";

            if (info.TryGetValue(tenant, out TenantInfoItem item))
            {
                if (!string.IsNullOrEmpty(item.Version))
                {
                    fromVer = " from " + item.Version;
                }
            }
            else
            {
                info[tenant] = new TenantInfoItem();
            }

            if (version != null)
            {
                info[tenant].Version = version;
                output.WriteLine($"Changing tenant version{fromVer} to version " + version);
            }

            WriteFileOperation("Uploading", "tenantInfo.json", false);
            var res = SetAllTenantsInfo(info);

            if (res.IsSuccess)
            {
                WriteSuccess();
                output.WriteLine();
            }
            else
            {
                WriteException(res.ExceptionMessage, res.Message, res.StackTrace);
                return(res);
            }
            return(new PublisherResult());
        }
Esempio n. 2
0
        public virtual IActionResult Index([FromRoute] string id, [FromQuery] LangConfig conf)
        {
            if (!Request.IsHttps && RestrictHttps)
            {
                string url = (HttpsUrl ?? "https://" + Request.Host) + Request.Path;
                return(Redirect(url));
            }

            string dom        = RequestedDomain;
            bool   isDevBuild = JsEnvironment == "dev";

            TenantInfoItem info = null;

            if (Tenants.TryGetValue(dom, out TenantInfoItem item))
            {
                info = item;
            }

            string version = Shell.ProjectAssembly.GetVersionString();

            if (item != null && item.Version != null)
            {
                version = item.Version;
            }

            string loc = conf?.lang == null?Request.GetLocaleFromCookie() : conf.lang;

            string package = isDevBuild ? "dev" : "v" + version;
            string path    = Path.Combine(Shell.AppRootPath, Shell.PublicRoot, "dist", package);
            string search  = isDevBuild ? "dev*.js" : dom + "-" + package + "*.js";

            Utils.CreateFolderForFile(path + "\\n.x");
            string[] files = Directory.GetFiles(path, search);

            var mod = new IndexModel
            {
                Title     = GetDefaultTitle(loc),
                Config    = ServerConfig,
                PackageId = package
            };

            mod.Config.Locale  = loc;
            mod.Config.Env     = JsEnvironment;
            mod.Config.Version = version;
            var urls = Shell.GetConfigAs <Dictionary <string, string> >("Services", false);

            if (urls != null)
            {
                mod.Config.Urls = new Dictionary <string, string>();
                foreach (var s in urls)
                {
                    mod.Config.Urls[s.Key] = WebUtils.FillConfigUrlParams(s.Value, Request);
                }
            }


            if (EmptyUrlHandler != null && Request.PathIsEmpty())
            {
                return(EmptyUrlHandler.Invoke(mod));
            }

            mod.Config.Domain  = dom;
            mod.Config.BaseURL = dom == DefaultDomain ? "/" : "/" + dom;
            mod.Config.Hash    = isDevBuild ? "" : "~7d078181";
            mod.Chunks         = files.Select(d => d.GetAfterLast("\\")).ToArray();

            return(IndexPage(mod));
        }