Пример #1
0
        private void btnUserLogin_Click(object sender, EventArgs e)
        {
            string errorMessage = string.Empty;

            this.btnUserLogin.Enabled = false;
            if ((this.txtUserName.Text.Length == 0) || (this.txtPassword.Text.Length == 0))
            {
                this.btnUserLogin.Enabled = true;
            }
            else
            {
                this.txtUserName.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
                string      text     = this.txtUserName.Text;
                string      password = this.txtPassword.Text;
                RegistryKey rootKey  = AppRegistry.GetRootKey(ref errorMessage);
                try
                {
                    AppRegistry.SaveUserName(rootKey, text, ref errorMessage);
                    if (errorMessage != string.Empty)
                    {
                        this.strError = this.strError + "\nUserName save error: " + errorMessage;
                    }
                    AppRegistry.SavePassword(rootKey, password, ref errorMessage);
                    if (errorMessage != string.Empty)
                    {
                        this.strError = this.strError + "\nPassword save error: " + errorMessage;
                    }
                    AppRegistry.SaveValue(rootKey, "local_IsLoggedOut", false, ref errorMessage, false, RegistryValueKind.Unknown);
                    if (errorMessage != string.Empty)
                    {
                        this.strError = this.strError + "\nIsLoggedOut save error: " + errorMessage;
                    }
                    AppRegistry.SaveValue(rootKey, "local_SaveLogIn", this.ckbSaveLogIn.Checked, ref errorMessage, false, RegistryValueKind.Unknown);
                    if (errorMessage != string.Empty)
                    {
                        this.strError = this.strError + "\nSaveLogIn save error: " + errorMessage;
                    }
                    AppRegistry.SaveValue(rootKey, "local_CountryCode", this.comboBoxCountry.SelectedValue, ref errorMessage, false, RegistryValueKind.Unknown);
                    if (errorMessage != string.Empty)
                    {
                        this.strError = this.strError + "\nSaveCountryCode save error: " + errorMessage;
                    }
                }
                catch (Exception exception)
                {
                    this.appManager.ShowBalloon("Exception with the login information: " + exception.Message + "\nError details: " + this.strError, 5);
                }
                base.Close();
                this.appManager.LogIn(true, null, null, null, null);
            }
        }
