public void LoadSyncFile(XElement doc) { SyncFile = doc; SourceDatabase = String.Empty; if (doc.Attribute("SourceDbType") != null) { SourceDatabase = doc.Attribute("SourceDbType").Value; } if (doc.Attribute("CreatedDate") != null) { DateGenerated = doc.Attribute("CreatedDate").Value; } if (doc.Attribute("CreatedUtc") != null) { DateGeneratedUtc = doc.Attribute("CreatedUtc").Value; } if (doc.Attribute("Version") != null) { EpiVersion = doc.Attribute("Version").Value; } if (doc.Attribute("VhfVersion") != null) { VhfVersion = doc.Attribute("VhfVersion").Value; } if (doc.Attribute("Id") != null) { FileID = doc.Attribute("Id").Value; } if (doc.Attribute("Region") != null) { Region = doc.Attribute("Region").Value; } if (doc.Attribute("StartDate") != null) { StartDate = doc.Attribute("StartDate").Value; } if (doc.Attribute("EndDate") != null) { EndDate = doc.Attribute("EndDate").Value; } foreach (XElement element in doc.Elements("Form")) { if (element.Attribute("Name").Value.Equals("CaseInformationForm", StringComparison.OrdinalIgnoreCase)) { CaseForm = element; // because sync files created from MDB-based projects have <record>s broken up by page it's necessary to rebuild them here if (SyncFile.Attribute("SourceDbType") != null && SyncFile.Attribute("SourceDbType").Value.Equals("Access")) { CaseData = RebuildCaseRecords(); } else { CaseData = CaseForm.Element("Data"); } } else if (element.Attribute("Name").Value.Equals("ContactEntryForm", StringComparison.OrdinalIgnoreCase)) { ContactForm = element; ContactData = ContactForm.Element("Data"); } else if (element.Attribute("Name").Value.Equals("LaboratoryResultsForm", StringComparison.OrdinalIgnoreCase)) { LabForm = element; LabData = LabForm.Element("Data"); } } LinksData = doc.Element("Links"); FollowUpsData = doc.Element("ContactFollowUps"); AnalysisViewModel = new AnalysisViewModel(SyncFile); }