Ejemplo n.º 1
0
        private async Task DeleteTenant(Tenant Tenant)
        {
            try
            {
                string message = string.Empty;
                var    aliases = await AliasService.GetAliasesAsync();

                foreach (var alias in aliases)
                {
                    if (alias.TenantId == Tenant.TenantId)
                    {
                        message += ", " + alias.Name;
                    }
                }
                if (string.IsNullOrEmpty(message))
                {
                    await TenantService.DeleteTenantAsync(Tenant.TenantId);

                    await logger.LogInformation("Tenant Deleted {Tenant}", Tenant);

                    StateHasChanged();
                }
                else
                {
                    AddModuleMessage("Tenant Cannot Be Deleted Until The Following Sites Are Deleted: " + message.Substring(2), MessageType.Warning);
                }
            }
            catch (Exception ex)
            {
                await logger.LogError(ex, "Error Deleting Tenant {Tenant} {Error}", Tenant, ex.Message);

                AddModuleMessage("Error Deleting Tenant", MessageType.Error);
            }
        }
Ejemplo n.º 2
0
        private async Task DeleteSite(Alias alias)
        {
            try
            {
                if (alias.SiteId != PageState.Site.SiteId || alias.TenantId != PageState.Site.TenantId)
                {
                    SiteService.SetAlias(alias);
                    await SiteService.DeleteSiteAsync(alias.SiteId);
                    await Log(alias, LogLevel.Information, "", null, "Site Deleted {SiteId}", alias.SiteId);

                    var aliases = await AliasService.GetAliasesAsync();

                    foreach (Alias a in aliases.Where(item => item.SiteId == alias.SiteId && item.TenantId == alias.TenantId))
                    {
                        await AliasService.DeleteAliasAsync(a.AliasId);
                    }

                    NavigationManager.NavigateTo(NavigateUrl());
                }
                else
                {
                    AddModuleMessage("You Can Not Delete The Current Site", MessageType.Warning);
                }
            }
            catch (Exception ex)
            {
                await Log(alias, LogLevel.Error, "", ex, "Error Deleting Site {SiteId} {Error}", alias.SiteId, ex.Message);

                AddModuleMessage("Error Deleting Site", MessageType.Error);
            }
        }
Ejemplo n.º 3
0
 public DKPModule(EQDKPService eqDkpService, AliasService aliasService, SettingsService settingsService)
 {
     EQDKPService    = eqDkpService;
     AliasService    = aliasService;
     SettingsService = settingsService;
     Log             = eqDkpService.Log;
 }
Ejemplo n.º 4
0
        public override bool Execute(FolderInput input)
        {
            var folder = new AliasService().GetFolderForAlias(input.AppFolder);

            Restart(folder);
            return(true);
        }
