//get a single Node from the XML field public PNROutputGroupXMLItem GetPNROutputGroupXMLItem(int node, PNROutputGroupLanguage pnrOutputGroupLanguage) { XDocument xDoc = new XDocument(pnrOutputGroupLanguage.PNROutputGroupXML); string baseRemarkType = xDoc.Root.Name.ToString(); var items = xDoc.Element(baseRemarkType).Elements("item"); var item = xDoc.Element(baseRemarkType).Elements("item").ElementAt(node); PNROutputGroupXMLItem pnrOutputGroupXMLItem = new PNROutputGroupXMLItem(); //Add LanguageName if (pnrOutputGroupLanguage.LanguageCode != null) { LanguageRepository languageRepository = new LanguageRepository(); Language language = new Language(); language = languageRepository.GetLanguage(pnrOutputGroupLanguage.LanguageCode); if (language != null) { pnrOutputGroupXMLItem.Language = language; } } //Add PolicyGroup Information PNROutputGroupRepository pnrOutputGroupRepository = new PNROutputGroupRepository(); PNROutputGroup pnrOutputGroup = new PNROutputGroup(); pnrOutputGroup = pnrOutputGroupRepository.GetGroup(pnrOutputGroupLanguage.PNROutputGroupId); if (pnrOutputGroup != null) { pnrOutputGroupXMLItem.PNROutputGroup = pnrOutputGroup; } //we need to keep version number, no need for other itmes PNROutputGroupLanguage pnrOutputGroupLanguage2 = new PNROutputGroupLanguage(); pnrOutputGroupLanguage2.VersionNumber = pnrOutputGroupLanguage.VersionNumber; pnrOutputGroupXMLItem.PNROutputGroupLanguage = pnrOutputGroupLanguage2; pnrOutputGroupXMLItem.Language.LanguageCode = pnrOutputGroupLanguage.LanguageCode; pnrOutputGroupXMLItem.PNROutputGroup.PNROutputGroupId = pnrOutputGroupLanguage.PNROutputGroupId; string valueText = (string)item.Value; if (valueText != null) { pnrOutputGroupXMLItem.Value = item.Value; } string remarkTypeAttribute = (string)item.Attribute("remarktype"); if (remarkTypeAttribute != null) { pnrOutputGroupXMLItem.RemarkType = item.Attribute("remarktype").Value; } string bindAttribute = (string)item.Attribute("bind"); if (bindAttribute != null) { pnrOutputGroupXMLItem.Bind = item.Attribute("bind").Value; } string qualifierAttribute = (string)item.Attribute("qualifier"); if (qualifierAttribute != null) { pnrOutputGroupXMLItem.Qualifier = item.Attribute("qualifier").Value; } string sequenceAttribute = (string)item.Attribute("sequence"); if (sequenceAttribute != null) { pnrOutputGroupXMLItem.Sequence = item.Attribute("sequence").Value; } string updateTypeAttribute = (string)item.Attribute("updatetype"); if (updateTypeAttribute != null) { pnrOutputGroupXMLItem.UpdateType = item.Attribute("updatetype").Value; } string groupIdAttribute = (string)item.Attribute("groupid"); if (groupIdAttribute != null) { pnrOutputGroupXMLItem.GroupId = item.Attribute("groupid").Value; } return(pnrOutputGroupXMLItem); }
//Add Data From Linked Tables for Display public void EditItemForDisplay(PNROutputGroupLanguage pnrOutputGroupLanguage) { //Add LanguageName if (pnrOutputGroupLanguage.LanguageCode != null) { LanguageRepository languageRepository = new LanguageRepository(); Language language = new Language(); language = languageRepository.GetLanguage(pnrOutputGroupLanguage.LanguageCode); if (language != null) { pnrOutputGroupLanguage.LanguageName = language.LanguageName; } } //Add PolicyGroup Information PNROutputGroupRepository pnrOutputGroupRepository = new PNROutputGroupRepository(); PNROutputGroup pnrOutputGroup = new PNROutputGroup(); pnrOutputGroup = pnrOutputGroupRepository.GetGroup(pnrOutputGroupLanguage.PNROutputGroupId); if (pnrOutputGroup != null) { pnrOutputGroupLanguage.PNROutputGroupName = pnrOutputGroup.PNROutputGroupName; } //Format XML if (pnrOutputGroupLanguage.PNROutputGroupXML != null) { XDocument xDoc = new XDocument(pnrOutputGroupLanguage.PNROutputGroupXML); string baseRemarkType = xDoc.Root.Name.ToString(); var items = xDoc.Element(baseRemarkType).Elements("item"); int counter = 0; PNROutputGroupXMLDoc pnrOutputGroupXMLDoc = new PNROutputGroupXMLDoc(); pnrOutputGroupXMLDoc.DocumentRoot = baseRemarkType; foreach (var item in items) { PNROutputGroupXMLItem pnrOutputGroupXMLItem = new PNROutputGroupXMLItem(); pnrOutputGroupXMLItem.ItemNumber = counter; string valueText = (string)item.Value; if (valueText != null) { pnrOutputGroupXMLItem.Value = item.Value; } string remarkTypeAttribute = (string)item.Attribute("remarktype"); if (remarkTypeAttribute != null) { pnrOutputGroupXMLItem.RemarkType = item.Attribute("remarktype").Value; } string bindAttribute = (string)item.Attribute("bind"); if (bindAttribute != null) { pnrOutputGroupXMLItem.Bind = item.Attribute("bind").Value; } string qualifierAttribute = (string)item.Attribute("qualifier"); if (qualifierAttribute != null) { pnrOutputGroupXMLItem.Qualifier = item.Attribute("qualifier").Value; } string sequenceAttribute = (string)item.Attribute("sequence"); if (sequenceAttribute != null) { pnrOutputGroupXMLItem.Sequence = item.Attribute("sequence").Value; } string updateTypeAttribute = (string)item.Attribute("updatetype"); if (updateTypeAttribute != null) { pnrOutputGroupXMLItem.UpdateType = item.Attribute("updatetype").Value; } string groupIdAttribute = (string)item.Attribute("groupid"); if (groupIdAttribute != null) { pnrOutputGroupXMLItem.GroupId = item.Attribute("groupid").Value; } pnrOutputGroupXMLDoc.AddPNROutputGroupXMLItem(pnrOutputGroupXMLItem); counter++; } pnrOutputGroupLanguage.PNROutputGroupXMLDOM = pnrOutputGroupXMLDoc; } }