Showing posts with label configuration. Show all posts
Showing posts with label configuration. Show all posts

Thursday, March 22, 2012

Custom Task and Reading Package Configuration

Hello All,

I have searched on this forum for a similar question but couldn't find it so I apologize if this has been asked. If so, I'd greatly appreciate a link to the question. I have created a custom task and am trying to read an xml package configuration file within my custom task. To be more specific, I have added an ADO.Net Connection to my database onto the package and have generated the appropriate tags within my package's configuration xml file. I'm not seeing the classes I should use to access the configuration file of the package I've created. Does anybody have any ideas how I can accomplish this or a link to a document that might cover the material? Thanks!

Jay_G

Jay,

First, let's be sure that what you're trying to do is what you really want to do.

Why do you want to read the configuration? Are you trying to do something with the configuration or do you simply want your custom task to be configured?

|||

Hello Kirk,

Thank you for responding. My custom task will, at times, need to read from a database and I figured the standard database connection string parameters would all be within the configuration file. I initially thought that I would need to use a package connection but the original intent of this custom task is be as easy to use and seemless as possible (meaning drop the task on the designer, set a few properties and be done). The custom task will be used over and over again within many packages. We didn't want to make all of our package developers have to configure a connection for this task but maybe this approach doesn't make sense. Does that make sense or should I be doing it a different way? I'm very new to SSIS and very much open to suggestions. Let me know if you need more clarification. Thanks again.

Jay_G

Saturday, February 25, 2012

Custom ControlFlow

I am trying to design a Component which can be configured by a UI. After Configuration from the Design pane the Data should be passed to the back-end of the Component.
When I look at some code samples I only see, that it's possible to pass simple data.
What I want is to put a grid on the UI and connect it to a DataTable. This is used for displaying and changing a configuration as a table.
Well, the question is: Can I pass the DataTable object to the backend-DLL as is? If so then how?
THX
Fridtjof
Can you please clarify whether you are creating a custom Task or a custom Data Flow Component, or another type of run-time object like a connection manager? The APIs are similar but not identical.

-Doug
|||From your subect I assume you mean a Task. Why can you not just create a property of your task, typed as a DataTable?|||Well I don't have any instance of the Backend Class in the Definition of the UI-Class, have I?
If I had one there would be no problem setting the DataSource of the Grid to that DataTable.
|||

You keep referring to the backend-class, do you mean the task itself, the class that inherits from Task?

If so you should have a reference to it in the UI. You need to cache it and pass it through, but otherwise there is not much point to the UI.

Review this code form one of my tasks. This is the UI class, the one that inherits from IDtsTaskUI. My form is ZipFileTaskUIForm, and has a modified constructor to accept the parameters passed through. You can see the TaskHost is cached in Initialize, and then passed to the form. This is how you get a reference to your task into the form.


public System.Windows.Forms.ContainerControl GetView()
{
return new ZipFileTaskUIForm(_taskHost, _dtsConnectionService, _dtsVariableService);
}
public void Initialize(TaskHost taskHost, IServiceProvider serviceProvider)
{
_taskHost = taskHost;

IDtsVariableService dtsVariableService = serviceProvider.GetService(typeof(IDtsVariableService)) as IDtsVariableService;
IDtsConnectionService dtsConnectionService = serviceProvider.GetService(typeof(IDtsConnectionService)) as IDtsConnectionService;
_dtsConnectionService = dtsConnectionService;
_dtsVariableService = dtsVariableService;
}


|||To your question: Yes I mean the class which inherits from Task! That's what I call Backend-Class.
Your code is from the Class which inherits from IDtsTaskUI.
The question is how can you access public members of my Backend-Class in the UI (Form).
Maybe I have to convert and cache then, because the ui is called at design-time and the Backend at runtime?
|||Your form should be invoked from the UI class (IDtsTaskUI). The sample I showed demonstrates grabbing TaskHost, and passing it through to the form. You use the TaskHost to access properies of the task itself. You cannot get direct access to the Task instance, but you should not actually need to as you have TaskHost instead.
If you have code that you wish to share between trasjk and UI classes, then make them public static. Instance members would not work anyway since you cannot get the instance.

|||In addition to the Initialize method in the UI class that comes from the IDtsXxxUI interface, I would be inclined to write an Initialize method of my own in my Windows Forms class and pass along a reference to my task or other object, so I can easily read its current property values to set initial control states and values, then update its properties from the controls when the user closes the form.