Ejemplo n.º 5
0
        public override bool Execute(OpenManifestInput input)
        {
            var directory = new AliasService().GetFolderForAlias(input.BottleDirectory);

            var packageFile = directory.AppendPath(PackageManifest.FILE);

            System.Console.WriteLine("Looking for " + packageFile);

            var system = new FileSystem();

            if (system.FileExists(packageFile))
            {
                System.Console.WriteLine("Opening file...");
                system.LaunchEditor(packageFile);
            }
            else
            {
                System.Console.WriteLine("Could not find a PackageManifest");
                System.Console.WriteLine("To create a new PackageManifest, use 'bottles init " + directory + " [PackageName]'");
            }



            return(true);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a new api from the currently registered
        /// repositories.
        /// </summary>
        public Api(
            IContentFactory contentFactory,
            IAliasRepository aliasRepository,
            IArchiveRepository archiveRepository,
            IMediaRepository mediaRepository,
            IPageRepository pageRepository,
            IPageTypeRepository pageTypeRepository,
            IParamRepository paramRepository,
            IPostRepository postRepository,
            IPostTypeRepository postTypeRepository,
            ISiteRepository siteRepository,
            ISiteTypeRepository siteTypeRepository,
            ICache cache              = null,
            IStorage storage          = null,
            IImageProcessor processor = null)
        {
            // Store the cache
            _cache = cache;

            // Create services without dependecies
            PageTypes = new PageTypeService(pageTypeRepository, cache);
            Params    = new ParamService(paramRepository, cache);
            PostTypes = new PostTypeService(postTypeRepository, cache);
            Sites     = new SiteService(siteRepository, contentFactory, cache);
            SiteTypes = new SiteTypeService(siteTypeRepository, cache);

            // Create services with dependencies
            Aliases  = new AliasService(aliasRepository, Sites, cache);
            Media    = new MediaService(mediaRepository, Params, storage, processor, cache);
            Pages    = new PageService(pageRepository, contentFactory, Sites, Params, cache);
            Posts    = new PostService(postRepository, contentFactory, Sites, Pages, cache);
            Archives = new ArchiveService(archiveRepository, Params, Posts);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Receives the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="room">The room.</param>
        /// <param name="options">The options.</param>
        public override void Receive(Message message, Room room, Options options)
        {
            var aliases = AliasService.ListAliases();

            foreach (var alias in aliases)
            {
                HipChatService.Say(room, alias);
            }

            HipChatService.Say(room, "{0} aliases.", aliases.Count);
        }
Ejemplo n.º 8
0
 private ApplicationManager()
 {
     Logger        = new Logger($@"{SharedLibrary.Utilities.OperatingDirectory}Logs{Path.DirectorySeparatorChar}IW4MAdmin.log");
     _servers      = new List <Server>();
     Commands      = new List <Command>();
     TaskStatuses  = new List <AsyncStatus>();
     MessageTokens = new List <MessageToken>();
     ClientSvc     = new ClientService();
     AliasSvc      = new AliasService();
     PenaltySvc    = new PenaltyService();
 }
Ejemplo n.º 9
0
        public override bool Execute(InstallPackageInput input)
        {
            var applicationFolder = new AliasService().GetFolderForAlias(input.AppFolder);
            var uninstallFlag     = input.UninstallFlag;
            var packageFileName   = input.PackageFile;

            var service = new PackageService(new FileSystem());

            service.InstallPackage(applicationFolder, packageFileName, uninstallFlag);

            return(true);
        }
Ejemplo n.º 10
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                _themeList = await ThemeService.GetThemesAsync();

                _aliasList = await AliasService.GetAliasesAsync();

                _alias = _aliasList.Find(item => item.AliasId == Int32.Parse(PageState.QueryString["id"]));
                SiteService.SetAlias(_alias);
                var site = await SiteService.GetSiteAsync(_alias.SiteId);

                if (site != null)
                {
                    _name       = site.Name;
                    _tenantList = await TenantService.GetTenantsAsync();

                    _tenant = _tenantList.Find(item => item.TenantId == site.TenantId).Name;

                    foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
                    {
                        _urls += alias.Name + "\n";
                    }

                    _themes        = ThemeService.GetThemeControls(_themeList);
                    _themetype     = site.DefaultThemeType;
                    _layouts       = ThemeService.GetLayoutControls(_themeList, _themetype);
                    _layouttype    = site.DefaultLayoutType;
                    _containers    = ThemeService.GetContainerControls(_themeList, _themetype);
                    _containertype = site.DefaultContainerType;
                    _createdby     = site.CreatedBy;
                    _createdon     = site.CreatedOn;
                    _modifiedby    = site.ModifiedBy;
                    _modifiedon    = site.ModifiedOn;
                    _deletedby     = site.DeletedBy;
                    _deletedon     = site.DeletedOn;
                    _isdeleted     = site.IsDeleted.ToString();

                    _initialized = true;
                }
            }
            catch (Exception ex)
            {
                await Log(_alias, LogLevel.Error, string.Empty, ex, "Error Loading Site {SiteId} {Error}", _alias.SiteId, ex.Message);

                AddModuleMessage(ex.Message, MessageType.Error);
            }
        }
Ejemplo n.º 11
0
 private ApplicationManager()
 {
     Logger            = new Logger($@"{Utilities.OperatingDirectory}IW4MAdmin.log");
     _servers          = new List <Server>();
     Commands          = new List <Command>();
     TaskStatuses      = new List <AsyncStatus>();
     MessageTokens     = new List <MessageToken>();
     ClientSvc         = new ClientService();
     AliasSvc          = new AliasService();
     PenaltySvc        = new PenaltyService();
     PrivilegedClients = new Dictionary <int, Player>();
     Api = new EventApi();
     ServerEventOccurred    += Api.OnServerEvent;
     ConfigHandler           = new BaseConfigurationHandler <ApplicationConfiguration>("IW4MAdminSettings");
     Console.CancelKeyPress += new ConsoleCancelEventHandler(OnCancelKey);
     StartTime = DateTime.UtcNow;
 }
