Exemple #1
0
        /// <summary>
        /// 检查是否有没做完的任务
        /// </summary>
        public static void CheckUnDone()
        {
            AlbumManager          xm_AlbumClawManager      = new AlbumManager();
            AlbumWorkManager      xm_AlbumClawWorkManager  = new AlbumWorkManager();
            WorkWrongAgainManager xm_WorkWrongAgainManager = new WorkWrongAgainManager();

            XM_SQlExecute sqlExecute = new XM_SQlExecute();

            SpiderTimeInfo.SpiderTimeId = sqlExecute.Check_XM_IsFinished();
            if (ModelArgs.ISCheckContinue && SpiderTimeInfo.SpiderTimeId > 1)
            {
                Console.WriteLine("检查到有未完成的任务,将继续上一次运行");
                //得到哪一年,运行到了一月

                //得到 frompage 和 YearMonth //然后调用...
                int startPage = 0;
                int yearMonth = 0;
                sqlExecute.GetUnDoneBySpiderId(SpiderTimeInfo.SpiderTimeId, ref startPage, ref yearMonth);

                if (startPage > 0 && yearMonth > 0)
                {
                    xm_AlbumClawWorkManager.ClawWorkOneMonth(yearMonth, startPage);
                }
            }
            else
            {
                SpiderTimeInfo.SpiderTimeId = sqlExecute.Insert_XM_SpiderTime_A_AlbumStartArgs();
            }

            Console.WriteLine("开启 剩下的任务");
            //开启 剩下的任务
            xm_AlbumClawManager.XM_AlbumClawAction();

            // SpiderTimeInfo.SpiderTimeId = 1;
            //运行中间过程中出错的
            Console.WriteLine("重新抓取中间被屏蔽的专辑连接");
            //剩下的也要开多线程

            xm_WorkWrongAgainManager.WorkWrongAgainAction();

            //  xm_AlbumClawWorkManager.WorkWrongAgain();
        }
Exemple #2
0
        public void XM_AlbumClawAction()
        {
            //为多线程准备数据

            AllTaskCount = ModelArgs.AllTaskCount - ModelArgs.HavingCompleted;

            YearMothStart = ModelArgs.StartYearMonth + ModelArgs.HavingCompleted;

            //开始插入数据,然后开始运行

            if (SpiderTimeInfo.SpiderTimeId > 0)
            {
                int i = 0;
                AlbumWorkManager albumClawWorkManager = new AlbumWorkManager();
                int yrarmonth = YearMothStart;
                while (yrarmonth <= ModelArgs.EndYearMonth)
                {
                    Console.WriteLine("TaskCount:{0}  Finish:{1}", ModelArgs.EndYearMonth - yrarmonth, i);
                    yrarmonth = YearMothStart + i;

                    try
                    {
                        //抓取一个月份的gedan数据
                        albumClawWorkManager.ClawWorkOneMonth(yrarmonth);
                    }
                    catch (Exception ex)
                    {
                        LogNet.LogBLL.Error("ClawWorkOneMonth", ex);
                    }
                    i++;
                }
            }
            else
            {
                LogNet.LogBLL.Info("XM_AlbumClawAction,获取SpiderTimeId出错");
                Console.WriteLine("XM_AlbumClawAction,获取SpiderTimeId出错");
            }
        }
        public void WorkWrongAgainAction(object objArgs)
        {
            //工作处理单个月份
            WorkWrongAgainArgs workWrongAgainArgs = objArgs as WorkWrongAgainArgs;    //数包装器
            HttpWrongInfo      httpWrongInfo      = workWrongAgainArgs.HttpWrongInfo; //参数分解
            ThreadCounter      treadCounter       = workWrongAgainArgs.ThreadCounter; //参数分解

            try
            {
                AlbumWorkManager albumClawWorkManager = new AlbumWorkManager();
                albumClawWorkManager.GetOneAlbumAllSong(httpWrongInfo.AlbumUrl);
                sqlExecute.Update_XM_HttpWrongByWrongId(httpWrongInfo);

                threadCounter.writerCounter("fcAdd"); //完成 计数
                threadCounter.writerCounter("tcSub"); //释放线程数
            }
            catch (Exception ex)
            {
                threadCounter.writerCounter("tcSub"); //释放线程数
                threadCounter.writerCounter("ecAdd"); //错误  计数
                LogNet.LogBLL.Info("XM_AlbumClawWorkAction", ex);
                return;
            }
        }