sandeep.narang

Taking lot of time to get tag attributes values

Discussion created by sandeep.narang on Sep 26, 2011
Latest reply on Sep 27, 2011 by andreas

Hi Team,

 

Is there any way to do the  search on attribute based on their type like tag or static ? As we are doing a search using AFElement.FindElementsByName and we want to get the attribute values based on input type (static or tag). We are using below code for the same, it is working fine when we have small data but take much time when data is large.....

 
objAFElementCollection = AFElement.FindElements(this.Database, null, "*", AFSearchField.Name, true, AFSortField.Name, AFSortOrder.Ascending, 0, 1000, out maxCount);

foreach (AFElement objAFElement in objAFElementCollection )
{

GetAttributeValues(objAFElement,"Tag");

//do some operations

}

 private List GetAttributeValues(AFElement objafelement, string attributeType)
 {
            List lstAttribute = new List();
            AFAttributeList attributes = new AFAttributeList(objafelement.Attributes);

            foreach (AFAttribute objAFAttributes in attributes)
            {
                if (attributeType == "ALL" || (attributeType == "STATIC" && objAFAttributes.DataReference == null) || (attributeType == "TAG" && objAFAttributes.DataReference != null))
                {
                    attribute objAttribute = new attribute();
                    AFValue AttrVal = objAFAttributes.GetValue();
                  
                        objAttribute.Name=objAFAttributes.Name;
                        if (objAFAttributes.DataReference != null)
                        {
                           if ((PISDK.PIPoint)objAFAttributes.RawPIPoint != null)
                                objAttribute.Settings = ((PISDK.PIPoint)objAFAttributes.RawPIPoint).Name;
                        }
                       objAttribute.Value = AttrVal.Value.ToString();
                       lstAttribute.Add(objAttribute);
                   }
            }
            return lstAttribute;
        }

 

 

Please assist us on it....

 

 

 

Thanks,

Outcomes