Example #1
0
        OnDisconnected(bool stopCalled)
#endif
        {
            //%%%%%%%%%%%%%%%%%%% notify users in scope of user disconnect
            string name = null;

            try {
                if (Context.User != null)
                {
                    name = Context.User.Identity.Name;
                }
                if (!string.IsNullOrWhiteSpace(name))
                {
                    Dispatch(this.Clients.Others, "userDisconnect", name);
                }
            } catch (Exception) { }

            try {
                string         host = Context.Headers["Host"];
                SiteDefinition site = await SiteDefinition.LoadSiteDefinitionAsync(host);

                if (site == null)
                {
                    throw new InternalError("No site definition for {0}", host);
                }
                using (ConnectionDataProvider connDP = new ConnectionDataProvider(site.Identity)) {
                    await connDP.RemoveItemAsync(Context.ConnectionId);
                }
            } catch (Exception) { }
#if MVC6
            await base.OnDisconnectedAsync(exception);
#else
            await base.OnDisconnected(stopCalled);
#endif
        }
        public async Task <ActionResult> SiteProperties_Partial(SitePropertiesModel model)
        {
            SiteDefinition origSite;

            if (model.SiteHost == null)
            {
                origSite = Manager.CurrentSite;
            }
            else
            {
                origSite = await SiteDefinition.LoadSiteDefinitionAsync(model.SiteHost);
            }
            if (!ModelState.IsValid)
            {
                return(PartialView(model));
            }
            ObjectSupport.CopyDataFromOriginal(origSite, model.Site);
            await model.Site.SaveAsync();

            ObjectSupport.ModelDisposition modelDisp = ObjectSupport.EvaluateModelChanges(origSite, model.Site);
            switch (modelDisp)
            {
            default:
            case ObjectSupport.ModelDisposition.None:
                return(FormProcessed(model, this.__ResStr("okSaved", "Site settings updated")));

            case ObjectSupport.ModelDisposition.PageReload:
                return(FormProcessed(model, this.__ResStr("okSaved", "Site settings updated"), OnClose: OnCloseEnum.ReloadPage, OnPopupClose: OnPopupCloseEnum.ReloadParentPage, ForceRedirect: true));

            case ObjectSupport.ModelDisposition.SiteRestart:
                return(FormProcessed(model, this.__ResStr("okSavedRestart", "Site settings updated - These settings won't take effect until the site is restarted")));
            }
        }
        public async Task <ActionResult> ConfirmRemoval_Partial(EditModel model)
        {
            model.SiteDomainDisplay = model.SiteDomain;
            if (!ModelState.IsValid)
            {
                return(PartialView(model));
            }

            SiteDefinition site = await SiteDefinition.LoadSiteDefinitionAsync(model.SiteDomain);

            if (site == null)
            {
                throw new InternalError($"Site {site.SiteDomain} not found");
            }

            SiteDefinition currentSite = Manager.CurrentSite;

            Manager.CurrentSite = site;
            try {
                await Manager.CurrentSite.RemoveAsync();
            } catch (Exception) {
                throw;
            } finally {
                Manager.CurrentSite = currentSite;
            }

            string nextPage = Manager.CurrentSite.MakeUrl(RealDomain: Manager.CurrentSite.SiteDomain);

            Manager.RestartSite();

            return(FormProcessed(null, this.__ResStr("okRemoved", "Site \"{0}\" has been removed(+nl)(+nl)The site is now restarting", model.SiteDomain),
                                 NextPage: nextPage));
        }
Example #4
0
        OnConnected()
#endif
        {
            try {
                string         host = Context.Headers["Host"];
                SiteDefinition site = await SiteDefinition.LoadSiteDefinitionAsync(host);

                if (site == null)
                {
                    throw new InternalError("No site definition for {0}", host);
                }

                string name      = null;
                string ipAddress = null;
                try {
                    if (Context.User != null)
                    {
                        name = Context.User.Identity.Name;
                    }
                } catch (Exception) { }
                try {
                    ipAddress = (string)Context.Request.Environment["server.RemoteIpAddress"];
                } catch (Exception) { }
                string connectionId = Context.ConnectionId;

                try {
                    using (ConnectionDataProvider connDP = new ConnectionDataProvider(site.Identity)) {
                        await connDP.UpdateEntryAsync(name, ipAddress, connectionId);
                    }
                } catch (Exception) { }

                //%%%%%%%%%%%%%%%%%%% notify users in scope of new user
                if (!string.IsNullOrWhiteSpace(name))
                {
                    Dispatch(this.Clients.Others, "userConnect", name);
                }
            } catch (Exception) { }
#if MVC6
            await base.OnConnectedAsync();
#else
            await base.OnConnected();
#endif
        }
        public async Task <ActionResult> SiteProperties(string domain)
        {
            SiteDefinition site;

            if (domain == null)
            {
                site = Manager.CurrentSite;
            }
            else
            {
                site = await SiteDefinition.LoadSiteDefinitionAsync(domain);
            }
            if (site == null)
            {
                throw new Error(this.__ResStr("errNoSite", "Site \"{0}\" not found", domain));
            }
            SitePropertiesModel model = new SitePropertiesModel {
                SiteHost = domain,
                Site     = site,
            };

            return(View(model));
        }