Esempio n. 1
0
        private static void SetLoggingContext()
        {
            var manifest = GlobalDataStore.Manifest;

            if (manifest != null)
            {
                TraceFactory.SetThreadContextProperty("Dispatcher", manifest.Dispatcher, false);
                TraceFactory.SetSessionContext(manifest.SessionId);
            }
        }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            UnhandledExceptionHandler.Attach();
            AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;

            Thread.CurrentThread.SetName("Main");

            VirtualClientController clientController = null;

            try
            {
                TraceFactory.Logger.Debug("Args: {0}".FormatWith(string.Join(" ", args)));
                int    startIndex = 0;
                string sessionId  = string.Empty;
                switch (args.Length)
                {
                case 2:
                    sessionId = args[1];
                    break;

                case 3:
                    sessionId  = args[1];
                    startIndex = int.Parse(args[2], CultureInfo.InvariantCulture);
                    break;

                default:
                    TraceFactory.Logger.Fatal("Invalid number of arguments.  Arguments passed in: {0}".FormatWith(args.Length));
                    TraceFactory.Logger.Fatal("Usage: {0} <Dispatcher Fully Qualified Domain Name> <Session Id> <Start Index for Software Installer>".FormatWith(AppDomain.CurrentDomain.FriendlyName));
                    Environment.Exit(1);
                    break;
                }

                // Set the logging context
                var dispatcher = args[0].Split('.')[0];
                TraceFactory.SetSessionContext(sessionId);
                TraceFactory.SetThreadContextProperty("Dispatcher", dispatcher, false);
                using (var officeWorkerStream =
                           File.Create(Path.Combine(Environment.CurrentDirectory, "OfficeWorkerBootStrapper.exe")))
                {
                    officeWorkerStream.Write(Properties.Resources.OfficeWorkerBootStrapper, 0,
                                             Properties.Resources.OfficeWorkerBootStrapper.Length);
                    officeWorkerStream.Flush(true);
                }


                clientController = new VirtualClientController(dispatcher, startIndex);
                clientController.Start(sessionId);
                TraceFactory.Logger.Debug("Client controller started.  Press Enter to terminate.");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error(ex);
            }
        }
Esempio n. 3
0
        private void SetSessionContext(SessionMapElement element)
        {
            string sessionId = null;
            string elementId = null;

            if (element != null)
            {
                sessionId = element.SessionId;
                elementId = element.Id.ToString();
            }
            TraceFactory.SetSessionContext(sessionId);
            TraceFactory.SetThreadContextProperty("SessionMapElementId", elementId, false);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var database = args[0];
            _sessionId = args[1];
            var proxyServiceUri = new Uri(args[2]);

            TraceFactory.SetThreadContextProperty("PID", Process.GetCurrentProcess().Id.ToString());
            TraceFactory.SetSessionContext(_sessionId);
            TraceFactory.Logger.Debug(string.Join(", ", args));

            UnhandledExceptionHandler.Attach();

            GlobalSettings.Load(database);
            FrameworkServicesInitializer.InitializeExecution();

            try
            {
                using (var sessionProxy = new SessionProxy(_sessionId))
                {
                    sessionProxy.OnExit += _sessionProxy_OnExit;
                    sessionProxy.StartFrontendService(proxyServiceUri);
                    sessionProxy.StartBackendService();

                    TraceFactory.Logger.Debug("Notify Dispatcher process is up...");
                    Retry.WhileThrowing
                        (
                            () =>
                            {
                                using (var connection = SessionDispatcherConnection.Create("localhost"))
                                {
                                    connection.Channel.NotifyProxyStarted(_sessionId);
                                }
                            },
                            10,
                            TimeSpan.FromSeconds(2),
                            new List<Type>() { typeof(EndpointNotFoundException) }
                        );
                    TraceFactory.Logger.Debug("Notify Dispatcher process is up...Done");

                    _mainThreadBlock.WaitOne();
                }
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error(ex);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Sets the session context for tracing
 /// </summary>
 /// <param name="sessionId">The session id.</param>
 private void SetTraceSessionContext(string sessionId)
 {
     TraceFactory.SetSessionContext(sessionId);
 }