Nael Nasereldeen · Sep 7, 2016 go to post

Edit:

it woks now, after we added 57772 port the url.

thanks.

Hi,

Thanks, this is very useful.

We followed the installation instructions, but it does not work, we get an 404 error . the URL is correct with a slash at the end.

I noticed that if i try to create a csp page in the ClassExplorer Web application, i get an error -

5912 = page does not exist.

The application settings:

What's missing?

Nael Nasereldeen · Nov 21, 2016 go to post

Thanks a lot for your quick answer Alok!

I tried it, it didn't work - 

I just got a file containing-

"Hello !"

And the file is ANSI encoded.

I guess Its because we have special translation tables, and I don't know the details of that configuration.

I just thought- if its that easy to do with XML files, why not with regular files?

Regards,

Nael

Nael Nasereldeen · Nov 21, 2016 go to post

Hi,

It did work after all..

When I changed the command

Do stream.Write("Hello " _ $CHAR(955) _ "!")

to a command containing English and Hebrew letters, I got a UTF8 encoded file.

Thanks for your help!

Regards,

Nael

Nael Nasereldeen · Nov 23, 2016 go to post

Thank you Tomas,

to clarify-

 Set stream.BOM=$C(239,187,191)

and 

Do stream.TranslateTableSet("UTF8")

are not equivalent , correct?

but TranslateTableSet does set the BOM ?

Thanks,

Nael

Nael Nasereldeen · Nov 24, 2016 go to post

Hi Tomas, 

thanks,

I checked , and I see that TranslateTable seems to set BOM ,

Because when I run the following two examples,

the files I got where identical

method 1:

Set stream=##class(%Stream.FileCharacter).%New()
Set sc=stream.LinkToFile("c:\temp\UTF8ExampleWithBom.txt")
Set stream.BOM=$C(239,187,191)
Do stream.TranslateTableSet("UTF8")
Do stream.Write("Hello שלום")
w stream.%Save()

method 2:

Set stream=##class(%Stream.FileCharacter).%New()
Set sc=stream.LinkToFile("c:\temp\UTF8ExampleNoBom.txt")
Do stream.TranslateTableSet("UTF8")
Do stream.Write("Hello שלום")
w stream.%Save()

Nael Nasereldeen · Sep 5, 2017 go to post

Ok good to know thanks.

I accepted.

Its not east to notice it in my opinion.. but maybe it's just me.

Thanks,

Nael

Nael Nasereldeen · Dec 10, 2017 go to post

OK Thanks a lot Vivek.

So the syntax is supported, and I have a specific problem with this table.

I will contact WRC.

Regards,

Nael

Nael Nasereldeen · Apr 3, 2018 go to post

Hi,

This is a very usefull article, thank you!

But it seems strange that Cache does not support exporting  classes to JSON in a native way.

We can use  %ZEN.Auxiliary.altJSONProvider , but for some reason, %Date properties are not handled

correctly - they are not converted to ODBC format. at least in Cache 2016.2

is this issue fixed in later Cache Versions?

Thanks,

Nael

Nael Nasereldeen · Apr 16, 2018 go to post

Thank you Robert,

We are aware of this parameter and we change it in some of our servers,

But right now we need to write code that works even without it being enabled.

Regards,

Nael

Nael Nasereldeen · Apr 16, 2018 go to post

Thanks Alexander!

that's a very useful tip, I should have read the whole $ZCONVERT documentation..

still, I think the most elegant solution to this specific problem is the suggestion by Dmitry- 

not using ZCVT at all, but using the TranslateTable Property of %Stream.FileCharacter

Regards,

Nael

Nael Nasereldeen · Apr 24, 2018 go to post

Thank you Gertjan!

when I write anything to EntityBody of the request, I don't get the length required error anymore.

I guess it makes sense, when using PUT, there is no point in sending an empty EntityBody.

Regards,

Nael

Nael Nasereldeen · Jun 27, 2019 go to post

Hi,

Thank you,

That would work if the caller is nice enough to set the second variable to null before calling the function. 

