Пример #1
0
        public virtual void Post(ApiCall call)
        {
            string subdomain  = call.GetValue("subdomain");
            string RootDomain = call.GetValue("rootdomain");
            Guid   SiteId     = call.GetGuidValue("SiteId");
            int    port       = (int)call.GetLongValue("Port");

            if (string.IsNullOrEmpty(RootDomain))
            {
                return;
            }

            bool DefaultBinding = call.GetBoolValue("DefaultBinding");

            if (SiteId != default(Guid))
            {
                if (port <= 0)
                {
                    DefaultBinding = false;
                }


                if (!DefaultBinding)
                {
                    port = 0;
                }


                if (port > 0)
                {
                    if (!SystemStart.WebServers.ContainsKey(port) && Lib.Helper.NetworkHelper.IsPortInUse(port))
                    {
                        throw new Exception(Data.Language.Hardcoded.GetValue("port in use", call.Context) + ": " + port.ToString());
                    }
                }


                if (DefaultBinding && port > 0)
                {
                    GlobalDb.Bindings.AddOrUpdate(null, null, SiteId, call.Context.User.CurrentOrgId, DefaultBinding, port);
                }
                else
                {
                    var domain = GlobalDb.Domains.Get(RootDomain);
                    if (domain.OrganizationId != default(Guid) && AppSettings.IsOnlineServer && domain.OrganizationId != call.Context.User.CurrentOrgId)
                    {
                        throw new Exception(Data.Language.Hardcoded.GetValue("Domain does not owned by current user", call.Context));
                    }

                    GlobalDb.Bindings.AddOrUpdate(RootDomain, subdomain, SiteId, call.Context.User.CurrentOrgId, DefaultBinding, port);
                }
            }
        }