-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.structs.go
More file actions
379 lines (350 loc) · 11.3 KB
/
main.structs.go
File metadata and controls
379 lines (350 loc) · 11.3 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
package main
import (
"sync"
"time"
apiLib "github.com/hornbill/goApiLib"
"github.com/hornbill/sqlx"
//SQL Drivers
_ "github.com/alexbrainman/odbc"
)
const (
version = "1.22.1"
repo = "goSWRequestImport"
appServiceManager = "com.hornbill.servicemanager"
)
var (
appDBDriver string
cacheDBDriver string
arrCallsLogged = make(map[string]string)
arrCallDetailsMaps = make([]map[string]interface{}, 0)
boolConfLoaded bool
bufferMutex = &sync.Mutex{}
configFileName string
configDryRun bool
configDebug bool
configCustomerOrg bool
configMaxRoutines string
configVersion bool
configSplitLogs bool
connStrSysDB string
connStrAppDB string
espXmlmc *apiLib.XmlmcInstStruct
counters counterTypeStruct
mapGenericConf swCallConfStruct
users []userListStruct
categories []categoryListStruct
closeCategories []categoryListStruct
customers []customerListStruct
organisations []orgListStruct
companies []groupListStruct
priorities []priorityListStruct
services []serviceListStruct
sites []siteListStruct
teams []groupListStruct
sqlCallQuery string
swImportConf swImportConfStruct
timeNow string
startTime time.Time
endTime time.Duration
mutexAnalysts = &sync.Mutex{}
mutexArrCallsLogged = &sync.Mutex{}
mutexBar = &sync.Mutex{}
mutexCategories = &sync.Mutex{}
mutexCloseCategories = &sync.Mutex{}
mutexCompanies = &sync.Mutex{}
mutexCounters = &sync.Mutex{}
mutexCustomers = &sync.Mutex{}
mutexOrgs = &sync.Mutex{}
mutexPriorities = &sync.Mutex{}
mutexServices = &sync.Mutex{}
mutexSites = &sync.Mutex{}
mutexTeams = &sync.Mutex{}
reqPrefix string
maxGoroutines = 1
boolProcessAttachments bool
dbapp *sqlx.DB
dbsys *sqlx.DB
)
// ----- Structures -----
type counterTypeStruct struct {
sync.Mutex
created int
createdSkipped int
existingRequests int
callsReturned int
filesAttached int
}
// ----- Config Data Structs
type swImportConfStruct struct {
HBConf hbConfStruct //Hornbill Instance connection details
SWServerAddress string
AttachmentRoot string
CustomerType string
SMProfileCodeSeperator string
RelatedRequestQuery string
CallDiaryQuery string
SWSystemDBConf sysDBConfStruct //Cache Data (sw_systemdb) connection details
SWAppDBConf appDBConfStruct //App Data (swdata) connection details
RequestTypesToImport []swCallConfStruct
PriorityMapping map[string]interface{}
TeamMapping map[string]interface{}
CategoryMapping map[string]interface{}
ResolutionCategoryMapping map[string]interface{}
ServiceMapping map[string]interface{}
StatusMapping map[string]interface{}
ExistingRequestMappings map[string]string
}
type hbConfStruct struct {
InstanceID string
APIKey string
UserName string
Password string
}
type refStruct struct {
MasterRef string
SlaveRef string
}
type sysDBConfStruct struct {
Driver string
UserName string
Password string
}
type appDBConfStruct struct {
Driver string
Server string
UserName string
Password string
ConnectionString string
Port int
Database string
Encrypt bool
}
type swCallConfStruct struct {
Import bool
CallClass string
SupportworksCallClass string
DefaultTeam string
DefaultPriority string
DefaultService string
SQLStatement string
CoreFieldMapping map[string]interface{}
AdditionalFieldMapping map[string]interface{}
}
type xmlmcResponse struct {
MethodResult string `xml:"status,attr"`
State stateStruct `xml:"state"`
}
// ----- Shared Structs -----
type stateStruct struct {
Code string `xml:"code"`
ErrorRet string `xml:"error"`
}
//----- Data Structs -----
type xmlmcSysSettingResponse struct {
MethodResult string `xml:"status,attr"`
State stateStruct `xml:"state"`
Setting string `xml:"params>option>value"`
}
// ----- Request Logged Structs
type xmlmcRequestResponseStruct struct {
MethodResult string `xml:"status,attr"`
RequestID string `xml:"params>primaryEntityData>record>h_pk_reference"`
SiteCountry string `xml:"params>rowData>row>h_country"`
Diags []string `xml:"diagnostic>log"`
State stateStruct `xml:"state"`
}
type xmlmcBPMSpawnedStruct struct {
MethodResult string `xml:"status,attr"`
Identifier string `xml:"params>identifier"`
State stateStruct `xml:"state"`
}
// ----- Site Structs
type siteListStruct struct {
SiteName string
SiteID int
}
type xmlmcSiteListResponse struct {
MethodResult string `xml:"status,attr"`
SiteID int `xml:"params>rowData>row>h_id"`
SiteName string `xml:"params>rowData>row>h_site_name"`
SiteCountry string `xml:"params>rowData>row>h_country"`
State stateStruct `xml:"state"`
}
// ----- Priority Structs
type priorityListStruct struct {
PriorityName string
PriorityID int
}
type xmlmcPriorityListResponse struct {
MethodResult string `xml:"status,attr"`
PriorityID int `xml:"params>rowData>row>h_pk_priorityid"`
PriorityName string `xml:"params>rowData>row>h_priorityname"`
State stateStruct `xml:"state"`
}
// ----- Service Structs
type serviceListStruct struct {
ServiceName string
ServiceID int
ServiceBPMIncident string
ServiceBPMService string
ServiceBPMChange string
ServiceBPMProblem string
ServiceBPMKnownError string
ServiceBPMRelease string
}
type xmlmcServiceListResponse struct {
MethodResult string `xml:"status,attr"`
ServiceID int `xml:"params>rowData>row>h_pk_serviceid"`
ServiceName string `xml:"params>rowData>row>h_servicename"`
BPMIncident string `xml:"params>rowData>row>h_incident_bpm_name"`
BPMService string `xml:"params>rowData>row>h_service_bpm_name"`
BPMChange string `xml:"params>rowData>row>h_change_bpm_name"`
BPMProblem string `xml:"params>rowData>row>h_problem_bpm_name"`
BPMKnownError string `xml:"params>rowData>row>h_knownerror_bpm_name"`
BPMRelease string `xml:"params>rowData>row>h_release_bpm_name"`
State stateStruct `xml:"state"`
}
// ----- Team Structs
type groupListStruct struct {
Name string
ID string
}
type xmlmcGroupListResponse struct {
MethodResult string `xml:"status,attr"`
ID string `xml:"params>id"`
Name string `xml:"params>name"`
State stateStruct `xml:"state"`
}
type xmlmcTeamListResponse struct {
MethodResult string `xml:"status,attr"`
ID string `xml:"params>rowData>row>h_id"`
Name string `xml:"params>rowData>row>h_name"`
State stateStruct `xml:"state"`
}
// ----- Category Structs
type categoryListStruct struct {
CategoryCode string
CategoryID string
CategoryName string
}
type xmlmcCategoryListResponse struct {
MethodResult string `xml:"status,attr"`
CategoryID string `xml:"params>id"`
CategoryName string `xml:"params>fullname"`
State stateStruct `xml:"state"`
}
// ----- Analyst Structs
type userListStruct struct {
UserID string
Name string
HomeOrg string
}
type xmlmcUserListResponse struct {
MethodResult string `xml:"status,attr"`
FullName string `xml:"params>name"`
FirstName string `xml:"params>firstName"`
LastName string `xml:"params>lastName"`
HomeOrg string `xml:"params>homeOrganization"`
State stateStruct `xml:"state"`
}
// ----- Customer Structs
type customerListStruct struct {
CustomerHornbillID string
CustomerID string
CustomerName string
CustomerOrgID string
}
type orgListStruct struct {
OrgID string
ContainerID string
}
type xmlmcOrgListResponse struct {
MethodResult string `xml:"status,attr"`
RowResult []xmlOrgListStruct `xml:"params>rowData>row"`
State stateStruct `xml:"state"`
}
type xmlOrgListStruct struct {
OrgID string `xml:"h_organization_id"`
ContainerID string `xml:"h_id"`
}
type xmlmcContactListResponse struct {
MethodResult string `xml:"status,attr"`
CustomerFirstName string `xml:"params>rowData>row>h_firstname"`
CustomerLastName string `xml:"params>rowData>row>h_lastname"`
CustomerOrgID string `xml:"params>rowData>row>h_organization_id"`
CustomerHornbillID string `xml:"params>rowData>row>h_pk_id"`
State stateStruct `xml:"state"`
}
// ----- Associated Record Struct
type reqRelStruct struct {
MasterRef string `db:"parentRequest"`
SlaveRef string `db:"childRequest"`
}
// ----- File Attachment Structs
type xmlmcAttachmentResponse struct {
MethodResult string `xml:"status,attr"`
ContentLocation string `xml:"params>contentLocation"`
State stateStruct `xml:"state"`
HistFileID string `xml:"params>primaryEntityData>record>h_pk_fileid"`
}
// ----- Email Attachment Structs
type xmlmcEmailAttachmentResponse struct {
MethodResult string `xml:"status,attr"`
Recipients []recipientStruct `xml:"params>recipient"`
RFCHeader string `xml:"params>rfcHeader"`
Subject string `xml:"params>subject"`
Body string `xml:"params>body"`
HTMLBody string `xml:"params>htmlBody"`
TimeSent string `xml:"params>timeSent"`
FileAttachments []fileAttachStruct `xml:"params>fileAttachment"`
State stateStruct `xml:"state"`
}
type fileAttachStruct struct {
FileName string `xml:"fileName"`
FileData string `xml:"fileData"`
FileSize string `xml:"fileSize"`
TimeStamp string `xml:"timeStamp"`
MIMEType string `xml:"contentType"`
ContentID string `xml:"contentId"`
}
type recipientStruct struct {
Class string `xml:"class"`
Address string `xml:"address"`
Name string `xml:"name"`
}
type swmStruct struct {
Content string
Subject string
Attachments []fileAttachStruct
}
// ----- File Attachment Struct
type fileAssocStruct struct {
ImportRef int
SmCallRef string
FileID string `db:"fileid"`
CallRef string `db:"callref"`
DataID string `db:"dataid"`
UpdateID string `db:"updateid"`
Compressed string `db:"compressed"`
SizeU float64 `db:"sizeu"`
SizeC float64 `db:"sizec"`
FileName string `db:"filename"`
AddedBy string `db:"addedby"`
TimeAdded string `db:"timeadded"`
FileTime string `db:"filetime"`
FileData string
Extension string
Description string
EmailAttachment fileAttachStruct
}
// RequestDetails struct for chan
type RequestDetails struct {
CallClass string
CallMap map[string]interface{}
SwCallID string
}
// RequestReferences struct for chan
type RequestReferences struct {
SmCallID string
SwCallID string
}