public static int Main( string[] args ) { // Check settings var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); if (!version.Equals( Properties.Settings.Default.Version )) { // Upgrade Properties.Settings.Default.Upgrade(); Properties.Settings.Default.Version = version; Properties.Settings.Default.Save(); } // For screen shots //Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("de"); // Prepare Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault( false ); // Check for configuration call if (args.Length < 1) { // Process Application.Run( new Configuration() ); // Done return 0; } // In error try { // Get command string cmd = args[0]; // Check mode bool delete = Equals( cmd, "/del" ); bool clickfinder = false; // Check parameter if (!delete && !Equals( cmd, "/add" )) { // Check for click finder call clickfinder = cmd.StartsWith( "Pos=" ); // In error if (!clickfinder) throw new ArgumentException( "/del /add" ); } // Relevant information string channelName, dura, title; DateTime start; // Check mode if (clickfinder) { // Parts string starttime; // Get parts channelName = args[2].Substring( 7 ).Replace( "\"", string.Empty ); starttime = args[3].Substring( 7 ).Replace( "\"", string.Empty ); dura = args[4].Substring( 6 ); title = args[5].Substring( 8 ).Replace( "\"", string.Empty ); // Create date starttime = starttime.Insert( 10, ":" ); starttime = starttime.Insert( 8, " " ); starttime = starttime.Insert( 6, "-" ); starttime = starttime.Insert( 4, "-" ); // Parse start = DateTime.Parse( starttime ); } else { // Get parts channelName = args[1]; title = args[5]; dura = args[4]; // Parse start = DateTime.Parse( args[2] ) + TimeSpan.Parse( args[3] ); } // Parse var minutes = int.Parse( dura ); // Load the name of the profile - can only use the default var profileName = VCRNETRestProxy.GetProfiles( EndPoint ).Select( profile => profile.name ).FirstOrDefault(); // Load collections var externals = Properties.Settings.Default.ExternalNames ?? new StringCollection(); var internals = Properties.Settings.Default.VCRNETNames ?? new StringCollection(); // See if channel is mapped for (var i = Math.Min( externals.Count, internals.Count ); i-- > 0; ) if (StringComparer.CurrentCultureIgnoreCase.Equals( externals[i], channelName )) return UpdateRecording( profileName, delete, internals[i], title, start, minutes ); // Ask user using (var dialog = new ChooseMapping( channelName, VCRNETRestProxy.GetSources( EndPoint, profileName ).Select( source => source.nameWithProvider ) )) if (dialog.ShowDialog() == DialogResult.OK) { // Cut off while (externals.Count > internals.Count) externals.RemoveAt( internals.Count ); while (internals.Count > externals.Count) internals.RemoveAt( externals.Count ); // Expand externals.Add( channelName ); internals.Add( dialog.MappedName ); // Back to settings Properties.Settings.Default.ExternalNames = externals; Properties.Settings.Default.VCRNETNames = internals; Properties.Settings.Default.Save(); // Process return UpdateRecording( profileName, delete, dialog.MappedName, title, start, minutes ); } // Report MessageBox.Show( string.Format( Properties.Resources.NoSuchChannel, channelName ) ); // Done return 1; } catch (Exception ex) { // Report MessageBox.Show( ex.Message ); // Done return 2; } }
public static int Main(string[] args) { // Check settings var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); if (!version.Equals(Properties.Settings.Default.Version)) { // Upgrade Properties.Settings.Default.Upgrade(); Properties.Settings.Default.Version = version; Properties.Settings.Default.Save(); } // For screen shots //Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("de"); // Prepare Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Check for configuration call if (args.Length < 1) { // Process Application.Run(new Configuration()); // Done return(0); } // In error try { // Get command string cmd = args[0]; // Check mode bool delete = Equals(cmd, "/del"); bool clickfinder = false; // Check parameter if (!delete && !Equals(cmd, "/add")) { // Check for click finder call clickfinder = cmd.StartsWith("Pos="); // In error if (!clickfinder) { throw new ArgumentException("/del /add"); } } // Relevant information string channelName, dura, title; DateTime start; // Check mode if (clickfinder) { // Parts string starttime; // Get parts channelName = args[2].Substring(7).Replace("\"", string.Empty); starttime = args[3].Substring(7).Replace("\"", string.Empty); dura = args[4].Substring(6); title = args[5].Substring(8).Replace("\"", string.Empty); // Create date starttime = starttime.Insert(10, ":"); starttime = starttime.Insert(8, " "); starttime = starttime.Insert(6, "-"); starttime = starttime.Insert(4, "-"); // Parse start = DateTime.Parse(starttime); } else { // Get parts channelName = args[1]; title = args[5]; dura = args[4]; // Parse start = DateTime.Parse(args[2]) + TimeSpan.Parse(args[3]); } // Parse var minutes = int.Parse(dura); // Load the name of the profile - can only use the default var profileName = VCRNETRestProxy.GetProfiles(EndPoint).Select(profile => profile.name).FirstOrDefault(); // Load collections var externals = Properties.Settings.Default.ExternalNames ?? new StringCollection(); var internals = Properties.Settings.Default.VCRNETNames ?? new StringCollection(); // See if channel is mapped for (var i = Math.Min(externals.Count, internals.Count); i-- > 0;) { if (StringComparer.CurrentCultureIgnoreCase.Equals(externals[i], channelName)) { return(UpdateRecording(profileName, delete, internals[i], title, start, minutes)); } } // Ask user using (var dialog = new ChooseMapping(channelName, VCRNETRestProxy.GetSources(EndPoint, profileName).Select(source => source.nameWithProvider))) if (dialog.ShowDialog() == DialogResult.OK) { // Cut off while (externals.Count > internals.Count) { externals.RemoveAt(internals.Count); } while (internals.Count > externals.Count) { internals.RemoveAt(externals.Count); } // Expand externals.Add(channelName); internals.Add(dialog.MappedName); // Back to settings Properties.Settings.Default.ExternalNames = externals; Properties.Settings.Default.VCRNETNames = internals; Properties.Settings.Default.Save(); // Process return(UpdateRecording(profileName, delete, dialog.MappedName, title, start, minutes)); } // Report MessageBox.Show(string.Format(Properties.Resources.NoSuchChannel, channelName)); // Done return(1); } catch (Exception ex) { // Report MessageBox.Show(ex.Message); // Done return(2); } }