Developer forum

Forum » Development » Edit source settings ans edit destination settings on my own provider

Edit source settings ans edit destination settings on my own provider

Grzegorz Morawski
Reply

 

Hello,

I have created my own SourceProvider and DestinationProvider.

Source provider inherits after your XmlProvider and DestinationProvider is created  from scratch.

Everything work beside 'Edit source settings' and 'Edit destination settings' button on job view.

In SoruceProvider I can see my own parameters but values are empty (but I see this values in job xml files in \Files\Files\Integration\jobs\).

In DestinationFiles I don't see parameters of my provider, but empty parameters form SqlProvider.

 

I tried use example providers http://developer.dynamicweb-cms.com/documentation/for-developers/data-integration/providers/how-do-i-create-my-own-provider.aspx.

On version 8.2.1.11. I needed add method CheckMappings and implement Serialize.

After this corrections example providers works as my own destination providers. I see parameters of SqlProvider.

 

What is essential to proper working 'Edit source settings' and 'Edit destination settings' button?
How correct example providers?


Replies

 
Jonas Dam
Reply
This post has been marked as an answer

Hi Grzegorz 

It seems you have stumbled on a bug in the system.

it is not currently possible to edit parameters for custom providers unless they inherit from the BaseProvider - if you simply implement the ISource and/or IDestination interfaces, it will not work. This is a bug, and I will have it fixed for the next hotfix.

 

If you cannot wait for the next release, there is a workaround:

inherit from the BaseProvider class, instead of the ConfigurableAddin class.

if you do so, there are a few other changes you have to make, in order for it to work.

  • add attribute AddInIgnore(false)  - this is needed, since the baseProvider is ignored, but the inherited provider should not be ignored.
  • implement interface INotSource - this is needed in order to hide the provider from the source selector, since the BaseProvider implements both ISource and IDestination interfaces.

additionally, you may need to add "Override" to some of the methods, in order to make sure that the base provider implementations are not used.

If you have any more questions, please let me know.

 

Regards, Jonas

 

Votes for this answer: 1
 
Grzegorz Morawski
Reply

Thank You Jonas,


I’ve followed by you advice. Everything seems to be nearly fine.
I can see my parameters controls but I don’t see values.
When I've set something, new data are saved (checked it in xml).
What I need implement to get values of parameters in setting control?
 

I've puted ExampleDestinationProvider.cs corrected according your advice in attachment .

 
Jonas Dam
Reply
This post has been marked as an answer

Hey again,

 

The file seems to be missing - I'm not sure what has gone wrong. If the following doesn't work for you, feel free to mail me the file, and I'll take a look. my adress is: jkd at Dynamicweb.dk

 

you need to implement two methods - Serialize and UpdateDestinationSettings. I have pasted examples for these methods  below, from the quick test I made to verify the bug. Note the the names of the nodes should match the addinNames you have in your decoration:

 

 

public string Serialize()
 {
 XDocument document = new XDocument(new XDeclaration("1.0", "utf-8", string.Empty));
 XElement root = new XElement("Parameters");
 document.Add(root);
 root.Add(CreateParameterNode(GetType(), "Input Field delimiter", SourceFieldDelimiter));
 return document.ToString();
 }
 protected static XElement CreateParameterNode(Type t, string name, string value)
 {
 XElement ret = null;

if ((t != null) && !string.IsNullOrEmpty(name))
 {
 if (!string.IsNullOrEmpty(value))
 return new XElement("Parameter", new XAttribute("addin", t.FullName), new XAttribute("name", name), new XAttribute("value", value));

return new XElement("Parameter", new XAttribute("addin", t.FullName), new XAttribute("name", name), new XAttribute("value", ""));

}

return ret;
 }

 

 

public void UpdateDestinationSettings(IDestination destination)
 {
 ExampleDestinationProvider1 newProvider = (ExampleDestinationProvider1)destination;
 SourceFieldDelimiter = newProvider.SourceFieldDelimiter;
 }

 

 

I believe this should be enough to both save and load the settings to the edit page.

 

 

Regards, Jonas

 

Votes for this answer: 1
 
Grzegorz Morawski
Reply

Now everything is OK.

I had a small typo in parameter name in Serialize().

Example is OK, I'm starting modify my own providers.

 

Thank you very much.

 
Jonas Dam
Reply

Glad to hear it - happy coding :)

 

You must be logged in to post in the forum