private void ButtonRemoveOnlineAccount_Clicked(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            if (b != null)
            {
                OfxDownloadData ofxData = b.DataContext as OfxDownloadData;

                if (ofxData != null)
                {
                    OnlineAccount oa = ofxData.OnlineAccount;

                    if (oa != null)
                    {
                        MessageBoxResult result = MessageBoxEx.Show("Permanently delete the online account \"" + ofxData.Caption + "\"", null, MessageBoxButton.YesNo);

                        if (result == MessageBoxResult.Yes)
                        {
                            oa.OnDelete();
                            foreach (Account a in myMoney.Accounts.GetAccounts())
                            {
                                if (a.OnlineAccount == oa)
                                {
                                    a.OnlineAccount = null;
                                }
                            }
                        }
                    }

                    ThreadSafeObservableCollection <OfxDownloadData> entries = this.OfxEventTree.ItemsSource as ThreadSafeObservableCollection <OfxDownloadData>;
                    entries.Remove(ofxData);
                }
            }
        }
示例#2
0
        public OnlineAccount CreateOnlineAccount()
        {
            //NOTE: this call is on hold. The ATM will not call this method.
            OnlineAccount ret = new OnlineAccount();

            ret.Password = Guid.NewGuid().ToString();
            ret.UserName = Guid.NewGuid().ToString();

            string result = "ERROR";

            try
            {
                WebSecurity.InitializeDatabaseConnection(_dbconn_name, "UserProfile", "UserId", "UserName", false);

                result = WebSecurity.CreateUserAndAccount(ret.UserName, ret.Password, null, true);//

                ret.ConfirmToken = result;
                ret.Success      = true;
            }
            catch (Exception ex)
            {
                //TODO log somewhere . ...
                result      = "ERROR_RUNTIME";
                ret.Success = false;
            }
            return(ret);
        }
        private void SyncOneAccount(OnlineAccount account)
        {
            List <OnlineAccount> list = new List <OnlineAccount>();

            list.Add(account);
            OfxThread thread = new OfxThread(myMoney, list, null, AccountHelper.PickAccount, this.Dispatcher);

            this.syncThreads.Add(thread);
            thread.Status += new OfxDownloadProgress(this.OnSyncUpdate);
            thread.Start();
        }
示例#4
0
 // Insert account in sorted order.
 void InsertAccount(OnlineAccount oa)
 {
     for (int i = 0, n = onlineAccounts.Count; i < n; i++)
     {
         OnlineAccount other = onlineAccounts[i] as OnlineAccount;
         if (other != null && string.Compare(other.Name, oa.Name, StringComparison.OrdinalIgnoreCase) > 0)
         {
             onlineAccounts.Insert(i, oa);
             return;
         }
     }
     onlineAccounts.Add(oa);
 }
        public override bool Equals(object obj)
        {
            if (obj.GetType() != typeof(OnlineAccount))
            {
                return(false);
            }
            OnlineAccount other = (OnlineAccount)obj;

            if (Acc.id != other.Acc.id)
            {
                return(false);
            }
            return(true);
        }
示例#6
0
        void OnOnlineAccountsChanged(object sender, ChangeEventArgs args)
        {
            bool changed = false;

            while (args != null)
            {
                OnlineAccount oa = args.Item as OnlineAccount;
                if (oa != null)
                {
                    if (args.ChangeType == ChangeType.Inserted)
                    {
                        newOnlineAccounts.Add(args.Item as OnlineAccount);
                    }
                    changed = true;
                }
                args = args.Next;
            }
            if (changed)
            {
                UpdateOnlineAccounts();
            }
        }
示例#7
0
 private void UpdateAccount(OnlineAccount account, bool logMe = false)
 {
     AccountPart.DataContext = null;
     Processing.IsEnabled    = false;
     if (account == null)
     {
         AccountPart.Visibility       = Visibility.Collapsed;
         LoginSignupPart.Visibility   = Visibility.Visible;
         UserNameComboBox.ItemsSource = App.Settings.StoredUser;
     }
     else
     {
         AccountPart.Visibility     = Visibility.Visible;
         LoginSignupPart.Visibility = Visibility.Collapsed;
         AccountPart.DataContext    = App.LoginedAccount;
         if (logMe)
         {
             App.StoreUser(account.UserName);
         }
         LoginSuccessed?.Invoke(this, EventArgs.Empty);
     }
 }
