/// <summary>
        /// 建構式,傳入CalendarRecord
        /// </summary>
        /// <param name="record"></param>
        public CancelCourseCalendar(CalendarRecord record)
        {
            StartDate = record.StartDateTime;
            EndDate = record.EndDateTime;
            TeacherName = record.TeacherName;
            AbsenceTeacherName = record.AbsTeacherName;
            ClassroomName = record.ClassroomName;

            if (record.ExchangeCalendar != null)
            {
                ExStartDate = record.ExchangeCalendar.StartDateTime;
                ExEndDate = record.ExchangeCalendar.EndDateTime;
                ExTeacherName = record.ExchangeCalendar.TeacherName;
                ExClassName = record.ExchangeCalendar.ClassName;
                ExClassroomName = record.ExchangeCalendar.ClassroomName;
                Type = "調課";
            }
            else
                Type = "代課";

            Content = record.ToXml().ToString();
        }
Пример #2
0
 /// <summary>
 /// 建構式,傳入行事曆
 /// </summary>
 /// <param name="vRecord"></param>
 public CalendarRecord(CalendarRecord vRecord)
 {
     this.AbsenceName = vRecord.AbsenceName;
     this.Cancel = vRecord.Cancel;
     this.ClassID = vRecord.ClassID;
     this.ClassName = vRecord.ClassName;
     this.ClassroomName = vRecord.ClassroomName;
     this.Comment = vRecord.Comment;
     this.EndDateTime = vRecord.EndDateTime;
     this.StartDateTime = vRecord.StartDateTime;
     this.ExchangeID = vRecord.ExchangeID;
     this.Level = vRecord.Level;
     this.Period = vRecord.Period;
     this.ReplaceID = vRecord.ReplaceID;
     this.Subject = vRecord.Subject;
     this.TeacherID = vRecord.TeacherID;
     this.TeacherName = vRecord.TeacherName;
     this.Weekday = vRecord.Weekday;
     this.CourseID = vRecord.CourseID;
     this.ScheduleComment = vRecord.ScheduleComment;
     this.Lock = vRecord.Lock;
     this.Delete = vRecord.Delete;
 }
Пример #3
0
        /// <summary>
        /// 確認行事曆間是否有交集
        /// </summary>
        /// <param name="SrcRecord"></param>
        /// <param name="DesRecords"></param>
        /// <returns></returns>
        private bool IsIntersect(CalendarRecord SrcRecord, List<CalendarRecord> DesRecords)
        {
            foreach (CalendarRecord record in DesRecords)
            {
                if (SrcRecord.IsIntersect(record))
                    return true;
            }

            return false;
        }
Пример #4
0
        /// <summary>
        /// 取得教師行事曆
        /// </summary>
        /// <param name="AssocID"></param>
        /// <param name="StartDate"></param>
        /// <param name="EndDate"></param>
        /// <returns></returns>
        public static List<CalendarRecord> GetTeacherCalendars(
            string AssocID,
            DateTime StartDate,
            DateTime EndDate)
        {
            AccessHelper mAccessHelper = Utility.AccessHelper;
            QueryHelper mQueryHelper = Utility.QueryHelper;

            List<CalendarRecord> CalendarRecords = new List<CalendarRecord>();

            //將教師所有課程行事曆找出來
            List<CourseCalendar> CourseCalendars = mAccessHelper
                .Select<CourseCalendar>("teacher_name='" + AssocID + "' and start_date_time>=" + StartDate.ToShortDateString() + " and end_date_time<=" + EndDate.ToShortDateString())
                .OrderBy(x => x.StartDateTime).ToList();

            List<string> ReplaceIDs = new List<string>();
            List<string> AbsenceIDs = new List<string>();

            #region 找出是被代課的系統編號
            if (CourseCalendars.Count > 0)
            {
                string strReplaceSQL = "select replace_id,teacher_name from $scheduler.course_calendar where replace_id in (" + string.Join(",", CourseCalendars.Select(x => x.UID).ToArray()) + ")";

                DataTable table = mQueryHelper.Select(strReplaceSQL);

                foreach (DataRow row in table.Rows)
                {
                    string TeacherID = row.Field<string>("teacher_name");
                    string ReplaceID = row.Field<string>("replace_id");

                    if (!string.IsNullOrWhiteSpace(TeacherID))
                        ReplaceIDs.Add(ReplaceID);
                    else
                        AbsenceIDs.Add(ReplaceID);
                }
            }
            #endregion

            foreach (CourseCalendar vCourseCalendar in CourseCalendars)
            {
                if (!vCourseCalendar.Cancel)
                {
                    CalendarRecord vCalendar = new CalendarRecord(vCourseCalendar);

                    if (!string.IsNullOrWhiteSpace(vCalendar.ReplaceID))
                        vCalendar.Status = "代課";
                    else if (!string.IsNullOrWhiteSpace(vCalendar.ExchangeID))
                        vCalendar.Status = "調課";
                    CalendarRecords.Add(vCalendar);
                }
                else if (ReplaceIDs.Contains(vCourseCalendar.UID))
                {
                    CalendarRecord vCalendar = new CalendarRecord(vCourseCalendar);
                    vCalendar.Status = "請假";
                    CalendarRecords.Add(vCalendar);
                }
                else if (AbsenceIDs.Contains(vCourseCalendar.UID))
                {
                    CalendarRecord vCalendar = new CalendarRecord(vCourseCalendar);
                    vCalendar.Status = "缺課";
                    CalendarRecords.Add(vCalendar);
                }
            }

            return CalendarRecords;
        }
