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.NameFROM %Dictionary.ClassDefinitionQuery_SubclassOf(:base)}
Eduard Lebedyuk · Feb 21, 2018 go to post

Here's a sample task.

tl;dr:

  • Should extend %SYS.Task.Definition
  • ParameterTaskName="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.

Eduard Lebedyuk · Feb 20, 2018 go to post

I'd recommend developing a REST API and Web application (you can pack it via Cordova, etc.)?

Even better, you can write a responsive web application and not bother with packers altogether. Unless you need things like camera/gps... a responsive web site is easier to develop and support.

Eduard Lebedyuk · Feb 17, 2018 go to post

Have you modified Import method in your class to show errors?

if $$$ISOK(tStatus) { set tCounter = tCounter + 1 } else { w $System.Status.GetErrorText(tStatus) return}

Most likely you're getting an error and import stops.

Eduard Lebedyuk · Feb 15, 2018 go to post

All datatypes go through the transformation.

The collation is determined in this order:

  1. If an index definition includes an explicitly specified collation for a property, the index uses that collation.
  2. If an index definition does not include an explicitly specified collation for a property, the index uses the collation explicitly specified in the property definition.
  3. If the property definition does not include an explicitly specified collation, then the index uses the collation that is the default for the property data type.
  4. If the property data type does not include an explicitly specified collation, then the index uses namespace default collation
  5. If the namespace default collation is not specified, then SQLUPPER is used.

Documentation.

Eduard Lebedyuk · Feb 13, 2018 go to post

The general approach is:

  1. XData to ZEN objects
  2. Modify object(s)
  3. Serialize back into XData.

Sample code (SAMPLES namespace):

/// This is the Desktop Demonstration page for the Zen demonstration application.
Class ZENDemo.AutoDemo Extends %ZEN.Component.page
{

/// Class name of application this page belongs to.
Parameter APPLICATION = "ZENDemo.Application";


/// This XML block defines the contents of this page.
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen" title="Zen Desktop Demo">
<tablePane sql="SELECT ID,Name FROM Sample.Person WHERE Name %STARTSWITH ? ORDER BY Name">
<column colName="ID" hidden="0"/>
<column colName="Name"/>
<parameter value="Z"/>
</tablePane>
</page>
}

/// Toggles visibility of the ID column.
/// w $System.Status.GetErrorText(##class(ZENDemo.AutoDemo).Modify())
ClassMethod Modify() As %Status
{
    #Dim pSC As %Status = $$$OK
    #Dim tPage As %ZEN.Component.page
    #Dim tHidden As %Boolean
    Set tSC = ..GetPageObject(, .tPage)
    Quit:$$$ISERR(tSC) tSC

    Set tHidden = tPage.children.GetAt(1).columns.GetAt(1).hidden

    Write "Old ID column hidden value: ", tHidden, !

    Set tPage.children.GetAt(1).columns.GetAt(1).hidden = 'tHidden

    Write "New ID column hidden value: ", 'tHidden, !

    Set tNewStream = ##class(%Stream.TmpCharacter).%New()
    Set tSC = ##class(%ZEN.Utils).%ObjectToXML(tNewStream, tPage)

    Write "New XData: ", 'tHidden, !
    Do tNewStream.Rewind()
    Do tNewStream.OutputToDevice()
    Do tNewStream.Rewind()

    Set tSC = ..SavePage(,tNewStream)

    Do $system.OBJ.Compile($classname())

    Quit tSC
}

ClassMethod GetPageObject(pClassName = {$classname()}, Output pPage As %ZEN.Component.page) As %Status
{
    Set tReader = ##class(%XML.Reader).%New()
    Set tSC = tReader.OpenStream(##class(%Dictionary.CompiledXData).%OpenId(pClassName _ "||" _ "Contents").Data)
    If $$$ISERR(tSC) Quit tSC

    Do tReader.Correlate("page","%ZEN.Component.page")

    #; there should only be one page defined
    Do tReader.Next(.pPage,.tSC)
    Quit:$$$ISERR(tSC) tSC
    Quit:'$IsObject(pPage) $$$ERROR($$$GeneralError,"No <page> element defined in Contents block.")

    Quit tSC
}

ClassMethod SavePage(pClassName = {$classname()}, pStream) As %Status
{
    Set tCDef = ##class(%Dictionary.ClassDefinition).%OpenId(pClassName)
    If '$IsObject(tCDef) {
        Set tSC = $$$ERROR($$$GeneralError,"Unable to open class definition: " _ tClass)
    }
    #; find XDATA Contents block
    Set tIndex = tCDef.XDatas.FindObjectId(pClassName _ "||" _ "Contents")
    If (tIndex '= "") {
        #; get XDATA as stream
        Set tStream = tCDef.XDatas.GetAt(tIndex).Data
        Do tStream.CopyFrom(pStream)
    }
    Else {
        #; create a new XData block !!!
    }
    Set tSC = tCDef.%Save()
    Quit tSC
}

}

Calling:

Write $System.Status.GetErrorText(##class(ZENDemo.AutoDemo).Modify())

Toggles visibility of the ID column.

Eduard Lebedyuk · Feb 8, 2018 go to post

Okay.

Another idea: you can define your session event class, and  set it as a session event class for your web application. That way you can track:

  • What pages and partials are requested
  • How long does the session lasts
  • How long does it take to execute the request
Eduard Lebedyuk · Feb 8, 2018 go to post

If I do a direct link without using the router it works fine

How fo you test directly? If you're doing it from a terminal, then that terminal process works as your OS user. Ensemble works under another OS user. Check that this user has access to file.