So Task passes reference to itself in calling Initialize in Task UI class, and Task UI class passes reference to task in calling custom Initialize method in Task UI Form class.

-Doug
|||

I am also facing same problem. When i explored i came to know that there was two method SaveToXML() and LoadXML() of IDTSPersist90 interface to handle this type of scenerio. But i could not able to raise these methods. you can transfer either string or interger...etc, but if you want to transfer some custom object i think you have to preserve the same in xml and retrieve it when ever needed

...Karun

|||

As I understand the issue, bearing in mind this thread crossed several, none of which matched the title that well, but you are writing a task and have a complex type that you need to persist. All persistance is through XML, and for complex stuff you need to implement IDTSPersist90 yourself. The methods are never called by you, they are called by the designer. You fill in the code to save and load the values to and from the XML document provided, and you can choose how you store the information in the XML.

For objects, I found the easiest way to to serialize them, and actually binary serialization at that. This snippet gives me a string that I can easily store in an xml element for the property.

public static string SerializeObject(object graph) { BinaryFormatter formatter1 = new BinaryFormatter(); MemoryStream stream1 = new MemoryStream(); formatter1.Serialize(stream1, graph); string text1 = Convert.ToBase64String(stream1.GetBuffer()); stream1.Close(); return text1; }

Another alternative is to use reflection to read an object's properties, and then build up an XML node that represents this. Here is an example of creating a new element with sub elements for each property-

public static XmlElement AddXmlObjectProperties(XmlElement parentElement, string propertyName, object propertyObject) { XmlElement element1 = XMLPersistanceHelper.AddXmlElement(parentElement, propertyName); Type type1 = propertyObject.GetType(); foreach (PropertyInfo info1 in type1.GetProperties()) { Type type2 = info1.PropertyType; string text1 = type2.Name; object obj1 = info1.GetValue(propertyObject, null); if (type2.IsEnum) { obj1 = Convert.ToInt32(info1.GetValue(propertyObject, null)); } if (obj1 != null) { XmlElement element2 = XMLPersistanceHelper.AddXmlElement(element1, "Property", obj1.ToString()); XMLPersistanceHelper.AddXmlAttribute(element2, "Name", info1.Name); XMLPersistanceHelper.AddXmlAttribute(element2, "Type", text1); } } return element1; }

Custom ControlFlow

I am trying to design a Component which can be configured by a UI. After Configuration from the Design pane the Data should be passed to the back-end of the Component.
When I look at some code samples I only see, that it's possible to pass simple data.
What I want is to put a grid on the UI and connect it to a DataTable. This is used for displaying and changing a configuration as a table.
Well, the question is: Can I pass the DataTable object to the backend-DLL as is? If so then how?
THX
Fridtjof
Can you please clarify whether you are creating a custom Task or a custom Data Flow Component, or another type of run-time object like a connection manager? The APIs are similar but not identical.

-Doug
|||From your subect I assume you mean a Task. Why can you not just create a property of your task, typed as a DataTable?|||Well I don't have any instance of the Backend Class in the Definition of the UI-Class, have I?
If I had one there would be no problem setting the DataSource of the Grid to that DataTable.
|||

You keep referring to the backend-class, do you mean the task itself, the class that inherits from Task?

If so you should have a reference to it in the UI. You need to cache it and pass it through, but otherwise there is not much point to the UI.

Review this code form one of my tasks. This is the UI class, the one that inherits from IDtsTaskUI. My form is ZipFileTaskUIForm, and has a modified constructor to accept the parameters passed through. You can see the TaskHost is cached in Initialize, and then passed to the form. This is how you get a reference to your task into the form.


public System.Windows.Forms.ContainerControl GetView()
{
return new ZipFileTaskUIForm(_taskHost, _dtsConnectionService, _dtsVariableService);
}
public void Initialize(TaskHost taskHost, IServiceProvider serviceProvider)
{
_taskHost = taskHost;

IDtsVariableService dtsVariableService = serviceProvider.GetService(typeof(IDtsVariableService)) as IDtsVariableService;
IDtsConnectionService dtsConnectionService = serviceProvider.GetService(typeof(IDtsConnectionService)) as IDtsConnectionService;
_dtsConnectionService = dtsConnectionService;
_dtsVariableService = dtsVariableService;
}


