Esempio n. 1
0
        private AFEventFrame CreateEventFrame(AFDatabase db, AFElementTemplate eventFrameTemplate, AFCategory elementCategory)
        {
            AFEventFrame ef = null;

            if (eventFrameTemplate == null)
            {
                AFElement el2       = db.Elements[Constants.AF_ELEMENT_NAME + "2"];
                AFElement el        = db.Elements[Constants.AF_ELEMENT_NAME];
                AFTime    startTime = new AFTime(DateTime.Now.AddDays(-1));
                ef = new AFEventFrame(db, Constants.AF_EVENT_FRAME_NAME);
                ef.ReferencedElements.Add(el);
                ef.ReferencedElements.Add(el2);
                ef.PrimaryReferencedElement = el;
                ef.SetStartTime(startTime);
                ef.CanBeAcknowledged = true;
                ef.SetEndTime(new AFTime("*"));
                ef.Categories.Add(elementCategory);
                AFEventFrame ef1 = ef.EventFrames.Add(Constants.AF_EVENT_FRAME_NAME + "Child1");
                AFEventFrame ef2 = ef.EventFrames.Add(Constants.AF_EVENT_FRAME_NAME + "Child2");
                ef.Attributes.Add(Constants.AF_ATTRIBUTE_NAME);
                IList <AFAnnotation> annotations = el.GetAnnotations();
                AFAnnotation         ann         = new AFAnnotation(ef);
                ann.Name  = Constants.AF_EVENT_FRAME_ANNOTATION_NAME;
                ann.Value = "Sample value for annotation";
                ann.Save();
            }
            else
            {
                AFElement myTank1   = db.Elements["Tank 1"];
                AFElement myTank2   = db.Elements["Tank 2"];
                AFTime    startTime = new AFTime("*-1d");
                ef = new AFEventFrame(db, "Tank Level 1", eventFrameTemplate);
                ef.ReferencedElements.Add(myTank1);
                ef.ReferencedElements.Add(myTank2);
                ef.PrimaryReferencedElement = myTank1;
                ef.SetStartTime(AFTime.Now);
                ef.CheckIn();
                AFTime endTime = AFTime.Now;
                ef.SetEndTime(endTime);
            }
            return(ef);
        }