/// <summary>
        /// 校验转出课次
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-03-14</para>
        /// </summary>
        /// <param name="outLessons">转出课次信息</param>
        /// <exception cref="BussinessException">
        /// 异常ID:60->未找到课次信息
        /// 异常ID:65->课程已正常考勤,不能再进行调课
        /// 异常ID:66->课程已被调整,不能再进行调课
        /// </exception>
        private void VerifyOutLesson(List <ViewCompleteStudentAttendance> outLessons)
        {
            if (!outLessons.Any())
            {
                //未找到课次信息
                throw new BussinessException(ModelType.Timetable, 60);
            }

            foreach (var item in outLessons)
            {
                AttendStatus status = (AttendStatus)item.AttendStatus;
                AdjustType   type   = (AdjustType)item.AdjustType;
                if (status == AttendStatus.Normal)
                {
                    //课程已正常考勤,不能再进行调课
                    throw new BussinessException(ModelType.Timetable, 65);
                }

                if (type != AdjustType.DEFAULT)
                {
                    //课程已被调整,不能再进行调课
                    throw new BussinessException(ModelType.Timetable, 66);
                }
            }
        }
        /// <summary>
        /// 更新学生考勤课次表考勤数据
        /// <para>作    者:郭伟佳</para>
        /// <para>创建时间:2019-03-13</para>
        /// </summary>
        /// <param name="LessonStudentIds">学生课次Id集合</param>
        /// <param name="lessonStudentList"> 学生课次课程考勤信息</param>
        /// <returns></returns>
        private async Task UpdateAttendStatus(List <long> LessonStudentIds, List <TblTimLessonStudent> lessonStudentList)
        {
            AttendStatus newAttendStatus = AttendStatus.Normal;
            AttendStatus oldAttendStatus = (AttendStatus)lessonStudentList.FirstOrDefault().AttendStatus;
            DateTime?    attendTime      = DateTime.Now;

            switch (oldAttendStatus)
            {
            case AttendStatus.Normal:
                newAttendStatus = AttendStatus.NotClockIn;
                attendTime      = null;
                break;

            case AttendStatus.NotClockIn:
            case AttendStatus.Leave:
                newAttendStatus = AttendStatus.Normal;
                attendTime      = DateTime.Now;
                break;
            }
            if (!await _lessonStudentRepository.Value.UpdateAttendStatusAsync(LessonStudentIds, newAttendStatus, oldAttendStatus,
                                                                              attendTime, attendUserType: AttendUserType.FINANCE))
            {
                throw new BussinessException(ModelType.Timetable, 56);
            }
        }
        public int AddEventToWatchList(Event event_to_add, AttendStatus status)
        {
            Response rsp = Util.Post ("watchlist.add", new UpcomingParam ("token", Token.TokenString),
                new UpcomingParam ("event_id", event_to_add.ID),
                new UpcomingParam ("status", status.ToString ().ToLower ())
                );

            return rsp.Watches[0].ID;
        }
 /// <summary>
 /// 补签学生考勤
 /// <para>作    者:zhiwei.Tang</para>
 /// <para>创建时间:2019-03-12</para>
 /// </summary>
 /// <param name="lessonStudentId">学生考勤ID集合</param>
 /// <param name="adjustType">调整状态</param>
 /// <param name="oldAttendStatus">旧考勤状态</param>
 /// <param name="time">考勤时间</param>
 /// <param name="replenishCode">补签码</param>
 public void UpdateStuAttend(
     IEnumerable <long> lessonStudentId, AdjustType adjustType,
     AttendStatus oldAttendStatus, DateTime time, string replenishCode)
 {
     base.Update(
         x => lessonStudentId.Contains(x.ReplenishLessonId) && x.AttendStatus == (int)oldAttendStatus,
         m => new TblTimReplenishLesson {
         AdjustType = (int)adjustType, AttendDate = time, ReplenishCode = replenishCode, UpdateTime = DateTime.Now
     });
 }
        public static bool ContainsStatusMail(IEnumerable<ScheduledEmailBlock> emails, AttendStatus status)
        {
            foreach (var scheduledEmailBlock in emails)
            {
                if (scheduledEmailBlock.EmailSendOptions == SendOptions.Action &&
                    scheduledEmailBlock.SendOnStatus == status)
                    return true;
            }
            return false;

        }