Ejemplo n.º 12
0
        public override bool Execute(IncludeWebContentInput input)
        {
            var folder = new AliasService().GetFolderForAlias(input.Folder);

            var manifest = new FileSystem().LoadPackageManifestFrom(folder);

            if (manifest.ContentFileSet == null)
            {
                manifest.ContentFileSet = new FileSet();
            }

            input.AppendIncludes(manifest.ContentFileSet);

            new FileSystem().PersistToFile(manifest, folder, PackageManifest.FILE);

            return(true);
        }
Ejemplo n.º 13
0
        protected override async Task OnParametersSetAsync()
        {
            var uri = new Uri(NavigationManager.Uri);

            _scheme = uri.Scheme + "://";

            var aliases = await AliasService.GetAliasesAsync();

            _sites = new List <Alias>();
            foreach (Alias alias in aliases)
            {
                if (!_sites.Exists(item => item.TenantId == alias.TenantId && item.SiteId == alias.SiteId))
                {
                    _sites.Add(alias);
                }
            }
        }
Ejemplo n.º 14
0
        public override bool Execute(InstallPackageInput input)
        {
            var applicationFolder = new AliasService().GetFolderForAlias(input.AppFolder);

            var packageFolder = FileSystem.Combine(applicationFolder, "bin", FubuMvcPackageFacility.FubuPackagesFolder);

            var destinationFileName = FileSystem.Combine(packageFolder, Path.GetFileName(input.PackageFile));

            if (input.UninstallFlag)
            {
                if (File.Exists(destinationFileName))
                {
                    Console.WriteLine("Deleting existing file " + destinationFileName);
                    File.Delete(destinationFileName);
                }
                else
                {
                    Console.WriteLine("File {0} does not exist", destinationFileName);
                }


                return(true);
            }

            if (!Directory.Exists(packageFolder))
            {
                Console.WriteLine("Creating folder " + packageFolder);
                Directory.CreateDirectory(packageFolder);
            }


            if (File.Exists(destinationFileName))
            {
                Console.WriteLine("Deleting existing file at " + destinationFileName);
                File.Delete(destinationFileName);
            }

            Console.WriteLine("Copying {0} to {1}", input.PackageFile, packageFolder);

            File.Copy(input.PackageFile, destinationFileName);
            return(true);
        }
Ejemplo n.º 15
0
        public SettingsViewModel(AliasService aliasService, WindowService windowService)
        {
            _aliasService = aliasService;
            _windowService = windowService;

            // Commands
            LocateTempDownloadPathCommand = new RelayCommand(LocateTempDownloadPath);
            LocateBackupPathCommand = new RelayCommand(LocateBackupPath, () => StagingSettings.UseBackup);

            SaveCommand = new RelayCommand(Save, () => !StagingSettings.IsSaved);
            ResetDefaultsCommand = new RelayCommand(ResetDefaults);
            CancelCommand = new RelayCommand(Cancel, () => !StagingSettings.IsSaved);

            // Events
            _aliasService.UserAliasesChanged += (sender, args) => GetUserAliases();
            UserAliases.ListChanged += (sender, args) => PutUserAliases();

            // Initial
            GetUserAliases();
        }
Ejemplo n.º 16
0
 private ApplicationManager()
 {
     _servers               = new List <Server>();
     Commands               = new List <Command>();
     TaskStatuses           = new List <AsyncStatus>();
     MessageTokens          = new List <MessageToken>();
     ClientSvc              = new ClientService();
     AliasSvc               = new AliasService();
     PenaltySvc             = new PenaltyService();
     ConfigHandler          = new BaseConfigurationHandler <ApplicationConfiguration>("IW4MAdminSettings");
     StartTime              = DateTime.UtcNow;
     OnQuit                 = new ManualResetEventSlim();
     PageList               = new PageList();
     AdditionalEventParsers = new List <IEventParser>();
     AdditionalRConParsers  = new List <IRConParser>();
     OnServerEvent         += OnGameEvent;
     OnServerEvent         += EventApi.OnGameEvent;
     _authenticator         = new TokenAuthentication();
     _metaService           = new MetaService();
 }
