Exemple #1
0
 /// <summary>
 /// 部分別PV取得
 /// </summary>
 /// <param name="title"></param>
 /// <param name="daily"></param>
 public void AnalyzePartPv(DB.Title title, DB.DailyScore daily)
 {
     AnalyzingLockContext(() =>
     {
         if ((daily == null) || (daily.PageView == 0) || (daily.Series == 1))
         {
             return;                                                                    //見るまでもないやつ(PV=0または1話しかない)
         }
         if (daily.PartPvChecked)
         {
             return;                         //取得済みならもうしない
         }
         var waitFor  = LastKasasagiDate.AddSeconds(KasasagiIntervalSec);
         var waitMsec = (waitFor - DateTime.Now).TotalMilliseconds;
         if (waitMsec > 0)
         {
             DebugReport.Log(this, $"kasasagi wait {waitMsec}");
             System.Threading.Thread.Sleep((int)waitMsec);
         }
         var narou       = new NarouAPI();
         var useKasasagi = narou.GetPartPvData(title, daily);
         if (useKasasagi)
         {
             LastKasasagiDate = DateTime.Now;
         }
     });
 }
Exemple #2
0
        /// <summary>
        /// 基本情報更新
        /// </summary>
        /// <param name="id">ユーザーID</param>
        public void UpdateUserData(string id, bool updatePv)
        {
            AnalyzingLockContext(() =>
            {
                //カレントと違うものなら、一度消してロードする。
                if ((authorInfo == null) || (authorInfo.ID != id))
                {
                    authorInfo = null;
                    Load(id);
                }

                //解析API準備
                var narou = new NarouAPI();
                var info  = narou.GetAuthorInfo(id);

                //PVデータ初回参照
                if (authorInfo == null)
                {
                    authorInfo = info;
                    authorInfo.Normalize();

                    if (updatePv)
                    {
                        GetPVData(true);
                    }
                }
                //当月度&先月度分PVデータ参照
                else
                {
                    //マージ
                    authorInfo.Merge(info);

                    if (updatePv)
                    {
                        //今月
                        var dt = DateTime.Now;
                        GetPVData(dt.Year, dt.Month, false);

                        //今日が1,2,3日であれば先月も見る(ユニークが反映されてないかもなので)
                        if (dt.Day <= 3)
                        {
                            //先月
                            dt = dt.AddMonths(-1);
                            GetPVData(dt.Year, dt.Month, false);
                        }
                    }
                }

                //著者名解決
                authorInfo.ResolveAuthorName();
                authorInfo.CheckedDate = DateTime.Now;
            });
        }
Exemple #3
0
 /// <summary>
 /// PVデータ取り込み(タイトル・月指定)
 /// </summary>
 /// <param name="title"></param>
 /// <param name="year"></param>
 /// <param name="month"></param>
 public void GetPVData(DB.Title title, int year, int month, bool useCache)
 {
     AnalyzingLockContext(() =>
     {
         var waitFor  = LastKasasagiDate.AddSeconds(KasasagiIntervalSec);
         var waitMsec = (waitFor - DateTime.Now).TotalMilliseconds;
         if (waitMsec > 0)
         {
             DebugReport.Log(this, $"kasasagi wait {waitMsec}");
             System.Threading.Thread.Sleep((int)waitMsec);
         }
         var narou       = new NarouAPI();
         var useKasasagi = narou.UpdatePVData(title, year, month, useCache);
         if (useKasasagi)
         {
             LastKasasagiDate = DateTime.Now;
         }
     });
 }