IPIPoints2.AddTags Maximum tag count

Discussion created by bpolaski on Jan 17, 2013
Latest reply on Jan 22, 2013 by mhamel

We have been developing a tool to help create AF structure and PI tags from an XML import file.  Using the tool usually results in trying to create 10K+ tags in one running.  To facilitate this large number of tags we decided that instead of using the PIPoints.Add method we would use the IPIPonts2.AddTags as it was to be a more efficient implementation for multiple tags.


In our testing we have run into an error being thrown by the call IPIPoints2.AddTags.
HRESULT: 0x800407B1 (Error adding tags to PIPoints collection.)


This error is caught by the surrounding Try Catch and not returned as part of the PIErrors that is returned by the operation.


The weird thing with the error is that it is not consistently thrown.  We can run the same import file multiple times and only get the error a few times in the runs.  It does not happen at the start of the call either, upon checking the PI server we find varying amounts of tags created before it throws the error.


My question is this:
Is there a threshold in which the IPIPoints2.AddTags starts having issues and we should do something to make smaller groups of tags to add instead of large chucks all at once?
Is there some condition weshould be checking for, before making the call which is causing the error? 


The Executing code section:

     IPIPoints2 ServerPointList = (IPIPoints2)currentPIServer.PIPoints;
     ServerPointList.AddTags(PITagList, out AddErrors, out CreatedTagList);
     if (AddErrors.Count != 0)
         // if there were problems try to edit the tags.
         // This assumes the tags that had issues already existed
         // record the adderrors
         foreach (PIError error in AddErrors)
             Logging.log.Error(error.Source + " " + error.Number + " " + error.Description);
         ServerPointList.EditTags(PITagList, out EditErrors);
         if (EditErrors.Count != 0)
             // if we were not able to fix the issue by editing tags
             // remove all of the added tags and back out of the import
             foreach (PIError error in EditErrors)
                 Logging.log.Error(error.Source + " " + error.Number + " " + error.Description);
catch (Exception ex)
    // something outside of anything expected happened.
    Logging.log.Error("The following error Occured while the tags were being built:" + ex.Message, ex);



Stack Trace of the error:
System.Runtime.InteropServices.COMException (0x800407B1): Exception from HRESULT: 0x800407B1
at PISDK.IPIPoints2.AddTags(NamedValues pnvsTagsAndAttrs, PIErrors& hErrors, PointList& hList, PIAsynchStatus pAsynchStatus)