Beispiel #1
0
        public static IndexInfo FromXml(string xml, string scope)
        {
            var info = new IndexInfo(scope);

            try
            {
                var doc = XDocument.Parse(xml);

                var lastIndexed = doc.Descendants("last-indexed-utc").FirstOrDefault()?.Value;
                if (lastIndexed.HasValue())
                {
                    info.LastIndexedUtc = lastIndexed.Convert <DateTime?>()?.ToUniversalTime();
                }

                var lastDuration = doc.Descendants("last-indexing-duration").FirstOrDefault()?.Value;
                if (lastDuration.HasValue())
                {
                    info.LastIndexingDuration = lastDuration.Convert <TimeSpan?>();
                }

                var isModified = doc.Descendants("is-modified").FirstOrDefault()?.Value;
                if (isModified.HasValue())
                {
                    info.IsModified = isModified.Convert <bool>();
                }
                else
                {
                    info.IsModified = lastIndexed.HasValue();
                }

                var status = doc.Descendants("status").FirstOrDefault()?.Value;
                if (status.HasValue())
                {
                    info.Status = status.Convert <IndexingStatus>();
                }

                info.Error = doc.Descendants("error").FirstOrDefault()?.Value;

                var documentCount = doc.Descendants("document-count").FirstOrDefault()?.Value;
                if (documentCount.HasValue())
                {
                    info.DocumentCount = documentCount.ToInt();
                }

                var fields = doc.Descendants("fields").FirstOrDefault()?.Value;
                if (fields.HasValue())
                {
                    info.Fields = fields.SplitSafe(", ");
                }

                var shouldRebuild = doc.Descendants("should-rebuild").FirstOrDefault()?.Value;
                if (shouldRebuild.HasValue())
                {
                    info.ShouldRebuild = shouldRebuild.Convert <bool>();
                }
            }
            catch { }

            return(info);
        }
Beispiel #2
0
        public IndexingCompletedEvent(IndexInfo indexInfo, bool wasRebuilt)
        {
            Guard.NotNull(indexInfo, nameof(indexInfo));

            IndexInfo  = indexInfo;
            WasRebuilt = wasRebuilt;
        }