Пример #5
0
        /// <summary>
        /// 取得場地行事曆
        /// </summary>
        /// <param name="AssocID"></param>
        /// <param name="StartDate"></param>
        /// <param name="EndDate"></param>
        /// <returns></returns>
        public static List<CalendarRecord> GetPlaceCalendars(string AssocID, DateTime StartDate, DateTime EndDate)
        {
            AccessHelper mAccessHelper = Utility.AccessHelper;

            List<CourseCalendar> CourseCalendars = mAccessHelper
                .Select<CourseCalendar>("classroom_name='" + AssocID + "' and cancel=false and start_date_time>=" + StartDate.ToShortDateString() + " and end_date_time<=" + EndDate.ToShortDateString())
                .OrderBy(x => x.StartDateTime).ToList();

            List<CalendarRecord> CalendarRecords = new List<CalendarRecord>();

            foreach (CourseCalendar vCourseCalendar in CourseCalendars)
            {
                if (!vCourseCalendar.Cancel)
                {
                    CalendarRecord vCalendar = new CalendarRecord(vCourseCalendar);

                    if (!string.IsNullOrWhiteSpace(vCalendar.ReplaceID))
                        vCalendar.Status = "代課";
                    else if (!string.IsNullOrWhiteSpace(vCalendar.ExchangeID))
                        vCalendar.Status = "調課";
                    CalendarRecords.Add(vCalendar);
                }
            }

            return CalendarRecords;
        }
Пример #6
0
        /// <summary>
        /// 建構式,傳入XElement做為參數
        /// </summary>
        /// <param name="Element"></param>
        public CalendarRecord(XElement Element,bool ContainsExchange)
        {
            UID = Element.Element("Uid").Value;

            CourseID = Element.Element("CourseID").Value;
            TeacherID = Element.Element("TeacherID").Value;
            TeacherName = Element.Element("TeacherName").Value;

            AbsTeacherID = Element.ElementText("AbsTeacherID");
            AbsTeacherName = Element.ElementText("AbsTeacherName");

            ClassID = Element.Element("ClassID").Value;
            ClassName = Element.Element("ClassName").Value;

            ClassroomName = Element.Element("ClassroomName").Value;

            Subject = Element.Element("Subject").Value;
            Level = Element.Element("Level").Value;

            AbsenceName = Element.Element("AbsenceName").Value;
            Lock = Element.Element("Lock").Value;
            Comment = Element.Element("Comment").Value;
            ScheduleComment = Element.Element("ScheduleComment").Value;

            Weekday = Element.Element("Weekday").Value;
            Period = Element.Element("Period").Value;

            StartDateTime = K12.Data.DateTimeHelper.ParseDirect(Element.Element("StartDateTime").Value);
            EndDateTime = K12.Data.DateTimeHelper.ParseDirect(Element.Element("EndDateTime").Value);

            ExchangeID = Element.Element("ExchangeID").Value;
            ReplaceID = Element.Element("ReplaceID").Value;

            EMailLog = Element.ElementText("EMailLog");

            Cancel = Element.Element("Cancel").Value.Equals("t") ? true : false;
            ExchangeCalendar = null;
            Delete = string.Empty;

            LastUpdate = K12.Data.DateTimeHelper.Parse(Element.ElementText("LastUpdate"));

            if (ContainsExchange)
            {
                ExchangeCalendar = new CalendarRecord();

                ExchangeCalendar.UID = Element.Element("ExUid").Value;

                ExchangeCalendar.CourseID = Element.Element("ExCourseID").Value;
                ExchangeCalendar.TeacherID = Element.Element("ExTeacherID").Value;
                ExchangeCalendar.TeacherName = Element.Element("ExTeacherName").Value;

                //AbsTeacherID = Element.ElementText("AbsTeacherID");
                //AbsTeacherName = Element.ElementText("AbsTeacherName");

                ExchangeCalendar.ClassID = Element.Element("ExClassID").Value;
                ExchangeCalendar.ClassName = Element.Element("ExClassName").Value;

                ExchangeCalendar.ClassroomName = Element.Element("ExClassroomName").Value;

                ExchangeCalendar.Subject = Element.Element("ExSubject").Value;
                ExchangeCalendar.Level = Element.Element("ExLevel").Value;

                ExchangeCalendar.AbsenceName = Element.Element("ExAbsenceName").Value;
                ExchangeCalendar.Lock = Element.Element("ExLock").Value;
                ExchangeCalendar.Comment = Element.Element("ExComment").Value;
                ExchangeCalendar.ScheduleComment = Element.Element("ExScheduleComment").Value;

                ExchangeCalendar.Weekday = Element.Element("ExWeekday").Value;
                ExchangeCalendar.Period = Element.Element("ExPeriod").Value;

                ExchangeCalendar.StartDateTime = K12.Data.DateTimeHelper.ParseDirect(Element.Element("ExStartDateTime").Value);
                ExchangeCalendar.EndDateTime = K12.Data.DateTimeHelper.ParseDirect(Element.Element("ExEndDateTime").Value);

                ExchangeCalendar.ExchangeID = Element.Element("ExExchangeID").Value;
                ExchangeCalendar.ReplaceID = Element.Element("ExReplaceID").Value;
                ExchangeCalendar.EMailLog = Element.ElementText("EMailLog");

                ExchangeCalendar.Cancel = Element.Element("ExCancel").Value.Equals("t") ? true : false;

                ExchangeCalendar.LastUpdate = K12.Data.DateTimeHelper.Parse(Element.ElementText("ExLastUpdate"));
            }
        }
Пример #7
0
        public object Clone()
        {
            CalendarRecord record = new CalendarRecord(this);

            return record;
        }