go to post Lorenzo Scalese · Mar 11, 2020 Hello @Dmitry Maslennikov , I've modified a 'legacy method' in order to implement a timeout. May be the following code could help you : /// Run a command line<BR/> /// Echos of command are stored in result argument <br/> /// Return 0 if a timeout occurs. ClassMethod runCmdWithTimeout( command As %String, ByRef result As %Binary, timeout As %Integer) As %Boolean { s end = $zh+timeout, timeout = 0 s a=$zu(69,40) n $et s $et="s a=$zu(68,40,"_a_")" o command:"qr" s a=$zu(68,40,1) u command f i=1:1 r line:1 s:line'="" result(i)=line s:$zh>end timeout=1 q:$zeof||timeout c command x $et q 'timeout }
go to post Lorenzo Scalese · Aug 24, 2019 Yes Exactly! @Eduard Lebedyuk .It's just a way.The code can be easily improved depending your needs (ex : return a list of id, namespace filter)
go to post Lorenzo Scalese · Aug 23, 2019 Hello @Rodolfo Moreira,For retrieve the task ID, I wrote this : ClassMethod getTaskId( ByRef sc As %Status = {$$$OK}, className As %String = {..%ClassName(1)}) As %String { Set id = "" Set rs = ##class(%Library.ResultSet).%New("%SYS.Task:TaskListDetail") Set sc = rs.Execute() Quit:$$$ISERR(sc) "" While (rs.Next(.sc)) { Quit:$$$ISERR(sc) if (rs.Get("TaskClass")=className){ Set id = rs.Get("ID") Quit } } Quit id } Hope this help you. Regards. Edit : modify this code for your needs (ex : return a list of Id, namespace filter...)
go to post Lorenzo Scalese · May 21, 2019 Great!There, a version with multidimensional array support until 4 subscripts level : ClassMethod GetPrivateProp( oref, propName, ByRef result As %Binary) As %String { Do ##class(%Studio.General).DumpObjectExecute(.arr,.oref) Set key = $o(arr(propName),1,value), @propName = arr(propName) For { Quit:(key="")||($Qs(key,0)'=propName) Set subscriptLevel = $Ql(key) If subscriptLevel=1 { Set @propName@($Qs(key,1))=value }ElseIf subscriptLevel=2 { Set @propName@($Qs(key,1),$Qs(key,2))=value }ElseIf subscriptLevel=3 { Set @propName@($Qs(key,1),$Qs(key,2),$Qs(key,3))=value }ElseIf subscriptLevel=4 { Set @propName@($Qs(key,1),$Qs(key,2),$Qs(key,3),$Qs(key,4))=value } Set key = $o(arr(key),1,value) } Merge result=@propName Kill @propName Quit:$Quit arr(propName) Quit }
go to post Lorenzo Scalese · May 18, 2019 Hello Eduard,For debug purpose , you can try this : Set obj = {Your test.ABC instance} Set res = ##class(%Studio.General).DumpObjectFunc(obj) While res.%Next() { Write !,"Property : ",res.%Get("Name"), !," Value : ",res.%Get("Value") } Or just perform a zw obj Regards. Lorenzo. EDIT : I tested with ##class(%Studio.General).DumpObjectFunc(obj). We can get value if "myProp" is not an object.
go to post Lorenzo Scalese · Mar 22, 2019 Hello,We are using this procedure in order to reduce the dowtime during software update. In short :Create a temp namespace. import and compile code.stopping application.switch DB code on target namespace.Execute a script for data update (if needed).starting application.It work fine for Caché.Coming soon, we will do that for production with HealthShare Health connect.It should be work fine also for a production, but I don't done a test yet.If you have a translate file, don't forget import your traductions because ^CacheMsg and ^CacheMsgNames are in CODE database.Regards.
go to post Lorenzo Scalese · Mar 9, 2019 Hello,I think, you should simply append your own error message like that : Set obj = ##class(User.tApplications).%OpenId(YourTApplicationId,"4",.errors) Set:$$$ISERR(errors) errors = $$$ADDSC(errors,$$$ERROR($$$GeneralError,$$$FormatText("%OpenId failed for User.tApplications with id %1",YourTApplicationId))) If an error occurs, variable "errors" will contain 2 errors. NS>d $System.Status.DecomposeStatus(error,.b) NS>zw b Your error is in the subscript b(2). Add #include %occStatus if you are in a routine (for macro usage). Regards.