Ejemplo n.º 17
0
 public ApplicationManager(ILogger logger, IMiddlewareActionHandler actionHandler, IEnumerable <IManagerCommand> commands,
                           ITranslationLookup translationLookup, IConfigurationHandler <CommandConfiguration> commandConfiguration,
                           IConfigurationHandler <ApplicationConfiguration> appConfigHandler, IGameServerInstanceFactory serverInstanceFactory,
                           IEnumerable <IPlugin> plugins, IParserRegexFactory parserRegexFactory, IEnumerable <IRegisterEvent> customParserEvents,
                           IEventHandler eventHandler, IScriptCommandFactory scriptCommandFactory, IDatabaseContextFactory contextFactory, IMetaService metaService,
                           IMetaRegistration metaRegistration, IScriptPluginServiceResolver scriptPluginServiceResolver)
 {
     MiddlewareActionHandler = actionHandler;
     _servers               = new ConcurrentBag <Server>();
     MessageTokens          = new List <MessageToken>();
     ClientSvc              = new ClientService(contextFactory);
     AliasSvc               = new AliasService();
     PenaltySvc             = new PenaltyService();
     ConfigHandler          = appConfigHandler;
     StartTime              = DateTime.UtcNow;
     PageList               = new PageList();
     AdditionalEventParsers = new List <IEventParser>()
     {
         new BaseEventParser(parserRegexFactory, logger, appConfigHandler.Configuration())
     };
     AdditionalRConParsers = new List <IRConParser>()
     {
         new BaseRConParser(parserRegexFactory)
     };
     TokenAuthenticator = new TokenAuthentication();
     _logger            = logger;
     _metaService       = metaService;
     _tokenSource       = new CancellationTokenSource();
     _loggers.Add(0, logger);
     _commands                    = commands.ToList();
     _translationLookup           = translationLookup;
     _commandConfiguration        = commandConfiguration;
     _serverInstanceFactory       = serverInstanceFactory;
     _parserRegexFactory          = parserRegexFactory;
     _customParserEvents          = customParserEvents;
     _eventHandler                = eventHandler;
     _scriptCommandFactory        = scriptCommandFactory;
     _metaRegistration            = metaRegistration;
     _scriptPluginServiceResolver = scriptPluginServiceResolver;
     Plugins = plugins;
 }
Ejemplo n.º 18
0
 public AliasModule(AliasService aliasService)
 {
     Log          = aliasService.Log;
     AliasService = aliasService;
 }
