-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cache.go
More file actions
169 lines (163 loc) · 4.16 KB
/
main.cache.go
File metadata and controls
169 lines (163 loc) · 4.16 KB
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
package main
import (
"encoding/xml"
"strconv"
)
// recordInCache -- Function to check if passed-thorugh record name has been cached
// if so, pass back the Record ID
func recordInCache(recordName, recordType string) (bool, string) {
boolReturn := false
strReturn := ""
switch recordType {
case "Service":
//-- Check if record in Service Cache
mutexServices.Lock()
for _, service := range services {
if service.ServiceName == recordName {
boolReturn = true
strReturn = strconv.Itoa(service.ServiceID)
}
}
mutexServices.Unlock()
case "Priority":
//-- Check if record in Priority Cache
mutexPriorities.Lock()
for _, priority := range priorities {
if priority.PriorityName == recordName {
boolReturn = true
strReturn = strconv.Itoa(priority.PriorityID)
}
}
mutexPriorities.Unlock()
case "Site":
//-- Check if record in Site Cache
mutexSites.Lock()
for _, site := range sites {
if site.SiteName == recordName {
boolReturn = true
strReturn = strconv.Itoa(site.SiteID)
}
}
mutexSites.Unlock()
case "Team":
//-- Check if record in Team Cache
mutexTeams.Lock()
for _, team := range teams {
if team.Name == recordName {
boolReturn = true
strReturn = team.ID
}
}
mutexTeams.Unlock()
case "Company":
mutexCompanies.Lock()
for _, company := range companies {
if company.ID == recordName {
boolReturn = true
strReturn = company.Name
}
}
mutexCompanies.Unlock()
case "Organisation":
//-- Check if record in Org Cache
mutexOrgs.Lock()
for _, org := range organisations {
if org.OrgID == recordName {
boolReturn = true
strReturn = org.ContainerID
}
}
mutexOrgs.Unlock()
}
return boolReturn, strReturn
}
func userInCache(userID string) (inCache bool, userName, homeOrg string) {
inCache = false
userName = ""
homeOrg = ""
mutexAnalysts.Lock()
for _, user := range users {
if user.UserID == userID {
inCache = true
userName = user.Name
homeOrg = user.HomeOrg
}
}
mutexAnalysts.Unlock()
return
}
func contactInCache(contactID string) (inCache bool, contactName, contactPK, contactOrgID string) {
contactName = ""
contactPK = ""
contactOrgID = ""
mutexCustomers.Lock()
for _, customer := range customers {
if customer.CustomerID == contactID {
inCache = true
contactName = customer.CustomerName
contactPK = customer.CustomerHornbillID
contactOrgID = customer.CustomerOrgID
}
}
mutexCustomers.Unlock()
return
}
func loadOrgs() error {
espXmlmc, err := NewEspXmlmcSession()
if err != nil {
return err
}
espXmlmc.SetParam("application", appServiceManager)
espXmlmc.SetParam("queryName", "getOrganizationContainers")
XMLOrgSearch, xmlmcErr := espXmlmc.Invoke("data", "queryExec")
if xmlmcErr != nil {
return xmlmcErr
}
var xmlRespon xmlmcOrgListResponse
err2 := xml.Unmarshal([]byte(XMLOrgSearch), &xmlRespon)
if err2 != nil {
return err2
}
mutexOrgs.Lock()
for index := range xmlRespon.RowResult {
var newOrgForCache orgListStruct
newOrgForCache.OrgID = xmlRespon.RowResult[index].OrgID
newOrgForCache.ContainerID = xmlRespon.RowResult[index].ContainerID
orgNamedMap := []orgListStruct{newOrgForCache}
organisations = append(organisations, orgNamedMap...)
}
mutexOrgs.Unlock()
return nil
}
// categoryInCache -- Function to check if passed-thorugh category been cached
// if so, pass back the Category ID and Full Name
func categoryInCache(recordName, recordType string) (bool, string, string) {
boolReturn := false
idReturn := ""
strReturn := ""
switch recordType {
case "RequestCategory":
//-- Check if record in Category Cache
mutexCategories.Lock()
for _, category := range categories {
if category.CategoryCode == recordName {
boolReturn = true
idReturn = category.CategoryID
strReturn = category.CategoryName
}
}
mutexCategories.Unlock()
case "ClosureCategory":
//-- Check if record in Category Cache
mutexCloseCategories.Lock()
for _, category := range closeCategories {
if category.CategoryCode == recordName {
boolReturn = true
idReturn = category.CategoryID
strReturn = category.CategoryName
}
}
mutexCloseCategories.Unlock()
}
return boolReturn, idReturn, strReturn
}