Esempio n. 1
0
        public List <CalendarADay> GetByDate(DateTime start, DateTime end, List <Notes> source)
        {
            List <CalendarADay> cd = new List <CalendarADay>();

            if (source != null && source.Count > 0)
            {
                _AccountID = source[0].Owner.Id;
                foreach (Notes notes in source)
                {
                    if (notes.RepeatType is MonthRepeat)
                    {
                        MonthRepeat type = (MonthRepeat)notes.RepeatType;

                        DateTime tempstart = type.RangeStart > start ? type.RangeStart : start;
                        DateTime tempend   = type.RangeEnd == null || type.RangeEnd > end
                                               ? end
                                               : Convert.ToDateTime(type.RangeEnd);
                        DateTime date = tempstart;
                        int      days = (tempend.Date - tempstart.Date).Days;
                        _PlanDutyFrom = new DateTime(tempstart.Year, tempstart.Month, 1);
                        _PlanDutyTo   = GetLastDate(tempend);
                        for (int i = 0; i <= days; i++)
                        {
                            if (RepeatValid(type, date))
                            {
                                List <MonthItem> monthitems = new List <MonthItem>();
                                MonthItem        monthitem  =
                                    new MonthItem(notes.Content,
                                                  RepeatUtility.DetailString(notes, notes.Start, notes.End), date,
                                                  CalendarShowType.Note);
                                monthitems.Add(monthitem);
                                List <DayItem> dayitems = new List <DayItem>();
                                DayItem        dayItem  =
                                    new DayItem(RepeatUtility.ConvertToDateTime(date, notes.Start),
                                                RepeatUtility.ConvertToDateTime(date, notes.End), notes.Content,
                                                CalendarShowType.Note);
                                dayItem.ObjectID = notes.PKID;
                                dayitems.Add(dayItem);
                                CalendarADay aday = new CalendarADay(date, monthitems, dayitems);
                                cd.Add(aday);
                            }
                            date = date.AddDays(1);
                        }
                    }
                }
            }

            return(cd);
        }
Esempio n. 2
0
        public List <CalendarADay> GetByDate(DateTime start, DateTime end, List <Notes> source)
        {
            List <CalendarADay> cd = new List <CalendarADay>();

            if (source != null && source.Count > 0)
            {
                foreach (Notes notes in source)
                {
                    if (notes.RepeatType is WeekRepeat)
                    {
                        WeekRepeat type = (WeekRepeat)notes.RepeatType;

                        DateTime tempstart = type.RangeStart > start ? type.RangeStart : start;
                        DateTime tempend   = type.RangeEnd == null || type.RangeEnd > end
                                               ? end
                                               : Convert.ToDateTime(type.RangeEnd);
                        DateTime date             = tempstart;
                        int      days             = (tempend.Date - tempstart.Date).Days;
                        DateTime rangestartmonday =
                            type.RangeStart.AddDays(-Convert.ToInt32(type.RangeStart.DayOfWeek) + 1);
                        for (int i = 0; i <= days; i++)
                        {
                            if ((date.Date.AddDays(-Convert.ToInt32(date.DayOfWeek) + 1) - rangestartmonday.Date).Days % type.NWeek == 0 &&
                                type.WeekList.Contains((Convert.ToInt32(date.DayOfWeek)).ToString()))
                            {
                                List <MonthItem> monthitems = new List <MonthItem>();
                                MonthItem        monthitem  =
                                    new MonthItem(notes.Content, RepeatUtility.DetailString(notes, notes.Start, notes.End), date, CalendarShowType.Note);
                                monthitems.Add(monthitem);
                                List <DayItem> dayitems = new List <DayItem>();
                                DayItem        dayItem  =
                                    new DayItem(RepeatUtility.ConvertToDateTime(date, notes.Start),
                                                RepeatUtility.ConvertToDateTime(date, notes.End), notes.Content,
                                                CalendarShowType.Note);
                                dayItem.ObjectID = notes.PKID;
                                dayitems.Add(dayItem);
                                CalendarADay aday = new CalendarADay(date, monthitems, dayitems);
                                cd.Add(aday);
                            }
                            date = date.AddDays(1);
                        }
                    }
                }
            }

            return(cd);
        }
