public int Parse(string[] args)
 {
     if (args == null || args.Length == 0)
     {
         Console.WriteLine("Wrong usage");
         Console.WriteLine("Parameters");
         Console.WriteLine("/c <one line command>");
         Console.WriteLine("/host <host address>");
         Console.WriteLine("/clean");
         Console.ReadLine();
         return -1;
     }
     try
     {
         var arguments = new InputArguments(args, "/", true);
         if (!arguments.Contains("/c"))
         {
             Console.WriteLine("Missing command");
             Console.WriteLine("/c <one line command>");
             return -1;
         }
         string mess = Send(arguments["/c"], "DCCPipe", arguments.Contains("/host") ? arguments["/host"] : ".",
             15000);
         if (arguments.Contains("/clean"))
         {
             var lines = PipeServerT.Pharse(mess);
             if (lines.ContainsKey("response"))
             {
                 if (lines["response"].StartsWith("["))
                 {
                     var list = JsonConvert.DeserializeObject<List<string>>(lines["response"]);
                     foreach (string s in list)
                     {
                         Console.WriteLine(s);
                     }
                 }
                 else
                 {
                     Console.WriteLine(lines["response"]);                            
                 }
             }
             else
             {
                 Console.WriteLine(lines["message"]);
             }
         }
         else
         {
             Console.WriteLine(mess);                    
         }
         return 0;
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error :");
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
         return -1;
     }
 }
Esempio n. 2
0
        //[STAThread]
        private static int Main(string[] args)
        {
            Console.WriteLine("digiCamControl command line utility");
            Console.WriteLine();

            _arguments = new InputArguments(args, "/");
            if (!args.Any() || _arguments.Contains("help"))
            {
                ShowHelp();
                Console.ReadLine();
                return 0;
            }
            InitApplication();
            Thread.Sleep(1000);
            while (CamerasAreBusy())
            {
                Thread.Sleep(1);
            }
            if (args != null && args.Count() == 1 && File.Exists(args[0]))
            {
                RunScript(args[0]);
                return 0;
            }
            if (ServiceProvider.DeviceManager.ConnectedDevices.Count == 0)
            {
                Console.WriteLine("No connected device was found ! Exiting");
                return 0;
            }
            int exitCodes = ExecuteArgs();
            Thread.Sleep(250);
            Thread thread = new Thread(WaitForCameras);
            thread.Start();

            Dispatcher.Run();

            return exitCodes;
        }