コード例 #1
0
ファイル: CAP.cs プロジェクト: 1stResponder/em-serializers
        /// <summary>
        /// Validates the CAP 1.1 Area elements are IPAWS Profile 1.0 compliant
        /// </summary>
        /// <param name="infoBlock">The information block portion of the CAP message</param>
        private void ValidateIPAWSProfilev10ForCAPv11AreaBlocks(InfoType infoBlock)
        {
            if (infoBlock.Area != null && infoBlock.Area.Count > 0)
            {
                AreaType ablock = infoBlock.Area[0]; // only first area is processed by IPAWS
                if (string.IsNullOrEmpty(ablock.AreaDesc))
                {
                    throw new System.ArgumentNullException("IPAWS Profile v1.0 requires that the areaDesc block not be null or empty.");
                }

                List <NameValueType> geoCodes = ablock.GeoCode.FindAll(g => g.Name.Equals("SAME"));
                if (geoCodes == null || geoCodes.Count < 1)
                {
                    throw new System.ArgumentException("IPAWS Profile v1.0 requires that there is at least one geoCode block with the valueName of SAME");
                }

                foreach (NameValueType geoCode in geoCodes)
                {
                    if (geoCode.Value.Length != 6)
                    {
                        throw new System.ArgumentException("IPAWS Profile v1.0 requires that the value of a geoCode block with the valueName of SAME be in PSSCCC format.");
                    }

                    int  psscccCode = 0;
                    bool canParse   = int.TryParse(geoCode.Value, out psscccCode);
                    if (!canParse)
                    {
                        throw new System.ArgumentException("IPAWS Profile v1.0 requires that the value of a geoCode block with the valueName of SAME be in PSSCCC format.");
                    }
                }
            }
        }
コード例 #2
0
ファイル: CAP.cs プロジェクト: 1stResponder/em-serializers
        /// <summary>
        /// Validates the CAP 1.1 Resource elements are IPAWS Profile 1.0 compliant
        /// </summary>
        /// <param name="infoBlock">Information block portion of the CAP message</param>
        private void ValidateIPAWSProfilev10ForCAPv11ResourceBlocks(InfoType infoBlock)
        {
            if (infoBlock.Resource != null && infoBlock.Resource.Count > 0)
            {
                foreach (ResourceType rblock in infoBlock.Resource)
                {
                    /*
                     * //if (rBlock.ResourceDesc != null && (rBlock.ResourceDesc.Equals("EAS Audio") || rBlock.ResourceDesc.Equals("EAS Streaming Audio")) == false)
                     * //{
                     * //  throw new System.ArgumentException("IPAWS Profile v1.0 requires the resourceDesc block to set to 'EAS Audio' or 'EAS Streaming Audio");
                     * //}*/

                    if (string.IsNullOrEmpty(rblock.UriString) && string.IsNullOrEmpty(rblock.DerefUri))
                    {
                        throw new System.ArgumentNullException("IPAWS Profile v1.0 requires that either the uri block or the drefUri block not be null or empty.");
                    }
                }
            }
        }
コード例 #3
0
ファイル: CAP.cs プロジェクト: 1stResponder/em-serializers
        /// <summary>
        /// Reads an XML Object From An Existing DOM
        /// </summary>
        /// <param name="rootNode">Node Containing the Root Object Element</param>
        public void ReadXML(XmlNode rootNode)
        {
            if (rootNode == (XmlNode)null)
            {
                throw new ArgumentNullException("RootNode");
            }

            if (rootNode.LocalName != "alert")
            {
                throw new ArgumentException("No alert Element found!");
            }

            XmlNode caproot = rootNode;

            this.capNamespace = caproot.NamespaceURI;

            InfoType infotypetmp;

            foreach (XmlNode node in caproot.ChildNodes)
            {
                if (string.IsNullOrEmpty(node.InnerText))
                {
                    continue;
                }

                switch (node.LocalName)
                {
                case "identifier":
                    this.messageID = node.InnerText;
                    break;

                case "sender":
                    this.senderID = node.InnerText;
                    break;

                case "sent":
                    this.sentDateTime = DateTime.Parse(node.InnerText);
                    if (this.sentDateTime.Kind == DateTimeKind.Unspecified)
                    {
                        this.sentDateTime = DateTime.MinValue;
                        throw new ArgumentException("TimeZone Information Must Be Specified");
                    }

                    this.sentDateTime = this.sentDateTime.ToUniversalTime();
                    break;

                case "status":
                    this.messageStatus = (StatusType)Enum.Parse(typeof(StatusType), node.InnerText);
                    break;

                case "msgType":
                    this.messageType = (MsgType)Enum.Parse(typeof(MsgType), node.InnerText);
                    break;

                case "source":
                    this.source = node.InnerText;
                    break;

                case "scope":
                    this.scope = (ScopeType)Enum.Parse(typeof(ScopeType), node.InnerText);
                    break;

                case "restriction":
                    this.restriction = node.InnerText;
                    break;

                case "addresses":
                    this.addresses = node.InnerText;
                    break;

                case "code":
                    this.handlingCode.Add(node.InnerText);
                    break;

                case "note":
                    this.note = node.InnerText;
                    break;

                case "references":
                    this.referenceIDs = node.InnerText;
                    break;

                case "incidents":
                    this.incidentIDs = node.InnerText;
                    break;

                case "info":
                    infotypetmp = new InfoType();
                    infotypetmp.ReadXML(node, this.sentDateTime);
                    this.info.Add(infotypetmp);
                    break;

                case "#comment":
                    break;

                default:
                    XElement xe = XElement.Load(new XmlNodeReader(node));
                    this.other.Add(xe);
                    break;
                }
            }

            this.Validate();
        }