public void Scaffold(string projectRoot) { ProjectRoot = projectRoot; // program.cpp WriteFile("program.cpp", TemplateResource.CPP_program); // c_cpp_properties.json var content = Transform(TemplateResource.CPP_c_cpp_properties, x => x .Replace("{GXX}", _path.GetPath(PathKind.MingwGXXExecutable, true)) .Replace("{ENV1}", _path.GetPath(PathKind.MingwInclude1Directory, true)) .Replace("{ENV2}", _path.GetPath(PathKind.MingwInclude2Directory, true))); WriteFile(".vscode/c_cpp_properties.json", content); // launch.json content = Transform(TemplateResource.CPP_launch, x => x.Replace("{GDB}", _path.GetPath(PathKind.MingwGDBExecutable, true))); WriteFile(".vscode/launch.json", content); // settings.json WriteFile(".vscode/settings.json", TemplateResource.CPP_settings); // tasks.json WriteFile(".vscode/tasks.json", TemplateResource.CPP_Console_tasks); }
public void Store(string name, object value) { var path = Path.Combine(_path.GetPath(PathKind.PersistanceDirectory), name + ".kfl"); using (var writer = new StreamWriter(path)) { _serializer.Serialize(writer, value); } }
public void Store(string name, object value) { var path = Path.Combine(_path.GetPath(PathKind.SettingsRoot), name + PathHelpers.JsonExtension); using var writer = File.OpenWrite(path); JsonSerializer.Serialize(writer, value, new JsonSerializerOptions { WriteIndented = true }); }
public void Store(string name, object value) { var path = Path.Combine(_path.GetPath(PathKind.PersistanceDirectory), name + ".kfl"); using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write)) using (var cryptoStream = new CryptoStream(fileStream, _aes.CreateEncryptor(), CryptoStreamMode.Write)) using (var writer = new StreamWriter(cryptoStream)) { _serializer.Serialize(writer, value); } }
public FirebirdSettings() { IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); string dataDirectory = pathManager.GetPath("<DATA>"); _databaseFile = Path.Combine(dataDirectory, DEFAULT_DATABASE_FILE); }
private bool TryCreateInsertVideoMediaMediaItem(MediaItem origMi, out MediaItem subMi) { subMi = null; IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); string resourceDirectory = pathManager.GetPath(@"<DATA>\Resources\"); string[] files = Directory.GetFiles(resourceDirectory, "InsertVideoMedia.*"); if (files == null || files.Length == 0) { return(false); } IDictionary <Guid, IList <MediaItemAspect> > aspects = new Dictionary <Guid, IList <MediaItemAspect> >(); foreach (var aspect in origMi.Aspects) { if (aspect.Key != ProviderResourceAspect.ASPECT_ID) { aspects.Add(aspect.Key, aspect.Value); } } MediaItemAspect providerResourceAspect = MediaItemAspect.CreateAspect(aspects, ProviderResourceAspect.Metadata); providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_INDEX, 0); providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_TYPE, ProviderResourceAspect.TYPE_PRIMARY); providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, ResourcePath.BuildBaseProviderPath(LocalFsResourceProviderBase.LOCAL_FS_RESOURCE_PROVIDER_ID, files[0]).Serialize()); providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_MIME_TYPE, MimeTypeDetector.GetMimeType(files[0], "video/unknown")); providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_SYSTEM_ID, ServiceRegistration.Get <ISystemResolver>().LocalSystemId); subMi = new MediaItem(Guid.Empty, aspects); return(true); }
public ScimoreDb() { try { IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); string dataDirectory = pathManager.GetPath("<DATA>"); string databasePath = Path.Combine(dataDirectory, DEFAULT_DATABASE_FILE); const string DATABASE_NAME = "MediaPortal"; _connectionString = "Initial Catalog=" + DATABASE_NAME; _db.Create(databasePath); _db.Open(databasePath); using (ScimoreConnection conn = _db.CreateConnection(_connectionString)) { using (IDbCommand command = conn.CreateCommand()) { command.CommandText = "CREATE DATABASE IF NOT EXISTS " + DATABASE_NAME; command.ExecuteNonQuery(); } } } catch (Exception e) { ServiceRegistration.Get <ILogger>().Critical("Error establishing database connection", e); throw; } }
public PersistanceStorage(IPathManager path) { _path = path; var dirPath = _path.GetPath(PathKind.PersistanceDirectory); Directory.CreateDirectory(dirPath); }
public FlutterInstallService(IFlutterGitClient flutterGitClient, IPathManager pathManager, ILogger <FlutterInstallService> logger, HttpClient httpClient) { InstallPath = pathManager.GetPath(PathKind.FlutterInstallRoot); _flutterGitClient = flutterGitClient; _logger = logger; _httpClient = httpClient; }
public FlutterInstallService(IFlutterGitClient flutterService, WebClient webClient, IPathManager pathManager, ILogger logger) { InstallPath = pathManager.GetPath(PathKind.FlutterInstallDirectory); _flutterService = flutterService; _webClient = webClient; _logger = logger; _webClient.DownloadProgressChanged += WebClient_DownloadProgressChanged; }
public void Start(string servePath) { var startInfo = new ProcessStartInfo { FileName = _pathManager.GetPath(PathKind.KFserverExecutable), Arguments = servePath, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }; Process.Start(startInfo); }
public PersistanceStorage(IPathManager path, IAuthorizationService authorization) { _path = path; _aes = new AesManaged { Key = authorization.GetKey(Environment.MachineName), IV = authorization.GetKey(Environment.MachineName) }; var dirPath = _path.GetPath(PathKind.PersistanceDirectory); Directory.CreateDirectory(dirPath); }
public void UpdateScores(bool restart = true) { _watcher.Stop(); var projectPath = _path.GetPath(PathKind.DefaultProjectRoot); var files = Directory.EnumerateFiles(projectPath, "*", SearchOption.AllDirectories); _settings.CodeCount = files.AsParallel().Select(Helpers.CountLines).Sum(); _settings.CodingTime = _settings.CodingTime.Add(TimeSpan.FromSeconds(_watcher.TotalSeconds)); _settings.ProjectCount = Directory.EnumerateDirectories(projectPath).AsParallel().Count() - 1; if (restart) { _watcher.Start(); } }
public TemplateService(IPathManager path) { _templates = new List <Template> { new Template("Konsol (C++)", new List <Transformable> { new Transformable("program.cpp", () => TR.CPP_program), new Transformable(".vscode/c_cpp_properties.json", () => TR.CPP_c_cpp_properties, x => x.Replace("{GXX}", path.GetPath(PathKind.MingwGXXExecutable, true)) .Replace("{ENV1}", path.GetPath(PathKind.MingwInclude1Directory, true)) .Replace("{ENV2}", path.GetPath(PathKind.MingwInclude2Directory, true))), new Transformable(".vscode/launch.json", () => TR.CPP_launch, x => x.Replace("{GDB}", path.GetPath(PathKind.MingwGDBExecutable, true))), new Transformable(".vscode/settings.json", () => TR.CPP_settings), new Transformable(".vscode/tasks.json", () => TR.CPP_Console_tasks) }), new Template("GUI Freeglut (C++)", new List <Transformable> { new Transformable("program.cpp", () => TR.CPP_program), new Transformable(".vscode/c_cpp_properties.json", () => TR.CPP_c_cpp_properties, x => x.Replace("{GXX}", path.GetPath(PathKind.MingwGXXExecutable, true)) .Replace("{ENV1}", path.GetPath(PathKind.MingwInclude1Directory, true)) .Replace("{ENV2}", path.GetPath(PathKind.MingwInclude2Directory, true))), new Transformable(".vscode/launch.json", () => TR.CPP_launch, x => x.Replace("{GDB}", path.GetPath(PathKind.MingwGDBExecutable, true))), new Transformable(".vscode/settings.json", () => TR.CPP_settings), new Transformable(".vscode/tasks.json", () => TR.CPP_GUI_tasks) }), new Template("Web (PHP/HTML/CSS/JS)", new List <Transformable> { new Transformable("index.html", () => TR.WEB_index) }, true), new Template("Python/Jupyter Notebook", new List <Transformable> { new Transformable("program.py", () => TR.PY_program) }), new Template("Kosong", null) }; }
public void Startup() { IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); string mountPoint = pathManager.GetPath("<REMOTERESOURCES>"); if (!Directory.Exists(mountPoint)) { Directory.CreateDirectory(mountPoint); } _dokanExecutor = Dokan.Dokan.Install(mountPoint); if (_dokanExecutor == null) { ServiceRegistration.Get <ILogger>().Warn("ResourceMountingService: Due to problems in DOKAN, resources cannot be mounted into the local filesystem"); } else { // We share the same synchronization object to avoid multithreading issues between the two classes _syncObj = _dokanExecutor.SyncObj; } }
public SQLCEDatabase() { try { IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); string dataDirectory = pathManager.GetPath("<DATABASE>"); string databaseFile = Path.Combine(dataDirectory, DEFAULT_DATABASE_FILE); int databaseSize = INITIAL_MAX_DATABASE_SIZE; FileInfo databaseFileInfo = new FileInfo(databaseFile); if (databaseFileInfo.Exists) { int bufferFileSize = (int)(databaseFileInfo.Length / (1024 * 1024)) + DATABASE_SIZE_BUFFER; if (bufferFileSize > databaseSize) { databaseSize = bufferFileSize; } } _connectionString = "Data Source='" + databaseFile + "'; Default Lock Timeout=" + LOCK_TIMEOUT + "; Max Buffer Size = " + MAX_BUFFER_SIZE + "; Max Database Size = " + databaseSize; SqlCeEngine engine = new SqlCeEngine(_connectionString); if (File.Exists(databaseFile)) { CheckUpgrade(engine); } else { Directory.CreateDirectory(dataDirectory); engine.CreateDatabase(); engine.Dispose(); } } catch (Exception e) { ServiceRegistration.Get <ILogger>().Critical("Error establishing database connection", e); throw; } }
private void cmdSave_Click(object sender, EventArgs e) { _tweaker.LockUsbCopying = chkWriteProtect.Checked; _tweaker.LockRegistryEditor = chkRegistry.Checked; _tweaker.LockTaskManager = chkTaskManager.Checked; _tweaker.LockControlPanel = chkControlPanel.Checked; _tweaker.LockWallpaper = chkWallpaper.Checked; _tweaker.LockDesktop = chkDesktop.Checked; if (rdWDefault.Checked || string.IsNullOrEmpty(_selectedWallpaperPath)) { _tweaker.WallpaperPath = ""; } else { try { var savePath = _path.GetPath(PathKind.WallpaperPath); if (File.Exists(savePath)) { File.Delete(savePath); } File.Copy(_selectedWallpaperPath, savePath); _tweaker.WallpaperPath = savePath; } catch (Exception exception) { MessageBox.Show(string.Format("{0}\r\n{1}", Resources.WallpaperCopyError, exception.Message), Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } _tweaker.Apply(); Settings.Default.Raf = chkRaf.Checked; Settings.Default.Save(); Close(); }
private void cmdSaveRegistry_Click(object sender, EventArgs e) { if (!_processManager.IsProcessElevated()) { MessageBox.Show(Resources.NotElevatedMessage, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } using (var frm = Program.Container.Resolve <AuthForm>()) { var result = frm.ShowDialog(); if (result == DialogResult.Abort) { MessageBox.Show(Resources.PasswordInvalidMessage, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } if (result != DialogResult.OK) { return; } } try { Settings.Default.Password = txtPassword.Text; Settings.Default.Save(); _systemTweaker.LockUsbCopying = chkWriteProtect.Checked; _systemTweaker.LockRegistryEditor = chkRegistry.Checked; _systemTweaker.LockTaskManager = chkTaskManager.Checked; _systemTweaker.LockControlPanel = chkControlPanel.Checked; _systemTweaker.LockDesktop = chkDesktop.Checked; _systemTweaker.LockWallpaper = chkWallpaper.Checked; if (rdWDefault.Checked) { _systemTweaker.WallpaperPath = null; } else { var storeWallpaperPath = _pathManager.GetPath(PathKind.WallpaperPath); var newWallpaperPath = lblFileName.Text; if (storeWallpaperPath == newWallpaperPath) { return; } if (File.Exists(storeWallpaperPath)) { File.Delete(storeWallpaperPath); } File.Copy(newWallpaperPath, storeWallpaperPath); _systemTweaker.WallpaperPath = storeWallpaperPath; } MessageBox.Show(Resources.SettingsSavedMessage, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(string.Format(Resources.SettingsFailedMessage, ex.Message), Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public static async Task LoadProfilesAsync(bool userProfiles) { try { string profileFile = FileUtils.BuildAssemblyRelativePath(PROFILE_FILE); if (userProfiles) { IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); string dataPath = pathManager.GetPath("<CONFIG>"); profileFile = Path.Combine(dataPath, PROFILE_FILE); } else { TranscodeProfileManager.ClearTranscodeProfiles(TRANSCODE_PROFILE_SECTION); } if (File.Exists(profileFile) == true) { XmlTextReader reader = new XmlTextReader(profileFile); EndPointProfile profile = null; while (reader.Read()) { if (reader.NodeType != XmlNodeType.Element && reader.NodeType != XmlNodeType.EndElement) { continue; } string nodeName = reader.Name; #region Profile if (nodeName == "Profile" && reader.NodeType == XmlNodeType.Element) { profile = new EndPointProfile(); while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "id") { profile.ID = reader.ReadContentAsString(); } else if (reader.Name == "name") { profile.Name = reader.ReadContentAsString(); } else if (reader.Name == "active") { profile.Active = reader.ReadContentAsBoolean(); } else if (reader.Name == "baseProfile") { string parentProfileId = reader.ReadContentAsString(); if (Profiles.ContainsKey(parentProfileId) == true) { profile.UpnpDevice.DeviceInformation.FriendlyName = Profiles[parentProfileId].UpnpDevice.DeviceInformation.FriendlyName; profile.UpnpDevice.DeviceInformation.Manufacturer = Profiles[parentProfileId].UpnpDevice.DeviceInformation.Manufacturer; profile.UpnpDevice.DeviceInformation.ManufacturerURL = Profiles[parentProfileId].UpnpDevice.DeviceInformation.ManufacturerURL; profile.UpnpDevice.DeviceInformation.ModelDescription = Profiles[parentProfileId].UpnpDevice.DeviceInformation.ModelDescription; profile.UpnpDevice.DeviceInformation.ModelName = Profiles[parentProfileId].UpnpDevice.DeviceInformation.ModelName; profile.UpnpDevice.DeviceInformation.ModelNumber = Profiles[parentProfileId].UpnpDevice.DeviceInformation.ModelNumber; profile.UpnpDevice.DeviceInformation.ModelURL = Profiles[parentProfileId].UpnpDevice.DeviceInformation.ModelURL; profile.UpnpDevice.DeviceInformation.SerialNumber = Profiles[parentProfileId].UpnpDevice.DeviceInformation.SerialNumber; profile.UpnpDevice.DeviceInformation.UPC = Profiles[parentProfileId].UpnpDevice.DeviceInformation.UPC; profile.UpnpDevice.AdditionalElements = Profiles[parentProfileId].UpnpDevice.AdditionalElements; profile.DirectoryContentBuilder = Profiles[parentProfileId].DirectoryContentBuilder; profile.ResourceAccessHandler = Profiles[parentProfileId].ResourceAccessHandler; profile.DirectoryContentFilter = Profiles[parentProfileId].DirectoryContentFilter; profile.ProtocolInfo = Profiles[parentProfileId].ProtocolInfo; profile.Settings.Thumbnails.MaxHeight = Profiles[parentProfileId].Settings.Thumbnails.MaxHeight; profile.Settings.Thumbnails.MaxWidth = Profiles[parentProfileId].Settings.Thumbnails.MaxWidth; profile.Settings.Thumbnails.Delivery = Profiles[parentProfileId].Settings.Thumbnails.Delivery; profile.Settings.Communication.AllowChunckedTransfer = Profiles[parentProfileId].Settings.Communication.AllowChunckedTransfer; profile.Settings.Communication.DefaultBufferSize = Profiles[parentProfileId].Settings.Communication.DefaultBufferSize; profile.Settings.Communication.InitialBufferSize = Profiles[parentProfileId].Settings.Communication.InitialBufferSize; profile.Settings.Metadata.Delivery = Profiles[parentProfileId].Settings.Metadata.Delivery; profile.MediaMimeMap = new Dictionary <string, MediaMimeMapping>(Profiles[parentProfileId].MediaMimeMap); } } } } #endregion Profile else if (nodeName == "DLNAProtocolInfo" && reader.NodeType == XmlNodeType.Element) { profile.ProtocolInfo = (ProtocolInfoFormat)Enum.Parse(typeof(ProtocolInfoFormat), reader.ReadElementContentAsString(), true); } #region Detections else if (nodeName == "Detections" && reader.NodeType == XmlNodeType.Element) { while (reader.Read()) { if (reader.Name == "Detections" && reader.NodeType == XmlNodeType.EndElement) { break; } if (reader.Name == "Detection" && reader.NodeType == XmlNodeType.Element) { Detection detection = new Detection(); while (reader.Read()) { if (reader.Name == "Detection" && reader.NodeType == XmlNodeType.EndElement) { break; } if (reader.Name == "UPnPSearch") { while (reader.Read()) { if (reader.Name == "UPnPSearch" && reader.NodeType == XmlNodeType.EndElement) { break; } if (reader.Name == "FriendlyName" && reader.NodeType == XmlNodeType.Element) { detection.UPnPSearch.FriendlyName = reader.ReadElementContentAsString(); } else if (reader.Name == "ModelName" && reader.NodeType == XmlNodeType.Element) { detection.UPnPSearch.ModelName = reader.ReadElementContentAsString(); } else if (reader.Name == "ModelNumber" && reader.NodeType == XmlNodeType.Element) { detection.UPnPSearch.ModelNumber = reader.ReadElementContentAsString(); } else if (reader.Name == "ProductNumber" && reader.NodeType == XmlNodeType.Element) { detection.UPnPSearch.ProductNumber = reader.ReadElementContentAsString(); } else if (reader.Name == "Server" && reader.NodeType == XmlNodeType.Element) { detection.UPnPSearch.Server = reader.ReadElementContentAsString(); } else if (reader.Name == "Manufacturer" && reader.NodeType == XmlNodeType.Element) { detection.UPnPSearch.Manufacturer = reader.ReadElementContentAsString(); } } } else if (reader.Name == "HttpSearch") { while (reader.Read()) { if (reader.Name == "HttpSearch" && reader.NodeType == XmlNodeType.EndElement) { break; } if (reader.NodeType == XmlNodeType.Element) { detection.HttpHeaders.Add(reader.Name, reader.ReadElementContentAsString()); } } } } profile.Detections.Add(detection); } } } #endregion Detections else if (nodeName == "DirectoryContentBuilder" && reader.NodeType == XmlNodeType.Element) { profile.DirectoryContentBuilder = (GenericDidlMessageBuilder.ContentBuilder)Enum.Parse(typeof(GenericDidlMessageBuilder.ContentBuilder), reader.ReadElementContentAsString(), true); } else if (nodeName == "ResourceAccessProtocol" && reader.NodeType == XmlNodeType.Element) { profile.ResourceAccessHandler = (GenericAccessProtocol.ResourceAccessProtocol)Enum.Parse(typeof(GenericAccessProtocol.ResourceAccessProtocol), reader.ReadElementContentAsString(), true); } else if (nodeName == "DirectoryContentFilter" && reader.NodeType == XmlNodeType.Element) { profile.DirectoryContentFilter = (GenericContentDirectoryFilter.ContentFilter)Enum.Parse(typeof(GenericContentDirectoryFilter.ContentFilter), reader.ReadElementContentAsString(), true); } #region UPNPDeviceDescription else if (nodeName == "UPNPDeviceDescription" && reader.NodeType == XmlNodeType.Element) { while (reader.Read()) { if (reader.Name == "UPNPDeviceDescription" && reader.NodeType == XmlNodeType.EndElement) { break; } if (reader.Name == "FriendlyName") { profile.UpnpDevice.DeviceInformation.FriendlyName = reader.ReadElementContentAsString().Replace("{computerName}", Dns.GetHostName()); } else if (reader.Name == "Manufacturer") { profile.UpnpDevice.DeviceInformation.Manufacturer = reader.ReadElementContentAsString(); } else if (reader.Name == "ManufacturerURL") { profile.UpnpDevice.DeviceInformation.ManufacturerURL = reader.ReadElementContentAsString(); } else if (reader.Name == "ModelDescription") { profile.UpnpDevice.DeviceInformation.ModelDescription = reader.ReadElementContentAsString(); } else if (reader.Name == "ModelName") { profile.UpnpDevice.DeviceInformation.ModelName = reader.ReadElementContentAsString(); } else if (reader.Name == "ModelNumber") { profile.UpnpDevice.DeviceInformation.ModelNumber = reader.ReadElementContentAsString(); } else if (reader.Name == "ModelURL") { profile.UpnpDevice.DeviceInformation.ModelURL = reader.ReadElementContentAsString(); } else if (reader.Name == "AdditionalElements") { profile.UpnpDevice.AdditionalElements = reader.ReadElementContentAsString().Replace("\t", "").Replace("\r", "").Replace("\n", "").Replace(" ", "").Trim(); } } } #endregion UPNPDeviceDescription else if (nodeName == "DLNAMediaFormats" && reader.NodeType == XmlNodeType.Element) { while (reader.Read()) { if (reader.Name == "DLNAMediaFormats" && reader.NodeType == XmlNodeType.EndElement) { break; } if (reader.Name == "MediaFormat" && reader.NodeType == XmlNodeType.Element) { MediaMimeMapping map = new MediaMimeMapping(); while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "mime") { map.MIME = reader.ReadContentAsString(); } else if (reader.Name == "name") { map.MIMEName = reader.ReadContentAsString(); } } reader.Read(); map.MappedMediaFormat = reader.Value; //Overwrite any inherited media map if (profile.MediaMimeMap.ContainsKey(map.MappedMediaFormat)) { profile.MediaMimeMap[map.MappedMediaFormat] = map; } else { profile.MediaMimeMap.Add(map.MappedMediaFormat, map); } } } } else if (nodeName == "Settings" && reader.NodeType == XmlNodeType.Element) { while (reader.Read()) { if (reader.Name == "Settings" && reader.NodeType == XmlNodeType.EndElement) { break; } else if (reader.Name == "Thumbnails" && reader.NodeType == XmlNodeType.Element) { while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "maxWidth") { profile.Settings.Thumbnails.MaxWidth = reader.ReadContentAsInt(); } else if (reader.Name == "maxHeight") { profile.Settings.Thumbnails.MaxHeight = reader.ReadContentAsInt(); } else if (reader.Name == "delivery") { profile.Settings.Thumbnails.Delivery = (ThumbnailDelivery)Enum.Parse(typeof(ThumbnailDelivery), reader.ReadContentAsString(), true); } } } else if (reader.Name == "Communication" && reader.NodeType == XmlNodeType.Element) { while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "allowChunckedTransfer") { profile.Settings.Communication.AllowChunckedTransfer = reader.ReadContentAsBoolean(); } else if (reader.Name == "initialBufferSize") { profile.Settings.Communication.InitialBufferSize = reader.ReadContentAsLong(); } else if (reader.Name == "defaultBufferSize") { profile.Settings.Communication.DefaultBufferSize = reader.ReadContentAsInt(); } } } else if (reader.Name == "Metadata" && reader.NodeType == XmlNodeType.Element) { while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "delivery") { profile.Settings.Metadata.Delivery = (MetadataDelivery)Enum.Parse(typeof(MetadataDelivery), reader.ReadContentAsString(), true); } } } } } else if (nodeName == "Profile" && reader.NodeType == XmlNodeType.EndElement) { if (Profiles.ContainsKey(profile.ID)) { //User profiles can override defaults if (userProfiles == true) { profile.Name = profile.Name + " [User]"; } Profiles[profile.ID] = profile; } else { Profiles.TryAdd(profile.ID, profile); } } } reader.Close(); await TranscodeProfileManager.LoadTranscodeProfilesAsync(TRANSCODE_PROFILE_SECTION, profileFile); } ProfileLinkSettings.Profiles = Profiles.ToDictionary(p => p.Key, p => p.Value.Name); } catch (Exception e) { Logger.Info("DlnaMediaServer: Exception reading profiles (Text: '{0}')", e.Message); } }
static void Main(params string[] args) { System.Threading.Thread.CurrentThread.Name = "Manager"; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Parse Command Line options CommandLineOptions mpArgs = new CommandLineOptions(); try { CommandLine.Parse(args, mpArgs); } catch (ArgumentException) { mpArgs.DisplayOptions(); return; } using (new ServiceScope(true)) //This is the first servicescope { ApplicationCore.RegisterCoreServices(); IPathManager pathManager = ServiceScope.Get <IPathManager>(); // Check if user wants to override the default Application Data location. if (mpArgs.IsOption(CommandLineOptions.Option.Data)) { pathManager.ReplacePath("DATA", (string)mpArgs.GetOption(CommandLineOptions.Option.Data)); } //Check whether the user wants to log method names in the logger //This adds an extra 10 to 40 milliseconds to the log call, depending on the length of the stack trace bool logMethods = mpArgs.IsOption(CommandLineOptions.Option.LogMethods); LogLevel level = LogLevel.All; if (mpArgs.IsOption(CommandLineOptions.Option.LogLevel)) { level = (LogLevel)mpArgs.GetOption(CommandLineOptions.Option.LogLevel); } ILogger logger = ServiceScope.Get <ILogger>(); logger.Level = level; logger.LogMethodNames = logMethods; logger.Debug("Manager: Registering Strings Manager"); ServiceScope.Add <ILocalisation>(new StringManager()); #if !DEBUG // Not in Debug mode (ie Release) then catch all Exceptions // In Debug mode these will be left unhandled. try { #endif // Start the system logger.Debug("ApplicationLauncher: Starting MediaPortal manager"); IPluginManager pluginManager = ServiceScope.Get <IPluginManager>(); pluginManager.Initialize(); pluginManager.Startup(true); Application.Run(new MainWindow()); pluginManager.Shutdown(); #if !DEBUG } catch (Exception ex) { CrashLogger crash = new CrashLogger(pathManager.GetPath("<LOG>")); crash.CreateLog(ex); //Form frm = // new YesNoDialogScreen("MediaPortal 2", "Unrecoverable Error", // "MediaPortal has encountered an unrecoverable error\r\nDetails have been logged\r\n\r\nRestart?", // BaseScreen.Image.bug); //restart = frm.ShowDialog() == DialogResult.Yes; } #endif } }
public static void LoadProfiles(bool userProfiles) { try { string profileFile = FileUtils.BuildAssemblyRelativePath(PROFILE_FILE_NAME); if (userProfiles) { IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); string dataPath = pathManager.GetPath("<CONFIG>"); profileFile = Path.Combine(dataPath, PROFILE_FILE_NAME); } else { TranscodeProfileManager.ClearTranscodeProfiles(TRANSCODE_PROFILE_SECTION); } if (File.Exists(profileFile) == true) { XmlTextReader reader = new XmlTextReader(profileFile); EndPointProfile profile = null; while (reader.Read()) { if (reader.NodeType != XmlNodeType.Element && reader.NodeType != XmlNodeType.EndElement) { continue; } string nodeName = reader.Name; #region Profile if (nodeName == "Profile" && reader.NodeType == XmlNodeType.Element) { profile = new EndPointProfile(); while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "id") { profile.ID = reader.ReadContentAsString(); } else if (reader.Name == "name") { profile.Name = reader.ReadContentAsString(); } else if (reader.Name == "active") { profile.Active = reader.ReadContentAsBoolean(); } else if (reader.Name == "baseProfile") { string parentProfileId = reader.ReadContentAsString(); if (Profiles.ContainsKey(parentProfileId) == true) { Logger.Info("ProfileManager: Profile: {0}, ParentProfile: {1}, ParentTargets: {2}", profile.Name, parentProfileId, string.Join(", ", Profiles[parentProfileId].Targets)); profile.Targets = new List <string>(Profiles[parentProfileId].Targets); profile.Settings.Thumbnails.MaxHeight = Profiles[parentProfileId].Settings.Thumbnails.MaxHeight; profile.Settings.Thumbnails.MaxWidth = Profiles[parentProfileId].Settings.Thumbnails.MaxWidth; profile.Settings.Thumbnails.Delivery = Profiles[parentProfileId].Settings.Thumbnails.Delivery; profile.Settings.Communication.AllowChunckedTransfer = Profiles[parentProfileId].Settings.Communication.AllowChunckedTransfer; profile.Settings.Communication.DefaultBufferSize = Profiles[parentProfileId].Settings.Communication.DefaultBufferSize; profile.Settings.Communication.InitialBufferSize = Profiles[parentProfileId].Settings.Communication.InitialBufferSize; profile.Settings.Metadata.Delivery = Profiles[parentProfileId].Settings.Metadata.Delivery; profile.MediaMimeMap = new Dictionary <string, MediaMimeMapping>(Profiles[parentProfileId].MediaMimeMap); } } } } #endregion Profile #region Targets else if (nodeName == "Targets" && reader.NodeType == XmlNodeType.Element) { while (reader.Read()) { if (reader.Name == "Targets" && reader.NodeType == XmlNodeType.EndElement) { break; } if (reader.Name == "Target" && reader.NodeType == XmlNodeType.Element) { profile.Targets.Add(reader.ReadElementContentAsString().Trim()); } } } #endregion Targets else if (nodeName == "WebMediaFormats" && reader.NodeType == XmlNodeType.Element) { while (reader.Read()) { if (reader.Name == "WebMediaFormats" && reader.NodeType == XmlNodeType.EndElement) { break; } if (reader.Name == "MediaFormat" && reader.NodeType == XmlNodeType.Element) { MediaMimeMapping map = new MediaMimeMapping(); while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "mime") { map.MIME = reader.ReadContentAsString(); } else if (reader.Name == "name") { map.MIMEName = reader.ReadContentAsString(); } } reader.Read(); map.MappedMediaFormat = reader.Value; //Overwrite any inherited media map if (profile.MediaMimeMap.ContainsKey(map.MappedMediaFormat)) { profile.MediaMimeMap[map.MappedMediaFormat] = map; } else { profile.MediaMimeMap.Add(map.MappedMediaFormat, map); } } } } else if (nodeName == "Settings" && reader.NodeType == XmlNodeType.Element) { while (reader.Read()) { if (reader.Name == "Settings" && reader.NodeType == XmlNodeType.EndElement) { break; } else if (reader.Name == "Thumbnails" && reader.NodeType == XmlNodeType.Element) { while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "maxWidth") { profile.Settings.Thumbnails.MaxWidth = reader.ReadContentAsInt(); } else if (reader.Name == "maxHeight") { profile.Settings.Thumbnails.MaxHeight = reader.ReadContentAsInt(); } else if (reader.Name == "delivery") { profile.Settings.Thumbnails.Delivery = (ThumbnailDelivery)Enum.Parse(typeof(ThumbnailDelivery), reader.ReadContentAsString(), true); } } } else if (reader.Name == "Communication" && reader.NodeType == XmlNodeType.Element) { while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "allowChunckedTransfer") { profile.Settings.Communication.AllowChunckedTransfer = reader.ReadContentAsBoolean(); } else if (reader.Name == "initialBufferSize") { profile.Settings.Communication.InitialBufferSize = reader.ReadContentAsLong(); } else if (reader.Name == "defaultBufferSize") { profile.Settings.Communication.DefaultBufferSize = reader.ReadContentAsInt(); } } } else if (reader.Name == "Metadata" && reader.NodeType == XmlNodeType.Element) { while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "delivery") { profile.Settings.Metadata.Delivery = (MetadataDelivery)Enum.Parse(typeof(MetadataDelivery), reader.ReadContentAsString(), true); } } } } } else if (nodeName == "Profile" && reader.NodeType == XmlNodeType.EndElement) { if (Profiles.ContainsKey(profile.ID)) { //User profiles can override defaults if (userProfiles == true) { profile.Name = profile.Name + " [User]"; } Profiles[profile.ID] = profile; } else { Profiles.Add(profile.ID, profile); } } } reader.Close(); TranscodeProfileManager.LoadTranscodeProfilesAsync(TRANSCODE_PROFILE_SECTION, profileFile); } } catch (Exception e) { Logger.Info("MP2Extended: Exception reading profiles (Text: '{0}')", e.Message); } }
public void Start() { Thread.CurrentThread.Name = "Main"; #if !DEBUG string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"Team MediaPortal\MP2-Server\Log"); #endif _systemStateService = new SystemStateService(); ServiceRegistration.Set <ISystemStateService>(_systemStateService); _systemStateService.SwitchSystemState(SystemState.Initializing, false); try { ILogger logger = null; try { // Check if user wants to override the default Application Data location. ApplicationCore.RegisterVitalCoreServices(_dataDirectory); ApplicationCore.RegisterCoreServices(); logger = ServiceRegistration.Get <ILogger>(); #if !DEBUG IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); logPath = pathManager.GetPath("<LOG>"); #endif BackendExtension.RegisterBackendServices(); } catch (Exception e) { if (logger != null) { logger.Critical("Error starting application", e); } _systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; BackendExtension.DisposeBackendServices(); ApplicationCore.DisposeCoreServices(); throw; } // Start the core logger.Debug("ApplicationLauncher: Starting core"); try { var mediaAccessor = ServiceRegistration.Get <IMediaAccessor>(); var pluginManager = ServiceRegistration.Get <IPluginManager>(); pluginManager.Initialize(); pluginManager.Startup(false); ApplicationCore.StartCoreServices(); BackendExtension.StartupBackendServices(); ApplicationCore.RegisterDefaultMediaItemAspectTypes(); // To be done after backend services are running mediaAccessor.Initialize(); _systemStateService.SwitchSystemState(SystemState.Running, true); BackendExtension.ActivateImporterWorker(); // To be done after default media item aspect types are present and when the system is running (other plugins might also install media item aspect types) } catch (Exception e) { logger.Critical("Error starting application", e); _systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; BackendExtension.DisposeBackendServices(); ApplicationCore.DisposeCoreServices(); _systemStateService.SwitchSystemState(SystemState.Ending, false); throw; // needed to cancel OnStart of the Service } } catch (Exception ex) { #if DEBUG ConsoleLogger log = new ConsoleLogger(LogLevel.All, false); log.Error(ex); #else ServerCrashLogger crash = new ServerCrashLogger(logPath); crash.CreateLog(ex); #endif _systemStateService.SwitchSystemState(SystemState.Ending, false); throw; // needed to cancel OnStart of the Service } }
/// <summary> /// The main entry point for the MP 2 client application. /// </summary> private static void Main(params string[] args) { Thread.CurrentThread.Name = "Main"; #if !DEBUG SplashScreen splashScreen = CreateSplashScreen(); splashScreen.ShowSplashScreen(); #endif // Parse Command Line options CommandLineOptions mpArgs = new CommandLineOptions(); ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error)); if (!parser.ParseArguments(args, mpArgs, Console.Out)) { Environment.Exit(1); } #if !DEBUG string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"Team MediaPortal\MP2-Client\Log"); #endif SystemStateService systemStateService = new SystemStateService(); ServiceRegistration.Set <ISystemStateService>(systemStateService); systemStateService.SwitchSystemState(SystemState.Initializing, false); try { ILogger logger = null; try { // Check if user wants to override the default Application Data location. ApplicationCore.RegisterCoreServices(mpArgs.DataDirectory); logger = ServiceRegistration.Get <ILogger>(); #if !DEBUG IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); logPath = pathManager.GetPath("<LOG>"); #endif UiExtension.RegisterUiServices(); } catch (Exception e) { if (logger != null) { logger.Critical("Error starting application", e); } systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; UiExtension.DisposeUiServices(); ApplicationCore.DisposeCoreServices(); throw; } // Start the core logger.Debug("ApplicationLauncher: Starting application"); try { IPluginManager pluginManager = ServiceRegistration.Get <IPluginManager>(); pluginManager.Initialize(); pluginManager.Startup(false); ApplicationCore.StartCoreServices(); ISkinEngine skinEngine = ServiceRegistration.Get <ISkinEngine>(); IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); IMediaAccessor mediaAccessor = ServiceRegistration.Get <IMediaAccessor>(); ILocalSharesManagement localSharesManagement = ServiceRegistration.Get <ILocalSharesManagement>(); // We have to handle some dependencies here in the start order: // 1) After all plugins are loaded, the SkinEngine can initialize (=load all skin resources) // 2) After the skin resources are loaded, the workflow manager can initialize (=load its states and actions) // 3) Before the main window is shown, the splash screen should be hidden // 4) After the workflow states and actions are loaded, the main window can be shown // 5) After the skinengine triggers the first workflow state/startup screen, the default shortcuts can be registered mediaAccessor.Initialize(); // Independent from other services localSharesManagement.Initialize(); // After media accessor was initialized skinEngine.Initialize(); // 1) workflowManager.Initialize(); // 2) #if !DEBUG splashScreen.CloseSplashScreen(); // 3) #endif skinEngine.Startup(); // 4) UiExtension.Startup(); // 5) ApplicationCore.RegisterDefaultMediaItemAspectTypes(); // To be done after UI services are running systemStateService.SwitchSystemState(SystemState.Running, true); Application.Run(); systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; // Block ServiceRegistration from trying to load new services in shutdown phase // 1) Stop UI extensions (Releases all active players, must be done before shutting down SE) // 2) Shutdown SkinEngine (Closes all screens, uninstalls background manager, stops render thread) // 3) Shutdown WorkflowManager (Disposes all models) // 4) Shutdown PluginManager (Shuts down all plugins) // 5) Remove all services UiExtension.StopUiServices(); skinEngine.Shutdown(); workflowManager.Shutdown(); pluginManager.Shutdown(); mediaAccessor.Shutdown(); localSharesManagement.Shutdown(); ApplicationCore.StopCoreServices(); } catch (Exception e) { logger.Critical("Error executing application", e); systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; } finally { UiExtension.DisposeUiServices(); ApplicationCore.DisposeCoreServices(); systemStateService.SwitchSystemState(SystemState.Ending, false); } } catch (Exception ex) { #if DEBUG ConsoleLogger log = new ConsoleLogger(LogLevel.All, false); log.Error(ex); #else UiCrashLogger crash = new UiCrashLogger(logPath); crash.CreateLog(ex); #endif systemStateService.SwitchSystemState(SystemState.Ending, false); Application.Exit(); } }
public string GetPathForProject(string title, Template template, string basePath = null) { var pathKind = template.UseXamppPath ? PathKind.XamppProjectRoot : PathKind.DefaultProjectRoot; return(Path.Combine(basePath ?? _path.GetPath(pathKind), _path.StripInvalidPathName(title))); }
/// <summary> /// The main entry point for the MP2 client application. /// </summary> private static void Main(params string[] args) { Thread.CurrentThread.Name = "Main"; // Parse command line options var mpOptions = new CommandLineOptions(); var parser = new CommandLine.Parser(with => with.HelpWriter = Console.Out); parser.ParseArgumentsStrict(args, mpOptions, () => Environment.Exit(1)); // Check if another instance is already running if (SingleInstanceHelper.IsAlreadyRunning(MUTEX_ID, out _mutex)) { _mutex = null; // Set focus on previously running app SingleInstanceHelper.SwitchToCurrentInstance(SingleInstanceHelper.SHOW_MP2_CLIENT_MESSAGE); // Stop current instance Console.Out.WriteLine("Application already running."); Environment.Exit(2); } #if !DEBUG string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"Team MediaPortal\MP2-Client\Log"); #endif Application.ThreadException += LauncherExceptionHandling.Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += LauncherExceptionHandling.CurrentDomain_UnhandledException; TaskScheduler.UnobservedTaskException += LauncherExceptionHandling.TaskScheduler_UnobservedTaskException; SystemStateService systemStateService = new SystemStateService(); ServiceRegistration.Set <ISystemStateService>(systemStateService); systemStateService.SwitchSystemState(SystemState.Initializing, false); try { #if !DEBUG SplashScreen splashScreen = null; #endif ILogger logger = null; try { // Check if user wants to override the default Application Data location. ApplicationCore.RegisterVitalCoreServices(true, mpOptions.DataDirectory); #if !DEBUG splashScreen = CreateSplashScreen(); splashScreen.ShowSplashScreen(); #endif ApplicationCore.RegisterCoreServices(); logger = ServiceRegistration.Get <ILogger>(); #if !DEBUG IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); logPath = pathManager.GetPath("<LOG>"); #endif UiExtension.RegisterUiServices(); } catch (Exception e) { if (logger != null) { logger.Critical("Error starting application", e); } systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; UiExtension.DisposeUiServices(); ApplicationCore.DisposeCoreServices(); throw; } // Start the core logger.Debug("ApplicationLauncher: Starting application"); try { IPluginManager pluginManager = ServiceRegistration.Get <IPluginManager>(); pluginManager.Initialize(); pluginManager.Startup(false); ApplicationCore.StartCoreServices(); ISkinEngine skinEngine = ServiceRegistration.Get <ISkinEngine>(); IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); IMediaAccessor mediaAccessor = ServiceRegistration.Get <IMediaAccessor>(); ILocalSharesManagement localSharesManagement = ServiceRegistration.Get <ILocalSharesManagement>(); // We have to handle some dependencies here in the start order: // 1) After all plugins are loaded, the SkinEngine can initialize (=load all skin resources) // 2) After the skin resources are loaded, the workflow manager can initialize (=load its states and actions) // 3) Before the main window is shown, the splash screen should be hidden // 4) After the workflow states and actions are loaded, the main window can be shown // 5) After the skinengine triggers the first workflow state/startup screen, the default shortcuts can be registered mediaAccessor.Initialize(); // Independent from other services localSharesManagement.Initialize(); // After media accessor was initialized skinEngine.Initialize(); // 1) workflowManager.Initialize(); // 2) #if !DEBUG splashScreen.CloseSplashScreen(); // 3) #endif skinEngine.Startup(); // 4) UiExtension.Startup(); // 5) ApplicationCore.RegisterDefaultMediaItemAspectTypes().Wait(); // To be done after UI services are running _ipcServer = new IpcServer("Client"); _ipcServer.CustomShutdownCallback = () => { ServiceRegistration.Get <IScreenControl>().Shutdown(); return(true); }; try { _ipcServer.Open(); } catch (Exception ipcEx) { logger.Error(ipcEx); } systemStateService.SwitchSystemState(SystemState.Running, true); if (mpOptions.AutoStart) { StartFocusKeeper(); } Application.Run(); systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; // Block ServiceRegistration from trying to load new services in shutdown phase // 1) Stop UI extensions (Releases all active players, must be done before shutting down SE) // 2) Shutdown SkinEngine (Closes all screens, uninstalls background manager, stops render thread) // 3) Shutdown WorkflowManager (Disposes all models) // 4) Shutdown ImporterWorker // 5) Shutdown PluginManager (Shuts down all plugins) // 6) Remove all services UiExtension.StopUiServices(); skinEngine.Shutdown(); workflowManager.Shutdown(); ServiceRegistration.Get <IImporterWorker>().Shutdown(); pluginManager.Shutdown(); mediaAccessor.Shutdown(); localSharesManagement.Shutdown(); ApplicationCore.StopCoreServices(); } catch (Exception e) { logger.Critical("Error executing application", e); systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; } finally { if (_ipcServer != null) { _ipcServer.Close(); } UiExtension.DisposeUiServices(); ApplicationCore.DisposeCoreServices(); systemStateService.SwitchSystemState(SystemState.Ending, false); } } catch (Exception ex) { #if DEBUG ConsoleLogger log = new ConsoleLogger(LogLevel.All, false); log.Error(ex); #else UiCrashLogger crash = new UiCrashLogger(logPath); crash.CreateLog(ex); #endif systemStateService.SwitchSystemState(SystemState.Ending, false); // Release mutex for single instance if (_mutex != null) { _mutex.ReleaseMutex(); } Application.Exit(); } }
public string GetPathForProject(string title, string?basePath = null) { return(Path.Combine(basePath ?? _path.GetPath(PathKind.ProjectRoot), PathHelpers.StripInvalidPathName(title))); }
public void OpenFolder(string path) { var vscode = _path.GetPath(PathKind.VisualStudioCodeExecutable); _processManager.Run(vscode, $"\"{path}\""); }
/// <summary> /// The main entry point for the MP 2 server application. /// </summary> private static void Main(params string[] args) { Thread.CurrentThread.Name = "Main"; // Parse Command Line options CommandLineOptions mpArgs = new CommandLineOptions(); ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error)); if (!parser.ParseArguments(args, mpArgs, Console.Out)) { Environment.Exit(1); } #if !DEBUG string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"Team MediaPortal\MP2-Server\Log"); #endif Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); SystemStateService systemStateService = new SystemStateService(); ServiceRegistration.Set <ISystemStateService>(systemStateService); systemStateService.SwitchSystemState(SystemState.Initializing, false); try { ILogger logger = null; try { // Check if user wants to override the default Application Data location. ApplicationCore.RegisterCoreServices(mpArgs.DataDirectory); logger = ServiceRegistration.Get <ILogger>(); #if !DEBUG IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); logPath = pathManager.GetPath("<LOG>"); #endif BackendExtension.RegisterBackendServices(); } catch (Exception e) { if (logger != null) { logger.Critical("Error starting application", e); } systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; BackendExtension.DisposeBackendServices(); ApplicationCore.DisposeCoreServices(); throw; } // Start the core logger.Debug("ApplicationLauncher: Starting core"); try { IMediaAccessor mediaAccessor = ServiceRegistration.Get <IMediaAccessor>(); IPluginManager pluginManager = ServiceRegistration.Get <IPluginManager>(); pluginManager.Initialize(); pluginManager.Startup(false); ApplicationCore.StartCoreServices(); BackendExtension.StartupBackendServices(); ApplicationCore.RegisterDefaultMediaItemAspectTypes(); // To be done after backend services are running mediaAccessor.Initialize(); systemStateService.SwitchSystemState(SystemState.Running, true); BackendExtension.ActivateImporterWorker(); // To be done after default media item aspect types are present and when the system is running (other plugins might also install media item aspect types) Application.Run(new MainForm()); systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; // Block ServiceRegistration from trying to load new services in shutdown phase mediaAccessor.Shutdown(); pluginManager.Shutdown(); BackendExtension.ShutdownBackendServices(); ApplicationCore.StopCoreServices(); } catch (Exception e) { logger.Critical("Error executing application", e); systemStateService.SwitchSystemState(SystemState.ShuttingDown, true); ServiceRegistration.IsShuttingDown = true; } finally { BackendExtension.DisposeBackendServices(); ApplicationCore.DisposeCoreServices(); systemStateService.SwitchSystemState(SystemState.Ending, false); } } catch (Exception ex) { #if DEBUG ConsoleLogger log = new ConsoleLogger(LogLevel.All, false); log.Error(ex); #else ServerCrashLogger crash = new ServerCrashLogger(logPath); crash.CreateLog(ex); #endif systemStateService.SwitchSystemState(SystemState.Ending, false); Application.Exit(); } }