コード例 #1
0
        public void DeleteTest()
        {
            string path = Constants.AF_TIMERULE_PATH;

            instance.Delete(webId);
            StandardPISystem.Refresh();
            var newTimeRule = AFObject.FindObject(path) as AFTimeRule;

            Assert.IsNull(newTimeRule);
        }
コード例 #2
0
        public void DeleteTest()
        {
            instance.Delete(webId);
            StandardPISystem.Refresh();
            AFDatabase db = AFObject.FindObject(Constants.AF_DATABASE_NAME) as AFDatabase;

            Assert.IsNull(db);
            DeleteSampleDatabaseForTests();
            CreateSampleDatabaseForTests();
        }
コード例 #3
0
        public static T Find <T>(this PISystems systems, string path)
            where T : AFObject
        {
            if (systems.DefaultPISystem == null)
            {
                throw new InvalidOperationException("Default PISystem must be set.");
            }

            return(AFObject.FindObject(path, systems.DefaultPISystem) as T);
        }
コード例 #4
0
        public void Init()
        {
            PIWebApiClient client = PIWebApiClientGenerator.GenerateInstance();

            instance             = client.Configuration;
            configElement        = AFObject.FindObject(Constants.PIWEBAPI_CONFIGURATION_ELEMENT_PATH) as AFElement;
            corsExpHeaders       = configElement.Attributes[Constants.PIWEBAPI_CONFIGURATION_CORSEXPHEADERS].GetValue().Value.ToString();
            corsMethods          = configElement.Attributes[Constants.PIWEBAPI_CONFIGURATION_CORSMETHODS].GetValue().Value.ToString();
            scanSearchInterval   = configElement.Attributes[Constants.PIWEBAPI_CONFIGURATION_CORSEACHSCANINTERVALS].GetValue().ValueAsInt32();
            corsMethodsAttribute = configElement.Attributes[Constants.PIWEBAPI_CONFIGURATION_CORSMETHODS];
        }
コード例 #5
0
        public void DeleteTest()
        {
            instance.Delete(webId);
            StandardPISystem.UOMDatabase.Refresh();
            string   path        = Constants.AF_UOM_CLASS_PATH;
            UOMClass newUomClass = AFObject.FindObject(path) as UOMClass;

            Assert.IsNull(newUomClass);
            DeleteSampleDatabaseForTests();
            CreateSampleDatabaseForTests();
        }
コード例 #6
0
        public void CreateUnitTest()
        {
            PIUnit unitDTO = new PIUnit(null, null, Constants.AF_UOM_CLASS_UNIT + "4", Constants.AF_UOM_CLASS_ABBR + "4", "Test4 for Swagger", null, null, null, 1, 0, Constants.AF_UOM_CLASS_ABBR);

            instance.CreateUnit(webId, unitDTO);
            StandardPISystem.UOMDatabase.Refresh();
            string   path        = Constants.AF_UOM_CLASS_PATH;
            UOMClass newUomClass = AFObject.FindObject(path) as UOMClass;

            Assert.IsNotNull(newUomClass);
        }
コード例 #7
0
        public void DeleteTest()
        {
            string path = Constants.AF_SECURITY_MAPPING_PATH;

            instance.Delete(webId);
            StandardPISystem.Refresh();
            AFSecurityMapping mySecurityMapping = AFObject.FindObject(path) as AFSecurityMapping;

            Assert.IsNull(mySecurityMapping);
            DeleteSampleDatabaseForTests();
            CreateSampleDatabaseForTests();
        }
コード例 #8
0
        public void CreateElementCategoryTest()
        {
            string            path            = Constants.AF_DATABASE_PATH;
            PIElementCategory elementCategory = new PIElementCategory(null, null, "elementCategorySwagger");

            instance.CreateElementCategory(webId, elementCategory);

            AFDatabase db = AFObject.FindObject(path) as AFDatabase;

            db.Refresh();
            Assert.IsNotNull(db.ElementCategories[elementCategory.Name]);
        }
コード例 #9
0
        public void DeleteTest()
        {
            string path = Constants.AF_SECURITY_IDENTITY_PATH;

            instance.Delete(webId);
            StandardPISystem.Refresh();
            AFSecurityIdentity mySecurityIdentity = AFObject.FindObject(path) as AFSecurityIdentity;

            Assert.IsNull(mySecurityIdentity);
            DeleteSampleDatabaseForTests();
            CreateSampleDatabaseForTests();
        }
