This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
XPObjects.vb
118 lines (96 loc) · 4.26 KB
/
XPObjects.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports DevExpress.Xpo
Imports DevExpress.XtraScheduler
Imports DevExpress.XtraScheduler.Xml
Namespace Scheduler_Grid_XPO.Data
' XP object
Public Class XPAppointment
Inherits XPObject
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Public AllDay As Boolean ' Appointment.AllDay
<Size(SizeAttribute.Unlimited)> _
Public Description As String ' Appointment.Description - !!! To set the Memo field type.
Public Finish As Date ' Appointment.End
Public Label As Integer ' Appointment.Label
Public Location As String ' Appointment.Location
<Size(SizeAttribute.Unlimited)> _
Public Recurrence As String ' Appointment.RecurrenceInfo - !!! To set the Memo field type.
<Size(SizeAttribute.Unlimited)> _
Public Reminder As String ' Appointment.ReminderInfo - !!! To set the Memo field type.
Public Start As Date ' Appointment.Start
Public Status As Integer ' Appointment.Status
<Size(SizeAttribute.Unlimited)> _
Public Subject As String ' Appointment.Subject - !!! To set the Memo field type.
Public AppointmentType As Integer ' Appointment.Type
<Association()> _
Public ReadOnly Property Resources() As XPCollection(Of XPResource)
Get
Return GetCollection(Of XPResource)("Resources")
End Get
End Property
<NonPersistent()> _
Public Property ResourceIds() As String
Get
Return GenerateResourceIdsString()
End Get
Set(ByVal value As String)
Dim resourceIds_Renamed As ResourceIdCollection = GenerateResourceIdsString(value)
Resources.SuspendChangedEvents()
Try
ClearResources()
Dim count As Integer = resourceIds_Renamed.Count
For i As Integer = 0 To count - 1
Dim resource As XPResource = Me.Session.GetObjectByKey(Of XPResource)(resourceIds_Renamed(i))
If resource IsNot Nothing Then
Resources.Add(resource)
End If
Next i
Finally
Resources.ResumeChangedEvents()
End Try
End Set
End Property
Private Sub ClearResources()
Dim count As Integer = Resources.Count
Do While count > 0
Resources.Remove(Resources(0))
count -= 1
Loop
End Sub
Private Function GenerateResourceIdsString(ByVal xml As String) As ResourceIdCollection
Dim result As New ResourceIdCollection()
If String.IsNullOrEmpty(xml) Then
Return result
End If
Return AppointmentResourceIdCollectionXmlPersistenceHelper.ObjectFromXml(result, xml)
End Function
Private Function GenerateResourceIdsString() As String
Dim resourceIds_Renamed As New ResourceIdCollection()
Dim count As Integer = Resources.Count
For i As Integer = 0 To count - 1
resourceIds_Renamed.Add(Resources(i).Oid)
Next i
Dim helper As New AppointmentResourceIdCollectionXmlPersistenceHelper(resourceIds_Renamed)
Return helper.ToXml()
End Function
End Class
' XP object
Public Class XPResource
Inherits XPObject
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
<Size(SizeAttribute.Unlimited)> _
Public Name As String ' Resource.Caption - !!! To set the Memo field type.
<Association()> _
Public ReadOnly Property Appointments() As XPCollection(Of XPAppointment)
Get
Return GetCollection(Of XPAppointment)("Appointments")
End Get
End Property
End Class
End Namespace