示例#6
0
        public bool SendStatusMail(IParticipant participant)
        {
            AttendStatus  status       = AttendStatus.Undefined;
            EventPageBase CurrentEvent = EPiServer.DataFactory.Instance.Get <EventPageBase>(participant.EventPage);

            Enum.TryParse <AttendStatus>(participant.AttendStatus, out status);
            foreach (ScheduledEmailBlock scheduledEmailBlock in AttendScheduledEmailEngine.GetScheduledEmails(CurrentEvent.ContentLink, SendOptions.Action, status))
            {
                AttendScheduledEmailEngine.SendScheduledEmail(scheduledEmailBlock, participant);
            }
            return(true);
        }
 /// <summary>
 /// 更新学生补课/调课的考勤状态
 /// <para>作    者:郭伟佳</para>
 /// <para>创建时间:2019-03-16</para>
 /// </summary>
 /// <param name="lessonIdList">学生考勤ID集合</param>
 /// <param name="newAttendStatus">新考勤状态</param>
 /// <param name="oldAttendStatus">旧考勤状态</param>
 /// <param name="oldAdjustType">旧补课/调课状态</param>
 /// <param name="attendUserType">签到人员类型</param>
 public bool UpdateAttendStatus(IEnumerable <long> lessonIdList,
                                AttendStatus newAttendStatus,
                                AttendStatus oldAttendStatus,
                                AdjustType oldAdjustType      = AdjustType.DEFAULT,
                                AttendUserType attendUserType = AttendUserType.DEFAULT)
 {
     return(base.Update(x => lessonIdList.Contains(x.LessonId) && x.AttendStatus == (int)oldAttendStatus && x.AdjustType == (int)oldAdjustType,
                        m => new TblTimReplenishLesson()
     {
         AttendStatus = (int)newAttendStatus,
         AttendUserType = (int)attendUserType,
         UpdateTime = DateTime.Now
     }));
 }
示例#8
0
 /// <summary>
 /// 更新学生课程的考勤状态(异步)
 /// <para>作    者:郭伟佳</para>
 /// <para>创建时间:2019-03-13</para>
 /// </summary>
 /// <param name="lessonStudentId">学生考勤ID集合</param>
 /// <param name="newAttendStatus">新考勤状态</param>
 /// <param name="oldAttendStatus">旧考勤状态</param>
 /// <param name="attendTime">考勤时间</param>
 /// <param name="oldAdjustType">旧补课/调课状态</param>
 /// <param name="attendUserType">签到人员类型</param>
 public async Task <bool> UpdateAttendStatusAsync(IEnumerable <long> lessonStudentId,
                                                  AttendStatus newAttendStatus,
                                                  AttendStatus oldAttendStatus,
                                                  DateTime?attendTime,
                                                  AdjustType oldAdjustType      = AdjustType.DEFAULT,
                                                  AttendUserType attendUserType = AttendUserType.DEFAULT)
 {
     return(await base.UpdateTask(x => lessonStudentId.Contains(x.LessonStudentId) && x.AttendStatus == (int)oldAttendStatus && x.AdjustType == (int)oldAdjustType,
                                  x => new TblTimLessonStudent()
     {
         AttendStatus = (int)newAttendStatus,
         AttendUserType = (int)attendUserType,
         AttendDate = attendTime,
         UpdateTime = attendTime
     }));
 }
 /// <summary>
 /// 更新学生补课/调课的考勤状态
 /// <para>作    者:zhiwei.Tang</para>
 /// <para>创建时间:2019-03-07</para>
 /// </summary>
 /// <param name="lessonStudentId">学生考勤ID集合</param>
 /// <param name="newAttendStatus">新考勤状态</param>
 /// <param name="oldAttendStatus">旧考勤状态</param>
 /// <param name="oldAdjustType">旧补课/调课状态</param>
 /// <param name="time">考勤时间</param>
 /// <param name="attendUserType">签到人员类型</param>
 public bool UpdateAttendStatus(IEnumerable <long> lessonStudentId,
                                AttendStatus newAttendStatus,
                                AttendStatus oldAttendStatus,
                                AdjustType oldAdjustType,
                                DateTime time,
                                AttendUserType attendUserType = AttendUserType.DEFAULT)
 {
     return(base.Update(x => lessonStudentId.Contains(x.ReplenishLessonId) && x.AttendStatus == (int)oldAttendStatus && x.AdjustType == (int)oldAdjustType,
                        m => new TblTimReplenishLesson()
     {
         AttendStatus = (int)newAttendStatus,
         AttendUserType = (int)attendUserType,
         AttendDate = time,
         UpdateTime = time
     }));
 }
