/// <summary> /// Create Collection /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateMongoCollectionToolStripMenuItem_Click(object sender, EventArgs e) { //Advance CreateCollection var frm = new FrmCreateCollection { StrSvrPathWithTag = RuntimeMongoDbContext.SelectObjectTag, TreeNode = trvsrvlst.SelectedNode }; Utility.OpenForm(frm, true, true); if (frm.Result) { //这里表示: Client / Server 一个Client 可能连结复数Server var srvkey = RuntimeMongoDbContext.GetCurrentServerKey() + "/" + RuntimeMongoDbContext.GetCurrentServerKey(); var newCol = UiHelper.FillCollectionInfoToTreeNode( RuntimeMongoDbContext.GetCurrentIMongoDataBase().GetCollection <BsonDocument>(frm.CollectionName), srvkey); foreach (TreeNode item in trvsrvlst.SelectedNode.Nodes) { var strNodeType = TagInfo.GetTagType(item.Tag.ToString()); if (strNodeType == ConstMgr.CollectionListTag) { //自己添加的Collection不是SystemCollection item.Nodes.Add(newCol); break; } } DisableAllOpr(); } }
/// <summary> /// Save As View /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveAsView_Click(object sender, EventArgs e) { if (stages.Count == 0) { return; } var strViewName = MyMessageBox.ShowInput("pls Input Aggregate Pipeline Name :", "Save Aggregate Pipeline"); var pipeline = new BsonDocumentStagePipelineDefinition <BsonDocument, BsonDocument>(stages.Values.Select(x => (BsonDocument)x)); RuntimeMongoDbContext.GetCurrentIMongoDataBase().CreateView(strViewName, RuntimeMongoDbContext.GetCurrentCollectionName(), pipeline); }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdOK_Click(object sender, EventArgs e) { try { var pipeline = new BsonDocumentStagePipelineDefinition <BsonDocument, BsonDocument>(stages.Values.Select(x => (BsonDocument)x)); RuntimeMongoDbContext.GetCurrentIMongoDataBase().CreateView(txtViewName.Text, cmbViewOn.Text, pipeline); } catch (Exception ex) { Utility.ExceptionDeal(ex); } }
private void frmCreateView_Load(object sender, EventArgs e) { cmbViewOn.Items.Clear(); var ColList = RuntimeMongoDbContext.GetCurrentIMongoDataBase().ListCollections(); var viewlist = RuntimeMongoDbContext.GetCurrentDBViewNameList(); foreach (var item in ColList.ToList()) { var ColName = item.GetElement("name").Value.ToString(); if (!viewlist.Contains(ColName)) { cmbViewOn.Items.Add(ColName); } } }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdOK_Click(object sender, EventArgs e) { try { var pipeline = new BsonDocumentStagePipelineDefinition <BsonDocument, BsonDocument>(stages.Values.Select(x => (BsonDocument)x)); CreateViewOptions <BsonDocument> OptionalDoc = null; if (mCollation != null) { OptionalDoc = new CreateViewOptions <BsonDocument>(); OptionalDoc.Collation = mCollation; } RuntimeMongoDbContext.GetCurrentIMongoDataBase().CreateView(txtViewName.Text, cmbViewOn.Text, pipeline, OptionalDoc); } catch (Exception ex) { Utility.ExceptionDeal(ex); } }