コード例 #1
0
 /// <summary>
 /// OK
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdOK_Click(object sender, EventArgs e)
 {
     if (txtCollectionName.Text != String.Empty)
     {
         try
         {
             String ErrMessage;
             SystemManager.GetCurrentDataBase().IsCollectionNameValid(txtCollectionName.Text, out ErrMessage);
             if (ErrMessage != null)
             {
                 MyMessageBox.ShowMessage("Create MongoDatabase", "Argument Exception", ErrMessage, true);
                 return;
             }
             if (chkAdvance.Checked)
             {
                 CollectionOptionsBuilder option = new CollectionOptionsBuilder();
                 option.SetCapped(chkIsCapped.Checked);
                 option.SetMaxSize((long)numMaxSize.Value);
                 option.SetMaxDocuments((long)numMaxDocument.Value);
                 option.SetAutoIndexId(chkIsAutoIndexId.Checked);
                 Result = MongoDBHelper.CreateCollectionWithOptions(strSvrPathWithTag, treeNode, txtCollectionName.Text, option);
             }
             else
             {
                 Result = MongoDBHelper.CreateCollection(strSvrPathWithTag, treeNode, txtCollectionName.Text);
             }
             this.Close();
         }
         catch (ArgumentException ex)
         {
             MyMessageBox.ShowMessage("Create MongoDatabase", "Argument Exception", ex.Message, true);
             Result = false;
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// OK
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdOK_Click(object sender, EventArgs e)
 {
     //不支持中文 JIRA ticket is created : SERVER-4412
     //SERVER-4412已经在2013/03解决了
     //collection names are limited to 121 bytes after converting to UTF-8.
     if (txtCollectionName.Text != String.Empty)
     {
         try
         {
             String ErrMessage;
             SystemManager.GetCurrentDataBase().IsCollectionNameValid(txtCollectionName.Text, out ErrMessage);
             if (ErrMessage != null)
             {
                 MyMessageBox.ShowMessage("Create MongoDatabase", "Argument Exception", ErrMessage, true);
                 return;
             }
             if (chkAdvance.Checked)
             {
                 CollectionOptionsBuilder option = new CollectionOptionsBuilder();
                 option.SetCapped(chkIsCapped.Checked);
                 option.SetMaxSize((long)numMaxSize.Value);
                 option.SetMaxDocuments((long)numMaxDocument.Value);
                 //CappedCollection Default is AutoIndexId After MongoDB 2.2.2
                 option.SetAutoIndexId(chkIsAutoIndexId.Checked);
                 Result = MongoDBHelper.CreateCollectionWithOptions(strSvrPathWithTag, treeNode, txtCollectionName.Text, option);
             }
             else
             {
                 Result = MongoDBHelper.CreateCollection(strSvrPathWithTag, treeNode, txtCollectionName.Text);
             }
             this.Close();
         }
         catch (ArgumentException ex)
         {
             SystemManager.ExceptionDeal(ex, "Create MongoDatabase", "Argument Exception");
             Result = false;
         }
     }
 }