Exemple #1
0
        public ViewDesignerDoc(int itemId, DataViewHierarchyAccessor accessor, string viewName)
        {
            _accessor   = accessor;
            _connection = accessor.Connection;
            _itemId     = itemId;
            InitializeComponent();

            _init = true;
            try
            {
                _typeQB = NpgsqlDataAdapterToolboxItem._vsdesigner.GetType("Microsoft.VSDesigner.Data.Design.QueryBuilderControl");

                if (_typeQB != null)
                {
                    _queryDesigner = Activator.CreateInstance(_typeQB) as UserControl;
                    _typeQB.InvokeMember("Provider", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { "Npgsql" });
                    _typeQB.InvokeMember("ConnectionString", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { _connection.ConnectionSupport.ConnectionString });
                    _typeQB.InvokeMember("EnableMorphing", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { false });
                    Controls.Add(_queryDesigner);
                    _queryDesigner.Dock    = DockStyle.Fill;
                    _queryDesigner.Visible = true;
                }

                StringBuilder tables = new StringBuilder();

                using (DataReader reader = _connection.Command.Execute("SELECT * FROM sqlite_master", 1, null, 30))
                {
                    while (reader.Read())
                    {
                        tables.Append(reader.GetItem(2).ToString());
                        tables.Append(",");
                    }
                }

                int n = 1;

                if (String.IsNullOrEmpty(viewName))
                {
                    string alltables = tables.ToString();

                    do
                    {
                        viewName = String.Format("View{0}", n);
                        n++;
                    } while (alltables.IndexOf(viewName + ",", StringComparison.OrdinalIgnoreCase) > -1 || _editingTables.ContainsValue(viewName));

                    _editingTables.Add(GetHashCode(), viewName);
                }
                _view = new Npgsql.Designer.Design.View(viewName, _connection.ConnectionSupport.ProviderObject as DbConnection, this);
            }
            finally
            {
                _init = false;
            }
        }
Exemple #2
0
 internal ViewHolder(Npgsql.Designer.Design.View parent)
 {
     _triggers = parent.Triggers as List <ViewTrigger>;
 }
Exemple #3
0
    public ViewDesignerDoc(int itemId, DataViewHierarchyAccessor accessor, string viewName)
    {
      _accessor = accessor;
      _connection = accessor.Connection;
      _itemId = itemId;
      InitializeComponent();

      _init = true;
      try
      {
        _typeQB = NpgsqlDataAdapterToolboxItem._vsdesigner.GetType("Microsoft.VSDesigner.Data.Design.QueryBuilderControl");

        if (_typeQB != null)
        {
          _queryDesigner = Activator.CreateInstance(_typeQB) as UserControl;
          _typeQB.InvokeMember("Provider", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { "Npgsql" });
          _typeQB.InvokeMember("ConnectionString", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { _connection.ConnectionSupport.ConnectionString });
          _typeQB.InvokeMember("EnableMorphing", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.NonPublic, null, _queryDesigner, new object[] { false });
          Controls.Add(_queryDesigner);
          _queryDesigner.Dock = DockStyle.Fill;
          _queryDesigner.Visible = true;
        }

        StringBuilder tables = new StringBuilder();

        using (DataReader reader = _connection.Command.Execute("SELECT * FROM sqlite_master", 1, null, 30))
        {
          while (reader.Read())
          {
            tables.Append(reader.GetItem(2).ToString());
            tables.Append(",");
          }
        }

        int n = 1;

        if (String.IsNullOrEmpty(viewName))
        {
          string alltables = tables.ToString();

          do
          {
            viewName = String.Format("View{0}", n);
            n++;
          } while (alltables.IndexOf(viewName + ",", StringComparison.OrdinalIgnoreCase) > -1 || _editingTables.ContainsValue(viewName));

          _editingTables.Add(GetHashCode(), viewName);
        }
        _view = new Npgsql.Designer.Design.View(viewName, _connection.ConnectionSupport.ProviderObject as DbConnection, this);
      }
      finally
      {
        _init = false;
      }
    }