-
Notifications
You must be signed in to change notification settings - Fork 1
/
GanttDataProvider.vb
191 lines (148 loc) · 9.61 KB
/
GanttDataProvider.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
Imports System
Imports System.Collections.Generic
Imports System.Web
Imports System.Web.SessionState
Namespace DXWebApplication1
Public Module GanttDataProvider
Const TasksSessionKey As String = "Tasks1", DependenciesSessionKey As String = "Dependencies1", ResourcesSessionKey As String = "Resources1", ResourceAssignmentsSessionKey As String = "ResourceAssignments1"
Private ReadOnly Property Session As HttpSessionState
Get
Return HttpContext.Current.Session
End Get
End Property
Public Function GetTasks() As Object
Return Tasks
End Function
Public Function GetDependencies() As Object
Return Dependencies
End Function
Public Function GetResources() As Object
Return Resources
End Function
Public Function GetResourceAssignments() As Object
Return ResourceAssignments
End Function
Public ReadOnly Property Tasks As List(Of Task)
Get
If Session(TasksSessionKey) Is Nothing Then Session(TasksSessionKey) = CreateTasks()
Return CType(Session(TasksSessionKey), List(Of Task))
End Get
End Property
Public ReadOnly Property Dependencies As List(Of Dependency)
Get
If Session(DependenciesSessionKey) Is Nothing Then Session(DependenciesSessionKey) = CreateDependencies()
Return CType(Session(DependenciesSessionKey), List(Of Dependency))
End Get
End Property
Public ReadOnly Property Resources As List(Of Resource)
Get
If Session(ResourcesSessionKey) Is Nothing Then Session(ResourcesSessionKey) = CreateResources()
Return CType(Session(ResourcesSessionKey), List(Of Resource))
End Get
End Property
Public ReadOnly Property ResourceAssignments As List(Of ResourceAssignment)
Get
If Session(ResourceAssignmentsSessionKey) Is Nothing Then Session(ResourceAssignmentsSessionKey) = CreateResourceAssignments()
Return CType(Session(ResourceAssignmentsSessionKey), List(Of ResourceAssignment))
End Get
End Property
Private Function CreateTasks() As List(Of Task)
Dim result = New List(Of Task)()
result.Add(CreateTask("0", Nothing, "Software Development", "02/21/2021 08:00:00", "03/15/2021 15:00:00", "02/21/2021 08:00:00", "03/25/2021 12:00:00", "31", "1", "0", "", ""))
result.Add(CreateTask("1", "0", "Scope", "02/21/2021 08:00:00", "02/26/2021 12:00:00", "02/23/2021 00:00:00", "03/01/2021 00:00:00", "60", "1", "1", "", ""))
result.Add(CreateTask("2", "1", "Determine project scope", "02/22/2021 08:00:00", "02/24/2021 12:00:00", "02/24/2021 00:00:00", "02/28/2021 00:00:00", "100", "1", "2", "1", "Important"))
result.Add(CreateTask("3", "1", "Secure project sponsorship", "02/22/2021 13:00:00", "02/23/2021 12:00:00", "02/22/2021 08:00:00", "02/24/2021 00:00:00", "100", "1", "2", "1", ""))
result.Add(CreateTask("4", "1", "Define preliminary resources", "02/22/2021 13:00:00", "02/26/2021 12:00:00", "02/21/2021 13:00:00", "02/25/2021 00:00:00", "60", "1", "2", "2", ""))
result.Add(CreateTask("5", "1", "Secure core resources", "02/25/2021 13:00:00", "02/26/2021 12:00:00", "02/27/2021 00:00:00", "02/28/2021 12:00:00", "0", "1", "2", "2", ""))
result.Add(CreateTask("6", "1", "Scope complete", "02/26/2021 12:00:00", "02/27/2021 12:00:00", "02/27/2021 12:00:00", "03/1/2021 12:00:00", "0", "0", "2", "", "Important"))
result.Add(CreateTask("7", "0", "Analysis/Software Requirements", "02/26/2021 13:00:00", "03/18/2021 12:00:00", "02/27/2021 00:00:00", "03/21/2021 00:00:00", "80", "1", "1", "", "Important"))
result.Add(CreateTask("8", "7", "Conduct needs analysis", "02/26/2021 13:00:00", "03/05/2021 12:00:00", "02/24/2021 13:00:00", "03/02/2021 00:00:00", "100", "1", "2", "3", ""))
result.Add(CreateTask("9", "7", "Draft preliminary software specifications", "03/05/2021 13:00:00", "03/08/2021 12:00:00", "03/08/2021 08:00:00", "03/11/2021 00:00:00", "100", "1", "2", "3", ""))
result.Add(CreateTask("10", "7", "Develop preliminary budget", "03/08/2021 13:00:00", "03/12/2021 12:00:00", "03/07/2021 13:00:00", "03/10/2021 00:00:00", "100", "1", "2", "2", ""))
result.Add(CreateTask("11", "7", "Review software specifications/budget with team", "03/12/2021 13:00:00", "03/14/2021 17:00:00", "03/13/2021 17:00:00", "03/16/2021 00:00:00", "100", "1", "2", "2,3", ""))
result.Add(CreateTask("12", "7", "Incorporate feedback on software specifications", "03/13/2021 08:00:00", "03/19/2021 17:00:00", "03/15/2021 08:00:00", "03/23/2021 17:00:00", "70", "1", "2", "3", ""))
result.Add(CreateTask("13", "7", "Develop delivery timeline", "03/14/2021 08:00:00", "03/14/2021 17:00:00", "03/14/2021 08:00:00", "03/16/2021 10:00:00", "0", "1", "2", "2", ""))
result.Add(CreateTask("14", "7", "Obtain approvals to proceed (concept, timeline, budget)", "03/15/2021 08:00:00", "03/15/2021 12:00:00", "03/15/2021 08:00:00", "03/16/2021 12:00:00", "0", "1", "2", "1,2", ""))
result.Add(CreateTask("15", "14", "Secure required resources", "03/15/2021 13:00:00", "03/18/2021 12:00:00", "03/18/2021 13:00:00", "03/25/2021 12:00:00", "0", "1", "2", "2", ""))
Return result
End Function
Public Function CreateTask(ByVal key As String, ByVal parentkey As String, ByVal title As String, ByVal start As String, ByVal [end] As String, ByVal actualstart As String, ByVal actualEnd As String, ByVal percent As String, ByVal type As String, ByVal status As String, ByVal resources As String, ByVal description As String) As Task
Dim task = New Task()
task.Key = key
task.ParentKey = parentkey
task.Title = title
task.StartDate = Date.Parse(start, Globalization.CultureInfo.InvariantCulture)
task.EndDate = Date.Parse([end], Globalization.CultureInfo.InvariantCulture)
task.ActualStartDate = Date.Parse(actualstart, Globalization.CultureInfo.InvariantCulture)
task.ActualEndDate = Date.Parse(actualEnd, Globalization.CultureInfo.InvariantCulture)
task.Progress = Convert.ToInt32(percent)
task.Resources = resources
task.Description = description
Return task
End Function
Private Function CreateDependencies() As List(Of Dependency)
Dim result = New List(Of Dependency)()
For i As Integer = 0 To Tasks.Count - 1
Dim task As Task = Tasks(i)
If Not String.IsNullOrEmpty(task.ParentKey) AndAlso Not Equals(task.ParentKey, "-1") Then
result.Add(New Dependency() With {.Key = CreateUniqueId(), .Type = 0, .PredecessorKey = Tasks(i - 1).Key, .SuccessorKey = task.Key})
End If
Next
Return result
End Function
Private Function CreateResources() As List(Of Resource)
Dim result = New List(Of Resource)()
result.Add(New Resource() With {.Key = "1", .Name = "Management"})
result.Add(New Resource() With {.Key = "2", .Name = "Project Manager"})
result.Add(New Resource() With {.Key = "3", .Name = "Analyst"})
result.Add(New Resource() With {.Key = "4", .Name = "Developer"})
result.Add(New Resource() With {.Key = "5", .Name = "Testers"})
result.Add(New Resource() With {.Key = "6", .Name = "Trainers"})
result.Add(New Resource() With {.Key = "7", .Name = "Technical Communicators"})
result.Add(New Resource() With {.Key = "8", .Name = "Deployment Team"})
Return result
End Function
Private Function CreateResourceAssignments() As List(Of ResourceAssignment)
Dim result = New List(Of ResourceAssignment)()
For Each task As Task In Tasks
If Not String.IsNullOrEmpty(task.Resources) Then
Dim resourcesID As String() = task.Resources.Split(New Char() {","c}, StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 0 To resourcesID.Length - 1
result.Add(New ResourceAssignment() With {.Key = CreateUniqueId(), .TaskKey = task.Key, .ResourceKey = resourcesID(i)})
Next
End If
Next
Return result
End Function
Private Function CreateUniqueId() As String
Return Guid.NewGuid().ToString()
End Function
End Module
Public Class Task
Public Property Key As String
Public Property ParentKey As String
Public Property Title As String
Public Property Description As String
Public Property StartDate As Date
Public Property EndDate As Date
Public Property ActualStartDate As Date
Public Property ActualEndDate As Date
Public Property Progress As Integer
Public Property Resources As String
End Class
Public Class Dependency
Public Property Key As String
Public Property PredecessorKey As String
Public Property SuccessorKey As String
Public Property Type As Integer
End Class
Public Class Resource
Public Property Key As String
Public Property Name As String
End Class
Public Class ResourceAssignment
Public Property Key As String
Public Property TaskKey As String
Public Property ResourceKey As String
End Class
End Namespace