Example #1
0
        private InvalidationInformation GetInvalidationInformation(ITextMessage message)
        {
            XElement xml = null;

            try
            {
                xml = XElement.Parse(message.Text);
            }
            catch (Exception)
            {
                Logger.Error("Unable to parse invalidation xml!. Returning an empty collection. Nothing is invalidated!");
                //throw new Exception();
                return(new InvalidationInformation());
            }

            var invalidationInformation = new InvalidationInformation();

            //Get all pages to invalidate
            Logger.Debug(string.Format("XML invalidation message: ", xml.ToString()));
            var allPageUrls = xml.Descendants().Where(e => e.Name.LocalName.Equals("url")).ToList();

            if (allPageUrls.Any())
            {
                var urlInfo = allPageUrls.Select(urlElem => new InvalidationUrl {
                    Url = urlElem.Value, PublicationId = int.Parse(urlElem.Attribute("pubId").Value), TcmUri = string.Format("tcm:{0}-{1}-64", urlElem.Attribute("pubId").Value, urlElem.Attribute("itemId").Value)
                }).Cast <IInvalidationUrl>().ToList();
                //return new InvalidationInformation { InvalidationUrls = urlInfo };
                invalidationInformation.InvalidationUrls = urlInfo;
            }

            return(invalidationInformation);
        }
Example #2
0
        private InvalidationInformation GetInvalidationInformation(ITextMessage message)
        {
            XElement xml = null;
            try
            {
                xml = XElement.Parse(message.Text);
            }
            catch (Exception)
            {
                Logger.Error("Unable to parse invalidation xml!. Returning an empty collection. Nothing is invalidated!");
                //throw new Exception();
                return new InvalidationInformation();
            }

            var invalidationInformation = new InvalidationInformation();
            //Get all pages to invalidate
            Logger.Debug(string.Format("XML invalidation message: ", xml.ToString()));
            var allPageUrls = xml.Descendants().Where(e => e.Name.LocalName.Equals("url")).ToList();
            if (allPageUrls.Any())
            {
                var urlInfo = allPageUrls.Select(urlElem => new InvalidationUrl { Url = urlElem.Value, PublicationId = int.Parse(urlElem.Attribute("pubId").Value), TcmUri = string.Format("tcm:{0}-{1}-64", urlElem.Attribute("pubId").Value, urlElem.Attribute("itemId").Value) }).Cast<IInvalidationUrl>().ToList();
                //return new InvalidationInformation { InvalidationUrls = urlInfo };
                invalidationInformation.InvalidationUrls = urlInfo;
            }

            return invalidationInformation;
        }