Ejemplo n.º 19
0
        private async Task SaveSite()
        {
            try
            {
                if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && (_layouts.Count == 0 || _layouttype != "-") && _containertype != "-")
                {
                    var unique = true;
                    foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        if (_aliasList.Exists(item => item.Name == name && item.SiteId != _alias.SiteId && item.TenantId != _alias.TenantId))
                        {
                            unique = false;
                        }
                    }

                    if (unique)
                    {
                        SiteService.SetAlias(_alias);
                        var site = await SiteService.GetSiteAsync(_alias.SiteId);

                        if (site != null)
                        {
                            site.Name                 = _name;
                            site.LogoFileId           = null;
                            site.DefaultThemeType     = _themetype;
                            site.DefaultLayoutType    = _layouttype ?? string.Empty;
                            site.DefaultContainerType = _containertype;
                            site.IsDeleted            = (_isdeleted == null || Boolean.Parse(_isdeleted));

                            site = await SiteService.UpdateSiteAsync(site);

                            _urls = _urls.Replace("\n", ",");
                            var names = _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                            foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
                            {
                                if (!names.Contains(alias.Name))
                                {
                                    await AliasService.DeleteAliasAsync(alias.AliasId);
                                }
                            }

                            foreach (string name in names)
                            {
                                if (!_aliasList.Exists(item => item.Name == name))
                                {
                                    Alias alias = new Alias
                                    {
                                        Name     = name,
                                        TenantId = site.TenantId,
                                        SiteId   = site.SiteId
                                    };
                                    await AliasService.AddAliasAsync(alias);
                                }
                            }

                            await Log(_alias, LogLevel.Information, PermissionNames.Edit, null, "Site Saved {Site}", site);

                            NavigationManager.NavigateTo(NavigateUrl());
                        }
                    }
                    else
                    {
                        AddModuleMessage("An Alias Specified Has Already Been Used For Another Site", MessageType.Warning);
                    }
                }
                else
                {
                    AddModuleMessage("You Must Provide A Site Name, Alias, And Default Theme/Container", MessageType.Warning);
                }
            }
            catch (Exception ex)
            {
                await Log(_alias, LogLevel.Error, string.Empty, ex, "Error Saving Site {SiteId} {Error}", _alias.SiteId, ex.Message);

                AddModuleMessage("Error Saving Site", MessageType.Error);
            }
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public AliasApiController(IApi api, AliasService service)
 {
     _api     = api;
     _service = service;
 }
        private async Task Refresh()
        {
            Alias         alias = null;
            Site          site;
            List <Page>   pages;
            Page          page;
            User          user = null;
            List <Module> modules;
            var           moduleid      = -1;
            var           action        = string.Empty;
            var           urlparameters = string.Empty;
            var           editmode      = false;
            var           reload        = Reload.None;
            var           lastsyncdate  = DateTime.UtcNow;
            var           runtime       = GetRuntime();

            Uri uri = new Uri(_absoluteUri);

            // get path
            var path = uri.LocalPath.Substring(1);

            // parse querystring
            var querystring = ParseQueryString(uri.Query);

            // the reload parameter is used to reload the PageState
            if (querystring.ContainsKey("reload"))
            {
                reload = Reload.Site;
            }

            if (PageState != null)
            {
                editmode     = PageState.EditMode;
                lastsyncdate = PageState.LastSyncDate;
            }

            alias = await AliasService.GetAliasAsync(path, lastsyncdate);

            SiteState.Alias = alias; // set state for services
            lastsyncdate    = alias.SyncDate;

            // process any sync events for site or page
            if (reload != Reload.Site && alias.SyncEvents.Any())
            {
                if (PageState != null && alias.SyncEvents.Exists(item => item.EntityName == EntityNames.Page && item.EntityId == PageState.Page.PageId))
                {
                    reload = Reload.Page;
                }
                if (alias.SyncEvents.Exists(item => item.EntityName == EntityNames.Site && item.EntityId == alias.SiteId))
                {
                    reload = Reload.Site;
                }
            }

            if (reload == Reload.Site || PageState == null || alias.SiteId != PageState.Alias.SiteId)
            {
                site = await SiteService.GetSiteAsync(alias.SiteId);

                reload = Reload.Site;
            }
            else
            {
                site = PageState.Site;
            }

            if (site != null)
            {
                if (PageState == null || reload == Reload.Site)
                {
                    // get user
                    var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

                    if (authState.User.Identity.IsAuthenticated)
                    {
                        user = await UserService.GetUserAsync(authState.User.Identity.Name, site.SiteId);
                    }
                }
                else
                {
                    user = PageState.User;
                }

                // process any sync events for user
                if (reload != Reload.Site && user != null && alias.SyncEvents.Any())
                {
                    if (alias.SyncEvents.Exists(item => item.EntityName == EntityNames.User && item.EntityId == user.UserId))
                    {
                        reload = Reload.Site;
                    }
                }

                if (PageState == null || reload >= Reload.Site)
                {
                    pages = await PageService.GetPagesAsync(site.SiteId);
                }
                else
                {
                    pages = PageState.Pages;
                }

                // format path and remove alias
                path = path.Replace("//", "/");

                if (!path.EndsWith("/"))
                {
                    path += "/";
                }

                if (alias.Path != "")
                {
                    path = path.Substring(alias.Path.Length + 1);
                }

                // extract admin route elements from path
                var segments = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                int result;

                int modIdPos         = 0;
                int actionPos        = 0;
                int urlParametersPos = 0;

                for (int i = 0; i < segments.Length; i++)
                {
                    if (segments[i] == Constants.UrlParametersDelimiter)
                    {
                        urlParametersPos = i + 1;
                    }

                    if (i >= urlParametersPos && urlParametersPos != 0)
                    {
                        urlparameters += "/" + segments[i];
                    }

                    if (segments[i] == Constants.ModuleDelimiter)
                    {
                        modIdPos  = i + 1;
                        actionPos = modIdPos + 1;
                        if (actionPos > segments.Length - 1)
                        {
                            action = Constants.DefaultAction;
                        }
                        else
                        {
                            action = segments[actionPos];
                        }
                    }
                }

                // check if path has moduleid and action specification ie. pagename/moduleid/action/
                if (modIdPos > 0)
                {
                    int.TryParse(segments[modIdPos], out result);
                    moduleid = result;
                    if (actionPos > segments.Length - 1)
                    {
                        path = path.Replace(segments[modIdPos - 1] + "/" + segments[modIdPos] + "/", "");
                    }
                    else
                    {
                        path = path.Replace(segments[modIdPos - 1] + "/" + segments[modIdPos] + "/" + segments[actionPos] + "/", "");
                    }
                }

                if (urlParametersPos > 0)
                {
                    path = path.Replace(segments[urlParametersPos - 1] + urlparameters + "/", "");
                }

                // remove trailing slash so it can be used as a key for Pages
                if (path.EndsWith("/"))
                {
                    path = path.Substring(0, path.Length - 1);
                }

                if (PageState == null || reload >= Reload.Page)
                {
                    page = pages.Where(item => item.Path == path).FirstOrDefault();
                }
                else
                {
                    page = PageState.Page;
                }

                // failsafe in case router cannot locate the home page for the site
                if (page == null && path == "")
                {
                    page = pages.FirstOrDefault();
                    path = page.Path;
                }

                // check if page has changed
                if (page != null && page.Path != path)
                {
                    page     = pages.Where(item => item.Path == path).FirstOrDefault();
                    reload   = Reload.Page;
                    editmode = false;
                }

                if (page != null)
                {
                    if (PageState == null)
                    {
                        editmode = false;
                    }

                    // check if user is authorized to view page
                    if (UserSecurity.IsAuthorized(user, PermissionNames.View, page.Permissions))
                    {
                        page = await ProcessPage(page, site, user);

                        if (PageState != null && (PageState.ModuleId != moduleid || PageState.Action != action))
                        {
                            reload = Reload.Page;
                        }

                        if (PageState == null || reload >= Reload.Page)
                        {
                            modules = await ModuleService.GetModulesAsync(site.SiteId);

                            (page, modules) = ProcessModules(page, modules, moduleid, action, (!string.IsNullOrEmpty(page.DefaultContainerType)) ? page.DefaultContainerType : site.DefaultContainerType);
                        }
                        else
                        {
                            modules = PageState.Modules;
                        }

                        _pagestate = new PageState
                        {
                            Alias         = alias,
                            Site          = site,
                            Pages         = pages,
                            Page          = page,
                            User          = user,
                            Modules       = modules,
                            Uri           = new Uri(_absoluteUri, UriKind.Absolute),
                            QueryString   = querystring,
                            UrlParameters = urlparameters,
                            ModuleId      = moduleid,
                            Action        = action,
                            EditMode      = editmode,
                            LastSyncDate  = lastsyncdate,
                            Runtime       = runtime
                        };

                        OnStateChange?.Invoke(_pagestate);
                    }
                }
                else
                {
                    if (user == null)
                    {
                        // redirect to login page
                        NavigationManager.NavigateTo(Utilities.NavigateUrl(alias.Path, "login", "returnurl=" + path));
                    }
                    else
                    {
                        await LogService.Log(null, null, user.UserId, GetType().AssemblyQualifiedName, Utilities.GetTypeNameLastSegment(GetType().AssemblyQualifiedName, 1), LogFunction.Security, LogLevel.Error, null, "Page Does Not Exist Or User Is Not Authorized To View Page {Path}", path);

                        if (path != "")
                        {
                            // redirect to home page
                            NavigationManager.NavigateTo(Utilities.NavigateUrl(alias.Path, "", ""));
                        }
                    }
                }
            }
            else
            {
                // site does not exist
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Receives the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="room">The room.</param>
        /// <param name="options">The options.</param>
        public override void Receive(Message message, Room room, Options options)
        {
            AliasService.RemoveAlias(options.Name);

            HipChatService.Say(room, "Removed alias '{0}'.", options.Name);
        }
Ejemplo n.º 23
0
        private async Task SaveSite()
        {
            if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && (_layouts.Count == 0 || _layouttype != "-") && _containertype != "-" && _sitetemplatetype != "-")
            {
                var duplicates = new List <string>();
                var aliases    = await AliasService.GetAliasesAsync();

                foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    if (aliases.Exists(item => item.Name == name))
                    {
                        duplicates.Add(name);
                    }
                }

                if (duplicates.Count == 0)
                {
                    InstallConfig config = new InstallConfig();

                    if (_tenantid == "+")
                    {
                        if (!string.IsNullOrEmpty(_tenantname) && _tenants.FirstOrDefault(item => item.Name == _tenantname) == null)
                        {
                            // validate host credentials
                            var user = new User();
                            user.SiteId   = PageState.Site.SiteId;
                            user.Username = Constants.HostUser;
                            user.Password = _hostpassword;
                            user          = await UserService.LoginUserAsync(user, false, false);

                            if (user.IsAuthenticated)
                            {
                                if (!string.IsNullOrEmpty(_server) && !string.IsNullOrEmpty(_database))
                                {
                                    var connectionString = string.Empty;
                                    if (_databasetype == "LocalDB")
                                    {
                                        connectionString = "Data Source=" + _server + ";AttachDbFilename=|DataDirectory|\\" + _database + ".mdf;Initial Catalog=" + _database + ";Integrated Security=SSPI;";
                                    }
                                    else
                                    {
                                        connectionString = "Data Source=" + _server + ";Initial Catalog=" + _database + ";";

                                        if (_integratedsecurity)
                                        {
                                            connectionString += "Integrated Security=SSPI;";
                                        }
                                        else
                                        {
                                            connectionString += "User ID=" + _username + ";Password="******"You Must Specify A Server And Database", MessageType.Error);
                                }
                            }
                            else
                            {
                                AddModuleMessage("Invalid Host Password", MessageType.Error);
                            }
                        }
                        else
                        {
                            AddModuleMessage("Tenant Name Is Missing Or Already Exists", MessageType.Error);
                        }
                    }
                    else
                    {
                        var tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid));
                        if (tenant != null)
                        {
                            config.TenantName       = tenant.Name;
                            config.ConnectionString = tenant.DBConnectionString;
                            config.IsNewTenant      = false;
                        }
                    }

                    if (!string.IsNullOrEmpty(config.TenantName))
                    {
                        config.SiteName         = _name;
                        config.Aliases          = _urls.Replace("\n", ",");
                        config.DefaultTheme     = _themetype;
                        config.DefaultLayout    = _layouttype;
                        config.DefaultContainer = _containertype;
                        config.SiteTemplate     = _sitetemplatetype;

                        ShowProgressIndicator();

                        var installation = await InstallationService.Install(config);

                        if (installation.Success)
                        {
                            var aliasname = config.Aliases.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0];
                            var uri       = new Uri(NavigationManager.Uri);
                            NavigationManager.NavigateTo(uri.Scheme + "://" + aliasname, true);
                        }
                        else
                        {
                            await logger.LogError("Error Creating Site {Error}", installation.Message);

                            AddModuleMessage(installation.Message, MessageType.Error);
                        }
                    }
                }
                else
                {
                    AddModuleMessage(string.Join(", ", duplicates.ToArray()) + " Already Used For Another Site", MessageType.Warning);
                }
            }
            else
            {
                AddModuleMessage("You Must Provide A Tenant, Site Name, Alias, Default Theme/Container, And Site Template", MessageType.Warning);
            }
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public AliasApiController(IApi api, AliasService service, ManagerLocalizer localizer)
 {
     _api       = api;
     _service   = service;
     _localizer = localizer;
 }
