static AFAttributeList GetAttributes(AFDatabase database)
        {
            int startIndex = 0;
            int pageSize   = 1000;
            int totalCount;

            AFAttributeList attrList = new AFAttributeList();

            do
            {
                AFAttributeList results = AFAttribute.FindElementAttributes(
                    database: database,
                    searchRoot: null,
                    nameFilter: null,
                    elemCategory: null,
                    elemTemplate: database.ElementTemplates["MeterBasic"],
                    elemType: AFElementType.Any,
                    attrNameFilter: "Energy Usage",
                    attrCategory: null,
                    attrType: TypeCode.Empty,
                    searchFullHierarchy: true,
                    sortField: AFSortField.Name,
                    sortOrder: AFSortOrder.Ascending,
                    startIndex: startIndex,
                    maxCount: pageSize,
                    totalCount: out totalCount);

                attrList.AddRange(results);

                startIndex += pageSize;
            } while (startIndex < totalCount);

            return(attrList);
        }
Beispiel #2
0
        private AFAttributeList GetAttributes()
        {
            int startIndex = 0;
            int totalCount;
            int pageSize = 1000;

            AFAttributeList attrList = new AFAttributeList();

            do
            {
                AFAttributeList attrListTemp = AFAttribute.FindElementAttributes(
                    database: AttributeTemplate.Database,
                    searchRoot: null,
                    nameFilter: "*",
                    elemCategory: null,
                    elemTemplate: AttributeTemplate.ElementTemplate,
                    elemType: AFElementType.Any,
                    attrNameFilter: AttributeTemplate.Name,
                    attrCategory: null,
                    attrType: TypeCode.Empty,
                    searchFullHierarchy: true,
                    sortField: AFSortField.Name,
                    sortOrder: AFSortOrder.Ascending,
                    startIndex: startIndex,
                    maxCount: pageSize,
                    totalCount: out totalCount);

                attrList.AddRange(attrListTemp);

                startIndex += pageSize;
            } while (startIndex < totalCount);

            return(attrList);
        }
        static void FindBuildingInfo(AFDatabase database, string templateName)
        {
            Console.WriteLine("Find Building Info: {0}", templateName);

            AFElementTemplate elemTemp        = database.ElementTemplates[templateName];
            AFCategory        buildingInfoCat = database.AttributeCategories["Building Info"];

            AFElement root = database.Elements["Wizarding World"];

            AFNamedCollectionList <AFAttribute> foundAttributes = AFAttribute.FindElementAttributes(
                database: database,
                searchRoot: root,
                nameFilter: "*",
                elemCategory: null,
                elemTemplate: elemTemp,
                elemType: AFElementType.Any,
                attrNameFilter: "*",
                attrCategory: buildingInfoCat,
                attrType: TypeCode.Empty,
                searchFullHierarchy: true,
                sortField: AFSortField.Name,
                sortOrder: AFSortOrder.Ascending,
                maxCount: 100);

            Console.WriteLine("Found {0} attributes.", foundAttributes.Count);
            Console.WriteLine();
        }
        public void Run()
        {
            PISystems piSystems = new PISystems();
            PISystem  piSystem  = piSystems["<AFSERVER>"];

            AFDatabase afDatabase = piSystem.Databases["NuGreen"];

            AFCategory elementCategory   = afDatabase.ElementCategories["Equipment Assets"];
            AFCategory attributeCategory = afDatabase.AttributeCategories["Real-Time Data"];

            AFElementTemplate elementTemplate = afDatabase.ElementTemplates["Boiler"];

            const int pageSize   = 1000;
            int       startIndex = 0;
            int       totalCount;

            do
            {
                // Find all "Water Flow" attributes in the NuGreen database.
                AFAttributeList attrList = AFAttribute.FindElementAttributes(
                    database: afDatabase,
                    searchRoot: null,
                    nameFilter: "*",
                    elemCategory: elementCategory,
                    elemTemplate: elementTemplate,
                    elemType: AFElementType.Any,
                    attrNameFilter: "*",
                    attrCategory: attributeCategory,
                    attrType: TypeCode.Double,
                    searchFullHierarchy: true,
                    sortField: AFSortField.Name,
                    sortOrder: AFSortOrder.Ascending,
                    startIndex: startIndex,
                    maxCount: pageSize,
                    totalCount: out totalCount);

                foreach (AFAttribute attr in attrList)
                {
                    Console.WriteLine("Parent element name: {0}", attr.Element);
                }

                startIndex += pageSize;
            } while (startIndex < totalCount);
        }