예제 #1
0
        /// <summary>
        /// ログを格納するスレッド
        /// </summary>
        private void StoreLogPoller()
        {
            if (this.logInfoQueue.IsEmpty)
            {
                Thread.Sleep(TimeSpan.FromSeconds(1));
                return;
            }

            var preLog      = new string[3];
            var preLogIndex = 0;
            var ignores     = TimelineSettings.Instance.IgnoreLogTypes.Where(x => x.IsIgnore);

            var logs = new List <LogLineEventArgs>(this.logInfoQueue.Count);

            while (this.logInfoQueue.TryDequeue(out LogLineEventArgs log))
            {
                // 直前とまったく同じ行はカットする
                if (preLog[0] == log.logLine ||
                    preLog[1] == log.logLine ||
                    preLog[2] == log.logLine)
                {
                    continue;
                }

                preLog[preLogIndex++] = log.logLine;
                if (preLogIndex >= 3)
                {
                    preLogIndex = 0;
                }

                // 無効なログ?
                if (ignores.Any(x => log.logLine.Contains(x.Keyword)))
                {
                    continue;
                }

                logs.Add(log);
            }

            foreach (var log in logs)
            {
                // ダメージ系の不要なログか?
                if (LogBuffer.IsDamageLog(log.logLine))
                {
                    continue;
                }

                this.AnalyzeLogLine(log);
                Thread.Yield();
            }
        }
예제 #2
0
        /// <summary>
        /// ログ行をインポートして解析する
        /// </summary>
        /// <param name="file">対象のファイル</param>
        public void ImportLogLinesFromCSV(
            string file)
        {
            if (!File.Exists(file))
            {
                return;
            }

            try
            {
                this.isImporting = true;

                // 冒頭にインポートを示すログを発生させる
                this.AnalyzeLogLine(new XIVLog(DateTime.Now, $"[00:00:00.000] {ConstantKeywords.ImportLog}"));

                // 各種初期化
                this.inCombat = false;
                this.CurrentCombatLogList.Clear();
                this.ActorHPRate.Clear();
                this.partyNames = null;
                this.combatants = null;
                this.no         = 1;

                var preLog      = new string[3];
                var preLogIndex = 0;
                var ignores     = TimelineSettings.Instance.IgnoreLogTypes.Where(x => x.IsIgnore);

                using (var reader = new StreamReader(
                           new FileStream(
                               file,
                               FileMode.Open,
                               FileAccess.Read,
                               FileShare.ReadWrite),
                           new UTF8Encoding(false)))
                    using (var parser = new TextFieldParser(reader)
                    {
                        TextFieldType = FieldType.Delimited,
                        Delimiters = new[] { "," },
                        HasFieldsEnclosedInQuotes = true,
                    })
                    {
                        while (!parser.EndOfData)
                        {
                            Thread.Yield();

                            var fields = default(string[]);

                            try
                            {
                                fields = parser.ReadFields();
                            }
                            catch
                            {
                                continue;
                            }

                            if (fields.Length < 6)
                            {
                                continue;
                            }

                            var detectTime = DateTime.Parse(fields[1]);
                            var log        = fields[4];
                            var zone       = fields[5];

                            // 直前とまったく同じ行はカットする
                            if (preLog[0] == log ||
                                preLog[1] == log ||
                                preLog[2] == log)
                            {
                                continue;
                            }

                            preLog[preLogIndex++] = log;
                            if (preLogIndex >= 3)
                            {
                                preLogIndex = 0;
                            }

                            // 無効なログ?
                            // ログ種別だけのゴミ?, 不要なログキーワード?, TLシンボルあり?, ダメージ系ログ?
                            if (log.Length <= 3 ||
                                ignores.Any(x => log.Contains(x.Keyword)) ||
                                log.Contains(TimelineController.TLSymbol) ||
                                LogBuffer.IsDamageLog(log))
                            {
                                continue;
                            }

                            // エフェクトに付与されるツールチップ文字を除去する
                            log = LogBuffer.RemoveTooltipSynbols(log);

                            // タイムスタンプを付与し直す
                            log = $"[{detectTime.ToString("HH:mm:ss.fff")}] {log}";

                            this.AnalyzeLogLine(new XIVLog(detectTime, log));
                        }
                    }

                var startCombat = this.CurrentCombatLogList.FirstOrDefault(x => x.Raw.Contains(ConstantKeywords.CombatStartNow));
                if (startCombat != null)
                {
                    this.SetOrigin(this.CurrentCombatLogList, startCombat);
                }
            }
            finally
            {
                this.isImporting = false;
            }
        }