Esempio n. 3
0
        public List <CalendarADay> GetByDate(DateTime start, DateTime end, List <Notes> source)
        {
            List <CalendarADay> cd = new List <CalendarADay>();

            foreach (Notes notes in source)
            {
                if (notes.RepeatType is NoRepeat)
                {
                    DateTime from = notes.Start;
                    DateTime to   = notes.End;
                    if (to >= from)
                    {
                        int      days = (to.Date - from.Date).Days;
                        DateTime date = from;
                        for (int i = 0; i <= days; i++)
                        {
                            if (date.Date <= end.Date && date.Date >= start.Date)
                            {
                                DateTime fromtemp = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
                                DateTime totemp   = fromtemp.AddDays(1).AddSeconds(-1);
                                if (i == 0)
                                {
                                    fromtemp = from;
                                }
                                if (i == days)
                                {
                                    totemp = to;
                                }
                                List <MonthItem> monthitems = new List <MonthItem>();
                                MonthItem        monthitem  =
                                    new MonthItem(notes.Content, RepeatUtility.DetailString(notes, fromtemp, totemp), fromtemp, CalendarShowType.Note);
                                monthitems.Add(monthitem);
                                List <DayItem> dayitems = new List <DayItem>();
                                DayItem        dayItem  = new DayItem(fromtemp, totemp, notes.Content, CalendarShowType.Note);
                                dayItem.ObjectID = notes.PKID;
                                dayitems.Add(dayItem);
                                CalendarADay aday = new CalendarADay(fromtemp.Date, monthitems, dayitems);
                                cd.Add(aday);
                                date = date.AddDays(1);
                            }
                        }
                    }
                }
            }
            return(cd);
        }
Esempio n. 4
0
        public List <CalendarADay> GetByDate(DateTime start, DateTime end, List <Notes> source)
        {
            List <CalendarADay> cd = new List <CalendarADay>();

            if (source != null && source.Count > 0)
            {
                List <PlanDutyDetail> planDutyDetailList =
                    new PlanDutyFacade().GetPlanDutyDetailByAccount(source[0].Owner.Id, start, end);

                foreach (Notes notes in source)
                {
                    if (notes.RepeatType is DayRepeat)
                    {
                        DayRepeat type = (DayRepeat)notes.RepeatType;

                        DateTime tempstart = type.RangeStart > start ? type.RangeStart : start;
                        DateTime tempend   = type.RangeEnd == null || type.RangeEnd > end
                                               ? end
                                               : Convert.ToDateTime(type.RangeEnd);
                        DateTime date = tempstart;
                        int      days = (tempend.Date - tempstart.Date).Days;
                        for (int i = 0; i <= days; i++)
                        {
                            bool isadd = false;
                            if (type.EveryWork || type.EveryWeek)
                            {
                                PlanDutyDetail detail = PlanDutyDetail.GetPlanDutyDetailByDate(planDutyDetailList, date);
                                if ((type.EveryWork && !detail.PlanDutyClass.IsWeek) ||
                                    (type.EveryWeek && detail.PlanDutyClass.IsWeek))
                                {
                                    isadd = true;
                                }
                            }
                            else
                            {
                                if ((date.Date - type.RangeStart.Date).Days % type.NDayOnce == 0)
                                {
                                    isadd = true;
                                }
                            }
                            if (isadd)
                            {
                                List <MonthItem> monthitems = new List <MonthItem>();
                                MonthItem        monthitem  =
                                    new MonthItem(notes.Content, RepeatUtility.DetailString(notes, notes.Start, notes.End), date, CalendarShowType.Note);
                                monthitems.Add(monthitem);
                                List <DayItem> dayitems = new List <DayItem>();
                                DayItem        dayItem  =
                                    new DayItem(RepeatUtility.ConvertToDateTime(date, notes.Start),
                                                RepeatUtility.ConvertToDateTime(date, notes.End), notes.Content,
                                                CalendarShowType.Note);
                                dayItem.ObjectID = notes.PKID;
                                dayitems.Add(dayItem);
                                CalendarADay aday = new CalendarADay(date, monthitems, dayitems);
                                cd.Add(aday);
                            }
                            date = date.AddDays(1);
                        }
                    }
                }
            }

            return(cd);
        }