private void Scheduler_Unload(object sender, EventArgs e) { ASPxScheduler scheduler = (ASPxScheduler)sender; if (SchedulerControllerResourceManager.ActiveViewType.Value != SchedulerViewType.Agenda) { ResourceBaseCollection resources = scheduler.ActiveView.GetResources(); SchedulerControllerResourceManager.Resources.Value = resources.Select(r => r.Id).ToList(); } }
private void QueryAppointmentDataSource(FetchAppointmentsEventArgs e, ResourceBaseCollection resources) { string resListString = String.Join(",", resources.Select(res => res.Id.ToString())); // Modify the FillBy query to fetch appointments only for the specified resources. appointmentsTableAdapter.Commands[1].CommandText = String.Format("SELECT Appointments.* FROM Appointments WHERE (OriginalOccurrenceStart >= @Start) AND(OriginalOccurrenceEnd <= @End) AND (ResourceID IN ({0})) OR (Type != 0)", resListString); appointmentsTableAdapter.FillBy(this.scheduleTestDataSet.Appointments, e.Interval.Start.AddDays(-PADDING_DAYS), e.Interval.End.AddDays(PADDING_DAYS)); queryExecutionCounter++; }
void schedulerDataStorage1_FetchAppointments(object sender, FetchAppointmentsEventArgs e) { ResourceBaseCollection resourcesVisible = new ResourceBaseCollection() { Capacity = schedulerControl1.ActiveView.ResourcesPerPage }; for (int i = 0; i < schedulerControl1.ActiveView.ResourcesPerPage; i++) { resourcesVisible.Add(schedulerDataStorage1.Resources[schedulerControl1.ActiveView.FirstVisibleResourceIndex + i]); } QueryAppointmentDataSource(e, resourcesVisible); }
void LoadResources() { ResourceBaseCollection resources = schedulerStorage1.Resources.Items; if (resources.Count <= 0) { resources.Add(this.schedulerStorage1.CreateResource(0, "Andrew Fuller")); resources.Add(this.schedulerStorage1.CreateResource(1, "Nancy Davolio")); resources.Add(this.schedulerStorage1.CreateResource(2, "Janet Leverling")); resources.Add(this.schedulerStorage1.CreateResource(3, "Margaret Peacock")); } int count = xpResources.Count; for (int i = 0; i < count; i++) { XPObject o = (XPObject)xpResources[i]; o.Save(); } }
void InitData() { ResourceBaseCollection resources = schedulerStorage.Resources.Items; if (resources.Count <= 0) { resources.Add(this.schedulerStorage.CreateResource(0, "Andrew Fuller")); resources.Add(this.schedulerStorage.CreateResource(1, "Nancy Davolio")); resources.Add(this.schedulerStorage.CreateResource(2, "Janet Leverling")); resources.Add(this.schedulerStorage.CreateResource(3, "Margaret Peacock")); int count = xpCollectionResources.Count; for (int i = 0; i < count; i++) { XPObject o = (XPObject)xpCollectionResources[i]; o.Save(); } } if (schedulerStorage.Appointments.Count == 0) { schedulerStorage.BeginUpdate(); Appointment aptPattern = schedulerStorage.CreateAppointment(AppointmentType.Pattern); DateTime curHour = DateTime.Now.Date.AddHours(DateTime.Now.Hour); aptPattern.Start = curHour.AddDays(-2); aptPattern.End = aptPattern.Start.AddHours(2); aptPattern.RecurrenceInfo.Start = aptPattern.Start; aptPattern.Subject = "Test Appointment To Split"; aptPattern.Description = "Again and again..."; aptPattern.ResourceId = schedulerStorage.Resources[0].Id; aptPattern.StatusKey = (int)AppointmentStatusType.Busy; aptPattern.LabelKey = 1; aptPattern.RecurrenceInfo.Type = RecurrenceType.Daily; aptPattern.RecurrenceInfo.Periodicity = 2; aptPattern.RecurrenceInfo.Range = RecurrenceRange.OccurrenceCount; aptPattern.RecurrenceInfo.OccurrenceCount = 10; schedulerControl.Storage.Appointments.Add(aptPattern); schedulerStorage.EndUpdate(); } }
private float CalcCurrentTotals(TimeInterval interval, Resource resource) { AppointmentBaseCollection apts = this.schedulerStorage1.GetAppointments(interval); float total = 0.0F; ResourceBaseCollection resources = new ResourceBaseCollection(); resources.Add(resource); ResourcesAppointmentsFilter filter = new ResourcesAppointmentsFilter(resources); filter.Process(apts); foreach (Appointment apt in (AppointmentBaseCollection)filter.DestinationCollection) { if (apt.CustomFields["CustomPrice"] != null) { float customprice; float.TryParse(apt.CustomFields["CustomPrice"].ToString(), out customprice); total = total + customprice; } } return(total); }