5 Replies Latest reply on May 9, 2015 9:57 PM by JFors

    Custom DataReference Attribute ConfigString null

    JFors

      I've created a custom datareference which seems to be working correctly as far as the value returned.  The problem symptom is that when I enter a ConfigString via system explorer  and commit the change, the ConfigString persists.  Then when I shutdown explorer and restart, the Attribute configstring is null. 

      I've provided the Property (Get:Set) of the configstring which is getting called.  Is there a something more I need to do?

       

      I've attached the class file for review.

        • Re: Custom DataReference Attribute ConfigString null
          Rick Davin

          In your ConfigString setter, you should use:

           

          // notify SDK and clients of change.  Required to have changes saved.
          SaveConfigChanges();
          

           

          This should do what you want, that is persist the changes.

           

          Using your entire ConfigString code, this would look like:

           

              public override string ConfigString
              {
                  // The ConfigString property is used to store and load the configuration of this data reference.
                  // The ConfigString for PerfMeas shall include a list(one or more) of AFAttribute references
                  // delimited by semicolon (;)
                  get
                  {
                      try
                      {
                          if (sConfig == null) Debug.WriteLine("Property Get Configstring is null");
                          else Debug.WriteLine(String.Format("Property Get Configstring is {0}", sConfig));
          
          
                          return sConfig;
                      }
                      catch { throw new ApplicationException(String.Format("Error in ConfigString Get '{0}'", sConfig)); }
                  } // end get
                  set
                  {
                      try
                      {
                          if (value == null) Debug.WriteLine("Property Set Configstring value is null", sConfig);
                          else Debug.WriteLine(String.Format("Property Set Configstring value is  {0}", value));
                                     
                            sConfig = value;
                            // notify SDK and clients of change.  Required to have changes saved.
                            SaveConfigChanges();
                      }  //end try 
                      catch { throw new ApplicationException(String.Format("error in configstring Set '{0}'", value)); }
                  }
              }
          

           

          See lines 26 and 27 above.

           

          Though you didn't ask, I see you are passing an empty AFAttributeList in GetInputs but maintaining your own private list named MyinputAttributes.  Later in GetValue you then fetch the data yourself, presumably to measure it.  Your fetching is done one attribute at a time inside a for loop but since MyinputAttributes is an AFAttributeList, you could issue a bulk call making things a bit faster.

          • Re: Custom DataReference Attribute ConfigString null
            bshang

            Hi John,

             

            I believe the changes to the ConfigString aren't being persisted to the AF server. To do this, in the Set accessor of the AFDataReference.ConfigString property, please call SaveConfigChanges().

             

            For example, try modifying the current Set to the one below:

             

                    set
                    {
                        try
                        {
                            if (value == null) Debug.WriteLine("Property Set Configstring value is null", sConfig);
                            else Debug.WriteLine(String.Format("Property Set Configstring value is  {0}", value));
                                     
                              sConfig = value;
                              SaveConfigChanges();
                        }  //end try
                        catch { throw new ApplicationException(String.Format("error in configstring Set '{0}'", value)); }
                    }
            

             

            You'll find a similar pattern in the example below in the new AF SDK online help. See example at the bottom.

            AFDataReference Class

             

            Just in case you haven't seen it, the TechSupport site below as some more supporting info regarding implementing a custom DR.

            Implementing AF 2.x Data References

             

            Please let us know how this goes.

            • Re: Custom DataReference Attribute ConfigString null
              bshang

              Haha, I was just reading the thoughts live from your mind!

              • Re: Custom DataReference Attribute ConfigString null
                JFors

                Thanks for the Posts, Rick & Barry. 

                Yes, I'm not storing the Attribute references except locally to prevent the values from already being retrieved and thus setting up the Cache.  I'm attempting to create a worst case performance measurement as if a user were to perform a typical query.  I'm limited in what AFSDK i can use as I've only got Visual Studio 2010, so the bulk calls are out. 

                 

                I think I've found a potential bug in AF and was wondering where I should present a post,  

                What I found while doing a recursive search of Element Attributes and filtering by the DataReferencePlugin.AssemblyFileName.  if I have an AFAttribute which is a child of an AFAttribute the AssemblyFileName has the value of the Parent AFAttribute and not its own. 

                 

                Thanks Again