1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
- <Export generator =" Cache" version =" 25" >
2
+ <Export generator =" Cache" version =" 25" zv = " Cache for Windows (x86-64) 2016.1 (Build 656U) " ts = " 2016-07-25 16:07:12 " >
3
3
<Class name =" CacheUpdater.Task" >
4
4
<Super >%SYS.Task.Definition</Super >
5
+ <TimeChanged >64121,39819.499352</TimeChanged >
5
6
<TimeCreated >63603,52252.541311</TimeCreated >
6
7
7
8
<Parameter name =" TaskName" >
@@ -164,19 +165,27 @@ Download list of files on https://raw.githubusercontent.com/ server.<br>
164
165
Set st = $$$OK
165
166
166
167
For i = 1:1:Links.Count() {
167
- Set streq = Request.Get($e(Links.GetAt(i),35,*)) // Remove "https://raw.githubusercontent.com/" from URL.
168
+ Set link = Links.GetAt(i)
169
+ Set streq = Request.Get($e(link,35,*)) // Remove "https://raw.githubusercontent.com/" from URL.
168
170
Set:$$$ISERR(streq) st=$$$ADDSC(st, streq)
169
171
170
172
Set binarystream = Request.HttpResponse.Data
171
173
Do binarystream.Rewind() // just in case
172
174
173
175
Set stream=##class(%GlobalCharacterStream).%New() //translating binary stream into character stream
174
176
While 'binarystream.AtEnd {
175
- Do stream.Write (binarystream.Read ())
177
+ Do stream.WriteLine (binarystream.ReadLine ())
176
178
}
177
179
Do stream.Rewind()
178
180
179
- Set stload = $system.OBJ.LoadStream(stream,"",.error,.items,,,,"UTF8")
181
+
182
+ Set strload = ""
183
+ If ..IsUDLFormat(link) {
184
+ Set stload = ..LoadUDLFile(stream, link)
185
+ }
186
+ Else {
187
+ Set stload = $system.OBJ.LoadStream(stream,"",.error,.items,,,,"UTF8")
188
+ }
180
189
181
190
Set:$$$ISERR(stload) st=$$$ADDSC(st, stload)
182
191
Merge Items = items // Does not overwrite existing array keys: Items(itemname)=""
@@ -187,6 +196,182 @@ Download list of files on https://raw.githubusercontent.com/ server.<br>
187
196
]]> </Implementation >
188
197
</Method >
189
198
199
+ <Method name =" LoadUDLFile" >
200
+ <Description ><![CDATA[
201
+ Imports the file in UDL file in the project
202
+ <b>contentStream</b> - the stream which contains the source code in udl format.<br>
203
+ <b>url</b> - the url where the file is located in the web.<br>]]> </Description >
204
+ <ClassMethod >1</ClassMethod >
205
+ <FormalSpec >contentStream:%GlobalCharacterStream,url:%String</FormalSpec >
206
+ <ReturnType >%Status</ReturnType >
207
+ <Implementation ><![CDATA[
208
+ Set st = $$$OK
209
+ Set ext = ..GetExt(url)
210
+ If ext = "cls" {
211
+ Set st = ..CreateClass(contentStream, url)
212
+ }
213
+ Elseif ext = "dfi" {
214
+ Set st = ..CreateDFI(contentStream, url)
215
+ }
216
+ Else {
217
+ Set st = ..CreateOther(contentStream, url)
218
+ }
219
+
220
+ Return st
221
+ ]]> </Implementation >
222
+ </Method >
223
+
224
+ <Method name =" CreateClass" >
225
+ <Description ><![CDATA[
226
+ Creates and imports the class into the project from stream
227
+ <b>contentStream</b> - the stream which contains the source code in udl format.<br>
228
+ <b>url</b> - the url where the file is located in the web.<br>]]> </Description >
229
+ <ClassMethod >1</ClassMethod >
230
+ <FormalSpec >contentStream:%CharacterStream,url:%String</FormalSpec >
231
+ <ReturnType >%Status</ReturnType >
232
+ <Implementation ><![CDATA[
233
+ Set st = ..GetClassName(url, .className)
234
+ Do contentStream.Rewind()
235
+ Return:$$$ISERR(st) st
236
+
237
+ If '..IsClassExist(className) {
238
+ Set clsDef = ##class(%Dictionary.ClassDefinition).%New()
239
+ Set clsDef.Name = className
240
+ Set st = clsDef.%Save()
241
+ Return:$$$ISERR(st) st
242
+ }
243
+
244
+
245
+ Set namespace = $namespace
246
+
247
+ Set st = ##class(%Compiler.UDL.TextServices).SetTextFromStream(namespace, className, contentStream)
248
+ Return st
249
+ ]]> </Implementation >
250
+ </Method >
251
+
252
+ <Method name =" CreateDFI" >
253
+ <Description ><![CDATA[
254
+ Creates and imports the dfi file into the project from stream
255
+ <b>contentStream</b> - the stream which contains the source code in udl format.<br>
256
+ <b>url</b> - the url where the file is located in the web.<br>]]> </Description >
257
+ <ClassMethod >1</ClassMethod >
258
+ <FormalSpec >contentStream:%CharacterStream,url:%String</FormalSpec >
259
+ <ReturnType >%Status</ReturnType >
260
+ <Implementation ><![CDATA[
261
+ Set st = $$$OK
262
+ Try {
263
+ Set st = ..GetDFIName(url, .name)
264
+ Return:$$$ISERR(st) st
265
+
266
+ Set tDoc = ##class(%DeepSee.UI.FolderItemDocument).%New(name)
267
+ Set st = tDoc.ImportFromXML(contentStream)
268
+ Return:$$$ISERR(st) st
269
+
270
+ Set st = tDoc.Save()
271
+ Return:$$$ISERR(st) st
272
+ } Catch e {
273
+ Set st = e.AsStatus()
274
+ }
275
+ Return st
276
+ ]]> </Implementation >
277
+ </Method >
278
+
279
+ <Method name =" IsClassExist" >
280
+ <Description ><![CDATA[
281
+ Checks whether the class exists
282
+ <b>className</b> - name of the class.<br>]]> </Description >
283
+ <ClassMethod >1</ClassMethod >
284
+ <FormalSpec >className:%String</FormalSpec >
285
+ <ReturnType >%Boolean</ReturnType >
286
+ <Implementation ><![CDATA[
287
+ Set query = "SELECT TOP 1 COUNT(ID) FROM %Dictionary.ClassDefinition WHERE ID = ?"
288
+ Set statement = ##class(%SQL.Statement).%New()
289
+ Set st = statement.%Prepare(query)
290
+ Set rset = statement.%Execute(className)
291
+ If rset.%Next() && (rset.%ROWCOUNT > 0) {
292
+ Return 1
293
+ }
294
+ Return 0
295
+ ]]> </Implementation >
296
+ </Method >
297
+
298
+ <Method name =" GetClassName" >
299
+ <Description ><![CDATA[
300
+ Gets the name of the class by url
301
+ <b>url</b> - the url where the file is located in the web.<br>
302
+ <b>name</b> - simply a variable which is injected by a class name<br>]]> </Description >
303
+ <ClassMethod >1</ClassMethod >
304
+ <FormalSpec ><![CDATA[ url:%String,&name]]> </FormalSpec >
305
+ <ReturnType >%Status</ReturnType >
306
+ <Implementation ><![CDATA[
307
+ Set formattedUrl = $Translate($Translate(url, "\", "/"), "/", ".")
308
+ Set name = $Replace($Extract(formattedUrl, $Find(formattedUrl, "cls."), *), ".cls", "")
309
+ Return $$$OK
310
+ ]]> </Implementation >
311
+ </Method >
312
+
313
+ <Method name =" GetDFIName" >
314
+ <Description ><![CDATA[
315
+ Gets the name of the dfi file by url
316
+ <b>url</b> - the url where the file is located in the web.<br>
317
+ <b>name</b> - simply a variable which is injected by a dfi file name<br>]]> </Description >
318
+ <ClassMethod >1</ClassMethod >
319
+ <FormalSpec ><![CDATA[ url:%String,&name]]> </FormalSpec >
320
+ <ReturnType >%Status</ReturnType >
321
+ <Implementation ><![CDATA[
322
+ Set formattedUrl = $Translate($Translate(url, "\", "/"), "/", ".")
323
+ Set name = $Replace($Extract(formattedUrl, $Find(formattedUrl, "dfi."), *), "%20", " ")
324
+ Return $$$OK
325
+ ]]> </Implementation >
326
+ </Method >
327
+
328
+ <Method name =" CreateOther" >
329
+ <Description ><![CDATA[
330
+ Creates and imports other files into the project from stream
331
+ <b>contentStream</b> - the stream which contains the source code in udl format.<br>
332
+ <b>url</b> - the url where the file is located in the web.<br>]]> </Description >
333
+ <ClassMethod >1</ClassMethod >
334
+ <FormalSpec >contentStream:%GlobalCharacterStream,url:%String</FormalSpec >
335
+ <ReturnType >%Status</ReturnType >
336
+ <Implementation ><![CDATA[
337
+ Set internalName = $Piece(url, "/", *)
338
+
339
+ Set rtn = ##class(%Routine).%New(internalName)
340
+ Set status = rtn.CopyFrom(contentStream)
341
+ Return:$$$ISERR(status) status
342
+
343
+ Set status = rtn.Save()
344
+ Return:$$$ISERR(status) status
345
+
346
+ Set status = rtn.Compile()
347
+ Return status
348
+ ]]> </Implementation >
349
+ </Method >
350
+
351
+ <Method name =" GetExt" >
352
+ <Description ><![CDATA[
353
+ Get extension of the file by url
354
+ <b>url</b> - the url where the file is located in the web.<br>]]> </Description >
355
+ <ClassMethod >1</ClassMethod >
356
+ <FormalSpec >url:%String</FormalSpec >
357
+ <ReturnType >%String</ReturnType >
358
+ <Implementation ><![CDATA[ Return $ZConvert($Piece(url, ".", *), "l")
359
+ ]]> </Implementation >
360
+ </Method >
361
+
362
+ <Method name =" IsUDLFormat" >
363
+ <Description ><![CDATA[
364
+ Checks whether the url contains a file in udl format
365
+ <b>url</b> - the url where the file is located in the web.<br>]]> </Description >
366
+ <ClassMethod >1</ClassMethod >
367
+ <FormalSpec >url:%String</FormalSpec >
368
+ <ReturnType >%Boolean</ReturnType >
369
+ <Implementation ><![CDATA[
370
+ Set extensions = "cls,mac,int,inc,dfi"
371
+ Return $Find(extensions, $Piece(url, ".", *))
372
+ ]]> </Implementation >
373
+ </Method >
374
+
190
375
<Method name =" CreateRequest" >
191
376
<ClassMethod >1</ClassMethod >
192
377
<FormalSpec >Username:%String,Password:%String</FormalSpec >
0 commit comments