Exemple #1
0
        static int consoleAppMain()
        {
            try
            {
                var ac = getAppConfig();

                if (ac.logFileName != "")
                {
                    SetLogFileName(Path.GetFullPath(ac.logFileName));
                }

                //var planRepo = getPlanRepo(ac);

                log.InfoFormat("Running with masterIp={0}, masterPort={1}", ac.masterIP, ac.masterPort);

                // use unique client id to avoid conflict with any other possible client
                string machineId = Guid.NewGuid().ToString();
                var    client    = new Dirigent.Net.Client(machineId, ac.masterIP, ac.masterPort);

                // first connect
                client.Connect();

                // use network-only agent (never local)
                string rootForRelativePaths = System.IO.Path.GetDirectoryName(System.IO.Path.GetFullPath(ac.sharedCfgFileName));
                var    agent = new Dirigent.Agent.Core.Agent(machineId, client, false, rootForRelativePaths);

                // let the agent receive the plan repository from master
                agent.tick();

                // process the console command
                MyCommandRepo cmdRepo = new MyCommandRepo(agent.Control);
                cmdRepo.ParseAndExecute(ac.nonOptionArgs);

                return(0); // everything OK
            }
            catch (Exception ex)
            {
                log.Error(ex);
                //Console.WriteLine(string.Format("Error: {0} [{1}]", ex.Message, ex.GetType().ToString()));
                Console.WriteLine(string.Format("Error: {0}", ex.Message));
                //ExceptionDialog.showException(ex, "Dirigent Exception", "");
                return(-1);
            }
        }
Exemple #2
0
        static int consoleAppMain()
        {
            try
            {
                var ac = getAppConfig();

                if (ac.logFileName != "")
                {
                    SetLogFileName(Path.GetFullPath(ac.logFileName));
                }

                //var planRepo = getPlanRepo(ac);

                log.InfoFormat("Running with masterIp={0}, masterPort={1}", ac.masterIP, ac.masterPort);

                // use unique client id to avoid conflict with any other possible client
                string machineId = Guid.NewGuid().ToString();
                var client = new Dirigent.Net.Client(machineId, ac.masterIP, ac.masterPort);

                // first connect
                client.Connect();

                // use network-only agent (never local)
                var agent = new Dirigent.Agent.Core.Agent(machineId, client, false);

                // let the agent receive the plan repository from master
                agent.tick();

                // process the console command
                MyCommandRepo cmdRepo = new MyCommandRepo(agent.Control);
                cmdRepo.ParseAndExecute(ac.nonOptionArgs);

                return 0; // everything OK

            }
            catch (Exception ex)
            {
                log.Error(ex);
                //Console.WriteLine(string.Format("Error: {0} [{1}]", ex.Message, ex.GetType().ToString()));
                Console.WriteLine(string.Format("Error: {0}", ex.Message));
                //ExceptionDialog.showException(ex, "Dirigent Exception", "");
                return -1;
            }
        }