public static void Main(string[] args) { // Must be fully safe try { // See if debugger attached Tools.EnableTracing = Debugger.IsAttached; Tools.DomainName = "VCR.NET"; // Dump environment //foreach (System.Collections.DictionaryEntry env in Environment.GetEnvironmentVariables()) // Tools.ExtendedLogging( "Environment {0}={1}", env.Key, env.Value ); // Load configuration into main application domain VCRConfiguration.Startup(); // Cleanup mess from earlier version try { // Clear var target = Path.Combine(Path.Combine(Tools.ApplicationDirectory.Parent.FullName, "bin"), "JMS.DVB.SourceManagement.dll"); if (File.Exists(target)) { File.Delete(target); } } catch (Exception e) { // Report VCRServer.LogError("DVB.NET Cleanup failed: {0}", e.Message); } // Show startup Tools.ExtendedLogging("Starting Service"); // Run Service.Startup(args); // Show termination Tools.ExtendedLogging("Terminating Service"); } catch (Exception e) { // Report Tools.LogException("Main", e); // Re-Throw throw e; } }
/// <summary> /// Lädt alle Profile erneut. /// </summary> internal static void Reset() { // Report Tools.ExtendedLogging("Reloading Profile List"); // Forward to profile manager ProfileManager.Refresh(); // Create a new state var newState = new _State(); // List of profiles var profiles = new List <Profile>(); // Load the setting var profileNames = VCRConfiguration.Current.ProfileNames; if (!string.IsNullOrEmpty(profileNames)) { foreach (var profileName in profileNames.Split('|')) { // Try to locate var profile = ProfileManager.FindProfile(profileName.Trim()); if (profile == null) { // This is not goot VCRServer.LogError(Properties.Resources.InternalError_NoProfile, profileName.Trim()); // Next continue; } // Report Tools.ExtendedLogging("Using Profile {0}", profile.Name); // Remember profiles.Add(profile); // Create the dictionary of sources var sourcesByIdentifier = new Dictionary <SourceIdentifier, SourceSelection>(); var sourcesByKey = new Dictionary <string, SourceSelection>(); // Load by name foreach (var byDisplayName in profile.AllSourcesByDisplayName) { sourcesByKey[byDisplayName.DisplayName] = byDisplayName; } // Remember it newState.SourceByIdentifierMap[profile.Name] = sourcesByIdentifier; newState.SourceBySelectionMap[profile.Name] = sourcesByKey; // Load list foreach (var source in sourcesByKey.Values) { // Just remember by identifier sourcesByIdentifier[source.Source] = source; // Correct back the name source.DisplayName = ((Station)source.Source).FullName; } } } // Fill it foreach (var profileMap in newState.SourceBySelectionMap.Values) { foreach (var mapEntry in profileMap) { newState.UniqueNameBySelectionMap[mapEntry.Value.SelectionKey] = mapEntry.Key; } } // Add all qualified names to allow semi-legacy clients to do a unique lookup foreach (var profileMap in newState.SourceBySelectionMap.Values) { foreach (var source in profileMap.ToList()) { if (!source.Key.Equals(source.Value.DisplayName)) { // Unmap the station var station = (Station)source.Value.Source; // Enter special notation profileMap[$"{station.Name} {station.ToStringKey()} [{station.Provider}]"] = source.Value; } } } // Use all newState.Profiles = profiles.ToArray(); newState.ProfileMap = profiles.ToDictionary(profile => profile.Name, newState.ProfileMap.Comparer); // Report Tools.ExtendedLogging("Activating new Profile Set"); // Use the new state CurrentState = newState; }