예제 #1
0
 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);
     }
 }
예제 #2
0
 public static void Configure(string logFile)
 {
     Configure(AppName, logFile);
     Log.LogDebug += Log_LogDebug;
     Log.LogError += Log_LogError;
     Log.LogInfo  += Log_LogInfo;
     Log.Debug(
         "--------------------------------===========================Application starting===========================--------------------------------");
     try
     {
         Log.Debug("Application version : " + Assembly.GetEntryAssembly().GetName().Version);
     }
     catch {}
     Analytics = new Analytics();
     Log.Debug("Init : Analytics");
     //DeviceManager = new CameraDeviceManager(Path.Combine(Classes.Settings.ApplicationFolder, "Devices"));
     DeviceManager = new CameraDeviceManager();
     Log.Debug("Init : DeviceManager");
     ExternalDeviceManager = new ExternalDeviceManager();
     Log.Debug("Init : ExternalDeviceManager");
     Trigger = new TriggerClass();
     Log.Debug("Init : Trigger");
     QueueManager = new QueueManager();
     Log.Debug("Init : QueueManager");
     //Branding = new Branding();
     ScriptManager = new ScriptManager();
     Log.Debug("Init : ScriptManager");
     PluginManager = new PluginManager();
     Log.Debug("Init : PluginManager");
     FilenameTemplateManager = new FilenameTemplateManager();
     _pipeServer             = new PipeServerT();
     _pipeServer.Listen("DCCPipe");
     Log.Debug("Init : _pipeServer");
 }
 public static void Configure(string logFile)
 {
     Configure(AppName, logFile);
     Log.LogDebug += Log_LogDebug;
     Log.LogError += Log_LogError;
     Log.Debug(
         "--------------------------------===========================Application starting===========================--------------------------------");
     try
     {
         Log.Debug("Application version : " + Assembly.GetEntryAssembly().GetName().Version);
     }
     catch {}
     Analytics             = new Analytics();
     DeviceManager         = new CameraDeviceManager();
     ExternalDeviceManager = new ExternalDeviceManager();
     Trigger       = new TriggerClass();
     ActionManager = new ActionManager();
     QueueManager  = new QueueManager();
     //Branding = new Branding();
     ScriptManager           = new ScriptManager();
     PluginManager           = new PluginManager();
     FilenameTemplateManager = new FilenameTemplateManager();
     _pipeServer             = new PipeServerT();
     _pipeServer.Listen("DCCPipe");
 }
 public int Parse(string[] args)
 {
     if (args == null || args.Length == 0)
     {
         Console.WriteLine("Wrong usage");
         ShowHelp();
         return(-1);
     }
     try
     {
         var arguments = new InputArguments(args, "/", true);
         if (arguments.Contains("/help"))
         {
             ShowHelp();
             return(0);
         }
         if (!arguments.Contains("/c"))
         {
             Console.WriteLine("ERROR: Missing command");
             ShowHelp();
             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 if (lines.ContainsKey("message"))
                 {
                     Console.WriteLine(lines["response"] + " " + lines["message"]);
                 }
                 else if (!lines["response"].Equals("null"))
                 {
                     Console.WriteLine(lines["response"]);
                 }
             }
             else
             {
                 Console.WriteLine(lines["message"]);
             }
         }
         else
         {
             Console.WriteLine(mess);
         }
         return(0);
     }
     catch (TimeoutException ex)
     {
         Console.WriteLine("Timeout Error (is the GUI running?):");
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
         return(-1);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error :");
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
         return(-1);
     }
 }