예제 #1
0
        /// <summary>
        /// Validates base fault.
        /// </summary>
        /// <param name="detail"></param>
        /// <param name="reason"></param>
        /// <returns></returns>
        protected bool ValidateBaseFault(BaseFaultType detail, out string reason)
        {
            // standard serializer does not parse Timestamp correctly - it goes in Any
            XmlElement timestampElement = FindElement(detail,
                                                      BaseNotification.TIMESTAMP,
                                                      BaseNotification.WSRFBFNAMESPACE);

            if (timestampElement != null)
            {
                string timestamp = timestampElement.InnerText;
                if (string.IsNullOrEmpty(timestamp))
                {
                    reason = "Timestamp is empty";
                    return(false);
                }
                if (!EventServiceUtils.IsValidXsdDateTime(timestamp))
                {
                    reason = string.Format("Timestamp '{0}' is not valid ", timestamp);
                    return(false);
                }
            }
            else
            {
                // should this error be fixed in some moment...
                if (detail.Timestamp == DateTime.MinValue)
                {
                    reason = "Timestamp not specified";
                    return(false);
                }
            }

            reason = string.Empty;
            return(true);
        }
예제 #2
0
        DateTime GetMessageTime(NotificationMessageHolderType Message)
        {
            string utcTimeValue = Message.Message.Attributes[OnvifMessage.UTCTIMEATTRIBUTE].Value;

            if (EventServiceUtils.IsValidXsdDateTime(utcTimeValue))
            {
                return(DateTime.Parse(utcTimeValue));
            }
            else
            {
                return(DateTime.MaxValue);
            }
        }