private static void Main(string[] args) { Console.WriteLine("Dbox Tuner"); Console.WriteLine(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); IrssLog.LogLevel = IrssLog.Level.Debug; IrssLog.Open("Dbox Tuner.log"); LoadSettings(); if (args.Length == 0) { Console.WriteLine("Usage:"); Console.WriteLine(" DboxTuner.exe Setup"); Console.WriteLine("or"); Console.WriteLine(" DboxTuner.exe Wake"); Console.WriteLine("or"); Console.WriteLine(" DboxTuner.exe Mute"); Console.WriteLine("or"); Console.WriteLine(" DboxTuner.exe SetSPTS"); Console.WriteLine("or"); Console.WriteLine(" DboxTuner.exe Message <Message Text>"); Console.WriteLine("or"); Console.WriteLine(" DboxTuner.exe Zap <Channel Number>"); Console.WriteLine(); } else { _url = UrlPrefix + _address; switch (args[0].ToUpperInvariant()) { case "SETUP": SetupForm setup = new SetupForm(); setup.Address = _address; setup.UserName = _userName; setup.Password = _password; setup.BoxType = _boxType; setup.Timeout = _timeout; if (setup.ShowDialog() == DialogResult.OK) { _address = setup.Address; _userName = setup.UserName; _password = setup.Password; _boxType = setup.BoxType; _timeout = setup.Timeout; SaveSettings(); Info("Setup saved"); } else { Info("Setup cancelled"); } break; case "WAKE": Info("Command: Wake"); WakeUp(); break; case "MUTE": Info("Command: Mute"); ToggleMute(); break; case "MESSAGE": Info("Command: Message \"{0}\"", args[1]); ShowMessage(args[1]); break; case "SETSPTS": Info("Command: Set SPTS"); SetSPTS(); break; case "INFO": Info("Command: Get Info"); string output = GetInfo(); Info(output); break; case "ZAP": Info("Command: Zap, Channel: {0}", args[1]); try { Info("Raising process priority"); Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; } catch { Info("Failed to elevate process priority"); } _tvBouquets = new DataTable(); _tvBouquets.ReadXml(DataFile); string expression = String.Format("Channel = '{0}'", args[1]); // Works on EnigmaV1, others unknown. /* string expression; switch (_boxType) { case StbBoxType.EnigmaV1: expression = String.Format("Channel = '{0}'", args[1]); break; case StbBoxType.EnigmaV2: expression = String.Format("Channel = '{0}'", args[1]); break; default: expression = String.Format("Channel = '{0}'", args[1]); break; } */ DataRow[] rows = _tvBouquets.Select(expression); if (rows.Length == 1) { //string channelName = rows[0]["ChannelName"] as string; string channelID = rows[0]["ID"] as string; //Info("Zapping to channel {0} \"{1}\"", channelName, channelID); ZapTo(channelID); break; } else if (rows.Length > 0) { Info("Multiple channels match Channel No \"{0}\"", args[1]); } Info("Cannot find channel ({0}) to tune", args[1]); break; default: Info("Unknown Command \"{0}\"", args[0]); break; } } IrssLog.Close(); }