示例#10
0
        /// <summary>
        /// 更新学生课程的考勤状态
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-03-07</para>
        /// </summary>
        /// <param name="lessonStudentId">学生考勤ID集合</param>
        /// <param name="newAttendStatus">新考勤状态</param>
        /// <param name="oldAttendStatus">旧考勤状态</param>
        /// <param name="oldAdjustType">旧补课/调课状态</param>
        /// <param name="attendTime">考勤时间</param>
        /// <param name="attendUserType">签到人员类型</param>
        public bool UpdateAttendStatus(IEnumerable <long> lessonStudentId,
                                       AttendStatus newAttendStatus, AttendStatus oldAttendStatus,
                                       AdjustType oldAdjustType, DateTime attendTime, AttendUserType attendUserType)
        {
            Expression <Func <TblTimLessonStudent, bool> > sourceLambda =
                x => lessonStudentId.Contains(x.LessonStudentId) &&
                x.AttendStatus == (int)oldAttendStatus &&
                x.AdjustType == (int)oldAdjustType;

            Expression <Func <TblTimLessonStudent, TblTimLessonStudent> > whereLambda =
                x => new TblTimLessonStudent()
            {
                AttendStatus   = (int)newAttendStatus,
                AttendUserType = (int)attendUserType,
                UpdateTime     = DateTime.Now,
                AttendDate     = attendTime
            };

            return(base.Update(sourceLambda, whereLambda));
        }
        public static void CreateScheduledEmail(EventPageBase EventPageBase, AttendStatus status, EmailTemplateBlock emailTemplate, ContentReference emailTemplateContentReference, string name)
        {
            ScheduledEmailBlock emailBlock =
                API.AttendScheduledEmailEngine.GenerateScheduledEmailBlock(EventPageBase.ContentLink).CreateWritableClone() as ScheduledEmailBlock;

            emailBlock.EmailSendOptions           = SendOptions.Action;
            emailBlock.SendOnStatus               = status;
            emailBlock.EmailTemplate.BCC          = emailTemplate.BCC;
            emailBlock.EmailTemplate.CC           = emailTemplate.CC;
            emailBlock.EmailTemplate.From         = emailTemplate.From;
            emailBlock.EmailTemplate.To           = emailTemplate.To;
            emailBlock.EmailTemplate.Subject      = emailTemplate.Subject;
            emailBlock.EmailTemplate.MainBody     = emailTemplate.MainBody;
            emailBlock.EmailTemplate.MainTextBody = emailTemplate.MainTextBody;

            emailBlock.EmailTemplateContentReference = emailTemplateContentReference;

            (emailBlock as IContent).Name = name;

            DataFactory.Instance.Save(emailBlock as IContent, SaveAction.Publish);
        }
 public static IEnumerable<IParticipant> GetParticipants(ContentReference EventPageBase, AttendStatus status)
 {
     return (from p in GetParticipants(EventPageBase) where p.AttendStatus == status.ToString() select p);
 }