|||To your question: Yes I mean the class which inherits from Task! That's what I call Backend-Class.
Your code is from the Class which inherits from IDtsTaskUI.
The question is how can you access public members of my Backend-Class in the UI (Form).
Maybe I have to convert and cache then, because the ui is called at design-time and the Backend at runtime?
|||Your form should be invoked from the UI class (IDtsTaskUI). The sample I showed demonstrates grabbing TaskHost, and passing it through to the form. You use the TaskHost to access properies of the task itself. You cannot get direct access to the Task instance, but you should not actually need to as you have TaskHost instead.
If you have code that you wish to share between trasjk and UI classes, then make them public static. Instance members would not work anyway since you cannot get the instance.

|||In addition to the Initialize method in the UI class that comes from the IDtsXxxUI interface, I would be inclined to write an Initialize method of my own in my Windows Forms class and pass along a reference to my task or other object, so I can easily read its current property values to set initial control states and values, then update its properties from the controls when the user closes the form.

So Task passes reference to itself in calling Initialize in Task UI class, and Task UI class passes reference to task in calling custom Initialize method in Task UI Form class.

-Doug
|||

I am also facing same problem. When i explored i came to know that there was two method SaveToXML() and LoadXML() of IDTSPersist90 interface to handle this type of scenerio. But i could not able to raise these methods. you can transfer either string or interger...etc, but if you want to transfer some custom object i think you have to preserve the same in xml and retrieve it when ever needed

...Karun

|||

As I understand the issue, bearing in mind this thread crossed several, none of which matched the title that well, but you are writing a task and have a complex type that you need to persist. All persistance is through XML, and for complex stuff you need to implement IDTSPersist90 yourself. The methods are never called by you, they are called by the designer. You fill in the code to save and load the values to and from the XML document provided, and you can choose how you store the information in the XML.

For objects, I found the easiest way to to serialize them, and actually binary serialization at that. This snippet gives me a string that I can easily store in an xml element for the property.

public static string SerializeObject(object graph) { BinaryFormatter formatter1 = new BinaryFormatter(); MemoryStream stream1 = new MemoryStream(); formatter1.Serialize(stream1, graph); string text1 = Convert.ToBase64String(stream1.GetBuffer()); stream1.Close(); return text1; }

Another alternative is to use reflection to read an object's properties, and then build up an XML node that represents this. Here is an example of creating a new element with sub elements for each property-

public static XmlElement AddXmlObjectProperties(XmlElement parentElement, string propertyName, object propertyObject) { XmlElement element1 = XMLPersistanceHelper.AddXmlElement(parentElement, propertyName); Type type1 = propertyObject.GetType(); foreach (PropertyInfo info1 in type1.GetProperties()) { Type type2 = info1.PropertyType; string text1 = type2.Name; object obj1 = info1.GetValue(propertyObject, null); if (type2.IsEnum) { obj1 = Convert.ToInt32(info1.GetValue(propertyObject, null)); } if (obj1 != null) { XmlElement element2 = XMLPersistanceHelper.AddXmlElement(element1, "Property", obj1.ToString()); XMLPersistanceHelper.AddXmlAttribute(element2, "Name", info1.Name); XMLPersistanceHelper.AddXmlAttribute(element2, "Type", text1); } } return element1; }

Custom configuration settings?

We are an ISV and our OLAP solution will be deployed to many customers. Needless to say, various values needs to be customized to meet the client needs, e.g. KPI goal values. What will the recommended way to implement custom configuration settings in the cube that are accessable to MDX calculations?An example would be helpful. I have vague understanding of what you are asking, perhaps more explanation will make it more clear.

Friday, February 17, 2012

Custom Assembly Configuration Problems

