Dataflow script component + custom object properties

138 views
Skip to first unread message

rofltrain

unread,
Mar 2, 2010, 7:57:25 AM3/2/10
to CozyRoc
I've made some headway with developing a custom UI + custom windows
form for a dataflow script property, however I've hit a roadblock when
it comes to saving + accessing that property.

Can you have a custom object/class with various properties, and then
save that as a property against a dataflow script? or do you need to
keep your objects within the basic types (e.g. string, int32).

I've got a basic UI that allows you to select input columns, and
assign them a "sort order". This then concatenates the columns in the
given order, and adds another column to the data flow
("ContatenatedValue"). While I could do this in a derived column, it's
a proof of concept re: complex properties.

Long story short, I have a custom class called ScriptSettings with
various properties. I have this declared as a property. I then have a
custom form that takes the current ScriptSettings object as a
parameter to the constructor. This is stored as a property against the
form. the form is displayed, and the user can make changes / edits.

The form returns a DialogResult of OK or Cancel, and depending on this
value, I would override the custom property with the new selected
values.

What's happening is that the script component will remember the values
when you're in the editing box. However whilst you're editing, the
value in the "setup" tab will display a GUID like
SC_94979cd092bd40a3acc9008e8d354603.vbproj.ScriptSettings


As soon as you click Okay and save the script, and then try and re-
edit the script component, it will forget the selected settings. or
throw an invalid cast exception (trying to convert from string to
ScriptSettings). I'm guessing that it doesn't like storing the
ScriptSettings object, and would prefer perhaps a comma delimited
string, or serialized XML or Json?

Unfortunately I need to store a more complex relationship than just
simple strings or arrays. e.g. I have to store a list of column names
and associated sort positions which are user defined. I can't just
load this into a single plain string and do a string.split.

however, I could serialize my class to a string object, and then
reload to an object for configuring, and reload at runtime. I would
prefer not to If I could avoid it though. Could you maybe store this
in a system.object variable or something?

Code is below :

'script main.vb

Private m_settings As ScriptSettings

<Editor(GetType(SelectedColumnEditor), GetType(UITypeEditor))> _
Property Column_Settings() As ScriptSettings
Get
Return m_settings
End Get
Set(ByVal value As ScriptSettings)
m_settings = value

End Set
End Property

'class for the UIEditor


Class SelectedColumnEditor
Inherits UITypeEditor

Public Overrides Function GetEditStyle(ByVal context As
System.ComponentModel.ITypeDescriptorContext) As
System.Drawing.Design.UITypeEditorEditStyle
Return UITypeEditorEditStyle.Modal

End Function

Public Overrides Function EditValue(ByVal context As
System.ComponentModel.ITypeDescriptorContext, ByVal provider As
System.IServiceProvider, ByVal value As Object) As Object
Dim uiForm As New ScriptSettingsUI(value, Nothing)

If uiForm.ShowDialog() = DialogResult.OK Then
EditValue = uiForm.ScriptSettings
Else

EditValue = value

End If

End Function


End Class


'code on the form

Public Sub New(ByVal settings As ScriptSettings, ByRef inputColumns
As IDTSInputColumnCollection100)
Me.ScriptSettings = settings

'set a few checkboxes to the value of the settings object
'set a few textboxes to a value in the settings object

End Sub

Private Sub button_Save_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles button_Save.Click
' capture the user input and save back to the properties on the
settings object


end sub


Ivan Peev

unread,
Mar 2, 2010, 5:08:56 PM3/2/10
to CozyRoc
Can you send a sample package with the script to sup...@cozyroc.com ?

Ivan Peev

unread,
Mar 3, 2010, 9:10:47 AM3/3/10
to CozyRoc
Hi,

I have checked the serialization and your guess was correct. Only base
types can be serialized string, int32 , etc. Your custom object should
serialize to/from string. The Script Component Plus has no way to know
how to serialize the custom object. The custom property is itself
stored in the SSIS package, which as you know is one big-long XML text
file. There is no binary serialization.

I think using JSON is a good idea. Btw CozyRoc SSIS+ installation
includes a .NET JSON library called LitJSON:

http://litjson.sourceforge.net/

It is pretty safe for you to use the same library for your
serialization routines. You may reference it in your script project.

On Mar 2, 7:57 am, rofltrain <d...@comradebear.com> wrote:

Ivan Peev

unread,
Feb 14, 2013, 7:44:07 AM2/14/13
to joshd...@gmail.com, coz...@googlegroups.com

Hi Josh,

Can you get into more details what you have tried so far? Do you have sample package you are testing and can you send a copy ?

--
Regards,

Ivan Peev
919-249-7421



On Wed, Feb 13, 2013 at 11:07 PM, <joshd...@gmail.com> wrote:
Hi Ivan, 
I'm hoping you have a JSON example, I've been killing myself for the past week and a half trying to consume a JSON feed using your components, tried JSON.net as well. Just can't seem to get it. Do you have any samples that you may be able to share?
Reply all
Reply to author
Forward
0 new messages