Ejemplo n.º 1
0
        public List <EventsTopicInfo> GetTopics()
        {
            TestTool.Proxies.Event.TopicSetType topicSet = GetTopicSet();

            if (topicSet == null || topicSet.Any == null || topicSet.Any.Length == 0)
            {
                return(null);
            }

            List <XmlElement> topics = new List <XmlElement>();

            foreach (XmlElement element in topicSet.Any)
            {
                FindTopics(element, topics);
            }

            List <EventsTopicInfo> topicInfos = new List <EventsTopicInfo>();

            foreach (XmlElement nextTopicElement in topics)
            {
                TopicInfo       info          = TopicInfo.ConstructTopicInfo(nextTopicElement);
                EventsTopicInfo nextTopicInfo = info.GetPlainInfo();
                topicInfos.Add(nextTopicInfo);
            }

            return(topicInfos);
        }
Ejemplo n.º 2
0
        void VerifySeekTopics(TopicSetType topicSet)
        {
            TopicSetHelper    Helper    = new TopicSetHelper(this, topicSet, false);
            List <XmlElement> topicList = Helper.FindTopics();

            foreach (XmlElement topicElement in topicList)
            {
                if (!TopicInfo.TopicsMatch(TopicInfo.ConstructTopicInfo(topicElement), BeginTopic))
                {
                    continue;
                }
                XmlElement messageDescription = topicElement.GetMessageDescription();
                if (messageDescription != null)
                {
                    bool isProperty = false;
                    // check that it is a property
                    if (messageDescription.HasAttribute(OnvifMessage.ISPROPERTY))
                    {
                        isProperty = XmlConvert.ToBoolean(messageDescription.Attributes[OnvifMessage.ISPROPERTY].Value);
                    }
                    Assert(!isProperty,
                           "Topic should not be property topic",
                           "Check " + BeginPath + " topic type");
                    return;
                }
            }
            Assert(false,
                   "Topic missed",
                   "Check " + BeginPath + " topic present");
        }
Ejemplo n.º 3
0
        static private TopicInfo CreateBeginTopic()
        {
            EventsTopicInfo BeginTopicInfo = new EventsTopicInfo();

            BeginTopicInfo.Topic = BeginPath;
            BeginTopicInfo.NamespacesDefinition = "tns1=http://www.onvif.org/ver10/topics";
            return(TopicInfo.ConstructTopicInfo(BeginTopicInfo));
        }
Ejemplo n.º 4
0
        protected XmlElement GetTopicElement(IEnumerable <XmlElement> topics, TopicInfo topicInfo)
        {
            // check if "our" topic is present
            XmlElement topicElement = null;

            foreach (XmlElement el in topics)
            {
                TopicInfo info = TopicInfo.ConstructTopicInfo(el);
                if (TopicInfo.TopicsMatch(info, topicInfo))
                {
                    topicElement = el;
                    break;
                }
            }
            return(topicElement);
        }
Ejemplo n.º 5
0
        List <TopicInfo> GetTopicInfos(string response)
        {
            XmlDocument soapRawResponse = BaseNotificationXmlUtils.GetRawResponse(response);

            // find Topic elements in "raw" packet
            string topicPath;

            topicPath = "/s:Envelope/s:Body/events:GetEventPropertiesResponse/t1:TopicSet";
            XmlNamespaceManager manager = CreateNamespaceManager(soapRawResponse);

            manager.AddNamespace("t1", "http://docs.oasis-open.org/wsn/t-1");

            XmlNode           topicSetNode    = soapRawResponse.SelectSingleNode(topicPath, manager);
            XmlElement        topicSetElement = topicSetNode as XmlElement;
            List <XmlElement> rootTopics      = new List <XmlElement>();

            foreach (XmlNode node in topicSetElement.ChildNodes)
            {
                XmlElement e = node as XmlElement;
                if (e != null)
                {
                    rootTopics.Add(e);
                }
            }

            // Check that the topic of interest is supported

            // select all topics
            List <XmlElement> topics = new List <XmlElement>();

            foreach (XmlElement element in rootTopics)
            {
                FindTopics(element, topics);
            }

            List <TopicInfo> topicInfos = new List <TopicInfo>();

            foreach (XmlElement topicElement in topics)
            {
                TopicInfo info = TopicInfo.ConstructTopicInfo(topicElement);
                topicInfos.Add(info);
            }

            return(topicInfos);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets invalid MessageContentFilter for element passed.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="manager"></param>
        /// <returns></returns>
        private FilterInfo GetInvalidMessageContentFilter(XmlElement element, XmlNamespaceManager manager)
        {
            FilterInfo filter = null;

            // if element is a topic
            if (element.RepresentsTopic())
            {
                // Element represents a topic.
                // Look for MessageDescription

                List <string> itemNames          = new List <string>();
                XmlElement    messageDescription = element.GetMessageDescription();
                if (messageDescription != null)
                {
                    CollectItemNames(messageDescription, manager, OnvifMessage.SIMPLEITEMDESCRIPTION, itemNames);
                    CollectItemNames(messageDescription, manager, OnvifMessage.ELEMENTITEMDESCRIPTION, itemNames);
                }

                string invalidItemName = itemNames.GetNonMatchingString();

                filter = new FilterInfo();

                filter.Filter = new FilterType();

                XmlDocument doc          = new XmlDocument();
                XmlElement  topicElement = doc.CreateTopicElement();

                TopicInfo topicInfo = TopicInfo.ConstructTopicInfo(element);
                string    topicPath = TopicInfo.CreateTopicPath(topicElement, topicInfo);

                topicElement.InnerText = topicPath;

                XmlElement contentFilterElement = doc.CreateContentFilterElement();

                string simpleItemPrefix = contentFilterElement.GetNamespacePrefix(OnvifMessage.ONVIF);
                contentFilterElement.InnerText = string.Format("boolean((//{0}:{1}[@{2}=\"{3}\"] )",
                                                               simpleItemPrefix, OnvifMessage.SIMPLEITEM, OnvifMessage.NAME, invalidItemName);

                filter.Filter.Any         = new XmlElement[] { topicElement, contentFilterElement };
                filter.Topic              = topicInfo;
                filter.MessageDescription = messageDescription;

                return(filter);
            }

            foreach (XmlNode childNode in element.ChildNodes)
            {
                XmlElement child = childNode as XmlElement;
                if (child != null)
                {
                    filter = GetInvalidMessageContentFilter(child, manager);
                    if (filter != null)
                    {
                        return(filter);
                    }
                }
            }

            // if cannot create filter for any element - return null
            return(null);
        }