private static void ExtractData(XDocument cli) { XElement summ = cli.Descendants("Summary").FirstOrDefault(); if (summ == null) { Console.WriteLine("Summary element not found"); } //Console.WriteLine(ExtractSummary(summ)); writer.WriteLine(ExtractSummaryHdr()); writer.WriteLine(ExtractSummary(summ)); XElement propfiles = cli.Descendants("PropertyFiles").FirstOrDefault(); // Console.WriteLine("Properties {0}", propfiles.Descendants("PropertyFile").Count()); foreach (XElement prop in propfiles.Descendants("PropertyFile").Descendants("Property")) { //Console.WriteLine(ExtractPropertyInfo(prop)); writer.WriteLine(ExtractPropertyInfoHdr()); writer.WriteLine(ExtractPropertyInfo(prop)); } foreach (XElement lease in propfiles.Descendants("LeaseFile")) { //Console.WriteLine(ExtractLeaseInfo(lease)); writer.WriteLine(ExtractLeaseInfoHdr()); writer.WriteLine(ExtractLeaseInfo(lease)); if (lease.Descendants("FileTransactions").Count() > 0) writer.WriteLine(ExtractFtransHdr(lease)); FileTransactions fTrans = new FileTransactions(); fTrans.GetIdValues(lease); if (fTrans != null && fTrans.IdValues.Count > 0) { foreach (var x in fTrans.IdValues) { writer.WriteLine(ExtractFtrans(fTrans,x.Key)); } } if (lease.Descendants("Tenants").Count() > 0) writer.WriteLine(ExtractTenantInfoHdr()); foreach (XElement tenant in lease.Descendants("Tenants")) { //Console.WriteLine(ExtractTenantInfo(tenant)); writer.WriteLine(ExtractTenantInfo(tenant)); } } }
private static void ExtractData(XDocument cli) { string tempStr; XElement summ = cli.Descendants("Summary").FirstOrDefault(); if (summ == null) { Console.WriteLine("Summary element not found"); return; } dictSumm = ExtractSummary(summ); XElement propfiles = cli.Descendants("PropertyFiles").FirstOrDefault(); foreach (XElement prop in propfiles.Descendants("PropertyFile").Descendants("Property")) { dictProp = ExtractPropertyInfo(prop); } WriteSummary(writer); tempStr = string.Empty; foreach (XElement lease in propfiles.Descendants("LeaseFile")) { //Console.WriteLine(ExtractLeaseInfo(lease)); dictLease = ExtractLeaseInfo(lease); //dictLeases.Add(dictLease); int ftransCnt = lease.Descendants("FileTransactions").Count(); if (ftransCnt > 0) { int cnt = 0; if (ftransCnt > 10) WriteMessage("File Transactions count > 10; only importing 10"); Dictionary<string, string> dictItem = null; FileTransactions fTrans = new FileTransactions(); fTrans.GetIdValues(lease); if (fTrans != null && fTrans.IdValues.Count > 0) { dictFiletrans = new List<Dictionary<string, string>>(); foreach (var x in fTrans.IdValues) { cnt++; if (cnt > 10) break; dictItem = new Dictionary<string, string>(); if (cnt == 1) dictItem = ExtractFtrans(fTrans, x.Key,true); else dictItem = ExtractFtrans(fTrans, x.Key); dictFiletrans.Add(dictItem); } } if (dictFiletrans.Count < 10) AddBlankTransactions(dictFiletrans); } int tenantCnt = lease.Descendants("Tenants").Count(); if (tenantCnt > 0) { int cnt = 0; if (tenantCnt > 3) WriteMessage("Tenant count > 3; only importing 3"); dictTenants = new List<Dictionary<string, string>>(); foreach (XElement tenant in lease.Descendants("Tenants")) { cnt++; if (cnt > 3) break; if (cnt == 1) dictTenants.Add( ExtractTenantInfo(tenant,true)); else dictTenants.Add(ExtractTenantInfo(tenant)); } if (dictTenants.Count < 3) AddBlankTenants(dictTenants); } } WriteLease(writer); }
private static string ExtractLeaseInfo(XElement lease) { List<string> st = new List<string>(); List<string> ftlist = new List<string>(); string ret = string.Empty; var temp = GetElements("LeaseFile"); if (temp == null) return ret; st.Add("LEASE"); FileTransactions fTrans = new FileTransactions(); fTrans.GetIdValues(lease); foreach (XElement de in temp) { Identification idvals = new Identification(); if (de.Attribute("location").Value == "Identification") { idvals.GetIdValues(lease); if (de.Attribute("orgval").Value != string.Empty) { if (idvals.IdValues.ContainsKey(de.Attribute("orgval").Value)) st.Add(idvals.IdValues[de.Attribute("orgval").Value]); } } else st.Add(GetItem(de.Attribute("location").Value, lease)); } return String.Join("|", st); }
private static Dictionary<string, string> ExtractLeaseInfo(XElement lease) { Dictionary<string, string> st = new Dictionary<string, string>(); //List<string> ftlist = new List<string>(); string ret = string.Empty; var temp = GetElements("LeaseFile"); if (temp == null) return st; FileTransactions fTrans = new FileTransactions(); fTrans.GetIdValues(lease); foreach (XElement de in temp) { Identification idvals = new Identification(); if (de.Attribute("location").Value == "Identification") { idvals.GetIdValues(lease); if (de.Attribute("orgval").Value != string.Empty) { if (idvals.IdValues.ContainsKey(de.Attribute("orgval").Value)) st.Add(de.Attribute("outputname").Value, idvals.IdValues[de.Attribute("orgval").Value]); } } else st.Add(de.Attribute("outputname").Value,GetItem(de.Attribute("location").Value, lease)); } return st; }