Esempio n. 1
0
        static void Main(string[] args)
        {
            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
            TraceFactory.SetThreadContextProperty("ProcessId", Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture));

            string controllerHost = string.Empty;
            string instanceId     = string.Empty;

            if (args.Length == 0)
            {
                // This is for handling Citrix Worker
                Thread.CurrentThread.SetName("Main");

                string datFile = @"C:\VirtualResource\UserConfiguration\{0}.dat".FormatWith(Environment.UserName);

                if (File.Exists(datFile))
                {
                    var items = File.ReadAllText(datFile).Split(',');
                    controllerHost = items[0];
                    instanceId     = items[1];
                    TraceFactory.SetThreadContextProperty("InstanceId", instanceId);
                }
                else
                {
                    throw new ArgumentOutOfRangeException("Local data file does not exist for user {0}".FormatWith(instanceId));
                }
            }
            else if (args.Length == 2)
            {
                // This is for handling the Office Worker and Admin Worker
                Thread.CurrentThread.SetName("Main");

                controllerHost = args[0];
                instanceId     = args[1];
                TraceFactory.SetThreadContextProperty("InstanceId", instanceId);
            }
            else
            {
                throw new ArgumentOutOfRangeException("Invalid arguments : {0}".FormatWith(string.Join(", ", args)));
            }

            TraceFactory.Logger.Debug("Host: {0}, InstanceId: {1}".FormatWith(controllerHost, instanceId));

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new WorkerExecutionForm(controllerHost, instanceId, LogFileReader.DataLogPath()));
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
            TraceFactory.SetThreadContextProperty("ProcessId", Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture));

            string instanceId = string.Empty;
            string sessionId  = string.Empty;

            if (args.Length == 2)
            {
                instanceId = args[0];
                sessionId  = args[1];

                TraceFactory.SetThreadContextProperty("InstanceId", instanceId);
                TraceFactory.SetThreadContextProperty("SessionId", sessionId);

                GlobalSettings.IsDistributedSystem = false;

                Thread.CurrentThread.SetName("Main");
                TraceFactory.Logger.Debug("Username set to {0}".FormatWith(instanceId));
            }
            else
            {
                throw new ArgumentOutOfRangeException("Invalid arguments : {0}".FormatWith(string.Join(", ", args)));
            }

            TraceFactory.Logger.Debug("User: {0}".FormatWith(instanceId));
            TraceFactory.Logger.Debug("Starting...");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            WorkerExecutionForm mainForm = new WorkerExecutionForm("localhost", instanceId, LogFileReader.DataLogPath(sessionId));

            mainForm.WindowState = FormWindowState.Minimized;
            Application.Run(mainForm);
        }