private void Combo_Select_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Institution inst = Combo_Select.SelectedItem as Institution;

            if (inst == null)
            {
                return;
            }
            PasswordBox.Clear();
            foreach (Window view in this.OwnedWindows)
            {
                view.Close();
            }

            try
            {
                if (!_source.DownloadInstitutionData(inst))
                {
                    return;
                }
            }
            catch (XmlException)
            {
                MessageBox.Show("Could not retrieve valid account information for this institution. The institution will not be loaded.", "Error Retrieving Institutions", MessageBoxButton.OK, MessageBoxImage.Error);
                Grid_Account.DataContext = null;
                return;
            }
            catch (InvalidDataException ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + "The institution will not be loaded.", "Error Retrieving Institution", MessageBoxButton.OK, MessageBoxImage.Warning);
                Grid_Account.DataContext = null;
                return;
            }
            AccountViewModel account = new AccountViewModel(inst, "", "");

            Grid_Account.DataContext = account;
        }
Beispiel #2
0
 public Account(Institution host, string userID, string accountNumber)
 {
     this.HostInstitution = host;
     this.UserID          = userID;
     this.AccountNumber   = accountNumber;
 }
Beispiel #3
0
 public AccountViewModel(Institution host, string user, string number)
 {
     Base = new Account(host, user, number);
 }
Beispiel #4
0
        public bool DownloadInstitutionData(Institution inst)
        {
            //false if failure
            bool failure = !true;

            if (inst == null || string.IsNullOrWhiteSpace(inst.ID))
            {
                return(failure);
            }

            XmlDocument doc = new XmlDocument();

            string searchString = DetailsString + inst.ID;

            doc.Load(searchString);



            XmlNode head = doc.DocumentElement;
            XmlNode node;

            if (head.Attributes["id"] == null || head.Attributes["id"].InnerText != inst.ID ||
                head.SelectSingleNode("name") == null || head.SelectSingleNode("name").InnerText != inst.Name)
            {
                throw new InvalidDataException("Institution returned did not match \"" + inst.Name + "\".");
            }

            node = head.SelectSingleNode("url");
            if (node == null || String.IsNullOrWhiteSpace(node.InnerText))
            {
                throw new InvalidDataException("Institution returned did not return a valid connection URL.");
            }
            inst.URL = node.InnerText;

            node = head.SelectSingleNode("org");
            if (node == null || String.IsNullOrWhiteSpace(node.InnerText))
            {
                throw new InvalidDataException("Institution returned did not return a valid connection ORG.");
            }
            inst.ORG = node.InnerText;


            node = head.SelectSingleNode("fid");
            if (node == null || String.IsNullOrWhiteSpace(node.InnerText))
            {
                throw new InvalidDataException("Institution returned did not return a valid identifier (FID).");
            }
            inst.FID = node.InnerText;

            node = head.SelectSingleNode("brokerid");
            if (node == null || String.IsNullOrWhiteSpace(node.InnerText))
            {
                Uri path = new Uri(inst.URL);
                if (path.Host != null)
                {
                    inst.BrokerID = path.Host.Substring(path.Host.IndexOf(".") + 1);
                }
                else
                {
                    throw new InvalidDataException("Institution returned did not return a valid Broker ID.");
                }
            }
            else
            {
                inst.BrokerID = node.InnerText;
            }

            return(!failure);
        }