/// <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));
                }
            }
        }
예제 #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));
                }
            }
        }
        /// <summary>
        /// サーチする
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchLogInfoBGWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            while (logmemoryInfo == null && !SearchLogInfoBGWorker.CancellationPending)
            {
                logmemoryInfo = FFXIVLogMemoryInfo.Create();
                if (logmemoryInfo == null)
                {
                    SetStatus(String.Format("ffxiv.exeの起動を確認します。"));
                    SetProgress(0, false);
                    for (int i = 10; i >= 0 && !SearchLogInfoBGWorker.CancellationPending; i--)
                    {
                        System.Threading.Thread.Sleep(1000);//10秒停止
                        SetStatus(String.Format("ffxiv.exe 起動再確認まで...{0}", i));
                    }
                    continue;
                }
                SetStatus("キャラクターのログインを確認しています・・・");
                SetProgress(0, false);
                bool success = false;
                System.Threading.ThreadStart action = () =>
                {
                    success = logmemoryInfo.SearchLogMemoryInfo();
                };
                System.Threading.Thread th = new System.Threading.Thread(action);
                th.Start();
                while (th.IsAlive)
                {
                    if (SearchLogInfoBGWorker.CancellationPending)
                    {//キャンセルされた
                        SetStatus("停止中");
                        logmemoryInfo.CancelSearching();
                        th.Join();
                        logmemoryInfo = null;
                        SetProgress(0, false);
                        return;
                    }
                    SetProgress(logmemoryInfo.Progress, true);
                    System.Threading.Thread.Sleep(100);
                }

                SetProgress(0, false);
                //ログのサーチに成功したか
                if (!success)
                {
                    logmemoryInfo = null;
                    for (int i = 10; i >= 0 && !SearchLogInfoBGWorker.CancellationPending; i--)
                    {
                        System.Threading.Thread.Sleep(1000);//10秒停止
                        SetStatus(String.Format("キャラクターのログイン再確認まで...{0}", i));
                    }
                }
                else
                {
                    InitializeData();
                }
            }
        }
 private void LogReadIntervalTimer_Tick(object sender, EventArgs e)
 {
     LogReadIntervalTimer.Stop();
     try
     {
         foreach (byte[] logdata in logmemoryInfo.GetNewLogsData())
         {
             FFXIVLog log = FFXIVLog.ParseSingleLog(logdata);
             rankingForm.AddLog(log);
             //actionreport
             FFXIVLogDataSet.AnaylzedRow arow = actionReport.Add(log);
             CheckReset(arow);
         }
         if (LogCount < actionReport.ds.Anaylzed.Count - 100)
         {
             LogCount = actionReport.ds.Anaylzed.Count;
             if (AutoSaveCheckBox.Checked)
             {
                 SaveLog();
             }
         }
         SetLogCount();
         LogReadIntervalTimer.Start();
     }
     catch(Exception _e)
     {              
         logmemoryInfo = null;
         SearchLogInfoBGWorker.RunWorkerAsync();
     }
 }