Hi,
I am attempting to integrate a third party .Net assembly into a custom
report I'm writing. The assembly provides functions for creating 2D barcodes
that are a required format for my solution. I've successfully referenced the
assembly and can run my report from visual studio without error.
However, when I deploy and run the report I get the following exception:
Failed to load expression host assembly. Details:
System.Security.Permissions.SecurityPermission (rsProcessingError)
I've added the Custom Assemblies block to my RSReportDesigner.config and my
RSReportServer.config. I have also added code groups to my
rssrvpolicy.config and rspreviewpolicy.config. I have deployed the
referenced dlls to the appropriate bin directories.
The only thing that I haven't done is code the custom assembly to 'assert
permissions'. I shouldn't have to because the assembly takes a simple string
and returns the encoded string - it doesn't use any 'secure' resources (no
files, db connections, etc.). I have also tried using 'FullTrust'
permissions in my code groups even though that is not recommended. In any
event, I do not have source code for this third party assembly nor license to
modify it if I could.
Is there anything I can do to make this work?
--
PaulThe problem is that the third party assembly has strong name and is not
marked with APTCA
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/aptcatypes.asp)
The report expressions at runtime are located in an untrusted assembly thus
any call to a non_APTCA assembly would fail. What you need to do is to
create a thin wrapper assembly that would accept calls from report
expressions and redirect them into the non-APTCA assembly. You will also
need to give fulltrust to that wrapper assembly
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Paul Keegstra" <PaulKeegstra@.discussions.microsoft.com> wrote in message
news:2F8F0E0C-9C98-4EBD-B9D5-AF6D667975BB@.microsoft.com...
> Hi,
> I am attempting to integrate a third party .Net assembly into a custom
> report I'm writing. The assembly provides functions for creating 2D
> barcodes
> that are a required format for my solution. I've successfully referenced
> the
> assembly and can run my report from visual studio without error.
> However, when I deploy and run the report I get the following exception:
> Failed to load expression host assembly. Details:
> System.Security.Permissions.SecurityPermission (rsProcessingError)
> I've added the Custom Assemblies block to my RSReportDesigner.config and
> my
> RSReportServer.config. I have also added code groups to my
> rssrvpolicy.config and rspreviewpolicy.config. I have deployed the
> referenced dlls to the appropriate bin directories.
> The only thing that I haven't done is code the custom assembly to 'assert
> permissions'. I shouldn't have to because the assembly takes a simple
> string
> and returns the encoded string - it doesn't use any 'secure' resources (no
> files, db connections, etc.). I have also tried using 'FullTrust'
> permissions in my code groups even though that is not recommended. In any
> event, I do not have source code for this third party assembly nor license
> to
> modify it if I could.
> Is there anything I can do to make this work?
> --
> Paul|||That doesn't work. Actually, it makes it worse because whereas before I had
a clearly identified exception, adding the wrapper class only results in my
expression evaluating to #Error - with no clue as to the cause. My guess is
it's just the same error, only now the exception has been wrapped out of view.
--
Paul
"Alexandre Mineev MSFT" wrote:
> The problem is that the third party assembly has strong name and is not
> marked with APTCA
> (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/aptcatypes.asp)
> The report expressions at runtime are located in an untrusted assembly thus
> any call to a non_APTCA assembly would fail. What you need to do is to
> create a thin wrapper assembly that would accept calls from report
> expressions and redirect them into the non-APTCA assembly. You will also
> need to give fulltrust to that wrapper assembly
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Paul Keegstra" <PaulKeegstra@.discussions.microsoft.com> wrote in message
> news:2F8F0E0C-9C98-4EBD-B9D5-AF6D667975BB@.microsoft.com...
> > Hi,
> >
> > I am attempting to integrate a third party .Net assembly into a custom
> > report I'm writing. The assembly provides functions for creating 2D
> > barcodes
> > that are a required format for my solution. I've successfully referenced
> > the
> > assembly and can run my report from visual studio without error.
> >
> > However, when I deploy and run the report I get the following exception:
> > Failed to load expression host assembly. Details:
> > System.Security.Permissions.SecurityPermission (rsProcessingError)
> >
> > I've added the Custom Assemblies block to my RSReportDesigner.config and
> > my
> > RSReportServer.config. I have also added code groups to my
> > rssrvpolicy.config and rspreviewpolicy.config. I have deployed the
> > referenced dlls to the appropriate bin directories.
> >
> > The only thing that I haven't done is code the custom assembly to 'assert
> > permissions'. I shouldn't have to because the assembly takes a simple
> > string
> > and returns the encoded string - it doesn't use any 'secure' resources (no
> > files, db connections, etc.). I have also tried using 'FullTrust'
> > permissions in my code groups even though that is not recommended. In any
> > event, I do not have source code for this third party assembly nor license
> > to
> > modify it if I could.
> >
> > Is there anything I can do to make this work?
> >
> > --
> > Paul
>
>

