예제 #1
0
        public IActionResult OnPostDelete(long Id)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                var DelObj = _CourseSrv.GetCourseSchedule(Id);
                if (DelObj != null)
                {
                    if (DelObj.ApplyNum > 0)
                    {
                        result.ErrorMsg = "已经有用户报名,不能删除此课程";
                    }
                    else
                    {
                        _CourseSrv.DeleteCourseSchdule(DelObj);
                        _CourseSrv.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }
            return(new JsonResult(result));
        }
예제 #2
0
        public void OnGet()
        {
            string lessonCode = HttpContext.Request.Query["LCode"];

            if (!string.IsNullOrEmpty(lessonCode))
            {
                CourseInfo = _CourseSrv.GetCourseSchedule(lessonCode);
            }
        }
예제 #3
0
        public IActionResult OnPostCourseLeave(List <EUserCourseLog> list)
        {
            ResultNormal result = new ResultNormal();
            var          us     = base.GetUserSession(false);

            try
            {
                if (us != null)
                {
                    _UserSrv.UpdateCourseLogToLeave(list, us.OpenId);


                    //wx通知
                    var time = StaticDataSrv.CourseTime;
                    UserLeaveTemplate wxMessage = new UserLeaveTemplate();
                    foreach (var c in list)
                    {
                        var ui   = _UserSrv.GetUserInfo(us.OpenId);
                        var cs   = _CourseSrv.GetCourseSchedule(c.LessonCode);
                        var desc = $"{cs.CourseName} | [{time[cs.Lesson].TimeRange}]";

                        var tec = _TecSrv.GetOpenIdByLessonCode(c.LessonCode, c.CourseDateTime);

                        if (!string.IsNullOrEmpty(ui.SalesOpenId))
                        {
                            wxMessage.data = wxMessage.GenerateData(ui.SalesOpenId, ui.ChildName, DateTime.Parse(c.CourseDateTime), desc);
                            WXApi.SendTemplateMessage <UserLeaveTemplate>(wxMessage);
                        }
                        if (tec != null)
                        {
                            wxMessage.data = wxMessage.GenerateData(tec.UserOpenId, ui.ChildName, DateTime.Parse(c.CourseDateTime), desc, true);
                            WXApi.SendTemplateMessage <UserLeaveTemplate>(wxMessage);
                        }
                    }
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "请重新登陆!";
                }
            }
            catch (EduException eex)
            {
                result.ErrorMsg = eex.Message;
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "请假失败,请联系工作人员";
                if (us != null)
                {
                    NLogHelper.ErrorTxt($"用户请假OpenId:{us.OpenId}");
                }
                NLogHelper.ErrorTxt($"MyLeaveModel[OnPostCourseLeave]:{ex.Message}");
            }
            return(new JsonResult(result));
        }
예제 #4
0
        public IActionResult OnPostSignForUser(string openId, string lessonCode, MemberType memberType, string date)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                var csType = _UserSrv.GetCurrentCourseScheduleType(openId, memberType);
                var us     = GetUserSession(false);
                if (us != null)
                {
                    DateTime signDate = DateTime.Parse(date);
                    var      log      = _BusinessSrv.UpdateCourseLogToSigned(openId, memberType, csType, lessonCode, signDate, us.OpenId);


                    //wx通知 --Begin
                    var course = _CourseSrv.GetCourseSchedule(log.LessonCode);
                    if (course == null)
                    {
                        result.ErrorMsg = "已签到,但未发送消息通知,请告知管理员!";
                        return(new JsonResult(result));
                    }
                    var userAccount = _UserSrv.GetUserAccount(openId);

                    if (userAccount.ReduceTime == 0)
                    {
                        userAccount.ReduceTime = 2;
                    }
                    var time = StaticDataSrv.CourseTime;

                    UserSignTemplate wxMessage = new UserSignTemplate();
                    wxMessage.data = wxMessage.GenerateData(openId, log.SignName,
                                                            $"{log.CourseDateTime} | {time[course.Lesson].TimeRange}",
                                                            course.CourseName,
                                                            userAccount.ReduceTime,
                                                            userAccount.RemainCourseTime,
                                                            userAccount.RemainSummerTime,
                                                            userAccount.RemainWinterTime);
                    WXApi.SendTemplateMessage <UserSignTemplate>(wxMessage);
                    //wx通知 --End
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "请重新登陆";
                }

                result.SuccessMsg = BaseEnumSrv.GetUserCourseLogStatusNameForTec(UserCourseLogStatus.SignIn);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }
            return(new JsonResult(result));
        }