Ejemplo n.º 1
0
        private 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("idtype").Value != string.Empty)
                    {
                        if (idvals.IdValues.ContainsKey(de.Attribute("idtype").Value))
                        {
                            st.Add(de.Attribute("outputname").Value, idvals.IdValues[de.Attribute("idtype").Value]);
                            continue;
                        }
                    }
                    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]);
                            continue;
                        }
                    }
                }
                else
                {
                    if (de.Attribute("date") != null && de.Attribute("date").Value == "1")
                        st.Add(de.Attribute("outputname").Value, GetItem(de.Attribute("location").Value, lease).Replace("-", ""));
                    else
                        st.Add(de.Attribute("outputname").Value, GetItem(de.Attribute("location").Value, lease));
                }
            }
            return st;
        }
Ejemplo n.º 2
0
        private void ExtractData(XDocument cli)
        {
            string tempStr;

            int tenantCnt = 0;
            int ftransCnt = 0;
            XElement summ = cli.Descendants("Summary").FirstOrDefault();
            if (summ == null)
            {
                throw new Exception("Summary element not found");
            }

            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;
            cntFalseCount = 0;
            bool collStatusFalse = false;
            var cntLease = propfiles.Descendants("LeaseFile").Count();

            foreach (XElement lease in propfiles.Descendants("LeaseFile"))
            {
                collStatusFalse = false;
                //Console.WriteLine(ExtractLeaseInfo(lease));
                dictLease = ExtractLeaseInfo(lease);
                //dictLeases.Add(dictLease);
                if (dictLease["CollectionStatus"] == "false")
                {
                    cntFalseCount++;
                    collStatusFalse = true;
                }
                ftransCnt = lease.Descendants("FileTransactions").Count();
                ftransMaxCount = GetElementsMaxCount("FileTransactions");
                dictFiletrans = new List<Dictionary<string, string>>();

                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)
                    {
                        foreach (var x in fTrans.IdValues)
                        {
                            cnt++;
                            if (cnt > ftransMaxCount) 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 < ftransMaxCount)
                    AddBlankTransactions(dictFiletrans, ftransMaxCount);

                tenantCnt = lease.Descendants("Tenants").Count();
                tenantMaxCnt = GetElementsMaxCount("Tenants");
                dictTenants = new List<Dictionary<string, string>>();
                if (tenantCnt > 0)
                {
                    int cnt = 0;
                    foreach (XElement tenant in lease.Descendants("Tenants"))
                    {
                        cnt++;
                        if (cnt > tenantMaxCnt) break;
                        if (cnt == 1)
                            dictTenants.Add(ExtractTenantInfo(tenant, true));  // primary tenant
                        else
                            dictTenants.Add(ExtractTenantInfo(tenant));
                    }

                    if (dictTenants.Count > 1)
                      ReplicateAddress();
                }
                if (dictTenants.Count < tenantMaxCnt)
                    AddBlankTenants(dictTenants, tenantMaxCnt);

                if (!collStatusFalse)
                    WriteLease(writer);
                else
                    WriteLease(writerFalse);
            }
        }