/// <summary>
        /// ログファイルからログを取得する
        /// </summary>
        /// <param name="logfile"></param>
        /// <returns></returns>
        public static FFXIVLog[] GetLogsFromFile(string logfile)
        {
            byte[]       buffer = File.ReadAllBytes(logfile);
            MemoryStream ms     = new MemoryStream(buffer);

            BinaryReader br = new BinaryReader(ms);

            int lastCount    = br.ReadInt32();
            int currentCount = br.ReadInt32();
            int length       = currentCount - lastCount;

            FFXIVLog[] logs = new FFXIVLog[length];

            int[] array = new int[length];

            for (int i = 0; i < length; i++)
            {
                array[i] = br.ReadInt32();
            }

            int lastptr = 0;

            int j = 0;

            foreach (int ptr in array)
            {
                byte[] data = br.ReadBytes(ptr - lastptr);
                logs[j++] = FFXIVLog.ParseSingleLog(data);
                lastptr   = ptr;
            }

            return(logs);
        }
Beispiel #2
0
        /// <summary>
        /// ログを反復して読み込みます
        /// </summary>
        private void ReadThread()
        {
            while (Enable)
            {
                try
                {
                    if (ffxivLogMemoryInfo == null)
                    {//ログ位置のサーチから
                        ffxivLogMemoryInfo = FFXIVLogMemoryInfo.Create();
                        continue;
                    }
                    byte[][]   newlogsdata = ffxivLogMemoryInfo.GetNewLogsData();
                    FFXIVLog[] newLogs     = new FFXIVLog[newlogsdata.Length];
                    for (int i = 0; i < newLogs.Length; i++)
                    {
                        newLogs[i] = FFXIVLog.ParseSingleLog(newlogsdata[i]);
                    }

                    LogEventArgs e = new LogEventArgs();
                    e.IsSuccess   = true;
                    e.LogCount    = newLogs.Length;
                    e.NewLogsData = newlogsdata;
                    e.NewLogs     = newLogs;
                    if (LogEvent != null)
                    {
                        LogEvent(this, e);
                    }
                    System.Threading.Thread.Sleep((int)(LogReadIntervalSec * 1000));
                }
                catch
                {
                    LogEventArgs e = new LogEventArgs();
                    e.IsSuccess = false;
                    if (LogEvent != null)
                    {
                        LogEvent(this, e);
                    }
                    System.Threading.Thread.Sleep((int)(RetryIntervalSec * 1000));
                }
            }
        }