Exemplo n.º 1
0
        private void buttonRemove_Click(object sender, EventArgs e)
        {
            bool       find       = false;
            ServerInfo serverInfo = null;

            for (int i = 0; i < LoginInfos.Infos.ServerInfos.Count; i++)
            {
                serverInfo = LoginInfos.Infos.ServerInfos[i];

                if (serverInfo.ServerName.Equals(comboBoxServerName.Text.Trim(), StringComparison.CurrentCultureIgnoreCase))
                {
                    serverInfo.LastLoginTime = DateTime.Now;
                    find = true;
                    break;
                }
            }

            if (find)
            {
                if (MessageBox.Show(string.Format("Are you sure you want to remove server {0}",
                                                  serverInfo.ServerName), "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                    DialogResult.Yes)
                {
                    LoginInfos.Infos.ServerInfos.Remove(serverInfo);
                    LoginInfos.Save();
                    LoginInfoLoad();
                }
            }
        }
Exemplo n.º 2
0
        static public void Load()
        {
            Microsoft.Win32.RegistryKey key;

            using (key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Hubble.net\QueryAnalyzer"))
            {
                if (key == null)
                {
                    Infos = new LoginInfos();
                    return;
                }

                object loginInfosObj;

                loginInfosObj = key.GetValue("LoginInfos", null);

                if (loginInfosObj == null)
                {
                    Infos = new LoginInfos();
                    return;
                }

                System.IO.MemoryStream m = new System.IO.MemoryStream((byte[])loginInfosObj);

                m.Position = 0;

                Infos = XmlSerialization <LoginInfos> .Deserialize(m);
            }
        }
Exemplo n.º 3
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            DbAccess dbAccess = new DbAccess();

            try
            {
                dbAccess.AscyncConnection = checkBoxAsyncConnect.Checked;

                if (comboBoxAuthentication.SelectedIndex == 0)
                {
                    dbAccess.Connect(comboBoxServerName.Text.Trim());
                }
                else
                {
                    dbAccess.Connect(comboBoxServerName.Text.Trim(),
                                     textBoxUserName.Text.Trim(), textBoxPassword.Text.Trim());
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            bool find = false;

            for (int i = 0; i < LoginInfos.Infos.ServerInfos.Count; i++)
            {
                ServerInfo serverInfo = LoginInfos.Infos.ServerInfos[i];

                if (serverInfo.ServerName.Equals(comboBoxServerName.Text.Trim(), StringComparison.CurrentCultureIgnoreCase))
                {
                    SetLoginInfo(serverInfo);
                    find = true;
                    break;
                }
            }

            if (!find)
            {
                ServerInfo serverInfo = new ServerInfo();

                SetLoginInfo(serverInfo);

                LoginInfos.Infos.ServerInfos.Add(serverInfo);
            }

            LoginInfos.Save();

            FormMain frmMain = new FormMain();

            this.Hide();

            GlobalSetting.DataAccess = dbAccess;

            frmMain.ShowDialog();

            Environment.Exit(0);
        }
Exemplo n.º 4
0
        private void LoginInfoLoad()
        {
            LoginInfos.Load();

            comboBoxServerName.Items.Clear();

            if (LoginInfos.Infos.ServerInfos.Count > 0)
            {
                foreach (ServerInfo serverInfo in LoginInfos.Infos.ServerInfos)
                {
                    comboBoxServerName.Items.Add(serverInfo.ServerName);
                }

                ShowLoginInfo(0);
            }
            else
            {
                comboBoxServerName.Text = "";
            }
        }