예제 #1
0
        public void run(string[] args)
        {
            string queueName = "rba16";
            if (File.Exists(workingDir + "\\agent.config"))
            {
                queueName = File.ReadAllText(workingDir + "\\agent.config");
            }
            bool skip = false;
            string input = "";
            if (args.Length > 0)
            {
                input = args[0];
                if (input.Equals("startup", StringComparison.InvariantCultureIgnoreCase))
                    skip = true;
            }
            if (File.Exists(workingDir + "\\topics.config"))
            {
                oldTopics = File.ReadAllLines(workingDir + "\\topics.config");
                if (oldTopics.Length > 0)
                    topics = oldTopics;
            }
            string res = "";
            foreach (var topic in topics)
            {
                res += topic + " ";
            }
            Console.WriteLine("Current queue is: " + queueName);
            Console.WriteLine("Current binding keys are: " + res);
            if (!skip)
            {
                Console.WriteLine(consoleMessage);
                ConsoleKeyInfo ck = Console.ReadKey();
                bool loop = true;
                do
                {
                    if (ConsoleKey.P.Equals(ck.Key))
                    {
                        AudioJobProcessor.WriteAllInstalledVoicesToFile();
                        Console.WriteLine(consoleMessage);
                        ck = Console.ReadKey();
                    }
                    if (ConsoleKey.N.Equals(ck.Key))
                    {
                        AudioJobProcessor.WriteVoiceNames();
                        Console.WriteLine(consoleMessage);
                        ck = Console.ReadKey();
                    }
                    if (ConsoleKey.C.Equals(ck.Key))
                    {
                        Console.WriteLine("Current binding keys are: " + res);
                        Console.WriteLine("Write each key separated by commas (,):");
                        string keys = Console.ReadLine();
                        topics = keys.Split(',');
                        Console.WriteLine(consoleMessage);
                        ck = Console.ReadKey();
                    }
                    if (ConsoleKey.Q.Equals(ck.Key))
                    {
                        Console.WriteLine("Current queue is: " + queueName + " Write new queue name: ");
                        queueName = Console.ReadLine();
                        Console.WriteLine(consoleMessage);
                        ck = Console.ReadKey();
                    }
                    if (ConsoleKey.Enter.Equals(ck.Key))
                    {
                        loop = false;
                        ck = Console.ReadKey();
                    }
                } while (loop);
                res = "";
                foreach (var topic in topics)
                {
                    res += topic + " ";
                }
                if (!File.Exists(workingDir + "\\agent.config"))
                {
                    File.Create(workingDir + "\\agent.config").Close();
                }
                File.WriteAllText(workingDir + "\\agent.config", queueName);

                if (!File.Exists(workingDir + "\\topics.config"))
                {
                    File.Create(workingDir + "\\topics.config").Close();
                }
                File.WriteAllLines(workingDir + "\\topics.config", topics);
            }
            Console.WriteLine("Audio Conversion Agent started listening on topics: " + res);
            QueueConsumer qc = new QueueConsumer();
            qc.Consume(queueName.Trim());
        }