13
13
/*/
14
14
CLASS UTCClass FROM FwModelEvent
15
15
DATA _cProgram as char
16
+ DATA _lAuto as logical
16
17
DATA cNegField as char
17
18
DATA cNegVal as char
18
19
DATA Def0 as Array
@@ -43,6 +44,7 @@ CLASS UTCClass FROM FwModelEvent
43
44
44
45
METHOD New() constructor
45
46
METHOD SetProgram()
47
+ METHOD SetAuto()
46
48
//Padroes do Observer
47
49
METHOD DeActivate()
48
50
METHOD Activate()
@@ -64,6 +66,7 @@ CLASS UTCClass FROM FwModelEvent
64
66
METHOD GenerateKanoah()
65
67
METHOD FieldTypeStr()
66
68
METHOD GenerateTIR()
69
+ METHOD GenerateRotAuto()
67
70
METHOD UtcFinalGenerate()
68
71
69
72
END CLASS
@@ -76,6 +79,7 @@ constructor
76
79
/*/
77
80
METHOD new() class UTCClASS
78
81
::_cProgram := ""
82
+ ::_lAuto := .F.
79
83
80
84
//Def0
81
85
::Def0 := Array(3)
@@ -153,6 +157,19 @@ Method SetProgram(cProgram) Class UTCClass
153
157
154
158
Return
155
159
160
+ /*/{Protheus.doc} setProgram
161
+ Set if is automatic from .INI
162
+
163
+ @author Andrews.Egas
164
+ @since 17/07/2018
165
+ @version 1.0
166
+ /*/
167
+ Method SetAuto(lAuto) Class UTCClass
168
+
169
+ ::_lAuto := lAuto
170
+
171
+ Return
172
+
156
173
/*/{Protheus.doc} Activate
157
174
Model Activate to start variables
158
175
@author Andrews.Egas
@@ -450,7 +467,7 @@ If ::DEF_MASTER <> NIL //If it runs before it open the view will be .F.
450
467
If oSubModel:GetModel():GetIdField(aKey[n],@oModelOw) > 0
451
468
xValue := oModelOw:GetValue(aKey[n],nLine)
452
469
Else
453
- xValue := oSubModel:GetValue(aKey[n],nLine)
470
+ Loop
454
471
EndIf
455
472
456
473
If ValType(xValue) == "D"
@@ -476,7 +493,9 @@ If ::DEF_MASTER <> NIL //If it runs before it open the view will be .F.
476
493
477
494
Next
478
495
479
- ::UpdCheckPoint(ctable,cQuery,aKey,aValues,AllTrim(str(nLine)))
496
+ If !Empty(aValues) .And. !Empty(aValues[1])
497
+ ::UpdCheckPoint(ctable,cQuery,aKey,aValues,AllTrim(str(nLine)))
498
+ EndIf
480
499
EndIf
481
500
conout(" GRID POS ")
482
501
@@ -755,10 +774,10 @@ EndIf
755
774
cFileName := ::_cProgram
756
775
757
776
// CSV Creation
758
- If !File(cFileName + "_" + cName + ".CSV") //check if the file already exist, and create next one
759
- nBFile := FCREATE(cFileName + "_" + cName + ".CSV")
777
+ If !File("\UTCTOOL\" + cFileName + "_" + cName + ".CSV") //check if the file already exist, and create next one
778
+ nBFile := FCREATE("\UTCTOOL\" + cFileName + "_" + cName + ".CSV")
760
779
Else
761
- nBFile := FCREATE(cFileName + "_" + cName + "_002"+".CSV")//changehere
780
+ nBFile := FCREATE("\UTCTOOL\" + cFileName + "_" + cName + "_002"+".CSV")//changehere
762
781
EndIf
763
782
764
783
If nBFile == -1 //check if was possible to crate the file
@@ -1114,10 +1133,10 @@ lRet := .T.
1114
1133
cFileName := ::_cProgram
1115
1134
1116
1135
// PRW Creation
1117
- If !File(cFileName + "_" + cName + ".PRW") //check if the file already exist, and create next one
1118
- nBFile := FCREATE(cFileName + "_" + cName + ".PRW")
1136
+ If !File("\UTCTOOL\" + cFileName + "_" + cName + ".PRW") //check if the file already exist, and create next one
1137
+ nBFile := FCREATE("\UTCTOOL\" + cFileName + "_" + cName + ".PRW")
1119
1138
Else
1120
- nBFile := FCREATE(cFileName + "_" + cName + "_002"+".PRW")//changehere
1139
+ nBFile := FCREATE("\UTCTOOL\" + cFileName + "_" + cName + "_002"+".PRW")//changehere
1121
1140
EndIf
1122
1141
1123
1142
If nBFile == -1 //check if was possible to crate the file
@@ -1261,10 +1280,10 @@ cFileName := ::_cProgram
1261
1280
1262
1281
1263
1282
// Kanoah Creation
1264
- If !File(cFileName + "_" + cName + ".TXT") //check if the file already exist, and create next one
1265
- nBFile := FCREATE(cFileName + "_" + cName + ".TXT")
1283
+ If !File("\UTCTOOL\" + cFileName + "_" + cName + ".TXT") //check if the file already exist, and create next one
1284
+ nBFile := FCREATE("\UTCTOOL\" + cFileName + "_" + cName + ".TXT")
1266
1285
Else
1267
- nBFile := FCREATE(cFileName + "_" + cName + "_002"+".TXT")//changehere
1286
+ nBFile := FCREATE("\UTCTOOL\" + cFileName + "_" + cName + "_002"+".TXT")//changehere
1268
1287
EndIf
1269
1288
1270
1289
If nBFile == -1 //check if was possible to crate the file
@@ -1387,10 +1406,10 @@ lRet := .T.
1387
1406
cFileName := ::_cProgram
1388
1407
1389
1408
// Kanoah Creation
1390
- If !File(cFileName + "_" + cName + ".py") //check if the file already exist, and create next one
1391
- nBFile := FCREATE(cFileName + "_" + cName + ".py")
1409
+ If !File("\UTCTOOL\" + cFileName + "_" + cName + ".py") //check if the file already exist, and create next one
1410
+ nBFile := FCREATE("\UTCTOOL\" + cFileName + "_" + cName + ".py")
1392
1411
Else
1393
- nBFile := FCREATE(cFileName + "_" + cName + "_002"+".py")//changehere
1412
+ nBFile := FCREATE("\UTCTOOL\" + cFileName + "_" + cName + "_002"+".py")//changehere
1394
1413
EndIf
1395
1414
1396
1415
If nBFile == -1 //check if was possible to crate the file
@@ -1518,6 +1537,127 @@ EndIf
1518
1537
1519
1538
Return
1520
1539
1540
+ //-------------------------------------------------------------------
1541
+ /*/{Protheus.doc} GenerateRotAuto
1542
+ generates the PRW file for automatic routines
1543
+
1544
+ @author andrews.egas
1545
+ @since 18/07/2019
1546
+ @version 1.0
1547
+
1548
+ /*/
1549
+ //-------------------------------------------------------------------
1550
+ METHOD GenerateRotAuto(oModel, cName) Class UTCClASS
1551
+ Local lRet as logical
1552
+ Local nBFile as numeric
1553
+ Local cFileName as Character
1554
+ Local cContFile as Character
1555
+ Local n as numeric
1556
+ Local nItem as numeric
1557
+ Local cConteType as Character
1558
+
1559
+ lRet := .T.
1560
+
1561
+ cFileName := ::_cProgram
1562
+
1563
+ // PRW Creation
1564
+ If !File("\UTCTOOL\" +cFileName + "_AUTO_" + cName + ".PRW") //check if the file already exist, and create next one
1565
+ nBFile := FCREATE("\UTCTOOL\" + cFileName + "_AUTO_" + cName + ".PRW")
1566
+ Else
1567
+ nBFile := FCREATE("\UTCTOOL\" + cFileName + "_AUTO_" + cName + "_002"+".PRW")//changehere
1568
+ EndIf
1569
+
1570
+ If nBFile == -1 //check if was possible to crate the file
1571
+ MsgStop('Erro ao criar destino. Ferror = '+str(ferror(),4),'Erro')
1572
+ lRet := .F.
1573
+ Else
1574
+ //variables
1575
+ cContFile :="" //start writing the file
1576
+
1577
+ cContFile += "/*/{Protheus.doc} " + cFileName + "Auto" + cFileName + "_01()" + CRLF
1578
+ cContFile += "auto creation" + CRLF
1579
+ cContFile += "@author UTCTOOL" + CRLF
1580
+ cContFile += "@since " + dtoc(dDatabase) + CRLF
1581
+ cContFile += "@version 1.0" + CRLF
1582
+ cContFile += "/*/" + CRLF
1583
+
1584
+ cContFile += "User Function " + cFileName + "_01()" + CRLF
1585
+ cContFile += "Local dDataBase := cTod('" + dToC(&(::DEF_VARS[3])) +"')" + CRLF
1586
+
1587
+ cContFile += "Local oModel := FWLoadModel('" + cFileName + "')" + CRLF
1588
+
1589
+ //DBSEEK
1590
+ If !Empty(::SEEK[1]) //check if there is SEEK in this test case (Update or delete)
1591
+ cContFile += CRLF
1592
+ cContFile += "dbSelectArea('" + ::SEEK[2] + "')" + CRLF
1593
+ cContFile += "('" + ::SEEK[2] + "')->(DbSetOrder( " + ::SEEK[3] + " ) )" + CRLF
1594
+ cContFile += "('" + ::SEEK[2] + "')->(DbSeek(" + ::SEEK[4] + "))" + CRLF
1595
+ cContFile += CRLF
1596
+ EndIf
1597
+
1598
+ //Feed Variables and Activate
1599
+ cContFile += "oModel:SetOperation(" + ::OPERATION[2] + ")" + CRLF
1600
+ cContFile += "oModel:Activate()" + CRLF + CRLF
1601
+
1602
+
1603
+ //Master
1604
+ If !Empty(::DEF_MASTER[1][2]) //If we don't have Master it is DELETE
1605
+ For n := 1 to Len(::DEF_MASTER)
1606
+ cContFile += CRLF //master Head
1607
+ //master
1608
+ cContFile += "//Start " + ::DEF_MASTER[n][2] + CRLF
1609
+
1610
+ For nItem := 3 to Len(::DEF_MASTER[n])
1611
+ //return the transformation
1612
+ cConteType := ::FieldTypeStr(oModel:GetModel(::DEF_MASTER[n][2]):GetStruct():GetFields(),::DEF_MASTER[n][nItem],::DATA_MASTER[n][nItem])
1613
+ If !Empty(cConteType)
1614
+ cContFile += "oModel:GetModel('" + ::DEF_MASTER[n][2] + "'):SetValue('" + ::DEF_MASTER[n][nItem] + "', " + cConteType + ")" + CRLF
1615
+ EndIf
1616
+ Next
1617
+ Next
1618
+ EndIf
1619
+
1620
+ //Details
1621
+ If !Empty(::DEF_ITEMS[1][2]) //check if we have details in this test
1622
+ For n := 1 to Len(::DEF_ITEMS)
1623
+
1624
+ //validation to check if we need to use addLine (Ex:CNBDETAIL2)
1625
+ If n > 1 .And. Val(substr(::DEF_ITEMS[n][2],Len(::DEF_ITEMS[n][2]),1)) > 1
1626
+ cContFile += CRLF
1627
+ cContFile += "oModel:GetModel('" + ::DATA_ITEMS[n][2] + "'):AddLine()" + CRLF
1628
+ EndIf
1629
+
1630
+ cContFile += CRLF //start Details
1631
+ cContFile += "//Start " + ::DATA_ITEMS[n][2] + CRLF
1632
+
1633
+ For nItem := 3 to Len(::DEF_ITEMS[n])
1634
+ cConteType := ::FieldTypeStr(oModel:GetModel(::DATA_ITEMS[n][2]):GetStruct():GetFields(),::DEF_ITEMS[n][nItem],::DATA_ITEMS[n][nItem])
1635
+ If !Empty(cConteType)
1636
+ cContFile += "oModel:GetModel('" + ::DATA_ITEMS[n][2] + "'):SetValue('" + ::DEF_ITEMS[n][nItem] + "', " + cConteType + ")" + CRLF
1637
+ EndIf
1638
+ Next
1639
+ Next
1640
+ EndIf
1641
+
1642
+ //Commit
1643
+ cContFile += CRLF
1644
+ cContFile += "oModel:CommitData()" + CRLF
1645
+
1646
+ cContFile += "Return " + CRLF
1647
+
1648
+ cContFile += CRLF
1649
+ conout("Criado Auto PRW")
1650
+
1651
+ FWRITE(nBFile,cContFile)
1652
+
1653
+ FCLOSE(nBFile)
1654
+
1655
+ MsgInfo(cFileName + "_AUTO_" + cName + ".PRW successfully generated", 'Test Case')
1656
+ EndIf
1657
+
1658
+ Return
1659
+
1660
+
1521
1661
//-------------------------------------------------------------------
1522
1662
/*/{Protheus.doc} FieldTypeStr
1523
1663
Return the type transformed in string, ex 01/01/2001 returns "CtoD('01/01/2001')"
@@ -1567,12 +1707,32 @@ Return the type transformed in string, ex 01/01/2001 returns "CtoD('01/01/2001')
1567
1707
/*/
1568
1708
//-------------------------------------------------------------------
1569
1709
Method UtcFinalGenerate(oModel) Class UTCClass
1710
+ Local bError := ErrorBlock({|e| MyErr(e)})
1711
+ Local cName := ""
1570
1712
1571
- aCheck := UTCCkBox() //1-TestCase.PRW, 2- Group/Suite.PRW 3- Kanoah, 4- TestCase TIR python, 5- Template.CSV
1572
- cName := Alltrim(GetRoutine("Test Name"))
1713
+ if !EMPTY(oModel:cSource)
1714
+ ::SetProgram(oModel:cSource)
1715
+ EndIf
1716
+
1717
+ If !(::_lAuto)
1718
+ aCheck := UTCCkBox() //1-TestCase.PRW, 2- Group/Suite.PRW 3- Kanoah, 4- TestCase TIR python, 5- Template.CSV
1719
+ cName := Alltrim(GetRoutine("Test Name"))
1720
+ Else
1721
+ If GetSrvProfString("utcfiles","0") <> "0"
1722
+ cfiles := GetSrvProfString("utcfiles","0")
1723
+ aCheck := {"1" $ cfiles , "2" $ cfiles , "3" $ cfiles , "4" $ cfiles , "5" $ cfiles , "6" $ cfiles} //create just TestCase e Kanoah
1724
+ else
1725
+ aCheck := {.T.,.F.,.T.,.F.,.F.,.F.} //create just TestCase e Kanoah
1726
+ EndIf
1727
+
1728
+ cName := "_" + STRTRAN(Time(),":","_")
1729
+ EndIf
1573
1730
1574
1731
If aCheck[1]
1575
- ::GeneratePrw(oModel,cName)
1732
+ // BEGIN SEQUENCE
1733
+ ::GeneratePrw(oModel,cName)
1734
+ // END SEQUENCE
1735
+ // ErrorBlock(bError)
1576
1736
EndIf
1577
1737
If aCheck[2]
1578
1738
UTCSources()
@@ -1586,5 +1746,12 @@ EndIf
1586
1746
If aCheck[5]
1587
1747
::GenerateCsv(cName)
1588
1748
EndIf
1749
+ If aCheck[6]
1750
+ ::GenerateRotAuto(oModel,cName)
1751
+ EndIf
1752
+
1753
+ Return
1589
1754
1590
- Return
1755
+ Static Function MyErr()
1756
+ BREAK
1757
+ Return .T.
0 commit comments