コード例 #10
0
        public void CreateEnumerationSetTest()
        {
            string           path           = Constants.AF_DATABASE_PATH;
            PIEnumerationSet enumerationSet = new PIEnumerationSet(null, null, "EnumerationSetSwagger", "Description...");

            instance.CreateEnumerationSet(webId, enumerationSet);

            AFDatabase db = AFObject.FindObject(path) as AFDatabase;

            db.Refresh();
            Assert.IsNotNull(db.EnumerationSets[enumerationSet.Name]);
        }
コード例 #11
0
        public void CreateTableTest()
        {
            string  path  = Constants.AF_DATABASE_PATH;
            PITable table = new PITable(null, null, "TableTestNameSwagger", "Description for table");

            instance.CreateTable(webId, table);

            AFDatabase db = AFObject.FindObject(path) as AFDatabase;

            db.Refresh();
            Assert.IsNotNull(db.Tables[table.Name]);
        }
コード例 #12
0
        public void DeleteTest()
        {
            instance.Delete(webId);
            AFDatabase db = StandardPISystem.Databases[Constants.AF_DATABASE_NAME];

            db.Refresh();
            AFAttribute attribute = AFObject.FindObject(Constants.AF_ATTRIBUTE_PATH) as AFAttribute;

            Assert.IsNull(attribute);
            DeleteSampleDatabaseForTests();
            CreateSampleDatabaseForTests();
        }
コード例 #13
0
        public void CreateElementTemplateTest()
        {
            string            path     = Constants.AF_DATABASE_PATH;
            PIElementTemplate template = new PIElementTemplate(null, null, "ElementTemplate", "Description..");

            instance.CreateElementTemplate(webId, template);

            AFDatabase db = AFObject.FindObject(path) as AFDatabase;

            db.Refresh();
            Assert.IsNotNull(db.ElementTemplates[template.Name]);
        }
コード例 #14
0
        public void CreateAttributeCategoryTest()
        {
            string path = Constants.AF_DATABASE_PATH;
            PIAttributeCategory attributeCategory = new PIAttributeCategory(null, null, "SwaggerAttributeCategory2Test", "Description...");

            instance.CreateAttributeCategory(webId, attributeCategory);

            AFDatabase db = AFObject.FindObject(path) as AFDatabase;

            db.Refresh();
            Assert.IsNotNull(db.AttributeCategories[attributeCategory.Name]);
        }
コード例 #15
0
        public void CreateElementTest()
        {
            string    path    = Constants.AF_DATABASE_PATH;
            PIElement element = new PIElement(null, null, "SwaggerElementTest");

            instance.CreateElement(webId, element);

            AFDatabase db = AFObject.FindObject(path) as AFDatabase;

            db.Refresh();
            Assert.IsNotNull(db.Elements[element.Name]);
        }
コード例 #16
0
        public void CreateAnalysisTemplateTest()
        {
            string             path     = Constants.AF_DATABASE_PATH;
            PIAnalysisTemplate template = new PIAnalysisTemplate(null, null, "AnalysisTemplateSwagger", "Description123");

            instance.CreateAnalysisTemplate(webId, template);

            AFDatabase db = AFObject.FindObject(path) as AFDatabase;

            db.Refresh();
            Assert.IsNotNull(db.AnalysisTemplates[template.Name]);
        }
コード例 #17
0
        public void DeleteTest()
        {
            instance.Delete(webId);
            AFDatabase db = StandardPISystem.Databases[Constants.AF_DATABASE_NAME];

            db.Refresh();
            AFCategory analysisCategory = AFObject.FindObject(Constants.AF_ANALYSIS_CATEGORY_PATH) as AFCategory;

            Assert.IsNull(analysisCategory);
            DeleteSampleDatabaseForTests();
            CreateSampleDatabaseForTests();
        }
コード例 #18
0
        public void DeleteTest()
        {
            instance.Delete(webId);
            AFDatabase db = StandardPISystem.Databases[Constants.AF_DATABASE_NAME];

            db.Refresh();
            AFAnalysisTemplate analysisTemplate = AFObject.FindObject(Constants.AF_ANALYSIS_TEMPLATE_PATH) as AFAnalysisTemplate;

            Assert.IsNull(analysisTemplate);
            DeleteSampleDatabaseForTests();
            CreateSampleDatabaseForTests();
        }
