-
Notifications
You must be signed in to change notification settings - Fork 1
/
DemoStockCls.xml
83 lines (71 loc) · 2.05 KB
/
DemoStockCls.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="IRIS for Windows (x86-64) 2018.1.1 (Build 522U)" ts="2018-04-05 15:07:10">
<Class name="Demo.Stock">
<Super>%Persistent</Super>
<TimeChanged>64741,35080.080605</TimeChanged>
<TimeCreated>64685,57614.490676</TimeCreated>
<Property name="TransDate">
<Type>%Date</Type>
</Property>
<Index name="TDX">
<Properties>TransDate</Properties>
</Index>
<Property name="StockOpen">
<Type>%Numeric</Type>
<Parameter name="SCALE" value="4"/>
</Property>
<Property name="High">
<Type>%Numeric</Type>
<Parameter name="SCALE" value="4"/>
</Property>
<Property name="Low">
<Type>%Numeric</Type>
<Parameter name="SCALE" value="4"/>
</Property>
<Property name="StockClose">
<Type>%Numeric</Type>
<Parameter name="SCALE" value="4"/>
</Property>
<Property name="Volume">
<Type>%Integer</Type>
</Property>
<Property name="Name">
<Type>%String</Type>
</Property>
<Index name="NameX">
<Type>bitmap</Type>
<Properties>Name</Properties>
</Index>
<Method name="LoadData">
<ClassMethod>1</ClassMethod>
<FormalSpec>FileLocation:%String="/tmp/irisupdate/all_stocks_1yr.csv"</FormalSpec>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[
set status = $$$OK
try {
set stream = ##class(%Stream.FileCharacter).%New()
set sc = stream.LinkToFile(FileLocation)
set line = stream.ReadLine() //don't use headers for anything
while 'stream.AtEnd {
set line = stream.ReadLine()
set stock = ##class(Demo.Stock).%New()
set stock.TransDate = $zdateh($piece(line,",",1))
set stock.StockOpen = $piece(line,",",2)
set stock.High = $piece(line,",",3)
set stock.Low = $piece(line,",",4)
set stock.StockClose = $piece(line,",",5)
set stock.Volume = $piece(line,",",6)
set stock.Name = $zstrip($piece(line,",",7),"*C")
set status = stock.%Save()
}
} catch sc {
write "In Catch block",!
write "error code: ",sc.Code,!
write "error location: ",sc.Location,!
write "error data:",$LISTGET(sc.Data,2),!
}
quit status
]]></Implementation>
</Method>
</Class>
</Export>