Пример #2
0
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (this.appManager.m_bAccountDashboardLoading)
     {
         MessageBox.Show("The Dashboard is currently refreshing accounts, please wait until complete to save account.", this.appManager.m_strApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     else
     {
         this.textBoxPhoneNumber.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
         if (this.textBoxPhoneNumber.Text.Length != 0)
         {
             try
             {
                 this.buttonSave.Enabled = false;
                 if (this.bNewAccount)
                 {
                     if (!this.appManager.IsDigitsOnly(this.textBoxPhoneNumber.Text))
                     {
                         this.strError = "Phone number must be numeric digits...";
                         this.textBoxPhoneNumber.Select();
                     }
                     if (!this.appManager.IsValidMobileNumber(this.appManager.FormatContactAddress(this.textBoxPhoneNumber.Text, true, false)))
                     {
                         this.strError = "Phone number is not a valid number of digits...";
                         this.textBoxPhoneNumber.Select();
                     }
                     if (this.appManager.GetAccountItem(this.textBoxPhoneNumber.Text).number != null)
                     {
                         this.strError = "Phone number is already saved, please select from the dropdown and update...";
                         this.comboBoxAccountList.Focus();
                     }
                     if (this.textBoxPassword.Text.Length == 0)
                     {
                         this.strError = "Please enter a password...";
                         this.textBoxPassword.Select();
                     }
                     if (this.comboBoxCountry.SelectedValue.ToString() == "")
                     {
                         this.strError = "Please select a country code...";
                         this.comboBoxCountry.Focus();
                     }
                 }
                 if (string.IsNullOrEmpty(this.strError))
                 {
                     bool   flag    = false;
                     bool   flag2   = false;
                     string session = string.Empty;
                     this.appManager.ShowBalloon("Please wait, account information is being verified...", 5);
                     string strPhoneDigits = this.appManager.FormatContactAddress(this.textBoxPhoneNumber.Text, true, false);
                     if (this.appManager.m_textService == null)
                     {
                         this.appManager.m_textService = new TextService();
                     }
                     try
                     {
                         if (AppRegistry.AuthorizeUser(strPhoneDigits, ref this.strError))
                         {
                             flag = this.appManager.m_textService.AccountLogIn(strPhoneDigits, this.textBoxPassword.Text, this.comboBoxCountry.SelectedValue.ToString(), ref session);
                         }
                     }
                     catch
                     {
                         flag2 = true;
                     }
                     if (flag2)
                     {
                         this.strError = "Exception connecting to Text Service\n\nPlease check your internet connection...";
                     }
                     else if (!flag)
                     {
                         this.strError = "Account Failed Authentication.\n\nPlease check your log in information and selected country...";
                     }
                     else
                     {
                         RegistryKey key = AppRegistry.GetSubKey(AppRegistry.GetRootKey(ref this.strError), strPhoneDigits, true, ref this.strError);
                         if (this.strError == string.Empty)
                         {
                             AppRegistry.SaveUserName(key, strPhoneDigits, ref this.strError);
                             AppRegistry.SavePassword(key, this.textBoxPassword.Text, ref this.strError);
                             AppRegistry.SaveValue(key, "CountryCode", this.comboBoxCountry.SelectedValue.ToString(), ref this.strError, false, RegistryValueKind.Unknown);
                             AppRegistry.SaveValue(key, "Title", this.textBoxAccountTitle.Text, ref this.strError, false, RegistryValueKind.Unknown);
                             AppRegistry.SaveValue(key, "Session", session, ref this.strError, false, RegistryValueKind.Unknown);
                         }
                         if (this.strError == string.Empty)
                         {
                             this.appManager.m_lsAccountItems = (from val in this.appManager.m_lsAccountItems
                                                                 where val.number != strPhoneDigits
                                                                 select val).ToList <AccountItem>();
                             AccountItem item = new AccountItem {
                                 countryCode       = this.comboBoxCountry.SelectedValue.ToString(),
                                 number            = strPhoneDigits,
                                 password          = this.textBoxPassword.Text,
                                 title             = this.textBoxAccountTitle.Text,
                                 session           = session,
                                 unReadMessageList = new List <TextMessage>(),
                                 connectionStatus  = "Connected"
                             };
                             this.appManager.m_lsAccountItems.Add(item);
                         }
                     }
                 }
             }
             catch (Exception exception)
             {
                 this.strError = "Error saving account: " + exception.Message;
             }
             if (!string.IsNullOrEmpty(this.strError))
             {
                 MessageBox.Show(this.strError, this.appManager.m_strApplicationName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 this.strError           = string.Empty;
                 this.buttonSave.Enabled = true;
             }
             else
             {
                 this.appManager.ShowBalloon("Account has been verified and saved.", 5);
                 this.ResetDisplay();
             }
             this.buttonSave.Enabled = true;
         }
     }
 }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool        flag         = true;
            string      errorMessage = string.Empty;
            RegistryKey rootKey      = AppRegistry.GetRootKey(ref errorMessage);

            try
            {
                AppRegistry.SaveValue(rootKey, "NotificationSound", this.comboBoxNotificationSound.SelectedValue.ToString(), ref errorMessage, false, RegistryValueKind.Unknown);
                if (errorMessage != string.Empty)
                {
                    this.strError = this.strError + "Notification sound save error: " + errorMessage;
                    flag          = false;
                }
                else
                {
                    this.appManager.m_strNotificationSound = this.comboBoxNotificationSound.SelectedValue.ToString();
                    if (this.appManager.m_strNotificationSound == "None")
                    {
                        this.appManager.m_bPlaySound = false;
                    }
                    else
                    {
                        this.appManager.m_bPlaySound = true;
                    }
                }
            }
            catch (Exception exception)
            {
                this.strError = this.strError + "Notification sound save error: " + exception.Message;
                flag          = false;
            }
            try
            {
                AppRegistry.SaveValue(rootKey, "NotificationInterval", Convert.ToInt32(this.comboBoxNotificationReminder.SelectedValue), ref errorMessage, false, RegistryValueKind.Unknown);
                if (errorMessage != string.Empty)
                {
                    this.strError = this.strError + "Notificaiton reminder save error: " + errorMessage;
                    flag          = false;
                }
                else
                {
                    this.appManager.m_nNotificationInterval = Convert.ToInt32(this.comboBoxNotificationReminder.SelectedValue);
                    this.appManager.m_dtNextNotification    = DateTime.Now.AddMinutes((double)this.appManager.m_nNotificationInterval);
                }
            }
            catch (Exception exception2)
            {
                this.strError = this.strError + "Notificaiton reminder save error: " + exception2.Message;
                flag          = false;
            }
            try
            {
                AppRegistry.SaveValue(rootKey, "FontSize", Convert.ToInt32(this.comboBoxFontSize.SelectedValue), ref errorMessage, false, RegistryValueKind.Unknown);
                if (errorMessage != string.Empty)
                {
                    this.strError = this.strError + "Font size save error: " + errorMessage;
                    flag          = false;
                }
                else
                {
                    this.appManager.m_nFontSize = Convert.ToInt32(this.comboBoxFontSize.SelectedValue);
                    this.appManager.m_fontSize  = new Font("Arial", (float)this.appManager.m_nFontSize);
                    this.bRefreshMessageForm    = true;
                }
            }
            catch (Exception exception3)
            {
                this.strError = this.strError + "Font size save error: " + exception3.Message;
                flag          = false;
            }
            try
            {
                AppRegistry.SaveValue(rootKey, "FontSizeDT", Convert.ToInt32(this.comboBoxFontSizeDT.SelectedValue), ref errorMessage, false, RegistryValueKind.Unknown);
                if (errorMessage != string.Empty)
                {
                    this.strError = this.strError + "Font size Date/Time save error: " + errorMessage;
                    flag          = false;
                }
                else
                {
                    this.appManager.m_nFontSizeDT = Convert.ToInt32(this.comboBoxFontSizeDT.SelectedValue);
                    this.appManager.m_fontSizeDT  = new Font("Arial", (float)this.appManager.m_nFontSizeDT);
                    this.bRefreshMessageForm      = true;
                }
            }
            catch (Exception exception4)
            {
                this.strError = this.strError + "Font size Date/Time save error: " + exception4.Message;
                flag          = false;
            }
            try
            {
                AppRegistry.SaveValue(rootKey, "LastMessageStatusLimit", Convert.ToInt32(this.comboBoxLastMessageStatus.SelectedValue), ref errorMessage, false, RegistryValueKind.Unknown);
                if (errorMessage != string.Empty)
                {
                    this.strError = this.strError + "Last message status save error: " + errorMessage;
                    flag          = false;
                }
                else if (this.appManager.m_nLastMessageStatusLimit != Convert.ToInt32(this.comboBoxLastMessageStatus.SelectedValue))
                {
                    this.appManager.m_nLastMessageStatusLimit = Convert.ToInt32(this.comboBoxLastMessageStatus.SelectedValue);
                    this.bRefreshMessageForm = true;
                    if (this.appManager.m_nLastMessageStatusLimit == 0)
                    {
                        this.appManager.m_lsConversationMetaData.Clear();
                    }
                    else
                    {
                        this.appManager.LoadConversations(true);
                    }
                }
            }
            catch (Exception exception5)
            {
                this.strError = this.strError + "Last message status save error: " + exception5.Message;
                flag          = false;
            }
            try
            {
                AppRegistry.SaveValue(rootKey, "UnreadMessageLimit", Convert.ToInt32(this.comboBoxUnreadMessageLimit.SelectedValue), ref errorMessage, false, RegistryValueKind.Unknown);
                if (errorMessage != string.Empty)
                {
                    this.strError = this.strError + "UnreadyMessage Count limit save error: " + errorMessage;
                    flag          = false;
                }
                else if (this.appManager.m_nUnreadMessageLimit != Convert.ToInt32(this.comboBoxUnreadMessageLimit.SelectedValue))
                {
                    this.appManager.m_nUnreadMessageLimit = Convert.ToInt32(this.comboBoxUnreadMessageLimit.SelectedValue);
                }
            }
            catch (Exception exception6)
            {
                this.strError = this.strError + "Unread Message Count limit save error: " + exception6.Message;
                flag          = false;
            }
            try
            {
                AppRegistry.SaveValue(rootKey, "EnableSignature", this.checkBoxEnableSignature.Checked, ref errorMessage, false, RegistryValueKind.Unknown);
                AppRegistry.SaveValue(rootKey, "Signature", this.textBoxSignature.Text, ref errorMessage, false, RegistryValueKind.Unknown);
                if (errorMessage != string.Empty)
                {
                    this.strError = this.strError + "Enable Signature save error: " + errorMessage;
                    flag          = false;
                }
                else
                {
                    this.appManager.m_bEnableSignature = this.checkBoxEnableSignature.Checked;
                    this.appManager.m_strSignature     = this.textBoxSignature.Text;
                    this.bRefreshMessageForm           = true;
                }
            }
            catch (Exception exception7)
            {
                this.strError = this.strError + "Enable Signature save error: " + exception7.Message;
                flag          = false;
            }
            try
            {
                AppRegistry.SaveValue(rootKey, "local_AccountDashboardRefreshInterval", Convert.ToInt32(this.comboBoxDashboardRefreshInterval.SelectedValue), ref errorMessage, false, RegistryValueKind.Unknown);
                if (errorMessage != string.Empty)
                {
                    this.strError = this.strError + "Dashboard refresh interval save error: " + errorMessage;
                    flag          = false;
                }
                else if (this.appManager.m_nAccountDashboardRefreshInterval != Convert.ToInt32(this.comboBoxDashboardRefreshInterval.SelectedValue))
                {
                    this.appManager.m_nAccountDashboardRefreshInterval = Convert.ToInt32(this.comboBoxDashboardRefreshInterval.SelectedValue);
                    this.appManager.StartMonitorAccountDashboardTimer();
                }
            }
            catch (Exception exception8)
            {
                this.strError = this.strError + "Dashboard refresh interval save error: " + exception8.Message;
                flag          = false;
            }
            try
            {
                AppRegistry.SaveValue(rootKey, "local_DashboardNotificationSound", this.comboBoxDashboardNotificationSound.SelectedValue.ToString(), ref errorMessage, false, RegistryValueKind.Unknown);
                if (errorMessage != string.Empty)
                {
                    this.strError = this.strError + "Dashboard notification sound save error: " + errorMessage;
                    flag          = false;
                }
                else
                {
                    this.appManager.m_strDashboardNotificationSound = this.comboBoxDashboardNotificationSound.SelectedValue.ToString();
                    if (this.appManager.m_strDashboardNotificationSound == "None")
                    {
                        this.appManager.m_bPlayDashboardSound = false;
                    }
                    else
                    {
                        this.appManager.m_bPlayDashboardSound = true;
                    }
                }
            }
            catch (Exception exception9)
            {
                this.strError = this.strError + "Dashboard notification sound save error: " + exception9.Message;
                flag          = false;
            }
            try
            {
                AppRegistry.SaveValue(rootKey, "local_DisableDashboardSettingChangeNotifications", this.checkBoxDisableDashboardSettingChangeNotifications.Checked, ref this.strError, false, RegistryValueKind.Unknown);
                if (errorMessage != string.Empty)
                {
                    this.strError = this.strError + "Dashboard Settign Change Notification save error: " + errorMessage;
                    flag          = false;
                }
                else
                {
                    this.appManager.m_bDisableDashboardSettingChangeNotifications = this.checkBoxDisableDashboardSettingChangeNotifications.Checked;
                }
            }
            catch (Exception exception10)
            {
                this.strError = this.strError + "Dashboard Settign Change Notification save error: " + exception10.Message;
                flag          = false;
            }
            if (this.appManager.m_bDashboardMode != this.checkBoxEnableDashboard.Checked)
            {
                this.changeEnableDashbaordMode = MessageBox.Show("You must exit and re-open the " + this.appManager.m_strApplicationName + " application for the change to Dashboard mode to take effect.  Would you like to exit " + this.appManager.m_strApplicationName + " now?", "Multiple Account Mode Change", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (this.changeEnableDashbaordMode == DialogResult.Yes)
                {
                    try
                    {
                        AppRegistry.SaveValue(rootKey, "local_DashboardMode", this.checkBoxEnableDashboard.Checked, ref errorMessage, false, RegistryValueKind.Unknown);
                        if (errorMessage != string.Empty)
                        {
                            this.strError = this.strError + "Enable Dashboard save error: " + errorMessage;
                            flag          = false;
                        }
                        else
                        {
                            AppRegistry.SaveUserName(rootKey, "", ref errorMessage);
                            if (errorMessage != string.Empty)
                            {
                                this.strError = this.strError + "\nUserName Save Error: " + errorMessage;
                            }
                            AppRegistry.SavePassword(rootKey, "", ref errorMessage);
                            if (errorMessage != string.Empty)
                            {
                                this.strError = this.strError + "\nPassword Save Error: " + errorMessage;
                            }
                        }
                    }
                    catch (Exception exception11)
                    {
                        this.strError = this.strError + "Enable Dashboard save error: " + exception11.Message;
                        flag          = false;
                    }
                }
            }
            if (flag)
            {
                if (this.changeEnableDashbaordMode == DialogResult.Yes)
                {
                    Application.Exit();
                }
                else if (this.changeEnableDashbaordMode == DialogResult.No)
                {
                    this.checkBoxEnableDashboard.Checked = this.appManager.m_bDashboardMode;
                }
                else
                {
                    base.Close();
                    if ((this.appManager.formMessages != null) && this.bRefreshMessageForm)
                    {
                        this.appManager.formMessages.Close();
                        this.appManager.ShowMessages();
                    }
                    this.appManager.ShowBalloon("Your settings have been saved.", 5);
                }
            }
            else
            {
                this.appManager.ShowBalloon("Exception saving settings: " + this.strError, 5);
            }
        }