Esempio n. 1
0
        private static List <OfxInstitutionInfo> LoadProviderList(XDocument doc)
        {
            List <OfxInstitutionInfo> list = new List <OfxInstitutionInfo>();
            Dictionary <string, OfxInstitutionInfo> map = new Dictionary <string, OfxInstitutionInfo>();

            foreach (XElement e in doc.Root.Elements())
            {
                OfxInstitutionInfo info = OfxInstitutionInfo.Create(e);
                if (info != null && info.Name != null)
                {
                    OfxInstitutionInfo other;
                    if (map.TryGetValue(info.Name, out other))
                    {
                        other.Merge(info);
                    }
                    else
                    {
                        list.Add(info);
                        map[info.Name] = info;
                    }
                }
            }

            return(list);
        }
Esempio n. 2
0
        private static void MergeProviderList(List <OfxInstitutionInfo> result, XDocument doc)
        {
            try
            {
                /* The financial institution list from http://www.ofxhome.com/api.php?all=yes
                 * is in this format:
                 *  <institutionlist>
                 *      <institutionid id="555" name="121 Financial Credit Union"/>
                 *      ...
                 */
                foreach (XElement institution in doc.Root.Elements())
                {
                    OfxInstitutionInfo c = OfxInstitutionInfo.Create(institution);

                    string name = c.Name;
                    if (!string.IsNullOrEmpty(name))
                    {
                        bool exists = false;
                        foreach (OfxInstitutionInfo i in result)
                        {
                            bool?mergable = IsMergable(i.MoneyDanceId, c.MoneyDanceId);
                            if (!mergable.HasValue)
                            {
                                mergable = IsMergable(i.OfxHomeId, c.OfxHomeId);
                            }
                            if (!mergable.HasValue)
                            {
                                mergable = IsMergable(i.Name, c.Name);
                            }

                            if (mergable == true)
                            {
                                exists = true;
                                i.Merge(c);
                                break;
                            }
                        }
                        if (!exists)
                        {
                            // found a new one!
                            result.Add(c);
                        }
                    }
                }
            }
            catch
            {
                // todo: error handling...
            }
        }