示例#1
0
文件: sync.cs 项目: Eisai/pragmasql
        private void PopulateDBConnections()
        {
            ListViewItem  item  = null;
            ListViewGroup group = null;

            _connParams = ConnectionParamsFactory.GetConnections();
            lvConnections.Items.Clear();
            string serverName = String.Empty;
            int    cnt        = 0;

            foreach (ConnectionParams connSpec in _connParams)
            {
#if PERSONAL_EDITION
                cnt++;
                if (cnt > _maxPersonalEditionConnCnt)
                {
                    lblPersonalEdLimit.Visible     = true;
                    lblPersonalEdLimit.Text        = String.Format("Only {0} connections are listed.", _maxPersonalEditionConnCnt);
                    lblPersonalEdLimit.ToolTipText = String.Format("Personal Edition does not support more than {0} saved connections.", _maxPersonalEditionConnCnt);

                    break;
                }
#endif
                string key       = ConnectionParams.PrepareConnKey(connSpec);
                string normalKey = key.Replace(((Char)29).ToString(), " as ");
                serverName = connSpec.Server.Trim().ToLowerInvariant();

                if (_groups.ContainsKey(serverName))
                {
                    group = _groups[serverName];
                }
                else
                {
                    group = new ListViewGroup(serverName, connSpec.Server);
                    lvConnections.Groups.Add(group);
                    _groups.Add(serverName, group);
                }
                item = new ListViewItem(normalKey, group);
                item.SubItems.Add(connSpec.Database);
                item.Tag = connSpec.ID;
                lvConnections.Items.Add(item);
            }

            if (_connParams.Count > 0)
            {
                lvConnections.Items[0].Selected = true;
            }

            InvalidateButtons();
        }
示例#2
0
        /*
         * public ConnectionParams FindByServerName(string name)
         * {
         *      foreach (ConnectionParams cp in this)
         *      {
         *              if (cp.Server.ToLowerInvariant() == name.ToLowerInvariant())
         *                      return cp;
         *      }
         *      return null;
         * }
         */

        public void Delete(ConnectionParams cp)
        {
            int index = 0;

            foreach (ConnectionParams d in this)
            {
                if (d.ID == cp.ID)
                {
                    this.RemoveAt(index);
                    ConnectionParamsFactory.Save(this);
                    return;
                }
                index++;
            }
        }
示例#3
0
文件: sync.cs 项目: Eisai/pragmasql
        private void AddNewConnectionSpec()
        {
#if PERSONAL_EDITION
            if (lvConnections.Items.Count >= _maxPersonalEditionConnCnt)
            {
                throw new PersonalEditionLimitation(String.Format("Personal Edition does not support more than {0} saved connections.", _maxPersonalEditionConnCnt));
            }
#endif
            frmConnectionParams frm = new frmConnectionParams();
            if (frm.ShowDialog() == DialogResult.OK)
            {
                AddConnectionSpecToList(frm.GetCurrentConnectionSpec());
                ConnectionParamsFactory.Save(_connParams);
                InvalidateButtons();
            }
        }
示例#4
0
文件: sync.cs 项目: Eisai/pragmasql
        private void EditSelectedConnectionSpec()
        {
            if (lvConnections.SelectedItems.Count == 0)
            {
                return;
            }

            frmConnectionParams frm = new frmConnectionParams(this.SelectedDataSource, true, false);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                _connParams.Delete(this.SelectedDataSource);
                lvConnections.Items.Remove(lvConnections.SelectedItems[0]);
                AddConnectionSpecToList(frm.GetCurrentConnectionSpec());
                ConnectionParamsFactory.Save(_connParams);
                InvalidateButtons();
            }
        }