public void Invoke()
        {
            StatuUpdate(string.Format("正在进行第{0}次自动采集任务。", General.Instance.collectCount));
            General.Instance.rooms = CollectUtility.GetCurrentRooms(Setting.Default.LiveType, Setting.Default.AreaID);
            General.Instance.ups   = General.Instance.GetUpsByRooms(General.Instance.rooms);
            StatuUpdate(string.Format("本次采集已完成5%,数据抓取完成,正在进行采集…"));
            for (int i = 0; i < General.Instance.rooms.Count; i++)
            {
                StatuUpdate(string.Format("本次采集已完成{1}%,正在采集{0}的信息…", General.Instance.ups[i].nickname, 89 * i / General.Instance.rooms.Count + 5));
                DownloadUtility.DownloadUpInfo(General.Instance.ups[i]);
                string sysCoverFilename = Path.Combine(Path.CacheDirectory, Path.GetFileName(General.Instance.rooms[i].system_cover.Split('?')[0]));
                if (!string.IsNullOrEmpty(General.Instance.rooms[i].system_cover))
                {
                    DownloadUtility.DownloadImage(General.Instance.rooms[i].system_cover, sysCoverFilename);
                }
            }

            StatuUpdate(string.Format("所有数据采集完成,正在保存数据…"));
            General.Instance.ups = General.Instance.UpsOnline2Local(General.Instance.ups);
            General.Instance.SaveInfo();
            General.Instance.SaveAllInfos2File();
            StatuUpdate(string.Format("第{0}次自动采集任务完成。", General.Instance.collectCount));

            Accomplish();
        }
        public void Invoke()
        {
            //采集信息
            UIStepDelegate(0);
            UITipTextDelegate("正在抓取数据……");
            UICountTextDelegate(string.Empty);
            General.Instance.rooms.Clear();
            General.Instance.rooms = CollectUtility.GetCurrentRooms(Setting.Default.LiveType, Setting.Default.AreaID);
            UIProgressBarValueSetDelegate(General.Instance.rooms.Count);
            UICountTextDelegate(string.Format("0/{0}", General.Instance.rooms.Count));

            //更新与下载信息
            General.Instance.ups = General.Instance.GetUpsByRooms(General.Instance.rooms);
            for (int i = 0; i < General.Instance.ups.Count; i++)
            {
                UITipTextDelegate(string.Format("采集{0}的信息中…", General.Instance.ups[i].nickname));
                UICountTextDelegate(string.Format("{0}/{1}", i + 1, General.Instance.rooms.Count));
                DownloadUtility.DownloadUpInfo(General.Instance.ups[i]);
                string sysCoverFilename = Path.Combine(Path.CacheDirectory, Path.GetFileName(General.Instance.rooms[i].system_cover.Split('?')[0]));
                if (!string.IsNullOrEmpty(General.Instance.rooms[i].system_cover))
                {
                    DownloadUtility.DownloadImage(General.Instance.rooms[i].system_cover, sysCoverFilename);
                }
                UIStepDelegate(i + 1);
            }

            //保存信息
            UITipTextDelegate("正在保存数据……");
            General.Instance.ups = General.Instance.UpsOnline2Local(General.Instance.ups);
            General.Instance.SaveInfo();
            General.Instance.SaveAllInfos2File();
            UIStepDelegate(100);

            TaskCallBack();
        }
Ejemplo n.º 3
0
        public string CollectInfoManual()
        {
            rooms.Clear();
            rooms = CollectUtility.GetCurrentRooms(Setting.Default.LiveType, Setting.Default.AreaID);
            ups   = GetUpsByRooms(rooms);
            foreach (var up in ups)
            {
                DownloadUtility.DownloadUpInfo(up);
            }

            return(string.Format("[{0}]: 第{1}次手动采集信息成功!共采集到{2}条信息。", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), ++collectCount, rooms.Count));
        }
Ejemplo n.º 4
0
 public void CollectInfoAuto()
 {
     rooms = CollectUtility.GetCurrentRooms(Setting.Default.LiveType, Setting.Default.AreaID);
     if (File.Exists(Path.InfoFile))
     {
         ups = GetUpsByFile();
     }
     else
     {
         ups = GetUpsByRooms(rooms);
         foreach (var up in ups)
         {
             DownloadUtility.DownloadUpInfo(up);
         }
         ups = UpsOnline2Local(ups);
         SaveInfo();
     }
 }