-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataHelper.vb
73 lines (63 loc) · 3.46 KB
/
DataHelper.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Imports DevExpress.XtraScheduler
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Namespace CustomAppointmentFlyoutExample
Friend Module DataHelper
Public RandomInstance As Random = New Random()
Public CustomResourceCollection As List(Of CustomResourceSourceObject) = New List(Of CustomResourceSourceObject)()
Public CustomEventList As List(Of CustomAppointmentSourceObject) = New List(Of CustomAppointmentSourceObject)()
Public Sub InitResources(ByVal storage As SchedulerStorage)
Dim mappings As ResourceMappingInfo = storage.Resources.Mappings
mappings.Id = "ResID"
mappings.Caption = "Name"
Call CustomResourceCollection.Add(CreateCustomResource(1, "Max Fowler", Color.PowderBlue))
Call CustomResourceCollection.Add(CreateCustomResource(2, "Nancy Drewmore", Color.PaleVioletRed))
Call CustomResourceCollection.Add(CreateCustomResource(3, "Pak Jang", Color.PeachPuff))
storage.Resources.DataSource = CustomResourceCollection
End Sub
Public Function CreateCustomResource(ByVal res_id As Integer, ByVal caption As String, ByVal ResColor As Color) As CustomResourceSourceObject
Dim cr As CustomResourceSourceObject = New CustomResourceSourceObject()
cr.ResID = res_id
cr.Name = caption
Return cr
End Function
Public Sub InitAppointments(ByVal storage As SchedulerStorage)
Dim mappings As AppointmentMappingInfo = storage.Appointments.Mappings
mappings.Start = "StartTime"
mappings.End = "EndTime"
mappings.Subject = "Subject"
mappings.AllDay = "AllDay"
mappings.Description = "Description"
mappings.Label = "Label"
mappings.Location = "Location"
mappings.RecurrenceInfo = "RecurrenceInfo"
mappings.ReminderInfo = "ReminderInfo"
mappings.ResourceId = "OwnerId"
mappings.Status = "Status"
mappings.Type = "EventType"
GenerateEvents(CustomEventList, storage)
storage.Appointments.DataSource = CustomEventList
End Sub
Public Sub GenerateEvents(ByVal eventList As List(Of CustomAppointmentSourceObject), ByVal storage As SchedulerStorage)
Dim count As Integer = storage.Resources.Count
For i As Integer = 0 To count - 1
Dim resource As Resource = storage.Resources(i)
Dim subjPrefix As String = resource.Caption & "'s "
eventList.Add(CreateEvent(subjPrefix & "meeting", resource.Id, 2, 5, 14))
eventList.Add(CreateEvent(subjPrefix & "travel", resource.Id, 3, 6, 10))
eventList.Add(CreateEvent(subjPrefix & "talk", resource.Id, 0, 4, 16))
Next
End Sub
Public Function CreateEvent(ByVal subject As String, ByVal resourceId As Object, ByVal status As Integer, ByVal label As Integer, ByVal sHour As Integer) As CustomAppointmentSourceObject
Dim apt As CustomAppointmentSourceObject = New CustomAppointmentSourceObject()
apt.Subject = subject
apt.OwnerId = resourceId
apt.StartTime = Date.Today.AddHours(RandomInstance.Next(12))
apt.EndTime = apt.StartTime.AddHours(RandomInstance.Next(4) + 1)
apt.Status = status
apt.Label = label
Return apt
End Function
End Module
End Namespace