-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathUTCtool.prw
678 lines (539 loc) · 19.9 KB
/
UTCtool.prw
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
#Include 'Protheus.ch'
#INCLUDE 'FWMVCDEF.CH'
static cRoutine as Character
static lLocaliza
//-------------------------------------------------------------------
/*/{Protheus.doc} UTCTool
Unite Test Creator Tool
Creation of TestCases, Group, Suite and CSV files for unit
test
@author andrews.egas
@since 05/04/2018
@version 1.0
/*/
//-------------------------------------------------------------------
Function UTCTool(lAuto)
Local oUTCTool := UTCClass():New()
Local cVersion as Character
Default lAuto := .F.
cVersion := "V4.00"
cRoutine := "code"
If !ExistDir("\UTCTOOL")
MakeDir( "\UTCTOOL") //make the new directory to save UTCTOOL files
EndIf
UTCHttpVersion(cVersion)
If !lAuto
While !Empty(cRoutine)
//source code
cRoutine := Alltrim(GetRoutine("Routine - UTCTOOL " + cVersion))
If !Empty(cRoutine)
if !Empty( cPaisLoc ) .AND. FindFunction( cRoutine + cPaisLoc )
lLocaliza := .T.
EndIf
UTCControl(cVersion, cRoutine)
If ValType(FWLoadModel(cRoutine)) <> "NIL"
oUTCTool:SetProgram(cRoutine)
FWMVCEventGeneric():InstallEvent(oUTCTool) //installs the Class UTCClass on all models
FWMVCEventGeneric():InstallButton({|| oUTCTool:SetNegative()},"Negative Test") //installs the button
&(cRoutine +'()') //Run the routine
FWMVCEventGeneric():UninstallEvent() //uninstall class
FWMVCEventGeneric():UninstallButton() //uninstall class
Else
Alert("It is not MVC routine")
EndIf
EndIf
EndDo
Else
UTCControl(cVersion, cRoutine)
cRoutine := "_AUTO_"
oUTCTool:SetAuto(.T.)
oUTCTool:SetProgram(cRoutine)
FWMVCEventGeneric():InstallEvent(oUTCTool) //installs the Class UTCClass on all models
FWMVCEventGeneric():InstallButton({|| oUTCTool:SetNegative()},"Negative Test") //installs the button
EndIf
Return
//-------------------------------------------------------------------
/*/{Protheus.doc} BrowseDef
Browse definition
@author Andrews Egas
@since 05/04/2018
@version MA3 - Russia
/*/
//-------------------------------------------------------------------
Static Function ToolBrowseDef() //the name must be different
Local oBrowse
oBrowse := FWLoadBrw(cRoutine)
If ValType(oBrowse) <> "U"
oBrowse:CMENUDEF := "UTCTOOL" //Change menudef to call UTCTOLL in stead of cRoutine menudef
Else
oBrowse := .F.
EndIf
Return oBrowse
//-------------------------------------------------------------------
/*/{Protheus.doc} MenuDef
Menu definition
@author Andrews Egas
@since 05/04/2018
@version MA3 - Russia
/*/
//-------------------------------------------------------------------
Static Function MenuDef()
Local aRotina as array
If lLocaliza //here we need to call in a different way
aRotina := FWLoadMenuDef(cRoutine + cPaisLoc)
Else
aRotina := FWLoadMenuDef(cRoutine)
EndIf
ADD OPTION aRotina TITLE "Parameters" ACTION 'UTCParam()' OPERATION 9 ACCESS 0
ADD OPTION aRotina TITLE "Create Source Code" ACTION 'UTCSources()' OPERATION 9 ACCESS 0
Return aRotina
//-------------------------------------------------------------------
/*/{Protheus.doc} ViewDef
Interface
@author Andrews Egas
@since 05/04/2018
@version 1.0
@project MA3
/*/
//-------------------------------------------------------------------
Static Function ViewDef()
Local oView as object
Local oModel as Object
Local oUTCTool := UTCClass():New()
Conout("UTCViewDef")
If lLocaliza
oView := FWLoadView(cRoutine + cPaisLoc)
Else
oView := FWLoadView(cRoutine)
EndIf
oModel := oView:GetModel()
oModel:InstallEvent("UTCClass",,oUTCTool) //install events to work UTCTOOL while user is "creating the test"
oView:SetModel(oModel)
oUTCTool:SetProgram(cRoutine)
oView:AddUserButton("Negative Test",'TEST',{|| oUTCTool:SetNegative()}) //Negative Test
Return oView
//-------------------------------------------------------------------
/*/{Protheus.doc} GetRoutine
User Interface Function to get the routine
@author Andrews Egas
@since 05/04/2018
@version 1.0
@project MA3
/*/
//-------------------------------------------------------------------
Function GetRoutine(cTitulo)
Local oDlg, oButton, oCombo, cCombo, cGet1:= space(15)
DEFINE MSDIALOG oDlg FROM 0,0 TO 150,250 PIXEL TITLE cTitulo
oGet1:= TGet():New(10,10,{|u| if(PCount()>0,cGet1:=u,cGet1)}, oDlg,;
100,15,'@!',;
,,,,,,.T.,,,,,,,,,,'cGet1')
oButton:=tButton():New(30,10,'Ok',oDlg,{||oDlg:End()},100,15,,,,.T.)
ACTIVATE MSDIALOG oDlg CENTERED
Return cGet1
//-------------------------------------------------------------------
/*/{Protheus.doc} UTCParam
Open parameters (pergunte) for routine
@author Andrews Egas
@since 05/04/2018
@version 1.0
@project MA3
/*/
//-------------------------------------------------------------------
Function UTCParam()
Local cPerg as Character
cPerg := Alltrim(GetRoutine("Pergunte Code"))
Pergunte(cPerg,.T.)
Return
//-------------------------------------------------------------------
/*/{Protheus.doc} UTCSources
Creation of TestCase, Group and Suite
@author Andrews Egas
@since 05/04/2018
@version 1.0
@project MA3
/*/
//-------------------------------------------------------------------
Function UTCSources()
Local nBFile as numeric
Local cFileName as Character
Local cContFile as Character
Local n as numeric
Local lRet as Logical
lRet := .F.
For n:= 1 to 3
If n == 1
cFileName := cRoutine + "TestCase" + IIF(lLocaliza,"_" + cPaisLoc,"")
cContFile := UTCCase(cRoutine,cFileName) //take testcase code to create
Elseif n == 2
cFileName := cRoutine + "TestGroup"
cContFile := UTCGroup(cRoutine,cFileName) //take testgroup code to create
Else
cFileName := cRoutine + "TestSuite"
cContFile := UTCSuite(cRoutine,cFileName) //take testSuite code to create
EndIf
If !File(cFileName + ".PRW") //check if the file already exist
nBFile := FCREATE(cFileName + ".PRW")
FWRITE(nBFile,cContFile)
FCLOSE(nBFile)
lRet := .T.
Else
Alert("Already exist " + cFileName + ".PRW")
EndIf
Next
If lRet
MsgInfo("files have been successfully generated"," Source Codes ")
EndIf
Return
/*/{Protheus.doc} UTCCase
Content of TestCase source code
@author Andrews Egas
@since 31/05/2018
@version 1.0
@project MA3
/*/
Function UTCCase(cRoutine,cFileName)
Local cRet as Character
cRet := ""
cRet += "#INCLUDE 'PROTHEUS.CH'" + CRLF
cRet += "#INCLUDE 'PARMTYPE.CH'" + CRLF
cRet += "#INCLUDE 'FWMVCDEF.CH'" + CRLF + CRLF
cRet += "/*/{Protheus.doc} " + cFileName + CRLF
cRet += "Automated tests" + CRLF
cRet += "@author UTCTOOL" + CRLF
cRet += "@since " + dtoc(dDatabase) + CRLF
cRet += "@version 1.0" + CRLF
cRet += "@see FWDefaultTestSuit , FWDefaultTestCase" + CRLF
cRet += "/*/"+ CRLF
cRet += "CLASS " + cFileName + " from FWDefaultTestCase" + CRLF + CRLF
cRet += "DATA oHelper" + CRLF + CRLF
cRet += "METHOD " + cFileName + "() CONSTRUCTOR" + CRLF
cRet += "METHOD SetUpClass()" + CRLF
cRet += "METHOD " + cRoutine + "_01()" + CRLF + CRLF
cRet += "ENDCLASS" + CRLF + CRLF
cRet += "/*/{Protheus.doc} " + cFileName + ":" + cFileName + "()" + CRLF
cRet += cFileName + " constructor method" + CRLF
cRet += "Instantiation of test cases" + CRLF
cRet += "@author UTCTOOL" + CRLF
cRet += "@since " + dtoc(dDatabase) + CRLF
cRet += "@version 1.0" + CRLF
cRet += "/*/" + CRLF
cRet += "METHOD " + cFileName + "() CLASS " + cFileName + CRLF + CRLF
cRet += "//--------------------------------------" + CRLF
cRet += "// Inherit parent object characteristics" + CRLF
cRet += "//--------------------------------------" + CRLF
cRet += "_Super:FWDefaultTestSuite()" + CRLF + CRLF
cRet += "//--------------------------------------------" + CRLF
cRet += "// Add test methods to the queue" + CRLF
cRet += "//--------------------------------------------" + CRLF
cRet += "::AddTestMethod('" + cRoutine + "_01',, 'auto creation utctool')" + CRLF + CRLF
cRet += "Return" + CRLF + CRLF
cRet += "/*/{Protheus.doc} " + cFileName + ":SetUpClass()" + CRLF
cRet += "Instantiation of FWTestHelper class" + CRLF
cRet += "@author UTCTOOL" + CRLF
cRet += "@since " + dtoc(dDatabase) + CRLF
cRet += "@version 1.0" + CRLF
cRet += "/*/" + CRLF
cRet += "METHOD SetUpClass() CLASS " + cFileName + CRLF + CRLF
cRet += "Local oHelper := FWTestHelper():New()" + CRLF + CRLF
cRet += "Return oHelper" + CRLF + CRLF
cRet += "/*/{Protheus.doc} " + cFileName + ":" + cRoutine + "_01()" + CRLF
cRet += "auto creation" + CRLF
cRet += "@author UTCTOOL" + CRLF
cRet += "@since " + dtoc(dDatabase) + CRLF
cRet += "@version 1.0" + CRLF
cRet += "/*/" + CRLF
cRet += "METHOD " + cRoutine + "_01() CLASS " + cFileName + CRLF + CRLF
If cPaisLoc == 'RUS'
cRet += "Return " + cRoutine + "TC('" + cRoutine + "_01','" + cRoutine + "')" + CRLF + CRLF
cRet += "/*/{Protheus.doc} " + cRoutine + "TC" + CRLF
cRet += "Static function to encapsulate MVC tests with CSV files " + CRLF
cRet += "@param cCase = Identifier string for the test case" + CRLF
cRet += " cModel = MVC Model" + CRLF
cRet += "@return FWTestHelper" + CRLF
cRet += "@author UTCTOOL" + CRLF
cRet += "@since " + dtoc(dDatabase) + CRLF
cRet += "@version 1.0" + CRLF
cRet += "/*/" + CRLF
cRet += "Static Function " + cRoutine + "TC( cCase, cModel)" + CRLF
cRet += "Local oModel := FWLoadModel( cModel )" + CRLF
cRet += "Local oHelper := FWScriptAuto():New()" + CRLF + CRLF
cRet += "oHelper:LoadCSV( cCase )" + CRLF
cRet += "If oHelper:IsOk()" + CRLF
cRet += " oModel:SetOperation( oHelper:nOper )" + CRLF
cRet += " oModel:Activate()" + CRLF + CRLF
cRet += " oHelper:SetModel( oModel )" + CRLF
cRet += " oHelper:SetCommit()" + CRLF
cRet += " oHelper:Activate()" + CRLF
cRet += "Endif" + CRLF + CRLF
cRet += "Return oHelper:GetOHelper()" + CRLF
Else
cRet += "Return oHelper"
EndIf
Return cRet
/*/{Protheus.doc} UTCGroup
Content of TestCase source code
@author Andrews Egas
@since 31/05/2018
@version 1.0
@project MA3
/*/
Function UTCGroup(cRoutine,cFileName)
Local cRet as Character
Local cCase as Character
cRet := ""
cRet += "#INCLUDE 'PROTHEUS.CH'" + CRLF
cRet += "#INCLUDE 'PARMTYPE.CH'" + CRLF + CRLF
cRet += "/*/{Protheus.doc} " + cFileName + CRLF
cRet += "@author UTCTOOL" + CRLF
cRet += "@since " + dtoc(dDatabase) + CRLF
cRet += "@version 1.0" + CRLF
cRet += "/*/" + CRLF
cRet += "CLASS " + cFileName + " FROM FWDefaultTestSuite" + CRLF + CRLF
cRet += "METHOD " + cFileName + "() CONSTRUCTOR" + CRLF + CRLF
cRet += "ENDCLASS" + CRLF + CRLF
cRet += "/*/{Protheus.doc} " + cFileName + ":" + cFileName + "()" + CRLF
cRet += "@author UTCTOOL" + CRLF
cRet += "@since " + dtoc(dDatabase) + CRLF
cRet += "@version 1.0" + CRLF
cRet += "/*/" + CRLF
cRet += "METHOD " + cFileName + "() CLASS " + cFileName + CRLF + CRLF
cRet += "//--------------------------------------" + CRLF
cRet += "// Inherit parent object characteristics" + CRLF
cRet += "//--------------------------------------" + CRLF
cRet += "_Super:FWDefaultTestSuite()" + CRLF + CRLF
cRet += "//---------------------------------------------------" + CRLF
cRet += "// Add the test cases to the group" + CRLF
cRet += "//---------------------------------------------------" + CRLF
cCase := cRoutine + "TestCase" + IIF(lLocaliza,"_"+cPaisLoc,"") //take the testcase name
cRet += "Self:AddTestCase(" + cCase + "():" + cCase + "())" + CRLF + CRLF
cRet += "Return" + CRLF
Return cRet
/*/{Protheus.doc} UTCGroup
Content of TestCase source code
@author Andrews Egas
@since 31/05/2018
@version 1.0
@project MA3
/*/
Function UTCSuite(cRoutine,cFileName)
Local cRet as Character
Local cCompany as Character
Local cBranch as Character
Local cUser as Character
Local cPass as Character
cRet := ""
//values, it must be changed for some parameter
cCompany := "T1"
cBranch := "D MG 01"
cUser := "admin"
cPass := "1234"
//-------------------------
cRet += "#INCLUDE 'PROTHEUS.CH'" + CRLF
cRet += "#INCLUDE 'PARMTYPE.CH'" + CRLF + CRLF
cRet += "/*/{Protheus.doc} " + cFileName + CRLF
cRet += "@author UTCTOOL" + CRLF
cRet += "@since " + dtoc(dDatabase) + CRLF
cRet += "@version 1.0" + CRLF
cRet += "/*/" + CRLF
cRet += "CLASS " + cFileName + " FROM FWDefaultTestSuite" + CRLF + CRLF
cRet += "DATA aParam" + CRLF
cRet += "METHOD " + cFileName + "() CONSTRUCTOR" + CRLF
cRet += "METHOD SetUpSuite()" + CRLF
cRet += "METHOD TearDownSuite()" + CRLF + CRLF
cRet += "ENDCLASS" + CRLF
cRet += "/*/{Protheus.doc} " + cFileName + ":" + cFileName + "()" + CRLF
cRet += "@author UTCTOOL" + CRLF
cRet += "@since " + dtoc(dDatabase) + CRLF
cRet += "@version 1.0" + CRLF
cRet += "/*/" + CRLF
cRet += "METHOD "+ cFileName + "() CLASS " + cFileName + CRLF + CRLF
cRet += "//--------------------------------------"+ CRLF
cRet += "// Inherit parent object characteristics"+ CRLF
cRet += "//--------------------------------------"+ CRLF
cRet += "_Super:FWDefaultTestSuite()"+ CRLF + CRLF
cRet += "//------------------------------------------------------"+ CRLF
cRet += "// List used TestGroups"+ CRLF
cRet += "//------------------------------------------------------"+ CRLF
cRet += "Self:AddTestSuite(" + cRoutine + "TestGroup():" + cRoutine + "TestGroup()) " + CRLF + CRLF
cRet += "Return" + CRLF + CRLF
cRet += "/*/{Protheus.doc} " + cFileName + ":SetUpSuite()" + CRLF
cRet += "@author UTCTOOL" + CRLF
cRet += "@since " + dtoc(dDatabase) + CRLF
cRet += "@version 1.0" + CRLF
cRet += "/*/" + CRLF
cRet += "METHOD SetUpSuite() CLASS " + cFileName + CRLF
cRet += "Local oHelper := FWTestHelper():New()" + CRLF
cRet += "Local cIniEmp := GetSrvProfString('ADVPR_EMP','"+ cCompany +"') //company" + CRLF
cRet += "Local cIniFil := GetSrvProfString('ADVPR_FIL','" + cBranch + "') //branch" + CRLF
cRet += "Local cIniUser := GetSrvProfString('ADVPR_USER','"+ cUser +"') //user" + CRLF
cRet += "Local cIniPass := GetSrvProfString('ADVPR_PASSWORD','" + cPass + "') //password" + CRLF + CRLF
cRet += "//-------------------------------------" + CRLF
cRet += "// Prepare testing environment" + CRLF
cRet += "//-------------------------------------" + CRLF
cRet += "oHelper:UTOpenFilial(cIniEmp,cIniFil,Nil,Nil,cIniUser,cIniPass)" + CRLF
cRet += "//-----------------------------------------" + CRLF
cRet += "// Parametrization setup" + CRLF
cRet += "//-----------------------------------------" + CRLF
cRet += "//oHelper:UTSetParam('MV_CTBCUBE' , '1', .T.)" + CRLF + CRLF
cRet += "//-------------------------------------" + CRLF
cRet += "// Activate auxiliary class" + CRLF
cRet += "//-------------------------------------" + CRLF
cRet += "oHelper:Activate()" + CRLF
cRet += "oHelper:UTLoadData( .T., ::aParam )" + CRLF
cRet += "Return oHelper" + CRLF + CRLF
cRet += "/*/{Protheus.doc} " + cFileName + ":TearDownSuite()" + CRLF
cRet += "@author UTCTOOL" + CRLF
cRet += "@since " + dtoc(dDatabase) + CRLF
cRet += "@version 1.0" + CRLF
cRet += "/*/" + CRLF
cRet += "METHOD TearDownSuite() CLASS " + cFileName + CRLF
cRet += "Local oHelper := FWTestHelper():New()" + CRLF + CRLF
cRet += "//----------------------------------------" + CRLF
cRet += "// Restore system default parameterization" + CRLF
cRet += "//----------------------------------------" + CRLF
cRet += "oHelper:UTRestParam(::aParam)" + CRLF
cRet += "//----------------------" + CRLF
cRet += "// Close the environment" + CRLF
cRet += "//----------------------" + CRLF
cRet += "oHelper:UTCloseFilial()" + CRLF
cRet += "Return oHelper" + CRLF
Return cRet
// Russia_R5
/*/{Protheus.doc} UTCHttpVersion
Checking version of UTCTOOL
@author Andrews Egas
@since 16/10/2018
@version 1.0
@project MA3
/*/
Static Function UTCHttpVersion(cVersion)
Local cRetGet
Local cInfo as Character
Local aInfo as array
Local n as numeric
cInfo := ""
cRetGet := HttpGet('https://github.com/andrewsegas/docs/blob/master/utcversion.txt')
If ValType(cRetGet) == 'C'
cInfo := SubStr(cRetGet,at("#utcversionation#",cRetGet)+17)
cInfo := SubStr(cInfo,1,at("#\utcversionation#",cInfo)-1)
aInfo := StrTokArr2(cInfo,"::")
If cVersion <> aInfo[1]
cInfo := "Você esta usando a versão: " + cVersion + CRLF
cInfo += "Ultima versão do UTCTOOL: " + aInfo[1] + CRLF + CRLF
For n := 2 to Len(aInfo)
cInfo += decodeUtf8(aInfo[n]) + CRLF
Next
cInfo += CRLF + "Atualizão disponivel no link: "+ CRLF +"https://github.com/andrewsegas/UTCTOOL"
MsgInfo(cInfo,"Oi, UTCTOOL tem atualização")
EndIf
EndIf
Return
/*/{Protheus.doc} UTCCkBox
Check box to control which file the user wants
@author Andrews Egas
@since 22/11/2018
@version 1.0
@project MA3
/*/
Function UTCCkBox()
Local oDlg, oButton, oCheck1, oCheck2, oCheck3, oCheck4, oCheck5
Local aCheck := Array(6,.F.) //1-TestCase.PRW, 2- TestGroup.PRW. 3- TestSuite.PRW. 4- Kanoah, 5- TestCase TIR python, 6- Template.CSV
DEFINE DIALOG oDlg TITLE "Arquivos desejados" FROM 180,180 TO 350,450 PIXEL
oCheck1 := TCheckBox():New(05,05,'TestCase PRW', {||aCheck[1]},oDlg,100,210,, {|| aCheck[1] := !aCheck[1]},,,,,,.T.,,,)
oCheck2 := TCheckBox():New(15,05,'TestGroup/Suite PRW', {||aCheck[2]},oDlg,100,210,, {|| aCheck[2] := !aCheck[2]},,,,,,.T.,,,)
oCheck3 := TCheckBox():New(25,05,'Descritivo Kanoah', {||aCheck[3]},oDlg,100,210,, {|| aCheck[3] := !aCheck[3]},,,,,,.T.,,,)
oCheck4 := TCheckBox():New(35,05,'TestCase TIR Python', {||aCheck[4]},oDlg,100,210,, {|| aCheck[4] := !aCheck[4]},,,,,,.T.,,,)
oCheck5 := TCheckBox():New(45,05,'Template CSV', {||aCheck[5]},oDlg,100,210,, {|| aCheck[5] := !aCheck[5]},,,,,,.T.,,,)
oCheck6 := TCheckBox():New(55,05,'Rotina automatica', {||aCheck[6]},oDlg,100,210,, {|| aCheck[6] := !aCheck[6]},,,,,,.T.,,,)
oButton:=tButton():New(65,10,'Ok',oDlg,{||oDlg:End()},100,15,,,,.T.)
ACTIVATE DIALOG oDlg CENTERED
Return aCheck
/*/{Protheus.doc} UTCcontrol
UTCTOOL Control
@author Andrews Egas
@since 10/07/2019
@version 1.0
@project MA3
/*/
Function UTCcontrol(cFunction, cRoutine)
Local aHeaders := Nil
Local cAddress := "http://metrics.engpro.totvs.com.br/write?db=utctool&u=utctool&p=pmgkjTHd7uZ2eTuR"
Local cUsrNme := ""
Local cData := ""
Default cFunction := ''
If !Empty(cFunction)
aHeaders := {"Content-Type: plain/text"}
cUsrNme := LogUserName()//SafeMacro("LogUserName()","unknow")
//cData := InfluxLine("routine_access", { {"routine", cFunction},{"userName", cUsrNme} }, {{"value", 1}}, "FwTimestamp(4)", "unknow")
cData := InfluxLine("routine_access", { {"routine", cRoutine},{"userName", cUsrNme} }, {{"value", 1}}, FwTimestamp(4), "unknow")
//cData := "UTCTOOL"
If !Empty(cData)
//StartJob("HttpPost", &("GetEnvServer()"), .F., cAddress, NIL, cData, 30, aHeaders)
EndIf
aSize(aHeaders,0)
aHeaders := Nil
EndIf
Return .T.
/*/{Protheus.doc} UTCcontrol
UTCTOOL Control
@author Andrews Egas
@since 10/07/2019
@version 1.0
@project MA3
/*/
Static Function InfluxLine(cMeasurement, aTagSet, aFieldSet, cTimeStamp, cDefault)
Local cLine := InfluxEscape(cMeasurement)
Local cKey := ""
Local cVal := ""
Local nI := 0
Default aTagSet := {}
Default cDefault := ""
For nI := 1 To Len(aTagSet)
cKey := InfluxEscape(aTagSet[nI][1])
If aTagSet[nI][2] != NIL
cVal := InfluxEscape(aTagSet[nI][2])
Else
cVal := InfluxEscape(cDefault)
EndIf
cLine += "," + cKey + "=" + cVal
Next nI
cLine += " "
For nI := 1 To Len(aFieldSet)
cKey := InfluxEscape(aFieldSet[nI][1])
If aFieldSet[nI][2] != NIL
cVal := InfluxEscape(aFieldSet[nI][2])
Else
cVal := InfluxEscape(cDefault)
EndIf
If nI == 1
cLine += cKey + "=" + cVal
Else
cLine += "," + cKey + "=" + cVal
EndIf
Next nI
If cTimeStamp != NIL
cLine += " " + PadR(cTimeStamp, 19, "0")
EndIf
Return cLine
Static Function InfluxEscape(cString)
cString := cVAltochar(cString)
cReturn := cString
cReturn := StrTran(cReturn, " ", "\ ")
cReturn := StrTran(cReturn, ",", "\,")
cReturn := StrTran(cReturn, '"', '\"f')
Return cReturn
/*/{Protheus.doc} u_AfterLogin
UTCTOOL install when we have utctool=1 in appserver.ini
@author Andrews Egas
@since 17/07/2019
@version 1.0
@project MA3
/*/
User Function AfterLogin()
Local cId := ParamIXB[1]
Local cNome := ParamIXB[2]
If GetSrvProfString("utctool","0") == "1"
UTCTool(.T.)
Conout("Usuário "+ cId + " - " + Alltrim(cNome)+" Utilizando UTCTOOL "+ Time())
EndIf
Return