コード例 #19
0
        public void DeleteTest()
        {
            instance.Delete(webId);
            AFDatabase db = StandardPISystem.Databases[Constants.AF_DATABASE_NAME];

            db.Refresh();
            AFElement element = AFObject.FindObject(Constants.AF_ELEMENT_PATH) as AFElement;

            Assert.IsNull(element);
            DeleteSampleDatabaseForTests();
            CreateSampleDatabaseForTests();
        }
コード例 #20
0
        public void CreateTableCategoryTest()
        {
            string          path          = Constants.AF_DATABASE_PATH;
            PITableCategory tableCategory = new PITableCategory(null, null, "Table1SwaggerCategory", "Description...");

            instance.CreateTableCategory(webId, tableCategory);

            AFDatabase db = AFObject.FindObject(path) as AFDatabase;

            db.Refresh();
            Assert.IsNotNull(db.TableCategories[tableCategory.Name]);
        }
コード例 #21
0
        public void DeleteTest()
        {
            instance.Delete(webId);
            AFDatabase db = StandardPISystem.Databases[Constants.AF_DATABASE_NAME];

            db.Refresh();
            AFEnumerationSet enumSet = AFObject.FindObject(Constants.AF_ENUMERATION_SET_PATH) as AFEnumerationSet;

            Assert.IsNull(enumSet);

            DeleteSampleDatabaseForTests();
            CreateSampleDatabaseForTests();
        }
コード例 #22
0
        public void DeleteEnumerationValueTest()
        {
            string path = Constants.AF_ENUMERATION_VALUE_PATH;

            instance.DeleteEnumerationValue(webId);
            AFDatabase db = StandardPISystem.Databases[Constants.AF_DATABASE_NAME];

            db.Refresh();
            AFEnumerationValue afEnumValue = AFObject.FindObject(path) as AFEnumerationValue;

            Assert.IsNull(afEnumValue);
            DeleteSampleDatabaseForTests();
            CreateSampleDatabaseForTests();
        }
コード例 #23
0
        public void DeleteTest()
        {
            string path = Constants.AF_EVENT_FRAME_PATH;

            instance.Delete(webId);
            AFDatabase db = StandardPISystem.Databases[Constants.AF_DATABASE_NAME];

            db.Refresh();
            AFEventFrame eventFrame = AFObject.FindObject(path) as AFEventFrame;

            Assert.IsNull(eventFrame);
            DeleteSampleDatabaseForTests();
            CreateSampleDatabaseForTests();
        }
コード例 #24
0
        public void DeleteTest()
        {
            StandardPISystem.UOMDatabase.Refresh();
            string path = Constants.AF_UOM_PATH;
            UOM    uom1 = AFObject.FindObject(path) as UOM;

            Assert.IsNotNull(uom1);

            instance.Delete(webId);
            StandardPISystem.UOMDatabase.Refresh();

            UOM uom = AFObject.FindObject(path) as UOM;

            Assert.IsNull(uom);
        }
コード例 #25
0
        public void CreateValueTest()
        {
            PIEnumerationValue enumerationValue = new PIEnumerationValue()
            {
                Name  = "Ultra Good",
                Value = 5
            };

            instance.CreateValue(webId, enumerationValue);
            AFDatabase db = StandardPISystem.Databases[Constants.AF_DATABASE_NAME];

            db.Refresh();
            AFEnumerationSet enumSet = AFObject.FindObject(Constants.AF_ENUMERATION_SET_PATH) as AFEnumerationSet;

            Assert.IsTrue(enumSet.Count == 5);
        }
コード例 #26
0
        public void CreateEventFrameTest()
        {
            PIEventFrame childEventFrame = new PIEventFrame()
            {
                Name      = Constants.AF_EVENT_FRAME_NAME + "3",
                StartTime = "*-2d",
                EndTime   = "*-1d"
            };

            instance.CreateEventFrame(webId, childEventFrame);
            string       path         = Constants.AF_EVENT_FRAME_PATH;
            AFEventFrame myEventFrame = AFObject.FindObject(path) as AFEventFrame;

            myEventFrame.Refresh();
            Assert.IsNotNull(myEventFrame.EventFrames[childEventFrame.Name]);
        }
