Example #1
0
        /// <summary>
        /// Waits appearance of the first folder in the collection data folder
        /// </summary>
        public static Task WaitStartCollectData(Logcfg logcfg)
        {
            var tcs = new TaskCompletionSource <bool>();

            var logPaths = logcfg.GetLogPaths();

            FileSystemWatcher[] watchers = new FileSystemWatcher[logPaths.Length];

            for (int x = 0; x < logPaths.Length; x++)
            {
                var watcher = new FileSystemWatcher
                {
                    NotifyFilter = NotifyFilters.DirectoryName,
                    Path         = logPaths[x],
                    Filter       = "*"
                };

                watcher.Created += (sender, args) =>
                {
                    watchers.ToList().ForEach(c => c.EnableRaisingEvents = false);
                    tcs.TrySetResult(true);
                    watchers.ToList().ForEach(c => c.Dispose());
                };

                watchers[x] = watcher;
            }

            watchers.ToList().ForEach(c => c.EnableRaisingEvents = true);

            return(tcs.Task);
        }
Example #2
0
        /// <summary>
        /// Returns paths of the log files
        /// </summary>
        /// <param name="logcfg">Logcfg instance</param>
        /// <returns></returns>
        public static string[] GetLogFiles(Logcfg logcfg)
        {
            List <string> files = new List <string>();

            foreach (var path in logcfg.GetLogPaths())
            {
                files.AddRange(Directory.GetFiles(path, "*.log", SearchOption.AllDirectories));
            }

            return(files.Distinct().ToArray());
        }