Ejemplo n.º 25
0
        private async Task SaveSite()
        {
            try
            {
                if (_name != string.Empty && _urls != string.Empty && _themetype != "-" && (_layouts.Count == 0 || _layouttype != "-") && _containertype != "-")
                {
                    var unique = true;
                    foreach (string name in _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        if (_aliasList.Exists(item => item.Name == name && item.SiteId != PageState.Alias.SiteId && item.TenantId != PageState.Alias.TenantId))
                        {
                            unique = false;
                        }
                    }

                    if (unique)
                    {
                        var site = await SiteService.GetSiteAsync(PageState.Site.SiteId);

                        if (site != null)
                        {
                            site.Name       = _name;
                            site.LogoFileId = null;
                            var logofileid = _logofilemanager.GetFileId();
                            if (logofileid != -1)
                            {
                                site.LogoFileId = logofileid;
                            }

                            site.DefaultThemeType     = _themetype;
                            site.DefaultLayoutType    = (_layouttype == "-" ? string.Empty : _layouttype);
                            site.DefaultContainerType = _containertype;
                            site.AllowRegistration    = (_allowregistration == null ? true : Boolean.Parse(_allowregistration));
                            site.IsDeleted            = (_isdeleted == null ? true : Boolean.Parse(_isdeleted));

                            site.PwaIsEnabled = (_pwaisenabled == null ? true : Boolean.Parse(_pwaisenabled));

                            var pwaappiconfileid = _pwaappiconfilemanager.GetFileId();
                            if (pwaappiconfileid != -1)
                            {
                                site.PwaAppIconFileId = pwaappiconfileid;
                            }

                            var pwasplashiconfileid = _pwasplashiconfilemanager.GetFileId();
                            if (pwasplashiconfileid != -1)
                            {
                                site.PwaSplashIconFileId = pwasplashiconfileid;
                            }

                            site = await SiteService.UpdateSiteAsync(site);

                            _urls = _urls.Replace("\n", ",");
                            var names = _urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
                            {
                                if (!names.Contains(alias.Name))
                                {
                                    await AliasService.DeleteAliasAsync(alias.AliasId);
                                }
                            }

                            foreach (string name in names)
                            {
                                if (!_aliasList.Exists(item => item.Name == name))
                                {
                                    Alias alias = new Alias();
                                    alias.Name     = name;
                                    alias.TenantId = site.TenantId;
                                    alias.SiteId   = site.SiteId;
                                    await AliasService.AddAliasAsync(alias);
                                }
                            }

                            var settings = await SettingService.GetSiteSettingsAsync(site.SiteId);

                            SettingService.SetSetting(settings, "SMTPHost", _smtphost);
                            SettingService.SetSetting(settings, "SMTPPort", _smtpport);
                            SettingService.SetSetting(settings, "SMTPSSL", _smtpssl);
                            SettingService.SetSetting(settings, "SMTPUsername", _smtpusername);
                            SettingService.SetSetting(settings, "SMTPPassword", _smtppassword);
                            await SettingService.UpdateSiteSettingsAsync(settings, site.SiteId);

                            await logger.LogInformation("Site Saved {Site}", site);

                            NavigationManager.NavigateTo(NavigateUrl());
                        }
                    }
                    else
                    {
                        AddModuleMessage("An Alias Specified Has Already Been Used For Another Site", MessageType.Warning);
                    }
                }
                else
                {
                    AddModuleMessage("You Must Provide A Site Name, Alias, And Default Theme/Container", MessageType.Warning);
                }
            }
            catch (Exception ex)
            {
                await logger.LogError(ex, "Error Saving Site {SiteId} {Error}", PageState.Site.SiteId, ex.Message);

                AddModuleMessage("Error Saving Site", MessageType.Error);
            }
        }
