9 Replies Latest reply on Apr 26, 2012 7:44 PM by mhamel

    Custom Data Reference cannot be made configurable

    Jaison_Rodrigues

      Hi All,

       

      I have developed a Custom DR plug-in which fetches data into PI AF using a WCF service. I have compiled this code into a assembly (dll) and registered it into PI AF using -regplugin and it works fine. But currently this Data Reference points to a WCF Service which is hosted in Development Environment. I have to hand-over this compiled Data Reference assembly to the Infrastructure, along with instructions how to register it, since we no longer have access to the Production environment.

       

       

       

      But in Production Environment the WCF Service will be hosted in different server, that means the Address of the Service in the Custom Data Reference  needs to be changed and pointed to  the server hosting the WCF service.

       

       

       

      Is there anyway in which we can make this Address configurable, so that we can change this at one place and Data Reference which is registered will read this change and point to correct WCF service address?

       

       

       

      I tried to place the web.config file in the Installation directory of PI AF, where the assemblies of all registered Plugins are placed, but still this doesn't work.

       

       

       

      Any help would be appreciated.

       

       

       

      Thanks in advance.

       

       

       

      Regards,

       

      Jaison Rodrigues

       

       

        • Re: Custom Data Reference cannot be made configurable
          MvanderVeeken

          You are right that having the web.config in the PI AF install directory does not do any good. Its also not possible to register the config file with the assemblies. This is because how the AF Plugin system works. 

           

          Usually you don't care a whole lot about this, but when it comes to WCF and app.config files it poses a bit of a challenge.

           

          From your description I get that you got it working without the app.config file, so you are probably creating the binding in code, and use that binding for the WCF client proxy. You probably have your URL to the service hard coded somewhere.

           

          The 'challenge' is to find a nice place to host these configuration settings (for instance binding type and URL). My preference would be to store this in some type of AF structure. I can see two nice options, one would be a small Element hierarchy, with attributes that contain configuration information. The other one would be to use an AFTable with key-value pairs to store information. 

           

          In your DataReference you will have access to the AFDatabase and AFServer that this DataReference is coming from. You can use this information to refer to either the table or the Element(s) where you store configuration data in. 

            • Re: Custom Data Reference cannot be made configurable
              Jaison_Rodrigues

              Thanks Michael,

               

              This would help. But I have one more challenge. My AF Structure or Hierarchy gets loaded from a different data source. I create a AF Database programmatically and then call another WCF service which fills up my database with Elements, attributes and Templates programatically.

               

              So creating a AF structure to store configuration information will not be of great help. But I can give it a try.

               

              And i have not hard coded the URL of the service. It's in the app.config file and is read when my code is compiled. Any further changes to the app.config file are of no use. Every time I make changes to app.config, I need to build my project and register the plugin again.

               

              Thanks for your suggestion. I would look forward for your comments on this.

               

              Regards,

               

              Jaison