示例#8
0
        void UpdateOnlineAccounts()
        {
            updating = true;

            // Find any new accounts
            foreach (OnlineAccount oa in money.OnlineAccounts.Items)
            {
                if (string.IsNullOrEmpty(oa.Name))
                {
                    // cleanup - this should be in the database
                    oa.OnDelete();
                }
                else if (!onlineAccounts.Contains(oa))
                {
                    InsertAccount(oa);
                }
            }

            var existing = money.OnlineAccounts.GetOnlineAccounts();

            // find any removed accounts;
            foreach (object obj in new List <object>(onlineAccounts))
            {
                OnlineAccount oa = obj as OnlineAccount;
                if (oa != null && !existing.Contains(oa))
                {
                    onlineAccounts.Remove(oa);
                }
            }

            if (editingAccount.OnlineAccount != null)
            {
                this.comboBoxOnlineAccount.SelectedItem = editingAccount.OnlineAccount;
            }

            updating = false;
        }
示例#9
0
        public OfxLoginDialog(OfxSignOnInfo info, OnlineAccount account, List <Block> prompt, OfxErrorCode code, string error)
        {
            this.account = account;

            this.UserNamePrompt = "User Name";
            this.UserName       = this.account.UserId;

            // provide what we know already...
            this.UserName             = this.account.UserId;
            this.PasswordConfirmation = this.account.Password;

            RichTextBox intro = this.IntroMessagePrompt;

            intro.Visibility = System.Windows.Visibility.Visible;

            intro.Document.Blocks.Clear();

            if (error != null)
            {
                this.ShowError(error);
            }
            else if (code == OfxErrorCode.SignonInvalid)
            {
                this.ShowError("Your sign on is invalid");
            }

            if (prompt == null)
            {
                prompt = new List <Block>();
            }
            if (prompt.Count == 0)
            {
                Paragraph instructions = new Paragraph();
                prompt.Add(instructions);
                instructions.Inlines.Add(new Run("Please enter your online banking credentials for "));
                instructions.Inlines.Add(new Run(this.account.Name)
                {
                    FontWeight = FontWeights.Bold
                });
                instructions.Inlines.Add(new Run("."));
            }

            // try and gain the user's trust...
            Uri       url   = new Uri(this.account.Ofx);
            Paragraph trust = new Paragraph();

            prompt.Add(trust);
            trust.Inlines.Add(new Run("These credentials will be sent securely using HTTPS to the OFX server at "));
            trust.Inlines.Add(new Run(url.Host)
            {
                FontWeight = FontWeights.Bold
            });
            trust.Inlines.Add(new Run(".  Click cancel if you are not sure that this is the right address."));

            foreach (Block b in prompt)
            {
                intro.Document.Blocks.Add(b);
            }

            if (info != null && !string.IsNullOrWhiteSpace(info.UserCredentialLabel1))
            {
                this.AddUserDefinedField("UserCred1", info.UserCredentialLabel1);
                this.SetUserDefinedField("UserCred1", this.account.UserCred1);
            }
            if (info != null && !string.IsNullOrWhiteSpace(info.UserCredentialLabel2))
            {
                this.AddUserDefinedField("UserCred2", info.UserCredentialLabel2);
                this.SetUserDefinedField("UserCred2", this.account.UserCred2);
            }

            this.OkClicked += new EventHandler <OkEventArgs>((s, e) =>
            {
                this.account.UserId   = this.UserName;
                this.account.Password = this.PasswordConfirmation;

                if (info != null && !string.IsNullOrWhiteSpace(info.UserCredentialLabel1))
                {
                    this.account.UserCred1 = this.GetUserDefinedField("UserCred1");
                }
                if (info != null && !string.IsNullOrWhiteSpace(info.UserCredentialLabel2))
                {
                    this.account.UserCred2 = this.GetUserDefinedField("UserCred2");
                }
            });
        }
        private void OnDetailsClick(object sender, RoutedEventArgs e)
        {
            Hyperlink       link    = (Hyperlink)sender;
            OfxDownloadData ofxData = link.DataContext as OfxDownloadData;

            if (ofxData != null)
            {
                switch (ofxData.OfxError)
                {
                case OfxErrorCode.AUTHTOKENRequired:
                case OfxErrorCode.AUTHTOKENInvalid:
                    ofxData.LinkCaption = "";
                    ofxData.Message     = "Getting authorization token...";
                    GetAuthenticationToken(ofxData, ofxData.OfxError);
                    return;

                case OfxErrorCode.MFAChallengeAuthenticationRequired:
                    ofxData.LinkCaption = "";
                    ofxData.Message     = "Getting MFA challenge questions...";
                    GetMFAChallenge(ofxData);
                    return;

                case OfxErrorCode.MustChangeUSERPASS:
                    ofxData.LinkCaption = "";
                    ofxData.Message     = "Getting new password...";
                    GetNewPassword(ofxData);
                    return;

                case OfxErrorCode.SignonInvalid:
                    ofxData.LinkCaption = "";
                    ofxData.Message     = "Logging in ...";
                    GetLogin(ofxData);
                    return;
                }

                if (ofxData.LinkCaption == tryAgainCaption)
                {
                    SyncOneAccount(ofxData.OnlineAccount);
                    return;
                }


                string template = ProcessHelper.GetEmbeddedResource("Walkabout.Ofx.OfxErrorTemplate.htm");
                // css uses curly brackets, so it must be substituted.
                string css = @"body, th, td { font-family: Verdana; font-size:10pt; }
h2 { font-size: 12pt; }";

                string response = null;
                string headers  = null;
                string message  = ofxData.Message;

                Exception error = ofxData.Error;
                if (error != null)
                {
                    HtmlResponseException htmlError = error as HtmlResponseException;
                    if (htmlError != null)
                    {
                        message  = htmlError.Message;
                        response = htmlError.Html;
                        headers  = "";
                    }
                    else
                    {
                        OfxException ofxerror = error as OfxException;
                        if (ofxerror != null)
                        {
                            message  = ofxerror.Message;
                            response = ofxerror.Response;
                            headers  = ofxerror.HttpHeaders;
                        }
                        else
                        {
                            message  = error.GetType().FullName + ": " + error.Message;
                            response = error.StackTrace;
                        }
                    }
                }
                OnlineAccount account = ofxData.OnlineAccount;
                string        result  = string.Format(template,
                                                      css,
                                                      account != null ? account.Ofx : "",
                                                      account != null ? account.Institution : "",
                                                      message,
                                                      response,
                                                      headers);

                string tempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "DownloadError.htm");
                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(tempPath))
                {
                    sw.WriteLine(result);
                }

                InternetExplorer.OpenUrl(IntPtr.Zero, tempPath);
            }
        }
        public ChangePasswordDialog(OfxSignOnInfo info, OnlineAccount account, MyMoney money)
        {
            this.account        = account;
            this.money          = money;
            this.UserNamePrompt = "User Name";
            this.UserName       = account.UserId;
            this.Title          = "Change Password";

            RichTextBox intro = this.IntroMessagePrompt;

            intro.Visibility = System.Windows.Visibility.Visible;

            intro.Document.Blocks.Clear();
            Paragraph p = new Paragraph();

            intro.Document.Blocks.Add(p);

            this.AddUserDefinedField(newPasswordFieldId, "New Password");
            this.AddUserDefinedField(confirmPasswordFieldId, "Confirm New Password");

            p.Inlines.Add(new Run(account.Name + " is requesting that you enter a new password."));

            OkClicked += new EventHandler <OkEventArgs>((s, e) =>
            {
                string newpswd        = this.GetUserDefinedField("NewPassword");
                string newpswdconfirm = this.GetUserDefinedField("ConfirmNewPassword");
                if (newpswd != newpswdconfirm)
                {
                    e.Cancel = true;
                    e.Error  = "New passwords do not match";
                    return;
                }
                if (info != null && newpswd.Length < info.MinimumLength)
                {
                    e.Cancel = true;
                    e.Error  = "New password must be at least " + info.MinimumLength + " characters";
                    return;
                }
                if (info != null && info.MaximumLength != 0 && newpswd.Length > info.MaximumLength)
                {
                    e.Cancel = true;
                    e.Error  = "New password cannot be more than " + info.MaximumLength + " characters";
                    return;
                }

                // capture value so thread can use it.
                newPassword = this.NewPassword;

                account.UserId   = this.UserName;
                account.Password = this.PasswordConfirmation;

                ThreadPool.QueueUserWorkItem(new WaitCallback(ChangePassword));
                e.Error  = "Sending new password information to " + account.Name + ".\nPlease do NOT close this dialog until we get a response.";
                e.Cancel = true;

                // stop user from hitting OK again and stop user from trying to cancel,
                // cancel is problematic because we won't know if the server
                // received the password change or not!
                DisableButtons();
            });
        }