public void SetAppIdForInstance(IContainer instance, IAppEnvironment env, int?appId, ILog parentLog) { Log.Add($"SetAppIdForInstance({instance.Id}, -, appid: {appId})"); // Reset temporary template /*BlocksManager.*/ ClearPreviewTemplate(instance.Id); // ToDo: Should throw exception if a real BlockConfiguration exists var module = (instance as Container <ModuleInfo>).UnwrappedContents; var zoneId = env.ZoneMapper.GetZoneId(module.OwnerPortalID); if (appId == 0 || !appId.HasValue) { DnnTenantSettings.UpdateInstanceSettingForAllLanguages(instance.Id, Settings.AppNameString, null, Log); } else { var appName = /*Factory.GetAppsCache*/ Eav.Apps.State.Zones[zoneId].Apps[appId.Value]; DnnTenantSettings.UpdateInstanceSettingForAllLanguages(instance.Id, Settings.AppNameString, appName, Log); } // Change to 1. available template if app has been set if (appId.HasValue) { var appIdentity = new AppIdentity(zoneId, appId.Value); var cms = new CmsRuntime(/*zoneId, appId.Value*/ appIdentity, Log, true, env.PagePublishing.IsEnabled(instance.Id)); var templateGuid = cms.Views.GetAll().FirstOrDefault(t => !t.IsHidden)?.Guid; if (templateGuid.HasValue) { /*BlocksManager.*/ SetPreviewTemplate(instance.Id, templateGuid.Value); } } }
/// <summary> /// Initializes a new instance of the <see cref="Log4JXmlEventLayoutRenderer" /> class. /// </summary> internal Log4JXmlEventLayoutRenderer(IAppEnvironment appEnvironment) { #if NETSTANDARD1_3 AppInfo = "NetCore Application"; #else AppInfo = string.Format( CultureInfo.InvariantCulture, "{0}({1})", appEnvironment.AppDomain.FriendlyName, appEnvironment.CurrentProcessId); #endif Parameters = new List <NLogViewerParameterInfo>(); try { _machineName = EnvironmentHelper.GetMachineName(); if (string.IsNullOrEmpty(_machineName)) { InternalLogger.Info("MachineName is not available."); } } catch (Exception exception) { InternalLogger.Error(exception, "Error getting machine name."); if (exception.MustBeRethrown()) { throw; } _machineName = string.Empty; } }
public MainAboutModel(RootModel root, ConnectionService connectionService, IAppEnvironment environment, IdService idService, CoreData coreData) { Root = root; _connectionService = connectionService; _environment = environment; _idService = idService; _coreData = coreData; CopyToClipboard = () => DoCopyToClipboard(); Version = ClientVersionHelper.GetVersion(); var assembly = Assembly.GetExecutingAssembly(); using (Stream stream = assembly.GetManifestResourceStream("Streamster.ClientCore.LICENSE.txt")) using (StreamReader reader = new StreamReader(stream)) { License = reader.ReadToEnd(); } using (Stream stream = assembly.GetManifestResourceStream("Streamster.ClientCore.CREDITS.txt")) using (StreamReader reader = new StreamReader(stream)) { Credits = reader.ReadToEnd(); } FeedbackSend = () => _ = SendFeedback(); }
public static async Task <int> ExecuteAsync( PluginOptions options, IConsole console, IAppEnvironment appEnvironment, InvocationContext context = null) { console.Out.WriteLine($"Installing plugin from package '{options.PackageId}'"); var packageManager = new NuGetPluginPackageManager(appEnvironment); try { PluginPackage result = await packageManager.InstallLatestAsync(options.PackageId).ConfigureAwait(false); console.Out.WriteLine($"Using plugin version {result.Version}"); console.Out.WriteLine($"Installed plugin {result.Name} to {result.PluginPath}"); } catch (System.IO.IOException) { console.Out.WriteLine("The latest version of this plugin is already installed."); return(ReturnCodes.Error); } return(ReturnCodes.Ok); }
public static async Task <int> ExecuteAsync( TemplateOptions options, IConsole console, IAppEnvironment appEnvironment, InvocationContext context = null) { console.Out.WriteLine($"Uninstalling template package '{options.PackageId}'"); var templateSettingsManager = new TemplateSettingsManager(appEnvironment); TemplatesSettings currentSettings = templateSettingsManager.LoadSettings() ?? new TemplatesSettings(); var packageManager = new NuGetTemplatePackageManager(appEnvironment); if (currentSettings.Packages.Exists(templatePackage => templatePackage.PackageId == options.PackageId)) { TemplatePackage package = currentSettings.Packages.Find(templatePackage => templatePackage.Id == options.PackageId); if (package != null) { await packageManager.UnnstallAsync(package).ConfigureAwait(false); currentSettings.Packages.Remove(package); if (currentSettings.DefaultTemplate.PackageName == package.PackageId) { currentSettings.DefaultTemplate = new DefaultTemplate(); } } } return(ReturnCodes.Ok); }
public ChannelModel(IChannel source, IAppEnvironment environment, CoreData coreData, MainTargetsModel parent) { Source = source; Parent = parent; if (source.TargetId != null) { Target = coreData.Root.Targets[source.TargetId]; HasRtmpUrlInFront = (Target.Flags & TargetFlags.Url) > 0; } else { Target = parent.CustomTarget; HasRtmpUrlInFront = true; } HasRtmpUrlInOptions = true;// (Target.Flags & TargetFlags.Url) > 0; Delete = () => parent.Remove(this); Start = DoStart; Stop = () => Source.IsOn = false; GoToHelp = () => environment.OpenUrl(string.Format(parent.AppData.TargetHintTemplate, source.TargetId ?? "Custom")); GoToWebUrl = () => environment.OpenUrl(WebUrl.Value); WebUrl.OnChange = (o, n) => Source.WebUrl = n == Target.WebUrl ? null : n; Name.OnChange = (o, n) => Source.Name = n == Target.Name ? null : n; RtmpUrl.OnChange = (o, n) => Source.RtmpUrl = n == Target.DefaultRtmpUrl ? null : n; IsTranscoded.OnChange = (o, n) => Transcoding.SetTranscoding(Source, n); TaskHelper.RunUnawaited(() => parent.GetImageAsync(Logo, source.TargetId), "Get image for channel"); }
public SearchProcess( IUserInterface userInterface, IAppEnvironment <SearchProcess> appEnvironment) { this.userInterface = userInterface; this.appEnvironment = appEnvironment; }
public void SetAppIdForInstance(IInstanceInfo instance, IAppEnvironment env, int?appId, Log parentLog) { Log.Add($"SetAppIdForInstance({instance.Id}, -, appid: {appId})"); // Reset temporary template ContentGroupManager.ClearPreviewTemplate(instance.Id); // ToDo: Should throw exception if a real ContentGroup exists var module = (instance as EnvironmentInstance <ModuleInfo>).Original; var zoneId = env.ZoneMapper.GetZoneId(module.OwnerPortalID); if (appId == 0 || !appId.HasValue) { DnnStuffToRefactor.UpdateInstanceSettingForAllLanguages(instance.Id, Settings.AppNameString, null, Log); } else { var appName = ((BaseCache)DataSource.GetCache(0, 0)).ZoneApps[zoneId].Apps[appId.Value]; DnnStuffToRefactor.UpdateInstanceSettingForAllLanguages(instance.Id, Settings.AppNameString, appName, Log); } // Change to 1. available template if app has been set if (appId.HasValue) { var app = App.LightWithoutData(new DnnTenant(null), zoneId, appId.Value, parentLog: Log); var templateGuid = app.TemplateManager.GetAllTemplates().FirstOrDefault(t => !t.IsHidden)?.Guid; if (templateGuid.HasValue) { ContentGroupManager.SetPreviewTemplate(instance.Id, templateGuid.Value); } } }
public LoginModel(RootModel root, MainModel main, UpdateModel updateModel, LocalSettingsService settingsService, ConnectionService connectionService, NotificationService notificationService, IAppEnvironment environment, IdService idService) { Root = root; _settingsService = settingsService; _connectionService = connectionService; _notificationService = notificationService; _main = main; _updateModel = updateModel; _environment = environment; _idService = idService; var s = settingsService.Settings; SavePassword = s.SavePassword; UserName = s.UserName; Password = s.Password; UserRegistered = s.UserRegistered; Version = ClientVersionHelper.GetVersion(); DoLogin = async() => await LoginAsync(true); DoAnonymousLogin = async() => await LoginAsync(false); if (s.AutoLogon && s.SavePassword && s.UserRegistered) { _ = DoAutoLogin(); } }
public StaticFilesCacheService(ConnectionService connectionService, IAppEnvironment environment) { // TODO: cache update!!!!! _connectionService = connectionService; _root = Path.Combine(environment.GetStorageFolder(), "cache"); _initCache = Task.Run(() => InitCache()); }
/// <summary> /// Initializes a new instance of the <see cref="BaseDirLayoutRenderer" /> class. /// </summary> internal BaseDirLayoutRenderer(IAppEnvironment appEnvironment) { _baseDir = appEnvironment.AppDomainBaseDirectory; #if !SILVERLIGHT && !NETSTANDARD1_3 _appEnvironment = appEnvironment; #endif }
/// <summary> /// Initializes a new instance of the <see cref="BaseDirLayoutRenderer" /> class. /// </summary> public BaseDirLayoutRenderer(IAppDomain appDomain) { _baseDir = appDomain.BaseDirectory; #if !SILVERLIGHT && !NETSTANDARD1_3 _appEnvironment = LogFactory.DefaultAppEnvironment; #endif }
public NormalizationEnginePhase( INormalizer normalizer, IWordExtractor wordExtractor, IAppEnvironment <NormalizationEnginePhase> appEnvironment) : base(appEnvironment) { this.normalizer = normalizer; this.wordExtractor = wordExtractor; }
public ConnectionService(IAppEnvironment environment, IdService idService, LogService logService, IAppResources appResources) { _environment = environment; _idService = idService; _logService = logService; _appResources = appResources; _domain = appResources.AppData.Domain; }
public AppLoader(string name, IEnumerable <string> tags, string[] _commandlineArguments) { _app = new App { Args = _commandlineArguments, }; _environment = new AppEnvironment(name, tags); }
public BooleanSearchEnginePhase( ISearchProcess searchProcess, ISearchExpressionParser expressionParser, IIndexScan indexScan, IAppEnvironment <BooleanSearchEnginePhase> appEnvironment) : base(appEnvironment) { this.searchProcess = searchProcess; this.expressionParser = expressionParser; this.indexScan = indexScan; }
public static async Task <int> ExecuteAsync( EnvironmentOptions options, IConsole console, IAppEnvironment appEnvironment, InvocationContext context = null) { await appEnvironment.InitializeAsync(console).ConfigureAwait(false); return(ReturnCodes.Ok); }
public static Task <int> ExecuteAsync( IConsole console, IAppEnvironment appEnvironment, InvocationContext context = null) { /*var packageManager = new NuGetPluginPackageManager(appEnvironment); * TemplatePackage result = await packageManager.InstallLatestAsync(options.PackageId).ConfigureAwait(false);*/ return(Task.FromResult(ReturnCodes.Ok)); }
public SceneEditingModel(CoreData coreData, SourcesModel sources, IAppEnvironment environment, ResourceService resourceService, IImageHelper imageHelper, StreamSettingsModel streamSettings) { CoreData = coreData; Sources = sources; Environment = environment; ResourceService = resourceService; ImageHelper = imageHelper; _streamSettings = streamSettings; AddLayer = SelectAddLayer; Close = DoClose; }
public MainModel(RootModel root, MainTargetsModel targets, MainSettingsModel settings, SourcesModel sources, StreamSettingsModel streamSettings, MainStreamerModel streamer, MainIndicatorsModel indicators, MainVpnModel vpn, MainAboutModel about, AudioModel audio, HubConnectionService hubConnectionService, IWindowStateManager windowStateManager, IAppEnvironment environment, CoreData coreData, StateLoggerService stateLoggerService, LocalSettingsService localSettingsService, IUpdateManager updateManager, TransientMessageModel transientMessageModel, IAppResources appResources, SceneEditingModel sceneEditingModel, ResourceService resourceService) { Root = root; Targets = targets; Settings = settings; Sources = sources; StreamSettings = streamSettings; Streamer = streamer; Indicators = indicators; Vpn = vpn; About = about; Audio = audio; _hubConnectionService = hubConnectionService; _windowStateManager = windowStateManager; _environment = environment; _coreData = coreData; _stateLoggerService = stateLoggerService; _localSettingsService = localSettingsService; _updateManager = updateManager; TransientMessage = transientMessageModel; _appResources = appResources; SceneEditing = sceneEditingModel; _resourceService = resourceService; _serverClient = new ModelClient { Filter = new FilterConfigurator(true).Build() }; _coreData.GetManager().Register(_serverClient); _serverClient.SerializeAndClearChanges(); _coreData.Subscriptions.OnChangeForSubscriptions = async() => await ProcessLocalOrRemoteChange(); _coreData.Subscriptions.OnLocalChange = async() => await ProcessLocalChange(); }
public static async Task <int> ExecuteAsync( NewFileOptions fileOptions, IConsole console, IAppEnvironment appEnvironment, InvocationContext context = null) { var settingsManager = new EnvironmentSettingsManager(appEnvironment); EnvironmentSettings environmentSettings = settingsManager.LoadSettings(); if (environmentSettings.WorkspacePath != null && fileOptions.FilePath != null) { console.Error.WriteLine("You must either set a workspace via the environment command or supply a filepath."); return(ReturnCodes.Error); } if (fileOptions.FilePath != null) { environmentSettings.WorkspacePath = fileOptions.FilePath.FullName; } List <ContentTypeConventionsRoot> conventions = await FindAllConventions(appEnvironment); // Select the convention that matches the template name specified ContentTypeConventionsRoot contentTypeConventionsRoot = conventions.FirstOrDefault(x => x.Conventions.Any(y => y.Conventions.Any(z => z.Value == fileOptions.TemplateName))); // Now find the filepath.. Convention convention = contentTypeConventionsRoot?.Conventions.SelectMany(x => x.Conventions).FirstOrDefault(x => x.ContentType.StartsWith(ConventionContentTypes.FilePaths, StringComparison.CurrentCultureIgnoreCase)); if (convention != null) { IVariableDirectoryPath variablePath = convention.Value.ToVariableDirectoryPath(); if (variablePath.TryResolve(environmentSettings.ToKvPs(), out IAbsoluteDirectoryPath evaluatedPath) == VariablePathResolvingStatus.Success) { IAbsoluteFilePath filepath = evaluatedPath.GetChildFileWithName($"post-{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.md"); if (!filepath.ParentDirectoryPath.Exists) { Directory.CreateDirectory(filepath.ParentDirectoryPath.ToString()); } string template = Path.Join(contentTypeConventionsRoot.FilePath.ParentDirectoryPath.ParentDirectoryPath.ToString(), contentTypeConventionsRoot?.Conventions.FirstOrDefault()?.TemplatePath); File.Copy(template, filepath.ToString()); console.Out.WriteLine($"Created: {filepath}"); } } return(ReturnCodes.Ok); }
public ISettings GetSettings(IAppEnvironment appEnvironment) { var appRootPath = appEnvironment.AppRootPath ?? string.Empty; if (appEnvironment.Location == EnvironmentLocation.AppHarbor) { return(new AppHarborSettings(WeatherKey, null)); } else { var configurationPath = Path.Combine(appRootPath, EnvironmentPath, "ConnectionString.txt"); return(new LocalSettings(WeatherKey, configurationPath)); } }
public static async Task <int> ExecuteAsync( TemplateOptions options, IConsole console, IAppEnvironment appEnvironment, InvocationContext context = null) { console.Out.WriteLine($"Installing template from package '{options.PackageId}'"); var templateSettingsManager = new TemplateSettingsManager(appEnvironment); TemplatesSettings currentSettings = templateSettingsManager.LoadSettings() ?? new TemplatesSettings(); var packageManager = new NuGetTemplatePackageManager(appEnvironment); if (currentSettings.Packages.Exists(x => x.PackageId == options.PackageId)) { TemplatePackage package = currentSettings.Packages.Find(x => x.Id == options.PackageId); if (package != null) { await packageManager.UnnstallAsync(package).ConfigureAwait(false); currentSettings.Packages.Remove(package); if (currentSettings.DefaultTemplate.PackageName == package.PackageId) { currentSettings.DefaultTemplate = new DefaultTemplate(); } } } TemplatePackage templatePackage = await packageManager.InstallLatestAsync(options.PackageId).ConfigureAwait(false); if (!currentSettings.Packages.Exists(x => x.Id == templatePackage.Id)) { currentSettings.Packages.Add(templatePackage); } currentSettings.DefaultTemplate ??= new DefaultTemplate { ContentType = templatePackage.Templates.First().ContentType, PackageName = templatePackage.PackageId, PackagePath = templatePackage.InstalltionPath, }; templateSettingsManager.SaveSettings(currentSettings); return(ReturnCodes.Ok); }
public static Task <int> ExecuteAsync( SetOptions options, IConsole console, IAppEnvironment appEnvironment, InvocationContext context = null) { var settingsManager = new EnvironmentSettingsManager(appEnvironment); EnvironmentSettings settings = settingsManager.LoadSettings() ?? new EnvironmentSettings(); if (options.Username != null) { settings.Username = options.Username.ToLowerInvariant(); } if (options.WorkspacePath != null) { settings.WorkspacePath = options.WorkspacePath.FullName; } if (options.PublishPath != null) { settings.PublishPath = options.PublishPath.FullName; } if (options.Key != null && options.Value != null) { if (settings.Configuration.ContainsKey(options.Key)) { settings.Configuration[options.Key] = options.Value; } else { settings.Configuration.Add(options.Key, options.Value); } } settingsManager.SaveSettings(settings); return(Task.FromResult(ReturnCodes.Ok)); }
public DnnApiControllerWithFixes() { // ensure that the sql connection string is correct // this is technically only necessary, when dnn just restarted and didn't already set this Settings.EnsureSystemIsInitialized(); // ensure that the call to this webservice doesn't reset the language in the cookie // this is a dnn-bug Helpers.RemoveLanguageChangingCookie(); Log = new Log("DNN.WebApi", null, $"Path: {HttpContext.Current?.Request?.Url?.AbsoluteUri}"); // ReSharper disable VirtualMemberCallInConstructor if (LogHistorySetName != null) { History.Add(LogHistorySetName, Log); } // ReSharper restore VirtualMemberCallInConstructor Env = new DnnEnvironment(Log); }
public LocalSettingsService(IAppEnvironment environment) { _file = Path.Combine(environment.GetStorageFolder(), FileName); Safe(() => { if (File.Exists(_file)) { var encrypted = File.ReadAllBytes(_file); var bytes = ProtectedData.Unprotect(encrypted, null, DataProtectionScope.CurrentUser); var str = Encoding.UTF8.GetString(bytes); Settings = JsonConvert.DeserializeObject <LocalSettings>(str); } else { NoSettingsFileAtLoad = true; } }); Settings = Settings ?? new LocalSettings(); }
public MainStreamerModel(CoreData coreData, ScreenRendererModel screenRenderer, SourcesModel sources, ResourceService resourceService, IAppEnvironment appEnvironment, IWindowStateManager windowStateManager, AudioModel audioModel, IAppResources appResource) { _coreData = coreData; _sources = sources; _resourceService = resourceService; _appEnvironment = appEnvironment; _windowStateManager = windowStateManager; _audioModel = audioModel; _appResource = appResource; ScreenRenderer = screenRenderer; _healthCheck = new StreamerHealthCheck(coreData); Core.InitOnMain(); }
public static async Task <int> ExecuteAsync( PluginOptions options, IConsole console, IAppEnvironment appEnvironment, InvocationContext context = null) { console.Out.WriteLine($"Uninstalling plugin with package id '{options.PackageId}'"); var packageManager = new NuGetPluginPackageManager(appEnvironment); try { await packageManager.UninstallAsync(options.PackageId).ConfigureAwait(false); } catch (Exception exception) { console.Error.WriteLine(exception.Message); return(ReturnCodes.Exception); } return(ReturnCodes.Ok); }
public LogService(IAppEnvironment environment, Func <HubConnectionService> hubConnectionServiceFactory) { Log.Logger = new LoggerConfiguration() .MinimumLevel.ControlledBy(_switch) #if DEBUG //.WriteTo.Async(a => //{ // a.Debug(outputTemplate: "[{Timestamp:dd HH:mm:ss.fff} {Level:u3}] {Message:lj}{NewLine}{Exception}"); //}) #endif .WriteTo.File(path: $"{environment.GetStorageFolder()}\\Logs\\Client.txt", fileSizeLimitBytes: 10_000_000, retainedFileCountLimit: 2, rollOnFileSizeLimit: true, // flushToDiskInterval: TimeSpan.Zero, outputTemplate: "[{Timestamp:dd HH:mm:ss.fff}] {Level:u3}]: {Message:lj}{NewLine}{Exception}") .WriteTo.ServerLog(hubConnectionServiceFactory) .CreateLogger(); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Log.Information($"Application started '{ClientVersionHelper.GetVersion()}'"); }
private static IEnumerable <IAbsoluteFilePath> FindAllConventionFiles(IAppEnvironment appEnvironment) { var conventionFilePaths = new List <IAbsoluteFilePath>(); foreach (IAbsoluteDirectoryPath pluginPath in appEnvironment.TemplatesPath.ChildrenDirectoriesPath) { foreach (IAbsoluteDirectoryPath child in pluginPath.ChildrenDirectoriesPath) { IAbsoluteDirectoryPath current = child; while (current != null) { if (current.GetChildFileWithName("conventions.json").Exists) { conventionFilePaths.Add(current.GetChildFileWithName("conventions.json")); } current = current.ChildrenDirectoriesPath.FirstOrDefault(); } } } return(conventionFilePaths); }