Hi,
I have built successfully built a custom task in SSIS where I send a notification to an internal notification system. I have now also built a custom UI for this component so the user can add a custom message to this internal messaging system, however, I
cannot figure out how to save the user's inputs in the custom UI and apply them to message that is being sent.
I have the following class titled 'InternalMessageTask' which currently sends a message: (this will send an internal message with the text "This Is a test message").
public class InternalMessageTask : Task
{
private string _Message = "This Is a test message";
public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents events, IDTSLogging log)
{
// Does some validating
}
public override DTSExecResult Execute(Connections cons, VariableDispenser vars, IDTSComponentEvents events, IDTSLogging log, Object txn)
{
// Send the message
SendInternalMessage(_Message); // This is a method that takes a string as an input and sends it to an internal notification system
}
public void SendInternalMessage(string MessageToSend)
{
// Some Code To Send a Message.
}
public string Message
{
get
{
return this._Message;
}
set
{
this._Message = value;
}
}
}
Now I have added the following:
class InternalMessageInterface : IDtsTaskUI
{
private TaskHost _taskHost;
private IServiceProvider _serviceProvider;
private InternalMessageUI _editor;
public void Initialize(TaskHost taskHost, IServiceProvider serviceProvider)
{
_taskHost = taskHost;
_serviceProvider = serviceProvider;
_editor = new InternalMessageUI(_taskHost);
}
public ContainerControl GetView()
{
return _editor;
}
public void New(IWin32Window parentWindow)
{
return;
}
public void Delete(IWin32Window parentWindow)
{
return;
}
}
And I also have a form titled 'InternalMessageUI' with the following code:
public partial class InternalMessageUI : Form
{
private TaskHost _taskHost;
private string _MessageFromUI = "";
public InternalMessageUI(TaskHost taskHost)
{
InitializeComponent();
this._taskHost = taskHost;
}
private void _BtnSave_Click(object sender, EventArgs e) // Save Button saves the message input by the user
{
_MessageFromUI = MessageTextBox.Text.Trim(); // MessageTextBox is a textbox on the form that a user will use to enter a message to send.
this.Close();
}
}
So basically I need to pass the value from _MessageFromUI in the InternalMessageUI class to the _Message variable in the InternalMessageTask class. How can I do this?