Пример #1
0
        public void Execute(IJobExecutionContext context)
        {
            //log.Info("现在异步处理教师在线情况");
            StudyOnlineEntities entities = new StudyOnlineEntities();
            //只刷新安卓端,手机系统,安卓为1,苹果为2,其它为0
            var a = DateTime.Now.AddMinutes(-5);
            //Console.WriteLine(a.ToString("yyyy-MM-dd HH:mm:ss"));
            var teacher = entities.NimUser.Where(o => o.Category == 1 && o.IsOnline == 1 && o.IsEnable == 1 && o.Refresh < a && o.System == 1).ToList();

            foreach (var item in teacher)
            {
                log.Debug("让教师下线:" + item.Username + " 最后刷新时间:" + item.Refresh.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                //Console.WriteLine(item.Username + "  " + item.Refresh.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                item.IsOnline = 0;
                item.IsQueue  = 0;
                item.IsEnable = 0;
            }

            entities.SaveChanges();
            entities.Dispose();
        }
Пример #2
0
        public void Execute(IJobExecutionContext context)
        {
            log.Info("----------now sync calllog----------");
            StudyOnlineEntities entities = new StudyOnlineEntities();

            //过滤条件要求是在当前时间2个小时之前的数据才处理,防止和现在的正在进行的通话冲突处理,因为如果此时正有一个通话,那么他的学生平衡就是不为1的
            DateTime       deadlineTime = DateTime.Now.AddHours(-2);
            List <CallLog> chats        = entities.CallLog.OrderByDescending(o => o.Start).Where(o => o.Start < deadlineTime && o.Finish == null && o.Refresh != null).ToList();

            log.Info("deadlineTime" + deadlineTime.ToString("yyyy-MM-dd HH:mm:ss"));

            foreach (var item in chats)
            {
                //记录下这记录的原始开始时间和结束时间
                log.Info(item.Id + " start:" + item.Start.Value.ToString("yyyy-MM-dd HH:mm:ss") + " refersh:" + item.Refresh.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                item.Finish = item.Refresh;//当结束标记为空的时候,用最后的刷新时间代替
                CallLogController.Balance(item);
            }
            entities.SaveChanges();
            entities.Dispose();
        }