I can define fields in a TT as a Progress.Lang.Object as assign with the following. How would I save these values in a DB field?
ASSIGN
ttblButtonAttribute.ImageBackground = oAppearance:ImageBackground
ttblButtonAttribute.ThemedElementAlpha = oAppearance:ThemedElementAlpha
ttblButtonAttribute.BackColor = oAppearance:BackColor
ttblButtonAttribute.ForeColor = oAppearance:ForeColor
.
You would need to serialize the object into a string, raw, or binary format and save that into a CLOB/BLOB field in the database. There is no way to save an ABL object as-is to the database. The current OERA model example here on communities site has some sample code on how to serialize objects.
You'll probably find this discussion interesting:
http://communities.progress.com/pcom/thread/39680?tstart=0
It shows how to unserialize an infragistics appearance object from a file. The code to serialize is similar. You can store these in the database as BLOB's if you need to and read them back in using the code from the above thread.
Yes, that was my question a few weeks ago that you answered. I have that working but there are other button attributes that I want to store that cannot be serialized so I was attempting to handle it all myself.
Thanks for the earlier post. I am working on some things right now.
hehe. i don't usually pay attention to the sender.
Matt,
How would I get a .NET Appearance:Image object into a MEMPTR? The PUT-BYTES does not compile.
METHOD PUBLIC STATIC MEMPTR ImageToMemptr (INPUT imageObject AS System.Drawing.Image):
DEFINE VARIABLE mMemptr AS MEMPTR NO-UNDO.
DEFINE VARIABLE myMemoryStream AS System.IO.MemoryStream NO-UNDO.
ASSIGN myMemoryStream = NEW System.IO.MemoryStream().
imageObject:Save(myMemoryStream,System.Drawing.Imaging.ImageFormat:Tiff).
SET-SIZE(mMemptr) = myMemoryStream:LENGTH.
PUT-BYTES (mMemptr,1) = myMemoryStream:ToArray().
RETURN mMemptr.
FINALLY:
myMemoryStream:Dispose().
DELETE OBJECT myMemoryStream.
END FINALLY.
END METHOD.
Hi,
Thank you for your email. I'm currently out of the office for business. I will return on May 23. During my absence I will have limited access to email. For urgent matters, call our office, leave a message on my voice mail or contact Gary Calcott (gcalcott@progress.com).
Best regards,
Wouter
--
Wouter Dupré
Senior Solutions Consultant
Progress Software NV
A. Stocletlaan 202 B | B-2570 Duffel | Belgium
Office +32 (0) 15 30 77 00 | Mobile +32 (0) 478 50 00 49
This seems to work. Not sure if there is a better way
METHOD PUBLIC STATIC MEMPTR ImageToMemptr (INPUT imageObject AS System.Drawing.Image):
DEFINE VARIABLE mMemptr AS MEMPTR NO-UNDO.
DEFINE VARIABLE myMemoryStream AS System.IO.MemoryStream NO-UNDO.
DEFINE VARIABLE iSize AS INTEGER NO-UNDO.
DEFINE VARIABLE iLoop AS INTEGER NO-UNDO.
ASSIGN myMemoryStream = NEW System.IO.MemoryStream().
imageObject:Save(myMemoryStream,System.Drawing.Imaging.ImageFormat:Tiff).
iSize = myMemoryStream:LENGTH.
SET-SIZE(mMemptr) = iSize.
DO iLoop = 1 TO iSize:
PUT-BYTE (mMemptr,iLoop) = myMemoryStream:ReadByte().
END.
RETURN mMemptr.
FINALLY:
myMemoryStream:Dispose().
DELETE OBJECT myMemoryStream.
END FINALLY.
END METHOD.
For enum values, you can store them as regular string then use something like the following to convert them back to the enum type.
DEFINE VARIABLE cellBackGround AS Infragistics.Documents.Report.Background NO-UNDO.
cellBackGround = CAST(System.Enum.Parse(Progress.Util.TypeHelper:GetType("Infragistics.Documents.Report.Background"),"WhiteSmoke"), Infragistics.Documents.Report.Background).
"WhiteSmoke" is the stored value.