Ejemplo n.º 26
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                _themeList = await ThemeService.GetThemesAsync();

                _aliasList = await AliasService.GetAliasesAsync();

                Site site = await SiteService.GetSiteAsync(PageState.Site.SiteId);

                if (site != null)
                {
                    _name       = site.Name;
                    _tenantList = await TenantService.GetTenantsAsync();

                    _tenant = _tenantList.Find(item => item.TenantId == site.TenantId).Name;
                    foreach (Alias alias in _aliasList.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList())
                    {
                        _urls += alias.Name + "\n";
                    }
                    if (site.LogoFileId != null)
                    {
                        _logofileid = site.LogoFileId.Value;
                    }

                    if (site.FaviconFileId != null)
                    {
                        _faviconfileid = site.FaviconFileId.Value;
                    }

                    _themes            = ThemeService.GetThemeControls(_themeList);
                    _themetype         = site.DefaultThemeType;
                    _layouts           = ThemeService.GetLayoutControls(_themeList, _themetype);
                    _layouttype        = site.DefaultLayoutType;
                    _containers        = ThemeService.GetContainerControls(_themeList, _themetype);
                    _containertype     = site.DefaultContainerType;
                    _allowregistration = site.AllowRegistration.ToString();

                    var settings = await SettingService.GetSiteSettingsAsync(site.SiteId);

                    _smtphost     = SettingService.GetSetting(settings, "SMTPHost", string.Empty);
                    _smtpport     = SettingService.GetSetting(settings, "SMTPPort", string.Empty);
                    _smtpssl      = SettingService.GetSetting(settings, "SMTPSSL", string.Empty);
                    _smtpusername = SettingService.GetSetting(settings, "SMTPUsername", string.Empty);
                    _smtppassword = SettingService.GetSetting(settings, "SMTPPassword", string.Empty);

                    _pwaisenabled = site.PwaIsEnabled.ToString();

                    if (site.PwaAppIconFileId != null)
                    {
                        _pwaappiconfileid = site.PwaAppIconFileId.Value;
                    }

                    if (site.PwaSplashIconFileId != null)
                    {
                        _pwasplashiconfileid = site.PwaSplashIconFileId.Value;
                    }

                    _pwaisenabled = site.PwaIsEnabled.ToString();
                    if (site.PwaAppIconFileId != null)
                    {
                        _pwaappiconfileid = site.PwaAppIconFileId.Value;
                    }
                    if (site.PwaSplashIconFileId != null)
                    {
                        _pwasplashiconfileid = site.PwaSplashIconFileId.Value;
                    }

                    _createdby  = site.CreatedBy;
                    _createdon  = site.CreatedOn;
                    _modifiedby = site.ModifiedBy;
                    _modifiedon = site.ModifiedOn;
                    _deletedby  = site.DeletedBy;
                    _deletedon  = site.DeletedOn;
                    _isdeleted  = site.IsDeleted.ToString();

                    _initialized = true;
                }
            }
            catch (Exception ex)
            {
                await logger.LogError(ex, "Error Loading Site {SiteId} {Error}", PageState.Site.SiteId, ex.Message);

                AddModuleMessage(ex.Message, MessageType.Error);
            }
        }