But he may not do it..

So if the function is:

MyFunc(Param1,Param2)
    if $d(Param2) {
    Answer= " 2 params"
    Else {
    Answer= " 1 params"
    }
  
    Param2="it's all good"
   Answer

Then:

USER>w $$MyFunc^%ZWBNAEL(1)
 1 params
USER>w $$MyFunc^%ZWBNAEL(1,.V)
 1 params

Nael Nasereldeen · Jun 27, 2019 go to post

Thank you Alexander,

I was not familiar with $stack , might be useful in various situations.

Nael Nasereldeen · Oct 27, 2019 go to post

Hi,

What I mean by a simple string, is a value that you can send Via a web service for example.

Thanks.

Nael Nasereldeen · Nov 12, 2019 go to post

Thanks,

I have another server, that is not in the network with the proxy I mentioned, and it does work with default settings as you said.

The problem is only when I must go through the proxy.

It's possible that the HttpRequest class is unable to handle this situation, but I am hoping that this is not the case.

Nael Nasereldeen · Dec 11, 2019 go to post

Hi,

Ok. here is the code, it's a minimal code of a many to many relationship:

Class TafnitTest.Student Extends (%Persistent, %JSON.Adaptor, %Populate)
{
Property MyName As %String;
Relationship Teachers As TafnitTest.TechersToStudents [ Cardinality = many, Inverse = Student ];
}
 

Class TafnitTest.Teacher Extends (%Persistent, %JSON.Adaptor, %Populate)
{

Property MyName As %String;

Relationship Students As TafnitTest.TechersToStudents [ Cardinality = many, Inverse = Tracher ];

}

Class TafnitTest.TechersToStudents Extends (%Persistent, %JSON.Adaptor, %Populate)
{

Relationship Student As TafnitTest.Student [ Cardinality = one, Inverse = Teachers ];

Index StudentIndex On Student;

Relationship Tracher As TafnitTest.Teacher [ Cardinality = one, Inverse = Students ];

Index TracherIndex On Tracher;

}

Also I will attach the code as an XML export for convenience of importing and testing, If I find a way to do upload a file here..

after creating the classes, populate:

W ##CLASS(TafnitTest.Teacher).Populate(100)
W ##CLASS(TafnitTest.Student).Populate(100)
W ##CLASS(TafnitTest.TeachersToStudents).Populate(100)
 

And the JSON Export:

d ##CLASS(TafnitTest.Student).%OpenId(1).%JSONExport()
{"MyName":"O3183","Teachers":[{},{}]}
 

The JSON indicated that two teachers  teach this student, but not the details.

In my post, the id is a property I added to the intermediate class. I did not add it in this minimal example.

Thanks!

Nael Naseraldeen

Nael Nasereldeen · Dec 11, 2019 go to post

Thank you very much Peter!

I will look into it now.

I really appreciate your effort to help!

Regards,

Nael Naseraldeen

Nael Nasereldeen · Oct 28, 2021 go to post

Hi,

I took the code from the article, still the same problem.. in Outlook I get a nice embedded pic,

In Gmail- the pic is attached.   

It seems there is a specific problem with Gmail displaying embedded images.

Did you manage to get a mail with embedded image to display correctly in Gmail?

I also tried the base64 method, and that also worked correctly only when the mail was opened in Outlook.

Method 1:

Set tmpEmail=##class(%Net.SMTP).%New()
  Set tmpEmail.smtpserver="xyz"
  Set msg=##class(%Net.MailMessage).%New()
  Set msg.From="from.."
  Set msg.Charset="Windows-1255"
  D msg.To.Insert("to..")
  Set msg.Subject="testing"
  set msg.IsHTML=1   
  set msg.MultiPartType="related"   
  do msg.AttachFile("c:\xyzxyz\","a.png")
  set part=msg.Parts.GetAt(1)
  set part.ContentType="image/png"
  set part.InlineAttachment=1 // otherwise, the default is attachment. graphic inside html
  do part.Headers.SetAt("id1","Content-ID")   
  do msg.TextData.Write("<b>Hello< / b>, </b><font color='red'>World<font color='red'></font>!")
  do msg.TextData.Write("<br/><img src='cid:id1'>")
  s status= tmpEmail.Send(msg)
 

Method 2 base64

  Set tmpEmail=##class(%Net.SMTP).%New()
  Set tmpEmail.smtpserver="xyz"
  Set msg=##class(%Net.MailMessage).%New()
  Set msg.From="from.."
  Set msg.Charset="Windows-1255"
  D msg.To.Insert("to..")
  Set msg.Subject="testing base64"
  set msg.IsHTML=1   
  set msg.MultiPartType="related"
  set stream=##class(%GlobalBinaryStream).%New()
  do stream.Write($system.Encryption.Base64Decode("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAADUUlEQVR42lWTWUwTURSGaUtIKY5QweISTUzceDGu0Rj1xURjTNQEE+ODGn0hPhBEQdqZztahBbrAtFih1Fprh9IBiVLLErZSU7BUoS7VqNH44ovx0S0ovdfO4Ez04cw9Ofec7/5zzr15NEnkUxSVFx8ObZ1x7nzHN6z9nOhnzOFwWCnECcKoEFbBRrrp6iF/XRvD0BoplkdTuAiIhtt3P3Fu+jJlKlkM1WoXLFjVeSnpXrC94gV3ciJp1X0L1K7+NtDfvXdpj1TmmUwm8QTfLa867T+ceWTSwO5r5b87XNaDEoBrv3p2Ai+AU1Qh5OiDGS4UXi4roAisQHBiYfJS2obAVPMyELYcGxViOIaKcLaNLXzadej5nBUBPXW6hdYW0z4RQOYUXK2tUfr8QeXL0Kn4JKEBk7QWdtrrLggJJEmoCBxVCf50qIaaa0HABFkEPZaLNnGfwPNFGV0u05Y554bvMQoBPLbxs9t9QydJpHP/KayRbsf+pG1NdgTTgDuGXa8dbS41ZtArxaQYT1WlHVqYaloGOcvJIan4X2MdViTl3vExbS+GPfXlvzzutj1LPch9HrYea59t0YIRtAAO+PQuIWYwNKikYty41Iuk/3TvMzsCB9HcQR7msgzgjZs7Z5rLQPR6PojeJW2d3oDCoG/IlwAYqlexbp/i9eB19ziuBoMoAlrR03YZ0G8+0JFhS8EjuhD6zWfuCTEjppcBOKYX1bwaqA5MM2oYZ4pBy7XjrAyY7sPqU01FcNZW/jtwZeXXVpt5u1RM4JhYzHFBddqz5/28fUU2NwngtVUbZUCE79o6x67/MYiXLiSbS8D9xp1vI7znkLvDK07A5/MiT7mzdxMMAsdMqxaiWDHkgzePigBUXy9KTfdWeVKNSjjPrvv5uKkYxszlIHX7eDLeVfkgbt30bt5eAlOOtT9nLRrI03szrOumOtcb4SrTSj2KKfr4nuUZ7kR8HFPAYXLlYqxRl43TGjjTWAhHCC1MNK/+lWA0cJLRgfsh95G/N1H136z7+BCSuHMuMEGVLo4a1XCKKcuO0WXZBw1FcNighmPWbe8jIeeJpdFiCrkHguWUyM92NBKseBut8T92bfsw66z49IyrHH2T5CvlqeCYUvL/ANIZ7+ohXSdWAAAAAElFTkSuQmCC"))
  do msg.AttachStream(stream,"id1")
    
  set part=msg.Parts.GetAt(1)
  set part.ContentType="image/png"
  set part.InlineAttachment=1    // otherwise, the default is attachment. graphic inside html
  do part.Headers.SetAt("id1","Content-ID")

  do msg.TextData.Write("<b>Hello< / b>, </b><font color='red'>World<font color='red'></font>!")
  do msg.TextData.Write("<br/><img src='cid:id1'>")
  s status= tmpEmail.Send(msg)