Esempio n. 1
0
        public List <CalendarADay> GetByDate(DateTime start, DateTime end, int accountID)
        {
            List <Notes>        notes = Notes.GetNotesByDate(start, end, accountID);
            List <CalendarADay> cal   = new List <CalendarADay>();
            var repeaters             = RepeatUtility.GetAllRepeat();

            foreach (IRepeat repeat in repeaters)
            {
                cal.AddRange(repeat.GetByDate(start, end, notes));
            }
            return(cal);
        }
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)
            {
                _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. 3
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. 4
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);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Account       _loginUser = Session[SessionKeys.LOGININFO] as Account;
            StringBuilder sb         = new StringBuilder();

            if (BasePage.HasHrmisSystem && _loginUser.IsHRAccount)
            {
                foreach (CalendarShowType type in CalendarShowType.GetHrType())
                {
                    sb.AppendFormat(
                        "<li><input value='{0}' type='checkbox' {3} /><span style='margin-left:15px;color:{2};'>{1}</span></li>",
                        type.ID, type.Name, type.Color, type.DefaultChecked ? "checked='checked'" : "");
                }
            }
            foreach (CalendarShowType type in CalendarShowType.GetSepType())
            {
                sb.AppendFormat(
                    "<li><input value='{0}' type='checkbox' {3} /><span style='margin-left:15px;color:{2};'>{1}</span></li>",
                    type.ID, type.Name, type.Color, type.DefaultChecked ? "checked='checked'" : "");
            }

            typeUL.InnerHtml   = sb.ToString();
            selfname.InnerHtml = _loginUser.Name;
            selfname.Attributes.Add("name", _loginUser.Name);


            /*便签*/
            List <NameValue> attributions = RepeatUtility.GetAll();

            ddlType.Items.Clear();
            foreach (NameValue attribution in attributions)
            {
                ListItem item = new ListItem(attribution.Name, attribution.Value, true);
                ddlType.Items.Add(item);
            }

            //部门
            List <Department> deps = BllInstance.DepartmentBllInstance.GetAllDepartment();

            ddlDepartment.Items.Clear();
            ListItem alldep = new ListItem(string.Empty, "-1", true);

            ddlDepartment.Items.Add(alldep);
            foreach (Department dep in deps)
            {
                ListItem item = new ListItem(dep.Name, dep.Id.ToString(), true);
                if (dep.Id == _loginUser.Dept.Id)
                {
                    item.Selected = true;
                }
                ddlDepartment.Items.Add(item);
            }

            //按月重复
            List <MonthDayTypeEnum> mdte = MonthDayTypeEnum.GetAll();

            ddlMonthDayTypeEnum.Items.Clear();
            foreach (MonthDayTypeEnum m in mdte)
            {
                ListItem item = new ListItem(m.Name, m.Value.ToString(), true);
                ddlMonthDayTypeEnum.Items.Add(item);
            }

            List <NDayMonthEnum> ndme = NDayMonthEnum.GetAll();

            ddlNDayMonthEnum.Items.Clear();
            foreach (NDayMonthEnum m in ndme)
            {
                ListItem item = new ListItem(m.Name, m.Value.ToString(), true);
                ddlNDayMonthEnum.Items.Add(item);
            }
        }
Esempio n. 6
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);
        }