Andy Stobirski · May 19, 2022 go to post

I solved it.

I changed to OnPage() method to use a %Stream.FileCharacter as follows:

ClassMethod OnPage() As %Status
{
	
	set fs = ##class(%Stream.FileCharacter).%New()
	set fs.Filename = %request.Get("filepath")
	
	do fs.OutputToDevice()
	quit $$$OK
}
Andy Stobirski · May 19, 2022 go to post

I solved it.

I changed to OnPage() method to use a  %Stream.FileCharacter as follows:

ClassMethod OnPage() As %Status
{
	
	set fs = ##class(%Stream.FileCharacter).%New()
	set fs.Filename = %request.Get("filepath")
	
	do fs.OutputToDevice()
	quit $$$OK	
	
}
Andy Stobirski · May 18, 2022 go to post

Hi there! Thanks for taking the time to reply. I implemented the above code and was quickly able to download the file in question. However, the PDF files that is downloaded doesn't have the same size as the original - in fact all are 5Kb smaller, e.g.197Kb downloads to a 192Kb file, 241Kb to a 236Kb etc

I modified the OnPreHttp() method to set content length, but that had no effect.

/// Set the appropriate header for the file.
ClassMethod OnPreHTTP() As %Boolean
{
set filepath = %request.Get("filepath") set tFs=##class(%Stream.FileCharacter).%New()
set tFs.Filename=filepath set %response.ContentType = "application/pdf"
do %response.SetHeader("Content-Disposition","attachment;filename="""_$P(filepath,"\",*)_"""")
Do %response.SetHeader("Content-Length",tFs.Size)     Quit $$$OK
}
 

Do you have any ideas?

Andy Stobirski · May 18, 2022 go to post

Thanks for the warning. Fortunately, this is for a internally hosted page accessed by username/password only by authorised operatives.

Andy Stobirski · Apr 22, 2022 go to post

I solved the problem: user error! One of the variable values was misspelt in the database. Thanks for taking the time to answer!

Andy Stobirski · Apr 22, 2022 go to post

After further experimentation, I have found that entirely omitting the where clause causes only 1 value to outputted in the second loop that examines the cursor.

Andy Stobirski · Apr 22, 2022 go to post

I have added that, but it had no effect. Thanks for taking the time to reply though.

Andy Stobirski · Apr 22, 2022 go to post

I have added that, but it had no effect. Thanks for taking the time to reply though.

Andy Stobirski · Apr 22, 2022 go to post

When I do that, it returns 0: 0.

If I don't have a where clause on the statement, it returns the correct number of rows 9, outputs 0:9.

If I include the first part of the where clause (MessageName = :tMessageName)   and omit the second (Identifier= :tIdentifier) it returns 7, which is a value I'd expect. Having both returns 0, and I have checked the spelling of the second variable which is correct.

Andy Stobirski · Mar 15, 2022 go to post

Aha - that makes a lot of sense! Why didn't I see that! blush

Thanks for taking the time to answer!

Andy Stobirski · Feb 12, 2022 go to post

Yes, I can see that might help. I'm writing the following class to XML

Class OutputData Extends (%Persistent, %XML.Adaptor)
{ 
Parameter XMLNAME = "OutputData"; 
Property Notes As %String(MAXLEN = "", XMLNAME = "Notes", XMLPROJECTION = "ATTRIBUTE");
}

Using the following code

#dim item as DATAEXTRACTION.Datix.Message.Fragment.NewClass1 
set item = ##class(DATAEXTRACTION.Datix.Message.Fragment.NewClass1).%New()
set item.Notes = "< > &" _$c(10)_$c(13)_ "TEST" 

#dim tWriter as %XML.Writer
set tWriter=##class(%XML.Writer).%New()
set tWriter.Indent=4 
do tWriter.OutputToFile("E:\Testing\out.xml") 
set tSC=tWriter.RootObject(item)

Which produces the following XML, the $C(10) and $C(13) are not encoded, but the other characters are:

<?xml version="1.0" encoding="UTF-8"?>
<OutputData Notes="&lt; &gt; &amp;

TEST"></OutputData>

And what I want is:

<?xml version="1.0" encoding="UTF-8"?>
<OutputData Notes="&lt; &gt; &amp; &#xA; &#XD; TEST"></OutputData>

The reason for wanting this is that I'm building a new system to replace some legacy code and the data outputted by the new system has to be identical

Andy Stobirski · Nov 24, 2021 go to post

I'll give it a try - how would I do that, I'm still new to objectscript at the moment.

Making the following change

 Property PersonIDs As list Of %String(XMLNAME = "PersonIDs", XMLPROJECTION = "ELEMENT");

Results in an error of:

ERROR #6232: Datatype validation failed for tag, PersonIDs (ending at line 9 character 15), with value:
1

Andy Stobirski · Nov 23, 2021 go to post

Hi David,

That's interesting, however, the XML file I am receiving is outputted from a web API and so I can't change it.

Thanks for taking the time to reply, though.

Andy