示例#13
0
 public static string Get(AttendStatus status)
 {
     return(Get(status.ToString()));
 }
 public static bool ContainsStatusMail(IEnumerable <ScheduledEmailBlock> emails, AttendStatus status)
 {
     foreach (var scheduledEmailBlock in emails)
     {
         if (scheduledEmailBlock.EmailSendOptions == SendOptions.Action &&
             scheduledEmailBlock.SendOnStatus == status)
         {
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// 获取上课学生列表
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-03-11</para>
        /// </summary>
        /// <param name="stuLessonList">学生课次信息</param>
        /// <returns>学生列表</returns>
        private List <ClassStudent> GetClassStudentList(IEnumerable <StudentLesson> stuLessonList)
        {
            List <ClassStudent> res = new List <ClassStudent>();

            //2.筛选学生ID
            var stuIdList = stuLessonList.Select(x => x.StudentId).Distinct().ToList();

            //3.获取学生信息
            var studentList = StudentService.GetStudentByIds(stuIdList)
                              .Result
                              .OrderBy(x => x.StudentName)
                              .ToList();

            // 0=未考勤
            // 1=正常签到 显示考勤时间
            // 2=补签未确认(缺勤) 显示撤回补签
            // 3=补签已确认 显示考勤时间
            // 4=请假(当前时间之前) 判断AdjustStatus是否已安排补课
            // 5=缺勤 判断AdjustStatus是否已安排补课
            // 6=请假(当前时间之后) 无需判断AdjustStatus是否已安排补课 显示 --
            // 7=补签未确认(请假) 显示撤回补签

            //4.生成考勤状态
            foreach (var stu in studentList)
            {
                var stuLesson = stuLessonList.FirstOrDefault(x => x.StudentId == stu.StudentId);
                if (stuLesson == null)
                {
                    continue;
                }

                ClassStudent student = new ClassStudent
                {
                    StudentId    = stu.StudentId,
                    StudentName  = stu.StudentName,
                    LessonId     = stuLesson.LessonId,
                    AttendStatus = 0,
                    AdjustStatus = false
                };

                AdjustType   stuAdjustType   = (AdjustType)stuLesson.AdjustType;
                AttendStatus stuAttendStatus = (AttendStatus)stuLesson.AttendStatus;

                //上课结束时间+缓冲时间
                DateTime eTime;
                if (stuLesson.LessonType == (int)LessonType.RegularCourse)
                {
                    //上课结束时间+缓冲时间
                    eTime = DateTime.Parse(stuLesson.ClassDate.ToString("yyyy-MM-dd") + " " + stuLesson.ClassEndTime);
                }
                else
                {
                    eTime = DateTime.Parse(stuLesson.ClassEndTime);
                }

                //0=未考勤
                if (DateTime.Now < eTime)
                {
                    student.AttendStatus = 0;
                }

                //1=正常签到 显示考勤时间
                if (stuAttendStatus == AttendStatus.Normal)
                {
                    student.AttendStatus = 1;
                    if (stuLesson.AttendDate.Value.Date == stuLesson.ClassDate.Date)
                    {
                        student.AttendTime = stuLesson.AttendDate.Value.ToString("HH:mm");
                    }
                    else
                    {
                        student.AttendTime = stuLesson.AttendDate.Value.ToString("yyyy-MM-dd HH:mm");
                    }
                }

                //2=补签未确认(缺勤) 显示撤回补签
                if (stuAttendStatus != AttendStatus.Leave && stuAdjustType == AdjustType.SUPPLEMENTNOTCONFIRMED)
                {
                    student.AttendStatus = 2;
                }

                //3=补签已确认 显示考勤时间
                else if (stuAdjustType == AdjustType.SUPPLEMENTCONFIRMED)
                {
                    student.AttendStatus = 3;
                    if (stuLesson.AttendDate.Value.Date == stuLesson.ClassDate.Date)
                    {
                        student.AttendTime = stuLesson.AttendDate.Value.ToString("HH:mm");
                    }
                    else
                    {
                        student.AttendTime = stuLesson.AttendDate.Value.ToString("yyyy-MM-dd HH:mm");
                    }
                }

                //4=请假(当前时间之前) 判断AdjustStatus是否已安排补课
                else if (eTime < DateTime.Now && stuAttendStatus == AttendStatus.Leave)
                {
                    student.AttendStatus = 4;
                    if (stuLesson.AdjustType == (int)AdjustType.MAKEUP ||
                        stuLesson.AdjustType == (int)AdjustType.SUPPLEMENTARYWEEK)
                    {
                        student.AdjustStatus = true;
                    }
                }

                //5=缺勤(当前时间之后) 判断AdjustStatus是否已安排补课
                else if (DateTime.Now > eTime && stuAttendStatus == AttendStatus.NotClockIn)
                {
                    student.AttendStatus = 5;
                    if (stuAdjustType == AdjustType.MAKEUP ||
                        stuAdjustType == AdjustType.SUPPLEMENTARYWEEK)
                    {
                        student.AdjustStatus = true;
                    }
                }

                //6=请假(当前时间之后) 无需判断AdjustStatus是否已安排补课 显示 --
                else if (eTime > DateTime.Now && stuAttendStatus == AttendStatus.Leave)
                {
                    student.AttendStatus = 6;
                }

                //7=补签未确认(请假) 显示撤回补签
                else if (stuAttendStatus == AttendStatus.Leave && stuAdjustType == AdjustType.SUPPLEMENTNOTCONFIRMED)
                {
                    student.AttendStatus = 7;
                }

                res.Add(student);
            }

            return(res);
        }
示例#16
0
 public static string Get(AttendStatus status)
 {
     return Get(status.ToString());
 }
        public static void CreateScheduledEmail(EventPageBase EventPageBase, AttendStatus status, EmailTemplateBlock emailTemplate, ContentReference emailTemplateContentReference, string name)
        {
            ScheduledEmailBlock emailBlock =
                API.AttendScheduledEmailEngine.GenerateScheduledEmailBlock(EventPageBase.ContentLink).CreateWritableClone() as ScheduledEmailBlock;
            emailBlock.EmailSendOptions = SendOptions.Action;
            emailBlock.SendOnStatus = status;
            emailBlock.EmailTemplate.BCC = emailTemplate.BCC;
            emailBlock.EmailTemplate.CC = emailTemplate.CC;
            emailBlock.EmailTemplate.From = emailTemplate.From;
            emailBlock.EmailTemplate.To = emailTemplate.To;
            emailBlock.EmailTemplate.Subject = emailTemplate.Subject;
            emailBlock.EmailTemplate.MainBody = emailTemplate.MainBody;
            emailBlock.EmailTemplate.MainTextBody = emailTemplate.MainTextBody;

            emailBlock.EmailTemplateContentReference = emailTemplateContentReference;

            (emailBlock as IContent).Name = name;

            DataFactory.Instance.Save(emailBlock as IContent, SaveAction.Publish);

        }
 public static IEnumerable <IParticipant> GetParticipants(ContentReference EventPageBase, AttendStatus status)
 {
     return(from p in GetParticipants(EventPageBase) where p.AttendStatus == status.ToString() select p);
 }
 public static IEnumerable<ScheduledEmailBlock> GetScheduledEmails(ContentReference EventPageBase, SendOptions option, AttendStatus status)
 {
     return (from e in GetAllEmails(EventPageBase) where e.SendOnStatus == status && e.EmailSendOptions == option select e);
 }
 public static IEnumerable <ScheduledEmailBlock> GetScheduledEmails(ContentReference EventPageBase, SendOptions option, AttendStatus status)
 {
     return(from e in GetAllEmails(EventPageBase) where e.SendOnStatus == status && e.EmailSendOptions == option select e);
 }