Custom assembly : Retrieving data from from configuration file.

Hi all,

my problem is that: I do read informations (e.g. connectionString) from configuration file by one custom assembly.
My environment is RS2005, VS.NET 2005 Prof.Edition, WIN2003 Server SP1, .NET Framework 2.0.50727
The scenario is that:
A text box into my report require a function contained into MyCustom.dll. This code do read information from MyCustom.dll.config.

This file contains:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="IS2009cfg" connectionString="data source=servername\instancename;initial catalog=dbname;user id=xx;password=yy;" />
</connectionStrings>
<appSettings>
<add key="DefaultHeaderLogo" value="This is a test" />
</appSettings>
</configuration>

Using
ConnectionStringSettings conn = ConfigurationManager.ConnectionStrings["IS2009cfg"];
the result is null.

Also using
string defaultHeaderLogo = ConfigurationManager.AppSettings["DefaultHeaderLogo"];
the result is null.

MyCustom.dll and MyCustom.dll.config are located into locations of Report Server and Report Designer, with this Build Events on succesfully build:

rem Copy custom assembly to ReportDesigner location...
copy "...mydeveloplocation...\bin\Debug\MyCustom.dll" "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\MyCustom.dll"
copy "...mydeveloplocation...\bin\Debug\MyCustom.dll.config" "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\MyCustom.dll.config"
rem Copy custom assembly to ReportServer location...
copy "...mydeveloplocation...\bin\Debug\MyCustom.dll" "C:\Program Files\Microsoft SQL Server\MSSQL.4\Reporting Services\ReportServer\bin\MyCustom.dll"
copy "...mydeveloplocation...\bin\Debug\MyCustom.dll.config" "C:\Program Files\Microsoft SQL Server\MSSQL.4\Reporting Services\ReportServer\bin\MyCustom.dll.config"

The question is simple: where I do locate configuration file for obtain value during report execution?

Many thank's in advance

Claudio Barca
Turin - Italy

Hi, I have the same problem
Do you have solve it?
Thanks

Custom assembly : Retrieving data from from configuration file.

Hi all,

my problem is that: I do read informations (e.g. connectionString) from configuration file by one custom assembly.
My environment is RS2005, VS.NET 2005 Prof.Edition, WIN2003 Server SP1, .NET Framework 2.0.50727
The scenario is that:
A text box into my report require a function contained into MyCustom.dll. This code do read information from MyCustom.dll.config.

This file contains:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="IS2009cfg" connectionString="data source=servername\instancename;initial catalog=dbname;user id=xx;password=yy;" />
</connectionStrings>
<appSettings>
<add key="DefaultHeaderLogo" value="This is a test" />
</appSettings>
</configuration>

Using
ConnectionStringSettings conn = ConfigurationManager.ConnectionStrings["IS2009cfg"];
the result is null.

Also using
string defaultHeaderLogo = ConfigurationManager.AppSettings["DefaultHeaderLogo"];
the result is null.

MyCustom.dll and MyCustom.dll.config are located into locations of Report Server and Report Designer, with this Build Events on succesfully build:

rem Copy custom assembly to ReportDesigner location...
copy "...mydeveloplocation...\bin\Debug\MyCustom.dll" "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\MyCustom.dll"
copy "...mydeveloplocation...\bin\Debug\MyCustom.dll.config" "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\MyCustom.dll.config"
rem Copy custom assembly to ReportServer location...
copy "...mydeveloplocation...\bin\Debug\MyCustom.dll" "C:\Program Files\Microsoft SQL Server\MSSQL.4\Reporting Services\ReportServer\bin\MyCustom.dll"
copy "...mydeveloplocation...\bin\Debug\MyCustom.dll.config" "C:\Program Files\Microsoft SQL Server\MSSQL.4\Reporting Services\ReportServer\bin\MyCustom.dll.config"

The question is simple: where I do locate configuration file for obtain value during report execution?

Many thank's in advance

Claudio Barca
Turin - Italy

Hi, I have the same problem
Do you have solve it?
Thanks

|||I had the same issue and after much debugging I discovered the ConfigurationManager was not reading from MyAssembly.dll.config, but rather it was accessing the machine.config. I added my connection string to the machine.config file and it starting working.