go to post Eduard Lebedyuk · Apr 26, 2017 It calls IsFileSame method from %UnitTest.TestCase class, which has a following signature: ClassMethod IsFileSame(file1, file2, ByRef diff) As %Boolean Diff would contain differences between files. You can check that.
go to post Eduard Lebedyuk · Apr 24, 2017 As Fabio saidSet class parameter HandleCorsRequest = 1 in your rest service class.To enable CORS support.
go to post Eduard Lebedyuk · Apr 24, 2017 There is no such method, but you can copy any number of characters between streams.What do you want to get by deleting stream lines?
go to post Eduard Lebedyuk · Apr 21, 2017 Check Ens.ProductionMonitorService business service - it provides a monitor service for the production status.
go to post Eduard Lebedyuk · Apr 20, 2017 documented way of translation table setting.Can you please link me to the documentation?
go to post Eduard Lebedyuk · Apr 20, 2017 Use DATEADD function to add/remove dates, and NOW to get current date: SELECT DATEADD('d', -1, NOW()) Returns yesterday date: 2017-04-19 20:11:00
go to post Eduard Lebedyuk · Apr 20, 2017 Do you want to serve arbitrary files? I think you can use stream server for that: /// Return physical file contents /// name - full path to file ClassMethod serve(name) As %Status { #dim sc As %Status = $$$OK #dim %response As %CSP.Response //kill %request.Data set %request.Data("STREAMOID",1)= ##class(%CSP.StreamServer).Encrypt(##class(%CSP.StreamServer).GetOidForFile(name)) if ##class(%CSP.StreamServer).OnPreHTTP() { set %response.Headers("Content-Disposition")="attachment; filename*=UTF-8''" _ ##class(%CSP.Page).EscapeURL(##class(%File).GetFilename(name), "UTF8") set sc = ##class(%CSP.StreamServer).OnPage() } quit sc } Also parameter cannot be assigned.
go to post Eduard Lebedyuk · Apr 20, 2017 Please clarify the following points:How does the code breaks? What error do you receive? At what point?Can you show a sample row?
go to post Eduard Lebedyuk · Apr 20, 2017 Files in OS by themselves do not have Content-Type attribute (streams, in web context can have Content-Type attribute). However, knowing file extension Caché has FileClassify utility method that can determine content type. Here's the wrapper I usually use: /// Determine file mime type /// name - full path to file ClassMethod getFileType(name) As %String { set ext = $zcvt($p(name, ".", *), "U") do ##class(%CSP.StreamServer).FileClassify(ext, .type , .bin, .charset) set ext = "/" _ ext _ "/" if ext = "/RTF/" { set type = "application/rtf" } return type } Or you can additional types into: set ^%SYS("CSP","MimeFileClassify", ext) = $lb(type, bin, charset)
go to post Eduard Lebedyuk · Apr 20, 2017 It's better to use stream wrappers instead of open/use directly.I'm not sure what's the correct way to set codepage with open command.
go to post Eduard Lebedyuk · Apr 20, 2017 Extra curly brace is there by design.Seems like strings starting from {, are json-parsed.
go to post Eduard Lebedyuk · Apr 20, 2017 That's, I think is an unrelated issue. This SQL: SELECT JSON_OBJECT('id': '{{}') Also throws the same error: [SQLCODE: <-400>:<Fatal error occurred>] [%msg: <Unexpected error occurred in JSON_OBJECT() function execution of <JSON_OBJECT>.%FromJSON({{}).Parsing error :: Line 1 Offset 2>] Seems like some data escaping is required. Very simple escaping (this query executes successfully): SELECT JSON_OBJECT('id': ' '||'{{}')
go to post Eduard Lebedyuk · Apr 20, 2017 Use translate table: ClassMethod create(file) As %Status { set stream = ##class(%Stream.FileCharacter).%New() set stream.TranslateTable = "CP874" set sc = stream.LinkToFile(file) quit:$$$ISERR(sc) sc do stream.WriteLine("Hello") quit stream.%Save() }
go to post Eduard Lebedyuk · Apr 19, 2017 If you're running your SOAP service with a custom listener, specify SSLConfig setting for the ensemble business host (Should be in Connection category).If you're running your SOAP service on the main web server, you should enable SSL for a web server. It's usually done by installing external web server and configuring SSL there.
go to post Eduard Lebedyuk · Apr 19, 2017 After you receive base64 string decode it: set text="Hello @" set text = $zcvt(text, "O", "UTF8") set base64text = $system.Encryption.Base64Encode(text) wrile base64text >SGVsbG8gQA== set decoded = $system.Encryption.Base64Encode(base64text) set decoded = $zcvt(text, "I", "UTF8") write decoded >Hello @
go to post Eduard Lebedyuk · Apr 19, 2017 Great article, Fabio! The problem can be that when data changes, then the whole record is copied, i.e. also data which does not change. That can be solved by checking m%<property> value. It has false positives sometimes (when you change value back, i.e.: a-b-a) and calling log code only if property value has changed. Forgot that it's only about object access. Still, you have old and new value, so: Do %code.WriteLine($Char(9,9,9)_"Set tOldValue = {"_tProperty.SqlFieldName_"*O}") Do %code.WriteLine($Char(9,9,9)_"Set tNewValue = {"_tProperty.SqlFieldName_"*N}") Do %code.WriteLine($Char(9,9,9)_"if {" _ tProperty.SqlFieldName _ "*C},tOldValue'=tNewValue {") All data changes are logged in a common table. Why not generate a separate log table for each class, inheriting from logged class, so 1 change == 1 record in log table. It also gives you the possibility of writing "easy" diff tool, so audit results can be displayed conveniently. If table person has a column "photo" with binary data (stream) containing the photography then each and every time yhe user changes the picture the role stream is recorded (consuming disk space). That problem can be solved by creating immutable stream-containing class. /// Immutable wrapper for stream Class User.Document Extends %Persistent { /// Global identifier to give to user (prevent id traversal) Property guid As %String [ InitialExpression = {$system.Util.CreateGUID()}, Required ]; /// Creation date time Property createDateTime As %TimeStamp [ InitialExpression = {$ZDATETIME($ZTIMESTAMP, 3, 1, 3)}; /// File name as supplied by user (only for display purposes) Property fileName As %String(MAXLEN =1000) [ Required ]; /// File stream Property content As %FileBinaryStream; /// User who uploaded the file Property user As %String [ InitialExpression = {$username} ]; /// Add new stream /// realName - real name of a stored file /// suppliedName - name supplied by user, used only for display purposes /// stream - stream with data Method %OnNew(realName As %String = "", suppliedName As %String = "", stream As %Stream.Object = {##class(%FileBinaryStream).%New()}) As %Status [ Private, ServerOnly = 1 ] { #dim sc As %Status = $$$OK set ..fileName = ##class(%File).GetFilename(suppliedName) set ..content.Filename = realName set sc = ..content.CopyFromAndSave(stream) quit sc } /// Serve file on web Method serve() As %Status { #dim sc As %Status = $$$OK #dim %response As %CSP.Response kill %request.Data set %request.Data("STREAMOID",1)= ##class(%CSP.StreamServer).Encrypt(..content.%Oid()) if ##class(%CSP.StreamServer).OnPreHTTP() { set %response.Headers("Content-Disposition")="attachment; filename*=UTF-8''"_##class(%CSP.Page).EscapeURL(..fileName,"UTF8") set st = ##class(%CSP.StreamServer).OnPage() } quit sc } That way your audit log table would contain only id references.
go to post Eduard Lebedyuk · Apr 19, 2017 Fixed the link to a correct article and I hadn't wrote about 7z problem even there. So here it is:Document files (docx, xlsx, pptx) zipped with 7z on linux cannot be opened by Microsoft Office on Windows.
go to post Eduard Lebedyuk · Apr 19, 2017 It does. Foreach = row/object indicates that object access calls triggers.
go to post Eduard Lebedyuk · Apr 19, 2017 Zip is also available on windows. I got some problems when using 7z on linux, so I'd like to recommend zip on both linux and windows. Code.