Example #1
0
 public void Start(StartupParams startup, IStartupHandler handler)
 {
     _startupParams  = startup;
     _startupHandler = handler;
     ConnectToVM();
     _license = new RhinoValidator(GetAppDataFolder());
 }
Example #2
0
 public void Start(StartupParams startup, IStartupHandler handler)
 {
     _startupParams = startup;
     _startupHandler = handler;
     ConnectToVM();
     _license = new RhinoValidator(GetAppDataFolder());
 }
Example #3
0
        static void Main(string[] args)
        {
            //args = new string[] { "3456", @"C:\Users\ack\src\Autotest.Net\AutoTest.Net.sln", Guid.NewGuid().ToString(), "debug", "0", "global" };
            LaunchArguments arguments = null;
            try
            {
                arguments = parseArguments(args);
                Logger.SetDebugMode(arguments.Debug);
                Logger.WriteInfo("Starting application");

                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                _feedback = new ServerFeedback();
                _feedback.ClientDisconnected += _feedback_ClientDisconnected;
                _feedback.ClientConnect += _feedback_ClientConnect;
                server = new TcpServer(_feedback);

                server.MessageReceived += OnRecieve;
                server.StartServer("127.0.0.1", arguments.Port);
                var writeLocator = new DefaultConfigFileLocator(server.Port.ToString(), arguments.IsGlobal);
                initializeConfiguration(writeLocator.GetConfigurationFile());
                if (arguments.IsGlobal)
                    _license = new RhinoValidator(Environment.SpecialFolder.CommonApplicationData);
                else
                    _license = new RhinoValidator(Environment.SpecialFolder.LocalApplicationData);

                _engine = new ATEngine(server, writeLocator, arguments.WatchPath, _license);
                _engine.Start();

                Logger.WriteInfo(string.Format("VM listening on 127.0.0.1:{0}", server.Port));
                startExitTimer();
                SendVmInitializedMessage(arguments.CorrelationId, server, arguments.OwnerPort);
                int clientsConnected = 0;
                while (!_shouldExit)
                {
                    if (clientsConnected == 0 && server.ClientCount > 0)
                        _engine.ValidateConfiguration();
                    clientsConnected = server.ClientCount;
                    Thread.Sleep(1000);
                    if (isMasterDead(arguments.MasterProcessId))
                        shutdown();
                }
                Logger.WriteDebug("We were told to shut down so now we'll send off a vm terminating message and die");
                if (server.ClientCount > 0)
                    SendVmTerminatingMessage(server, arguments.OwnerPort);
            }
            catch (Exception ex)
            {
                if (arguments != null)
                    Logger.Write(ex);
                else
                    Console.WriteLine(ex.ToString());
            }
            finally
            {
                AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
            }
            Logger.WriteDebug("Screw you guys I'm going home!");
        }
Example #4
0
 public ATEClient()
 {
     _syncContext = AsyncOperationManager.SynchronizationContext;
     _host.VMSpawned +=HostVmSpawned;
     _vm.RecievedSystemMessage += VmRecievedSystemMessage;
     _vm.RecievedMessage += VmRecievedMessage;
     _systemCache = new SystemCache();
     _license = new RhinoValidator(Environment.SpecialFolder.LocalApplicationData);
     Analytics.CanSendEventsWhen(() => MMConfiguration.AnonFeedback == true);
 }
Example #5
0
 public ATEngine(TcpServer server, ILocateWriteLocation writeLocator, string watchPath, IValidateLicense license)
 {
     _server       = server;
     _writeLocator = writeLocator;
     _watchPath    = watchPath;
     _license      = license;
     StartedPaused = false;
     IsRunning     = false;
     _isPaused     = StartedPaused;
 }
Example #6
0
 public ATEngine(TcpServer server, ILocateWriteLocation writeLocator, string watchPath, IValidateLicense license)
 {
     _server = server;
     _writeLocator = writeLocator;
     _watchPath = watchPath;
     _license = license;
     StartedPaused = false;
     IsRunning = false;
     _isPaused = StartedPaused;
 }
Example #7
0
 public ATEClient()
 {
     _syncContext               = AsyncOperationManager.SynchronizationContext;
     _host.VMSpawned           += HostVmSpawned;
     _vm.RecievedSystemMessage += VmRecievedSystemMessage;
     _vm.RecievedMessage       += VmRecievedMessage;
     _systemCache               = new SystemCache();
     _license = new RhinoValidator(Environment.SpecialFolder.LocalApplicationData);
     Analytics.CanSendEventsWhen(() => MMConfiguration.AnonFeedback == true);
 }
        // a little bit of reflection in order to be able to add the rules up top
        // and have them be run automatically, without having to worry about adding
        // them to the list of rules to run.  A good example of open/close principle for the class
        // DriverLicenseRules, we don't have to change this class in order to extend it
        // to all of the states
        public List <IValidateLicense> CreateRules()
        {
            var myRules = new List <IValidateLicense>();

            // here we are just adding all of the rules that implement the interface
            foreach (Type t in Assembly.GetCallingAssembly().GetTypes())
            {
                if (t.GetInterface("IValidateLicense") != null)
                {
                    IValidateLicense myRule = Activator.CreateInstance(t) as IValidateLicense;
                    myRules.Add(myRule);
                }
            }
            return(myRules);
        }
Example #9
0
        static void Main(string[] args)
        {
            //args = new string[] { "3456", @"C:\Users\ack\src\Autotest.Net\AutoTest.Net.sln", Guid.NewGuid().ToString(), "debug", "0", "global" };
            LaunchArguments arguments = null;

            try
            {
                arguments = parseArguments(args);
                Logger.SetDebugMode(arguments.Debug);
                Logger.WriteInfo("Starting application");

                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                _feedback = new ServerFeedback();
                _feedback.ClientDisconnected += _feedback_ClientDisconnected;
                _feedback.ClientConnect      += _feedback_ClientConnect;
                server = new TcpServer(_feedback);

                server.MessageReceived += OnRecieve;
                server.StartServer("127.0.0.1", arguments.Port);
                var writeLocator = new DefaultConfigFileLocator(server.Port.ToString(), arguments.IsGlobal);
                initializeConfiguration(writeLocator.GetConfigurationFile());
                if (arguments.IsGlobal)
                {
                    _license = new RhinoValidator(Environment.SpecialFolder.CommonApplicationData);
                }
                else
                {
                    _license = new RhinoValidator(Environment.SpecialFolder.LocalApplicationData);
                }

                _engine = new ATEngine(server, writeLocator, arguments.WatchPath, _license);
                _engine.Start();

                Logger.WriteInfo(string.Format("VM listening on 127.0.0.1:{0}", server.Port));
                startExitTimer();
                SendVmInitializedMessage(arguments.CorrelationId, server, arguments.OwnerPort);
                int clientsConnected = 0;
                while (!_shouldExit)
                {
                    if (clientsConnected == 0 && server.ClientCount > 0)
                    {
                        _engine.ValidateConfiguration();
                    }
                    clientsConnected = server.ClientCount;
                    Thread.Sleep(1000);
                    if (isMasterDead(arguments.MasterProcessId))
                    {
                        shutdown();
                    }
                }
                Logger.WriteDebug("We were told to shut down so now we'll send off a vm terminating message and die");
                if (server.ClientCount > 0)
                {
                    SendVmTerminatingMessage(server, arguments.OwnerPort);
                }
            }
            catch (Exception ex)
            {
                if (arguments != null)
                {
                    Logger.Write(ex);
                }
                else
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            finally
            {
                AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
            }
            Logger.WriteDebug("Screw you guys I'm going home!");
        }