コード例 #1
0
        private XElement RebuildCaseRecords()
        {
            XElement newData = new XElement("Data");

            XElement oldData = CaseForm.Element("Data");

            Dictionary <string, XElement> recordDictionary = new Dictionary <string, XElement>();

            foreach (XElement record in oldData.Elements("Record"))
            {
                string guid = record.Attribute("Id").Value;

                if (recordDictionary.ContainsKey(guid))
                {
                    foreach (XElement field in record.Elements())
                    {
                        recordDictionary[guid].Add(new XElement(field.Name, field.Value));
                    }
                }
                else
                {
                    XElement newElement = new XElement("Record");

                    newElement.Add(new XAttribute("Id", guid),
                                   new XAttribute("FKEY", record.Attribute("FKEY").Value),
                                   new XAttribute("FirstSaveUserId", record.Attribute("FirstSaveUserId").Value),
                                   new XAttribute("LastSaveUserId", record.Attribute("LastSaveUserId").Value),
                                   new XAttribute("FirstSaveTime", record.Attribute("FirstSaveTime").Value),
                                   new XAttribute("LastSaveTime", record.Attribute("LastSaveTime").Value),
                                   new XAttribute("RecStatus", record.Attribute("RecStatus").Value));

                    foreach (XElement field in record.Elements())
                    {
                        newElement.Add(new XElement(field.Name, field.Value));
                    }

                    recordDictionary.Add(guid, newElement);
                }
            }

            foreach (KeyValuePair <string, XElement> kvp in recordDictionary)
            {
                newData.Add(kvp.Value);
            }

            return(newData);
        }
コード例 #2
0
        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);
        }