Ejemplo n.º 1
0
        public void Run()
        {
            var JOMedia = QueryNews();

            while (JOMedia != null)
            {
                foreach (var item in JOMedia.item)
                {
                    foreach (var news in item.content.news_item)
                    {
                        var c = _dbContext.DbNewsInfo.Where(a => a.wxMediaID == item.media_id && a.NewsSource == NewsSource.WX_YunYi_GZH).Count();
                        if (c == 0)
                        {
                            ENewsInfo eNews = new ENewsInfo()
                            {
                                NewsSource     = NewsSource.WX_YunYi_GZH,
                                Auther         = news.author,
                                CoverImgUrl    = news.thumb_url,
                                PageUrl        = news.url,
                                Title          = news.title,
                                wxMediaID      = item.media_id,
                                CreateDateTime = DateSrv.ConverTimeStamp(item.content.create_time),
                                UpdateDateTime = DateSrv.ConverTimeStamp(item.content.update_time),
                            };
                            _dbContext.DbNewsInfo.Add(eNews);
                            _SyncCount++;
                        }
                        _dbContext.SaveChanges();
                    }
                }

                this._pageIndex++;
                JOMedia = QueryNews();
            }
        }
Ejemplo n.º 2
0
        public List <RArtComment> QueryArtComment(long artId, string unionIdQuerier, out int totalpage, int pageIndex = 1, int pageSize = 20)
        {
            var sql = from com in _dbContext.DbArtComment
                      join ui in _dbContext.DBUserInfo on com.UnionId equals ui.wx_unionid
                      join up in _dbContext.DbUserPraize.Where(a => a.PraizeTarget == PraizeTarget.Comments && a.UnionId == unionIdQuerier)
                      on com.Id equals up.RefId into quer_up
                      from qup in quer_up.DefaultIfEmpty()
                      where com.ArtId == artId
                      orderby com.CreateDateTime descending, com.Praize descending
                select new RArtComment
            {
                ArtId             = artId,
                CommentName       = ui.Name,
                Content           = com.Content,
                ClientDateTimeStr = DateSrv.DateTimeForClient(com.CreateDateTime),
                CreateDateTime    = com.CreateDateTime,
                HeaderUrl         = ui.wx_headimgurl,
                Praize            = com.Praize,
                RefId             = com.RefId,
                UnionId           = ui.wx_unionid,
                Id         = com.Id,
                HasPriaize = qup != null,
            };
            int c = sql.Count();

            totalpage = (sql.Count() / pageSize) + 1;
            sql       = sql.Skip((pageIndex - 1) * pageSize).Take(pageSize);
            return(sql.ToList());
        }
Ejemplo n.º 3
0
        private void TestTime()
        {
            var date = DateTime.Now;

            Thread.Sleep(2000);
            Console.WriteLine(DateSrv.DateTimeForClient(date));
            Console.Read();
        }
Ejemplo n.º 4
0
        public void UpdateTecCourse(string tecCode, ECourseSchedule courseSchedule, DateTime startDate, bool useRightNow)
        {
            var time = StaticDataSrv.CourseTime[courseSchedule.Lesson];

            int tcNum = _dbContext.DBTecCourse.Where(a => a.TecCode == tecCode && a.LessonCode == courseSchedule.LessonCode).Count();

            if (tcNum == 0)
            {
                ;
                int dayofWeek = DateSrv.GetSysDayOfWeek(startDate);

                if (courseSchedule.Day - dayofWeek >= 0)
                {
                    startDate = startDate.AddDays(courseSchedule.Day - dayofWeek);
                }
                else
                {
                    startDate = startDate.AddDays(7 - (dayofWeek - courseSchedule.Day));
                }

                //如果不立刻启用
                if (!useRightNow)
                {
                    //如果是当天,则跳过
                    if (startDate.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
                    {
                        startDate = startDate.AddDays(7);
                    }
                }



                DateTime endDate = new DateTime(startDate.Year, 12, 31);
                while (startDate <= endDate)
                {
                    dayofWeek = DateSrv.GetSysDayOfWeek(startDate);
                    if (dayofWeek == courseSchedule.Day)
                    {
                        _dbContext.DBTecCourse.Add(new ETecCourse
                        {
                            CourseDateTime = startDate,
                            //CourseScheduleType = courseSchedule.CourseScheduleType,
                            CoursingStatus = TecCoursingStatus.Normal,
                            LessonCode     = courseSchedule.LessonCode,
                            Day            = courseSchedule.Day,
                            CourseName     = courseSchedule.CourseName,
                            TecCode        = tecCode,
                            Lesson         = courseSchedule.Lesson,
                            TimeStart      = time.StartTime,
                            TimeEnd        = time.EndTime,
                        });
                        startDate = startDate.AddDays(7);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        //晚上跑Job修复用户上课
        public void RunJob_FixUserCourse()
        {
            //Job第二天凌晨运行,所以-1;
            var signDate = DateTime.Now.AddDays(-1);
            //     signDate = DateTime.Parse("2019-07-27");

            UserSrv     userSrv     = new UserSrv(_dbContext);
            BusinessSrv businessSrv = new BusinessSrv(_dbContext);

            var day = DateSrv.GetDayOfWeek(signDate);


            var sql = from uc in _dbContext.DBUserCoures
                      join cs in _dbContext.DbCourseSchedule on uc.LessonCode equals cs.LessonCode
                      join ui in _dbContext.DBUserInfo on uc.UserOpenId equals ui.OpenId
                      where cs.Day == day
                      orderby uc.UserOpenId
                      select new FixUserCourse
            {
                UserOpenId = uc.UserOpenId,
                LessonCode = uc.LessonCode,
                MemberType = ui.MemberType,
                UserName   = ui.Name
            };

            var userCourseList = sql.ToList();

            foreach (var uc in userCourseList)
            {
                if (!userSrv.IsSkipTodayUserCourse(uc.UserOpenId))
                {
                    try
                    {
                        uc.CurrentCourseSchedule = userSrv.GetCurrentCourseScheduleType(uc.UserOpenId, uc.MemberType);

                        var log = businessSrv.UpdateCourseLogToSigned(uc.UserOpenId, uc.MemberType,
                                                                      uc.CurrentCourseSchedule,
                                                                      uc.LessonCode,
                                                                      signDate,
                                                                      "",
                                                                      false,
                                                                      false);
                        log.SignName          = "系统签到";
                        log.IsFixedByAuto     = true;
                        log.AutoFixedDatetime = DateTime.Now;
                        NLogHelper.InfoTxt($"修复用户:{uc.UserName}[OpenId]{uc.UserOpenId},课程:{log.LessonCode}");
                        _dbContext.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        NLogHelper.ErrorTxt($"Error OpenId:{uc.UserOpenId};");
                    }
                }
            }
        }