コード例 #1
0
        private void _fileWriteTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            _fileWriteTimer.Stop();

            lock (_fileWriteLock)
            {
                if (_fileWriteBuffer.Count > 0)
                {
                    foreach (string key in _fileWriteBuffer.Keys)
                    {
                        string fileName = Path.Combine(LogFileReader.DataLogPath(key), "CitrixQueueCreation-{0}.csv".FormatWith(key));
                        if (!File.Exists(fileName))
                        {
                            string header = "Session Id, HostName, UserName, Type, Start, End, Duration, Print Driver, Client Queue, Citrix Queue"
                                            + Environment.NewLine;
                            File.WriteAllText(fileName, header);
                        }
                        TraceFactory.Logger.Debug(fileName);
                        File.AppendAllText(fileName, _fileWriteBuffer[key].ToString());
                    }

                    _fileWriteBuffer.Clear();
                }
            }

            _fileWriteTimer.Start();
        }
コード例 #2
0
        private string GetLogData(string sessionId)
        {
            string logFilePath;
            string pattern;

            if (GlobalSettings.IsDistributedSystem)
            {
                logFilePath = @"C:\VirtualResource\Distribution\SessionProxy\Logs";
                pattern     = "SessionProxy-{0}".FormatWith(sessionId);
            }
            else
            {
                logFilePath = LogFileReader.DataLogPath();
                pattern     = "StfWebService.exe.log";
            }

            StringBuilder builder  = new StringBuilder();
            var           logFiles = LogFileDataCollection.Create(logFilePath);

            foreach (var file in logFiles.Items.Where(x => x.FileName.StartsWith(pattern, StringComparison.OrdinalIgnoreCase)))
            {
                builder.AppendLine(file.FileData);
            }

            return(builder.ToString());
        }
コード例 #3
0
        /// <summary>
        /// Gets the dispatcher log data.
        /// </summary>
        /// <returns>
        /// A string buffer containing the current log data
        /// </returns>
        public string GetSessionLogFiles(string sessionId)
        {
            SetTraceSessionContext(sessionId);

            if (string.IsNullOrEmpty(sessionId))
            {
                return("Session does not exist");
            }

            string logFilePath = string.Empty;
            string pattern     = string.Empty;

            if (GlobalSettings.IsDistributedSystem)
            {
                string location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                logFilePath = Path.Combine(Path.GetDirectoryName(location), "SessionProxy", "Logs");
                //the log extension was missing previously
                pattern = "SessionProxy-{0}.log".FormatWith(sessionId);
            }
            else
            {
                logFilePath = LogFileReader.DataLogPath();
                pattern     = "STBConsole.log";
            }
            StringBuilder builder  = new StringBuilder();
            var           logFiles = LogFileDataCollection.Create(logFilePath);

            foreach (var file in logFiles.Items.Where(x => x.FileName.Equals(pattern)))
            {
                builder.AppendLine(file.FileData);
            }

            return(builder.ToString());
        }
コード例 #4
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()));
        }
コード例 #5
0
ファイル: ResourceHost.cs プロジェクト: ProjectAgri20/newrepo
        /// <summary>
        /// Copies the logs.
        /// </summary>
        protected void CopyClientControllerLogs()
        {
            TraceFactory.Logger.Debug("Copying additional files from {0}".FormatWith(Machine.Name));
            LogFileDataCollection logFiles = new LogFileDataCollection();

            try
            {
                using (var clientController = ClientControllerServiceConnection.Create(Machine.Name))
                {
                    logFiles = clientController.Channel.GetLogFiles(Manifest.SessionId);
                }
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error("Unable to capture client controller log files for {0} : {1}"
                                          .FormatWith(Machine.Name, ex.ToString()));
            }

            if (GlobalSettings.IsDistributedSystem)
            {
                try
                {
                    using (var printMonitor = new WcfClient <IPrintMonitorService>(MessageTransferType.Http, WcfService.PrintMonitor.GetHttpUri(Machine.Name)))
                    {
                        logFiles.Append(printMonitor.Channel.GetLogFiles());
                    }
                }
                catch (Exception ex)
                {
                    TraceFactory.Logger.Error("Unable to capture print monitor log files for {0} : {1}"
                                              .FormatWith(Machine.Name, ex.ToString()));
                }
            }

            TraceFactory.Logger.Debug("Done: {0}".FormatWith(Machine.Name));
            MapElement.UpdateStatus("Logs copied");
            //Write to Log Directory
            logFiles.Write(LogFileReader.DataLogPath(Manifest.SessionId));
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: ProjectAgri20/newrepo
        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);
        }
コード例 #7
0
 /// <summary>
 /// Gets the Log Files
 /// </summary>
 /// <returns></returns>
 public LogFileDataCollection GetLogFiles()
 {
     return(LogFileDataCollection.Create(LogFileReader.DataLogPath()));
 }
コード例 #8
0
 /// <summary>
 /// Gets the log files.
 /// </summary>
 /// <param name="sessionId">The session identifier.</param>
 /// <returns>LogFileDataCollection.</returns>
 public LogFileDataCollection GetCitrixLogFiles(string sessionId)
 {
     return(LogFileDataCollection.Create(LogFileReader.DataLogPath(sessionId)));
 }
コード例 #9
0
 /// <summary>
 /// Tells the service to copy any logs that are unique to this resource.
 /// </summary>
 public virtual LogFileDataCollection GetLogFiles(string sessionId)
 {
     return(LogFileDataCollection.Create(LogFileReader.DataLogPath()));
 }