コード例 #27
0
        /// <summary>
        /// Verify and process configuration
        /// </summary>
        private static bool TryInitialize(out Settings settings)
        {
            settings = new Settings();

            // Check the required settings
            string path = ConfigurationManager.AppSettings["AFDatabasePath"];

            if (String.IsNullOrWhiteSpace(path))
            {
                Console.WriteLine("AFDatabasePath is missing in appSettings.");
                return(false);
            }

            string rollupPath = ConfigurationManager.AppSettings["RollupPath"];

            if (String.IsNullOrWhiteSpace(rollupPath))
            {
                Console.WriteLine("RollupPath is missing in appSettings.");
                return(false);
            }

            // Parse the RollupPath setting into an array of hierarchy level names.
            // If there is no more than one level, return false beacuse there is nothing to build
            settings.RollupLevels = rollupPath.Split('|');
            if (settings.RollupLevels.Count() <= 1)
            {
                Console.WriteLine("RollupPath, {0}, is not valid.", rollupPath);
                return(false);
            }

            // Get the target AF Database and the leaf element template
            AFObject result = AFObject.FindObject(path);

            if (result is AFDatabase)
            {
                settings.TargetDatabase      = (AFDatabase)result;
                settings.LeafElementTemplate = settings.TargetDatabase.ElementTemplates[settings.RollupLevels[0]];
            }
            else
            {
                Console.WriteLine("Cannot find the specified AF Database, {0}.", path);
                return(false);
            }

            return(true);
        }
コード例 #28
0
        public void ObserveAFCachePerUser()
        {
            AFElement element1 = AFObject.FindObject(elementPath) as AFElement;
            AFElement element2 = AFObject.FindObject(elementPath) as AFElement;

            Assert.Same(element1, element2);

            // You'll need a local user named 'testuser' with password
            // '@bcd1234' to run this case.
            using (Impersonation.LogonUser(
                       null, "testuser", "@bcd1234", LogonType.Network))
            {
                element2 = AFObject.FindObject(elementPath) as AFElement;
            }

            Assert.NotSame(element1, element2);
        }
コード例 #29
0
        public void Init()
        {
            base.CommonInit();
            instance = client.StreamSet;
            base.CreateSampleDatabaseForTests();
            webIds = new List <string>();
            webIds.Add(client.Point.GetByPath(Constants.DATA_SERVER_PATH + @"\sinusoid").WebId);
            webIds.Add(client.Point.GetByPath(Constants.DATA_SERVER_PATH + @"\sinusoidu").WebId);
            webIds.Add(client.Point.GetByPath(Constants.DATA_SERVER_PATH + @"\cdt158").WebId);
            AFElement element = AFObject.FindObject(Constants.AF_ELEMENT_STREAMSET_PATH) as AFElement;

            element.Refresh();
            Assert.IsTrue(element.Attributes.Count == 3);
            webId      = client.Element.GetByPath(Constants.AF_ELEMENT_STREAMSET_PATH).WebId;
            attr1webId = client.Attribute.GetByPath(Constants.AF_ELEMENT_STREAMSET_PATH + "|sinusoid").WebId;
            attr2webId = client.Attribute.GetByPath(Constants.AF_ELEMENT_STREAMSET_PATH + "|sinusoidu").WebId;
            attr3webId = client.Attribute.GetByPath(Constants.AF_ELEMENT_STREAMSET_PATH + "|cdt158").WebId;
        }
コード例 #30
0
        public void SetValueTest()
        {
            DateTime     time  = DateTime.Today;
            PITimedValue value = new PITimedValue("t", null, true, false, false, 153);

            value.Substituted = null;
            instance.SetValue(webId, value);

            string     path = Constants.AF_ATTRIBUTE_PATH;
            AFDatabase db   = StandardPISystem.Databases[Constants.AF_DATABASE_NAME];

            db.Refresh();
            AFAttribute myAttribute = AFObject.FindObject(path) as AFAttribute;
            float       v1          = myAttribute.GetValue().ValueAsSingle();
            float       v2          = Convert.ToSingle(value.Value);

            Assert.IsTrue(v1 == v2);
        }