Ejemplo n.º 1
0
        private void CheckErrorTask(App app, Job jb, Int32 count, List <JobTask> list)
        {
            // 每分钟检查一下错误任务和中断任务
            var nextKey = $"_NextAcquireOld_{jb.ID}";
            var now     = TimerX.Now;
            var ext     = Session as IExtend;
            var next    = (DateTime)(ext[nextKey] ?? DateTime.MinValue);

            if (next < now)
            {
                var ps     = ControllerContext.Current.Parameters;
                var server = ps["server"] + "";
                var pid    = ps["pid"].ToInt();
                var ip     = (Session as INetSession).Remote.Host;

                next = now.AddSeconds(60);
                list.AddRange(jb.AcquireOld(server, ip, pid, count));

                if (list.Count > 0)
                {
                    // 既然有数据,待会还来
                    next = now;

                    var n1 = list.Count(e => e.Status == JobStatus.错误 || e.Status == JobStatus.取消);
                    var n2 = list.Count(e => e.Status == JobStatus.就绪 || e.Status == JobStatus.抽取中 || e.Status == JobStatus.处理中);
                    XTrace.WriteLine("作业[{0}/{1}]准备处理[{2}]个错误和[{3}]超时任务 [{4}]", app, jb.Name, n1, n2, list.Join(",", e => e.ID + ""));
                }
                else
                {
                    ext[nextKey] = next;
                }
            }
        }