예제 #1
0
        public void bindEvents()
        {
            int      clientID    = SessionHelper.getClientId();
            int      DaysinMonth = 0;
            DateTime fromDate    = DateTime.Now;
            DateTime toDate      = DateTime.Now;

            CRM.Data.Entities.SecUser user = null;

            int userID = SessionHelper.getUserId();

            user = SecUserManager.GetById(userID);

            if (user != null)
            {
                if (WebDayView1.Visible)
                {
                    fromDate = SchedulerManager.GetScheduleFromDate(WebScheduleInfo1);
                    toDate   = SchedulerManager.GetScheduleEndDate(WebDayView1);
                }
                else if (WebMonthView1.Visible)
                {
                    fromDate    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                    DaysinMonth = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
                    toDate      = fromDate.AddMonths(1).AddTicks(-1);
                }

                List <LeadTask> appointments = null;

                // get events from all users and show on scheduler
                Expression <Func <Task, bool> > predicate = PredicateBuilder.True <CRM.Data.Entities.Task>();
                predicate = predicate.And(LeadTask => LeadTask.creator_id == clientID);
                predicate = predicate.And(LeadTask => LeadTask.TaskType == 2);
                predicate = predicate.And(LeadTask => LeadTask.owner_id == userID);

                predicate = predicate.And(LeadTask => LeadTask.start_date >= fromDate && LeadTask.start_date <= toDate);


                appointments = TasksManager.GetEvents(predicate);


                Resource resource = new Resource();

                resource.DataKey = userID.ToString();

                resource.Name = user.FirstName + " " + user.LastName;

                WebScheduleInfo1.Activities.Clear();
                WebScheduleInfo1.VisibleResources.Clear();

                WebScheduleInfo1.VisibleResources.Add(resource);

                SchedulerManager.BindAppointment(WebScheduleInfo1, appointments);
            }
        }