Exemplo n.º 1
0
 public ColumnAddress(DatabaseAddress address, string sTableName, string sColumnName)
 {
     m_sServerName   = address.GetServerName();
     m_sDatabaseName = address.GetDatabaseName();
     m_sTableName    = sTableName == null ? string.Empty : sTableName.ToUpper();
     m_sColumnName   = sColumnName == null ? string.Empty : sColumnName.ToUpper();
 }
Exemplo n.º 2
0
        private void TestConnection()
        {
            string host = Properties.Settings.Default.mongodb_host;
            int    port = Properties.Settings.Default.mongodb_port;

            DatabaseAddress    address    = new DatabaseAddress(host, port);
            DatabaseConnection connection = DatabaseConnection.Instance;

            connection.Address = address;
            connection.Connect();
            bool isReachable = connection.Test();

            if (!isReachable)
            {
                MessageBox.Show("MongoDB is not reachable. Please configure.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                ConnectionForm connectionForm = new ConnectionForm();
                connectionForm.ShowDialog();
            }
            else
            {
                if (!connection.HasDatabaseCollection(Properties.Settings.Default.mongodb_database, Properties.Settings.Default.mongodb_collection_shares))
                {
                    connection.CreateCollection(Properties.Settings.Default.mongodb_collection_shares);
                    var database         = connection.Client.GetDatabase(Properties.Settings.Default.mongodb_database);
                    var sharesCollection = database.GetCollection <BsonDocument>(Properties.Settings.Default.mongodb_collection_shares);

                    /*
                     * var options = new CreateIndexOptions() { Unique = true };
                     * var field = new StringFieldDefinition<BsonDocument>("string_letter");
                     * var index = new IndexKeysDefinitionBuilder<BsonDocument>().Ascending(field);
                     */
                    // db.network_shares.createIndex({ "share_letter": 1}, { unique: true});
                    // var keys = Builders<BsonDocument>.IndexKeys.Ascending("i");
                    // collection.Indexes.CreateOne(keys);

                    sharesCollection.Indexes.CreateOne("{share_letter : 1}", new CreateIndexOptions()
                    {
                        Unique = true
                    });
                }
            }
        }
Exemplo n.º 3
0
        private void testConnectionBtn_Click(object sender, EventArgs e)
        {
            string host = this.hostTbx.Text;
            int    port = (int)this.portNud.Value;

            DatabaseAddress    address    = new DatabaseAddress(host, port);
            DatabaseConnection connection = DatabaseConnection.Instance;

            connection.Address = address;
            connection.Connect();
            bool isReachable = connection.Test();

            if (isReachable)
            {
                MessageBox.Show("MongoDB is reachable.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.saveBtn.Enabled = true;
            }
            else
            {
                MessageBox.Show("MongoDB is not reachable.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
 public ApiContextConfig()
 {
     m_databaseAddress = new DatabaseAddress();
 }
Exemplo n.º 5
0
 public ApiContextConfig(DatabaseAddress address)
 {
     m_databaseAddress = address;
 }
Exemplo n.º 6
0
 public int Test(DatabaseAddress address)
 {
     return(5);
 }