1 Reply Latest reply on Sep 30, 2015 12:25 PM by dng

    Error message in AF version

    Suganya_Ganesan

      Hi All,

       

      I have tried validating based on version Id but prompting error message as "cannot convert implicitly system.guid to osisoft.af.asset.afversion" Will anyone please resolve this issue??? Here is my code snippet .

       

      AFElement parentAFElement = objAFDatabase.Elements["MMO"];

                                              AFElement childAFElement = parentAFElement.Elements["Meters"];

                                              AFElement myAFElement = childAFElement.Elements[meterId];

                                              DateTime dtVersion = myAFElement.Version.EffectiveDate;

                                              AFVersion versionId = myAFElement.Version.VersionID;//......GETTING ERROR HERE................////

                                              //if (myAFElement.Version.VersionID.ToString() == "2")

                                              if(versionId.ToString() =="2")

                                              {

                                                  if (csvInputFileName.ToUpper().StartsWith("INCON"))

                                                  {

                                                      ExceptionHandling("Updated connection Mode file received before Initial Connection Mode Report", "EC17", "AC17");

                                                      LogMessage(csvInputFileName, startcsvDateProcess, "", "", "", "Updated connection Mode file received before Initial Connection Mode Report");

                                                  }

                                              }

        • Re: Error message in AF version
          dng

          Hi Suganya,

           

          The AFElement.Version property returns AFVersion, while the AFVersion.VersionID property returns a Guid. The error message indicates that you are trying to assign a Guid (VersionID) to a variable with type AFVersion. The following code will not throw an error:

          AFVersion afVersion = myAFElement.Version;
          Guid versionId = afVersion.VersionID;
          

           

          More importantly, what are you trying to achieve by comparing the versions? Consider finding a particular version by query date using the AFVersion.FindVersion method. You can also navigate back and forth to different versions using the AFVersion.PreviousVersion, NextVersion or LatestVersion methods. If you just want to see if there are multiple versions for this element, you can look at the AFVersion.HasMultipleVersions property.