/// <summary> /// 增加索引 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdAddIndex_Click(object sender, EventArgs e) { var ascendingKey = new List <string>(); var descendingKey = new List <string>(); var geoSpatialKey = string.Empty; var firstKey = string.Empty; var textKey = string.Empty; for (var i = 0; i < 5; i++) { var ctl = (CtlIndexCreate)Controls.Find("ctlIndexCreate" + (i + 1), true)[0]; if (ctl.KeyName == string.Empty) { continue; } firstKey = ctl.KeyName.Trim(); switch (ctl.IndexKeyType) { case EnumMgr.IndexType.Ascending: ascendingKey.Add(ctl.KeyName.Trim()); break; case EnumMgr.IndexType.Descending: descendingKey.Add(ctl.KeyName.Trim()); break; case EnumMgr.IndexType.GeoSpatial: geoSpatialKey = ctl.KeyName.Trim(); break; case EnumMgr.IndexType.Text: textKey = ctl.KeyName.Trim(); break; default: break; } } //Index UIOption var UIOption = new Operater.IndexOption(); UIOption.IsBackground = chkIsBackground.Checked; UIOption.IsDropDups = chkIsDroppedDups.Checked; UIOption.IsSparse = chkIsSparse.Checked; UIOption.IsUnique = chkIsUnique.Checked; UIOption.IsExpireData = chkExpireData.Checked; UIOption.TTL = (int)numTTL.Value; UIOption.ascendingKey = ascendingKey; UIOption.descendingKey = descendingKey; UIOption.geoSpatialKey = geoSpatialKey; UIOption.firstKey = firstKey; UIOption.textKey = textKey; UIOption.IndexName = txtIndexName.Text; var strMessageTitle = string.Empty; var strMessageContent = string.Empty; if (Operater.CreateIndex(UIOption, ref strMessageTitle, ref strMessageContent)) { RefreshList(); } MyMessageBox.ShowEasyMessage(strMessageTitle, strMessageContent); }
/// <summary> /// 增加索引 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdAddIndex_Click(object sender, EventArgs e) { //Index UIOption var uiOption = new Operater.IndexOption() { AscendingKey = new List <string>(), DescendingKey = new List <string>(), TextKey = new List <string>() }; var firstKey = string.Empty; for (var i = 0; i < 5; i++) { var ctl = (CtlIndexCreate)Controls.Find("ctlIndexCreate" + (i + 1), true)[0]; if (ctl.KeyName == string.Empty) { continue; } firstKey = ctl.KeyName.Trim(); switch (ctl.IndexKeyType) { case EnumMgr.IndexType.GeoSpatialHaystack: uiOption.GeoSpatialHaystackKey = ctl.KeyName.Trim(); break; case EnumMgr.IndexType.GeoSpatialSpherical: uiOption.GeoSpatialSphericalKey = ctl.KeyName.Trim(); break; case EnumMgr.IndexType.GeoSpatial: uiOption.GeoSpatialKey = ctl.KeyName.Trim(); break; case EnumMgr.IndexType.Ascending: uiOption.AscendingKey.Add(ctl.KeyName.Trim()); break; case EnumMgr.IndexType.Descending: uiOption.DescendingKey.Add(ctl.KeyName.Trim()); break; case EnumMgr.IndexType.Text: uiOption.TextKey.Add(ctl.KeyName.Trim()); break; case EnumMgr.IndexType.Hashed: uiOption.HashedKey = ctl.KeyName.Trim(); break; } } uiOption.IsBackground = chkIsBackground.Checked; uiOption.IsDropDups = chkIsDroppedDups.Checked; uiOption.IsSparse = chkIsSparse.Checked; uiOption.IsUnique = chkIsUnique.Checked; uiOption.IsExpireData = chkExpireData.Checked; //Partial Indexes uiOption.IsPartial = chkPartialIndexes.Checked; uiOption.Ttl = (int)numTTL.Value; uiOption.FirstKey = firstKey; uiOption.IndexName = txtIndexName.Text; //Partial Condition uiOption.PartialCondition = txtPartialIndexes.Text; var strMessageTitle = string.Empty; var strMessageContent = string.Empty; if (Operater.CreateIndex(uiOption, ref strMessageTitle, ref strMessageContent)) { RefreshList(); } MyMessageBox.ShowMessage(strMessageTitle, strMessageContent); }