public void ParseFromXElement(System.Xml.Linq.XElement source)
        {
            if (source.Name != XElementName)
                throw new Exception("Expected " + XElementName + " but got " + source.Name);

            ID = source.Element(IDFieldName).Value;

            dynamic doc = new Document.PreviewDocument(source.Element("Document").Attribute("DocumentType").Value);
            doc.LocalizedDocumentType = source.Element("Document").Attribute("LocalizedDocumentType").Value;
            Document = doc;

            Export = new DummyExport() { Name = source.Element("Export").Attribute("Name").Value, GuID = source.Element("Export").Attribute("ID").Value };
        }
        public void ParseFromXElement(System.Xml.Linq.XElement source)
        {
            if (source.Name != XElementName)
                throw new Exception("Expected " + XElementName + " but got " + source.Name);

            ID = source.Element("ID").Value;
            var docs = source.Elements("Entry");
            Documents.Clear();
            foreach (var doc in docs)
            {
                dynamic prevDoc = new Document.PreviewDocument(doc.Attribute("Type").Value) { DocumentID = doc.Attribute("ID").Value };
                prevDoc.LocalizedDocumentType = doc.Attribute("LocalizedDocumentType").Value;
                Documents.Add(prevDoc);
            }
        }
        private ObservableCollection<Document.PreviewDocument> documentsInInterval(DateTime IntervalStart, DateTime IntervalEnd, string DocumentType)
        {
            var sw = new Performance.Stopwatch("documentsInInterval");
            sw.Start();

            var output = new ObservableCollection<Document.PreviewDocument>();

            if (!DocumentDB.AncestorsAndSelf("Documents").Any())
                return output;

            if (!String.IsNullOrEmpty(DocumentType))
            {
                var list = from document in DocumentDB.Elements() where document.Name == DocumentType && IntervalStart <= DateTime.Parse(document.Element("Date").Value) && IntervalEnd >= DateTime.Parse(document.Element("Date").Value) select document;
                foreach (XElement item in list)
                {
                    dynamic temp = new Document.PreviewDocument(item.Name.ToString());
                    temp.DocumentID = item.Element("ID").Value;
                    temp.Customer = item.Element("CustomerPreview").Value;
                    temp.Date = DateTime.Parse(item.Element("Date").Value);

                    foreach (Interfaces.DocumentParser parser in AdditionalPreviewParsers.Where(x => x.DocumentType == item.Name.ToString()))
                    { var result = parser.ParseAdditionalPreviewData(ref temp, item); }

                    output.Add(temp);
                }
            }
            else 
            {
                var list = from document in DocumentDB.Elements() where IntervalStart <= DateTime.Parse(document.Element("Date").Value) && IntervalEnd >= DateTime.Parse(document.Element("Date").Value) select document;
                foreach (XElement item in list)
                {
                    dynamic temp = new Document.PreviewDocument(item.Name.ToString());
                    temp.DocumentID = item.Element("ID").Value;
                    temp.Customer = item.Element("PreviewCustomer").Value;
                    temp.Date = DateTime.Parse(item.Element("Date").Value);

                    foreach (Interfaces.DocumentParser parser in AdditionalPreviewParsers.Where(x => x.DocumentType == item.Name.ToString()))
                    { var result = parser.ParseAdditionalPreviewData(ref temp, item); }

                    output.Add(temp);
                }
            }

            logger.Info(sw.Result(output.Count));
            return output;
        }