Eduard Lebedyuk · Mar 2, 2018 go to post

Not directly. You receive the whole response and can process it line by line, terminating wherever you wish.

I'd recommend using WebSockets if possible.

Eduard Lebedyuk · Mar 2, 2018 go to post

Default namespace has a priority over script namespace. Remove user's default namespace.

Added as an answer.

Eduard Lebedyuk · Mar 2, 2018 go to post

Default namespace has a priority over script namespace. Remove user's default namespace.

Eduard Lebedyuk · Mar 1, 2018 go to post

You need to press "View other code" button (or Ctrl+Shift+V) and post zMypropertyGetSwizzled routine.

Eduard Lebedyuk · Mar 1, 2018 go to post

Please post this line of code (Open myClass -> See other code -> zMypropertyGetSwizzled routine, third line) :

zMypropertyGetSwizzled+3^myClass.2

Eduard Lebedyuk · Mar 1, 2018 go to post

Hello, everyone!

It's my first big webinar in English so I'm starting with the topic I'm familiar with  - REST APIs.

The main goal of this webinar is to  discuss REST APIs and how can we design them so they can evolve and grow without causing too much problems for everyone involved. Versioning, software layers separation, Broker separation - that kind of thing,

I would also like discuss some common challenges and how can we bypass them.

Then the tooling for the whole development life-cycle (dev-debug-test-document) would be presented.

And finally I'll show some REST API examples. Well, mainly UI clients for these APIs.

If you have a question about REST that sounds more or less relevant to the topics above - please post it here (or mail directly to me), I'll try to cover it too if possible.

Eduard Lebedyuk · Feb 27, 2018 go to post

First of all, you're calling class methods, so you don't need a file object. Instead of:

s file=##class(%File).%New()
d file.CopyFile(File,ArchivePath)
d file.Delete(File)

It's enough to write:

do ##class(%File).CopyFile(File,ArchivePath)
do ##class(%File).Delete(File)

Other things to consider:

  • You have file and File variables. That makes understanding what's going on more difficult than it should be.
  • Using full command names (set instead of s, do instead of d, etc.)

But, %File class has a method specifically for moving, so it's better to call it:

set Success = ##class(%File).Rename(File, ArchivePath, .RetCode)
write:(Success=$$$NO) "Rename failed with code: " _ RetCode
Eduard Lebedyuk · Feb 23, 2018 go to post

That's not a system macro.

Try searching (Edit -> Search in Files) for: '#define Fza' in'*.inc'

That should find you a macro definition.

Or you can check int code (Ctrl + Shift + V) to see what it compiled into.

Eduard Lebedyuk · Feb 22, 2018 go to post

That's probably unrelated problem?

Check application error log (SMP >  System Operation > System Logs> Application Error Log)?

Eduard Lebedyuk · Feb 21, 2018 go to post

Also can be used in class queries:

/// do ##class(class).subclassQueryFunc(baseclass).%Display()
Query subclassQuery(base) As %SQLQuery
{
SELECT 
  c.Name
FROM %Dictionary.ClassDefinitionQuery_SubclassOf(:base)
}
Eduard Lebedyuk · Feb 21, 2018 go to post

Here's a sample task.

tl;dr:

  • Should extend %SYS.Task.Definition
  • Parameter TaskName = "TASK NAME";
  • OnTask method is called once every time the task is run
  • Class properties become task parameters
Eduard Lebedyuk · Feb 21, 2018 go to post

I have encountered the exact same problem but was unable to reproduce it. In my case recompilation helped. Try to  recompile SALUTIC.MyUsers.BO.UsersREST. Please contact the WRC if you can reproduce this behavior.

Eduard Lebedyuk · Feb 21, 2018 go to post

If you're trying to access data across several namespaces of the same instance you don't need xDBC.  Use either mappings or queries with local cache to move data.

Eduard Lebedyuk · Feb 20, 2018 go to post

Well, in this case you definitely don't need to read from stream at all. You can save the stream in the database (or file using %Stream.FileCharacter)) and send it to the client later:

set stream = ##class(%Stream.GlobalCharacter).%New()
set sc = stream.CopyFromAndSave(%request.Content)
set oid = stream.%Oid()
kill (oid)
set stream = ##class(%Stream.GlobalCharacter).%Open(oid)
do stream.OutputToDevice()

Streams can be class properties too.

Eduard Lebedyuk · Feb 20, 2018 go to post

What do you need to do? Many actions can be either performed with streams or there's a workaround.

But ultimately yes, if the stream is beyond max string length (3641144 symbols) you'll need to process it chunk by chunk.

Eduard Lebedyuk · Feb 20, 2018 go to post

How did you determine that problem happens directly at allocation (setting the property)?

Eduard Lebedyuk · Feb 20, 2018 go to post

Try:

%request.Content.Data.Read($$$MaxStringLength)

If you have json you can cast it into object without reading the stream in user code:

Set obj = {}.%FromJSON(%request.Content.Data)

Same for XML (you can get it from Stream or even from url).

Eduard Lebedyuk · Feb 20, 2018 go to post

catch-scope is not seems to be reached

Have you enabled logging?

Error occurs on saving incorrect data and not on setting the data. Saving also does not throw an exception, only returns an error status.

Also you need to quit something:

#dim sc As %Status = $$$OK

try
{
  set myClass= ##class(SomeClass).%New()
  myClass.Date =  Sourcedata.Date  //Sourcedata send us wrong format to that datefield.
  set sc = myClass.%Save() // Error occurs on save.
} catch ex {
  set sc = ex.AsStatus()
  set errMsg = "Error in this method "  _ $System.Status.GetOneStatusText(sc)
  $$$LOGERROR(errMsg)
}
quit sc

On a side note, you're using 3 different naming conventions for variables in your snippet:

  • tHungarianNotation
  • CapitalCase
  • lowercase

It would probably be better to decide on one notation.