Esempio n. 1
0
        private void frmServerMonitor_Load(object sender, EventArgs e)
        {
            if (!GuiConfig.IsMono)
            {
                Icon = GetSystemIcon.ConvertImgToIcon(Resources.KeyInfo);
            }
            _mTime = new Timer {
                Interval = RefreshInterval * 1000
            };
            _mTime.Tick += M_Tick;
            var querySeries = new Series("Query")
            {
                ChartType  = SeriesChartType.Line,
                XValueType = ChartValueType.String,
                YValueType = ChartValueType.Int32
            };

            MonitorGrap.Series.Add(querySeries);

            var insertSeries = new Series("Insert")
            {
                ChartType  = SeriesChartType.Line,
                XValueType = ChartValueType.String,
                YValueType = ChartValueType.Int32
            };

            MonitorGrap.Series.Add(insertSeries);
            FormClosing += (x, y) => _mTime.Stop();
            _mTime.Start();
        }
Esempio n. 2
0
        /// <summary>
        ///     输出配置字典
        /// </summary>
        private void frmQuery_Load(object sender, EventArgs e)
        {
            if (!GuiConfig.IsMono)
            {
                Icon = GetSystemIcon.ConvertImgToIcon(GetResource.GetImage(ImageType.Query));
            }
            var fieldList = new List <DataFilter.QueryFieldItem>();

            fieldList = _currentDataViewInfo.MDataFilter.QueryFieldList;
            //增加第一个条件
            ConditionPan.AddCondition();
            if (_currentDataViewInfo.IsUseFilter)
            {
                //使用过滤:字段和条件的设定
                QueryFieldPicker.SetQueryFieldList(fieldList);
                if (_currentDataViewInfo.MDataFilter.QueryConditionList.Count > 0)
                {
                    ConditionPan.PutQueryToUi(_currentDataViewInfo.MDataFilter);
                }
            }
            else
            {
                //不使用过滤:字段初始化
                QueryFieldPicker.InitByCurrentCollection(true);
            }
            //多国语言
            GuiConfig.Translateform(this);
        }
Esempio n. 3
0
        /// <summary>
        /// 输出配置字典
        /// </summary>
        private void frmQuery_Load(object sender, EventArgs e)
        {
            this.Icon = GetSystemIcon.ConvertImgToIcon(GetResource.GetImage(ImageType.Query));
            List <DataFilter.QueryFieldItem> FieldList = new List <DataFilter.QueryFieldItem>();

            FieldList = CurrentDataViewInfo.mDataFilter.QueryFieldList;
            //增加第一个条件
            ConditionPan.AddCondition();
            if (CurrentDataViewInfo.IsUseFilter)
            {
                //使用过滤:字段和条件的设定
                QueryFieldPicker.setQueryFieldList(FieldList);
                if (CurrentDataViewInfo.mDataFilter.QueryConditionList.Count > 0)
                {
                    ConditionPan.PutQueryToUI(CurrentDataViewInfo.mDataFilter);
                }
            }
            else
            {
                //不使用过滤:字段初始化
                QueryFieldPicker.InitByCurrentCollection(true);
            }
            if (!SystemManager.IsUseDefaultLanguage)
            {
                this.Text            = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Query_Title);
                tabFieldInfo.Text    = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Query_FieldInfo);
                tabCondition.Text    = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Query_Filter);
                tabSql.Text          = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.ConvertSql_Title);
                cmdAddCondition.Text = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Query_Filter_AddCondition);
                cmdLoad.Text         = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Query_Action_Load);
                cmdSave.Text         = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_Save);
                cmdOK.Text           = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_OK);
                cmdCancel.Text       = SystemManager.mStringResource.GetText(StringResource.TextType.Common_Cancel);
            }
        }
Esempio n. 4
0
 private void frmUser_Load(object sender, EventArgs e)
 {
     if (_ModifyName != String.Empty)
     {
         this.Text           = "Change Password";
         txtUserName.Enabled = false;
         txtUserName.Text    = _ModifyName;
     }
     if (!SystemManager.IsUseDefaultLanguage)
     {
         if (_ModifyName == String.Empty)
         {
             if (_IsAdmin)
             {
                 this.Text = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Main_Menu_Operation_Server_AddUserToAdmin);
             }
             else
             {
                 this.Text = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Main_Menu_Operation_Database_AddUser);
             }
             this.Icon = GetSystemIcon.ConvertImgToIcon(MagicMongoDBTool.Properties.Resources.AddUserToDB);
         }
         else
         {
             this.Icon = GetSystemIcon.ConvertImgToIcon(MagicMongoDBTool.Properties.Resources.DBkey);
             //this.Text = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Main_Menu_Operation_Database_ChangePassword);
         }
         lblUserName.Text   = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_Username);
         lblPassword.Text   = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_Password);
         lblConfirmPsw.Text = SystemManager.mStringResource.GetText(StringResource.TextType.Common_ConfirmPassword);
         chkReadOnly.Text   = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_ReadOnly);
         cmdOK.Text         = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_OK);
         cmdCancel.Text     = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_Cancel);
     }
 }
        private void frmServerMonitor_Load(object sender, EventArgs e)
        {
            Icon = GetSystemIcon.ConvertImgToIcon(ResourceLib.Properties.Resources.KeyInfo);
            M    = new Timer {
                Interval = 3000
            };
            M.Tick += M_Tick;
            var QuerySeries = new Series("Query")
            {
                ChartType  = SeriesChartType.Line,
                XValueType = ChartValueType.String,
                YValueType = ChartValueType.Int32
            };

            MonitorGrap.Series.Add(QuerySeries);

            var InsertSeries = new Series("Insert")
            {
                ChartType  = SeriesChartType.Line,
                XValueType = ChartValueType.String,
                YValueType = ChartValueType.Int32
            };

            MonitorGrap.Series.Add(InsertSeries);
            FormClosing += (x, y) => M.Stop();
            M.Start();
        }
Esempio n. 6
0
        private void frmServerMonitor_Load(object sender, EventArgs e)
        {
            this.Icon  = GetSystemIcon.ConvertImgToIcon(MagicMongoDBTool.Properties.Resources.KeyInfo);
            M          = new Timer();
            M.Interval = 3000;
            M.Tick    += M_Tick;
            Series QuerySeries = new Series("Query");

            QuerySeries.ChartType  = SeriesChartType.Line;
            QuerySeries.XValueType = ChartValueType.String;
            QuerySeries.YValueType = ChartValueType.Int32;
            MonitorGrap.Series.Add(QuerySeries);

            Series InsertSeries = new Series("Insert");

            InsertSeries.ChartType  = SeriesChartType.Line;
            InsertSeries.XValueType = ChartValueType.String;
            InsertSeries.YValueType = ChartValueType.Int32;
            MonitorGrap.Series.Add(InsertSeries);
            this.FormClosing += (x, y) =>
            {
                M.Stop();
            };
            M.Start();
        }
Esempio n. 7
0
 private void frmUser_Load(object sender, EventArgs e)
 {
     if (_modifyName != string.Empty)
     {
         Text = "Change User Config";
         txtUserName.Enabled = false;
         txtUserName.Text    = _modifyName;
         var userInfo = RuntimeMongoDbContext.GetCurrentDataBase().GetCollection(ConstMgr.CollectionNameUser)
                        .FindOneAs <BsonDocument>(Query.EQ("user", _modifyName));
         userRoles.SetRoles(userInfo["roles"].AsBsonArray);
         _otherDbRolesDict.Clear();
         foreach (var item in userInfo["otherDBRoles"].AsBsonDocument)
         {
             _otherDbRolesDict.Add(item.Name, item);
         }
         RefreshOtherDbRoles();
     }
     if (!GuiConfig.IsUseDefaultLanguage)
     {
         if (_modifyName == string.Empty)
         {
             Text = GuiConfig.GetText(_isAdmin
                 ? TextType.MainMenuOperationServerAddUserToAdmin
                 : TextType.MainMenuOperationDatabaseAddUser);
             if (!GuiConfig.IsMono)
             {
                 Icon = GetSystemIcon.ConvertImgToIcon(Resources.AddUserToDB);
             }
         }
         else
         {
             if (!GuiConfig.IsMono)
             {
                 Icon = GetSystemIcon.ConvertImgToIcon(Resources.DBkey);
             }
             Text = GuiConfig.GetText(TextType.CommonChangePassword);
         }
         lblUserName.Text =
             GuiConfig.GetText(TextType.CommonUsername);
         lblPassword.Text =
             GuiConfig.GetText(TextType.CommonPassword);
         lblConfirmPsw.Text =
             GuiConfig.GetText(TextType.CommonConfirmPassword);
         //chkReadOnly.Text = GUIConfig.GetText(MongoCola.Module.ResourceLib.MongoHelper.TextType.Common_ReadOnly);
         colRoles.Text    = GuiConfig.GetText(TextType.CommonRoles);
         colDataBase.Text =
             GuiConfig.GetText(TextType.CommonDataBase);
         cmdOK.Text     = GuiConfig.GetText(TextType.CommonOk);
         cmdCancel.Text = GuiConfig.GetText(TextType.CommonCancel);
     }
 }
Esempio n. 8
0
 private void frmUser_Load(object sender, EventArgs e)
 {
     if (_ModifyName != String.Empty)
     {
         this.Text           = "Change User Config";
         txtUserName.Enabled = false;
         txtUserName.Text    = _ModifyName;
         var userInfo = SystemManager.GetCurrentDataBase().GetCollection(MongoDBHelper.COLLECTION_NAME_USER)
                        .FindOneAs <BsonDocument>(MongoDB.Driver.Builders.Query.EQ("user", _ModifyName));
         this.userRoles.setRoles(userInfo["roles"].AsBsonArray);
         OtherDBRolesDict.Clear();
         foreach (var item in userInfo["otherDBRoles"].AsBsonDocument)
         {
             OtherDBRolesDict.Add(item.Name, item);
         }
         RefreshOtherDBRoles();
     }
     if (!SystemManager.IsUseDefaultLanguage)
     {
         if (_ModifyName == String.Empty)
         {
             if (_IsAdmin)
             {
                 this.Text = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Main_Menu_Operation_Server_AddUserToAdmin);
             }
             else
             {
                 this.Text = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Main_Menu_Operation_Database_AddUser);
             }
             this.Icon = GetSystemIcon.ConvertImgToIcon(MagicMongoDBTool.Properties.Resources.AddUserToDB);
         }
         else
         {
             this.Icon = GetSystemIcon.ConvertImgToIcon(MagicMongoDBTool.Properties.Resources.DBkey);
             this.Text = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_ChangePassword);
         }
         lblUserName.Text   = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_Username);
         lblPassword.Text   = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_Password);
         lblConfirmPsw.Text = SystemManager.mStringResource.GetText(StringResource.TextType.Common_ConfirmPassword);
         //chkReadOnly.Text = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_ReadOnly);
         colRoles.Text    = SystemManager.mStringResource.GetText(StringResource.TextType.Common_Roles);
         colDataBase.Text = SystemManager.mStringResource.GetText(StringResource.TextType.Common_DataBase);
         cmdOK.Text       = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_OK);
         cmdCancel.Text   = SystemManager.mStringResource.GetText(MagicMongoDBTool.Module.StringResource.TextType.Common_Cancel);
     }
 }
Esempio n. 9
0
        private void frmStatus_Load(object sender, EventArgs e)
        {
            this.Icon = GetSystemIcon.ConvertImgToIcon(MagicMongoDBTool.Properties.Resources.KeyInfo);
            String strType = SystemManager.SelectTagType;
            List <BsonDocument> SrvDocList = new List <BsonDocument>();
            BsonDocument        cr         = new BsonDocument();

            switch (strType)
            {
            case MongoDBHelper.SERVER_TAG:
            case MongoDBHelper.SINGLE_DB_SERVER_TAG:
                if (SystemManager.GetCurrentServerConfig().LoginAsAdmin)
                {
                    cr = MongoDBHelper.ExecuteMongoSvrCommand(MongoDBHelper.serverStatus_Command, SystemManager.GetCurrentServer()).Response;
                }
                break;

            case MongoDBHelper.DATABASE_TAG:
            case MongoDBHelper.SINGLE_DATABASE_TAG:
                cr = SystemManager.GetCurrentDataBase().GetStats().Response.ToBsonDocument();
                break;

            case MongoDBHelper.COLLECTION_TAG:
                cr = SystemManager.GetCurrentCollection().GetStats().Response.ToBsonDocument();
                break;

            default:
                if (SystemManager.GetCurrentServerConfig().LoginAsAdmin)
                {
                    cr = MongoDBHelper.ExecuteMongoSvrCommand(MongoDBHelper.serverStatus_Command, SystemManager.GetCurrentServer()).Response;
                }
                break;
            }
            if (!SystemManager.IsUseDefaultLanguage)
            {
                this.Text = SystemManager.mStringResource.GetText(StringResource.TextType.Main_Menu_Mangt_Status);
            }
            SrvDocList.Add(cr);
            MongoDBHelper.FillDataToTreeView(strType, this.trvStatus, SrvDocList, 0);
            this.trvStatus.DatatreeView.Nodes[0].Expand();
        }
Esempio n. 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmServerMonitor_Load(object sender, EventArgs e)
        {
            //填充分组
            GuiConfig.Translateform(this);
            UIAssistant.FillComberWithArray(cmbCatalog, SystemStatus.GetCatalog().ToArray());
            //自定义分组
            cmbCatalog.Items.Add("Custom");

            cmbCatalog.SelectedIndex = 0;
            if (!GuiConfig.IsMono)
            {
                Icon = GetSystemIcon.ConvertImgToIcon(Resources.KeyInfo);
            }
            _mTime = new Timer {
                Interval = RefreshInterval * 1000
            };
            NumTimeInterval.Value = RefreshInterval;
            _mTime.Tick          += SetValue;
            SetValue(null, null);
            FormClosing += (x, y) => _mTime.Stop();
            _mTime.Start();
        }
Esempio n. 11
0
        /// <summary>
        ///     输出配置字典
        /// </summary>
        private void frmQuery_Load(object sender, EventArgs e)
        {
            Icon = GetSystemIcon.ConvertImgToIcon(GetResource.GetImage(ImageType.Query));
            var fieldList = new List <DataFilter.QueryFieldItem>();

            fieldList = _currentDataViewInfo.MDataFilter.QueryFieldList;
            //增加第一个条件
            ConditionPan.AddCondition();
            if (_currentDataViewInfo.IsUseFilter)
            {
                //使用过滤:字段和条件的设定
                QueryFieldPicker.SetQueryFieldList(fieldList);
                if (_currentDataViewInfo.MDataFilter.QueryConditionList.Count > 0)
                {
                    ConditionPan.PutQueryToUi(_currentDataViewInfo.MDataFilter);
                }
            }
            else
            {
                //不使用过滤:字段初始化
                QueryFieldPicker.InitByCurrentCollection(true);
            }
            if (GuiConfig.IsUseDefaultLanguage)
            {
                return;
            }
            Text = GuiConfig.GetText(TextType.QueryTitle);
            tabFieldInfo.Text    = GuiConfig.GetText(TextType.QueryFieldInfo);
            tabCondition.Text    = GuiConfig.GetText(TextType.QueryFilter);
            tabSql.Text          = GuiConfig.GetText(TextType.ConvertSqlTitle);
            cmdAddCondition.Text =
                GuiConfig.GetText(TextType.QueryFilterAddCondition);
            cmdLoad.Text   = GuiConfig.GetText(TextType.QueryActionLoad);
            cmdSave.Text   = GuiConfig.GetText(TextType.CommonSave);
            cmdOK.Text     = GuiConfig.GetText(TextType.CommonOk);
            cmdCancel.Text = GuiConfig.GetText(TextType.CommonCancel);
        }
Esempio n. 12
0
        /// <summary>
        ///     窗体初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmStatus_Load(object sender, EventArgs e)
        {
            if (!GuiConfig.IsMono)
            {
                Icon = GetSystemIcon.ConvertImgToIcon(Resources.KeyInfo);
            }
            GuiConfig.Translateform(this);
            var strType   = RuntimeMongoDbContext.SelectTagType;
            var docStatus = new BsonDocument();

            cmbChartField.Visible          = false;
            chartResult.Visible            = false;
            tempIsDisplayNumberWithKSystem = CtlTreeViewColumns.IsDisplayNumberWithKSystem;
            CtlTreeViewColumns.IsDisplayNumberWithKSystem = true;

            switch (strType)
            {
            case ConstMgr.ServerTag:
            case ConstMgr.SingleDbServerTag:
                if (RuntimeMongoDbContext.GetCurrentServerConfig().LoginAsAdmin)
                {
                    var StatusList = new List <BsonDocument>();
                    var Status     = CommandExecute.ExecuteMongoSvrCommand(DataBaseCommand.ServerStatusCommand,
                                                                           RuntimeMongoDbContext.GetCurrentServer()).Response;
                    StatusList.Add(Status);
                    try
                    {
                        var ServerDesripter = MongoUtility.ToolKit.MongoHelper.GetCurrentServerDescription();
                        StatusList.Add(ServerDesripter);
                    }
                    catch (Exception)
                    {
                        //Repl的时候,无法获得
                    }
                    UiHelper.FillDataToTreeView(strType, trvStatus, StatusList, 0);
                    trvStatus.Height = trvStatus.Height * 2;
                    trvStatus.DatatreeView.Nodes[0].Expand();
                    trvStatus.DatatreeView.Nodes[1].Expand();
                    return;
                }
                break;

            case ConstMgr.DatabaseTag:
            case ConstMgr.SingleDatabaseTag:
                docStatus             = RuntimeMongoDbContext.GetCurrentDataBase().GetStats().Response.ToBsonDocument();
                cmbChartField.Visible = true;
                chartResult.Visible   = true;
                //{{ "db" : "aaaa",
                //   "collections" : 8,
                //   "objects" : 0,
                //   "avgObjSize" : 0.0,
                //   "dataSize" : 0.0,
                //   "storageSize" : 32768.0,
                //   "numExtents" : 0,
                //   "indexes" : 8,
                //   "indexSize" : 32768.0,
                //   "ok" : 1.0 }}
                var statuspoint = docStatus.AsBsonDocument;
                //这里其实应该看Collection的Status,不同的引擎所拥有的状态不一样
                if (statuspoint.Contains("avgObjSize"))
                {
                    cmbChartField.Items.Add("AverageObjectSize");
                }
                if (statuspoint.Contains("dataSize"))
                {
                    cmbChartField.Items.Add("DataSize");
                }
                if (statuspoint.Contains("extentCount"))
                {
                    cmbChartField.Items.Add("ExtentCount");
                }
                if (statuspoint.Contains("indexes"))
                {
                    cmbChartField.Items.Add("IndexCount");
                }
                if (statuspoint.Contains("lastExtentSize"))
                {
                    cmbChartField.Items.Add("LastExtentSize");
                }
                //MaxDocuments仅在CapedCollection时候有效
                if (statuspoint.Contains("MaxDocuments"))
                {
                    cmbChartField.Items.Add("MaxDocuments");
                }
                if (statuspoint.Contains("ObjectCount"))
                {
                    cmbChartField.Items.Add("ObjectCount");
                }
                if (statuspoint.Contains("PaddingFactor"))
                {
                    cmbChartField.Items.Add("PaddingFactor");
                }
                if (statuspoint.Contains("storageSize"))
                {
                    cmbChartField.Items.Add("StorageSize");
                }
                cmbChartField.SelectedIndex = 0;
                try
                {
                    RefreshDbStatusChart("StorageSize");
                }
                catch (Exception ex)
                {
                    Utility.ExceptionDeal(ex);
                }
                break;

            case ConstMgr.CollectionTag:
                //TODO:这里无法看到Collection的Document Validation信息。
                docStatus = RuntimeMongoDbContext.GetCurrentCollection().GetStats().Response.ToBsonDocument();
                //图形化初始化
                chartResult.Visible = true;

                chartResult.Series.Clear();
                chartResult.Titles.Clear();
                var seriesResult = new Series("Usage");
                var dpDataSize   = new DataPoint(0, RuntimeMongoDbContext.GetCurrentCollection().GetStats().DataSize)
                {
                    LegendText    = "DataSize",
                    LegendToolTip = "DataSize",
                    ToolTip       = "DataSize"
                };
                seriesResult.Points.Add(dpDataSize);

                var dpTotalIndexSize = new DataPoint(0,
                                                     RuntimeMongoDbContext.GetCurrentCollection().GetStats().TotalIndexSize)
                {
                    LegendText    = "TotalIndexSize",
                    LegendToolTip = "TotalIndexSize",
                    ToolTip       = "TotalIndexSize"
                };
                seriesResult.Points.Add(dpTotalIndexSize);

                var dpFreeSize = new DataPoint(0,
                                               RuntimeMongoDbContext.GetCurrentCollection().GetStats().StorageSize -
                                               RuntimeMongoDbContext.GetCurrentCollection().GetStats().TotalIndexSize -
                                               RuntimeMongoDbContext.GetCurrentCollection().GetStats().DataSize)
                {
                    LegendText    = "FreeSize",
                    LegendToolTip = "FreeSize",
                    ToolTip       = "FreeSize"
                };
                seriesResult.Points.Add(dpFreeSize);

                seriesResult.ChartType = SeriesChartType.Pie;
                chartResult.Series.Add(seriesResult);
                chartResult.Titles.Add(new Title("Usage"));

                break;

            default:
                if (RuntimeMongoDbContext.GetCurrentServerConfig().LoginAsAdmin)
                {
                    docStatus =
                        CommandExecute.ExecuteMongoSvrCommand(DataBaseCommand.ServerStatusCommand,
                                                              RuntimeMongoDbContext.GetCurrentServer()).Response;
                    trvStatus.Height = trvStatus.Height * 2;
                }
                break;
            }
            UiHelper.FillDataToTreeView(strType, trvStatus, docStatus);
            trvStatus.DatatreeView.Nodes[0].Expand();
        }
Esempio n. 13
0
        private void frmStatus_Load(object sender, EventArgs e)
        {
            this.Icon = GetSystemIcon.ConvertImgToIcon(MagicMongoDBTool.Properties.Resources.KeyInfo);
            String       strType   = SystemManager.SelectTagType;
            BsonDocument DocStatus = new BsonDocument();

            cmbChartField.Visible = false;
            chartResult.Visible   = false;
            switch (strType)
            {
            case MongoDBHelper.SERVER_TAG:
            case MongoDBHelper.SINGLE_DB_SERVER_TAG:
                if (SystemManager.GetCurrentServerConfig().LoginAsAdmin)
                {
                    DocStatus             = MongoDBHelper.ExecuteMongoSvrCommand(MongoDBHelper.serverStatus_Command, SystemManager.GetCurrentServer()).Response;
                    this.trvStatus.Height = this.trvStatus.Height * 2;
                }
                break;

            case MongoDBHelper.DATABASE_TAG:
            case MongoDBHelper.SINGLE_DATABASE_TAG:
                DocStatus             = SystemManager.GetCurrentDataBase().GetStats().Response.ToBsonDocument();
                cmbChartField.Visible = true;
                chartResult.Visible   = true;

                cmbChartField.Items.Add("AverageObjectSize");
                cmbChartField.Items.Add("DataSize");
                cmbChartField.Items.Add("ExtentCount");
                cmbChartField.Items.Add("IndexCount");
                cmbChartField.Items.Add("LastExtentSize");
                //MaxDocuments仅在CapedCollection时候有效
                //cmbChartField.Items.Add("MaxDocuments");
                cmbChartField.Items.Add("ObjectCount");
                cmbChartField.Items.Add("PaddingFactor");
                cmbChartField.Items.Add("StorageSize");
                cmbChartField.SelectedIndex = 0;
                try
                {
                    RefreshDBStatusChart("StorageSize");
                }
                catch (Exception ex)
                {
                    SystemManager.ExceptionDeal(ex);
                }
                break;

            case MongoDBHelper.COLLECTION_TAG:
                DocStatus = SystemManager.GetCurrentCollection().GetStats().Response.ToBsonDocument();
                //图形化初始化
                chartResult.Visible = true;

                chartResult.Series.Clear();
                chartResult.Titles.Clear();
                Series    SeriesResult = new Series("Usage");
                DataPoint dpDataSize   = new DataPoint(0, SystemManager.GetCurrentCollection().GetStats().DataSize);
                dpDataSize.LegendText    = "DataSize";
                dpDataSize.LegendToolTip = "DataSize";
                dpDataSize.ToolTip       = "DataSize";
                SeriesResult.Points.Add(dpDataSize);

                DataPoint dpTotalIndexSize = new DataPoint(0, SystemManager.GetCurrentCollection().GetStats().TotalIndexSize);
                dpTotalIndexSize.LegendText    = "TotalIndexSize";
                dpTotalIndexSize.LegendToolTip = "TotalIndexSize";
                dpTotalIndexSize.ToolTip       = "TotalIndexSize";
                SeriesResult.Points.Add(dpTotalIndexSize);

                DataPoint dpFreeSize = new DataPoint(0, SystemManager.GetCurrentCollection().GetStats().StorageSize -
                                                     SystemManager.GetCurrentCollection().GetStats().TotalIndexSize -
                                                     SystemManager.GetCurrentCollection().GetStats().DataSize);
                dpFreeSize.LegendText    = "FreeSize";
                dpFreeSize.LegendToolTip = "FreeSize";
                dpFreeSize.ToolTip       = "FreeSize";
                SeriesResult.Points.Add(dpFreeSize);

                SeriesResult.ChartType = SeriesChartType.Pie;
                chartResult.Series.Add(SeriesResult);
                chartResult.Titles.Add("Usage");

                break;

            default:
                if (SystemManager.GetCurrentServerConfig().LoginAsAdmin)
                {
                    DocStatus             = MongoDBHelper.ExecuteMongoSvrCommand(MongoDBHelper.serverStatus_Command, SystemManager.GetCurrentServer()).Response;
                    this.trvStatus.Height = this.trvStatus.Height * 2;
                }
                break;
            }
            if (!SystemManager.IsUseDefaultLanguage)
            {
                this.Text = SystemManager.mStringResource.GetText(StringResource.TextType.Main_Menu_Mangt_Status);
            }
            MongoDBHelper.FillDataToTreeView(strType, this.trvStatus, DocStatus);
            this.trvStatus.DatatreeView.Nodes[0].Expand();
        }
Esempio n. 14
0
        /// <summary>
        ///     Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmUser_Load(object sender, EventArgs e)
        {
            if (_modifyName != string.Empty)
            {
                Text = "Change User Config";
                txtUserName.Enabled = false;
                txtUserName.Text    = _modifyName;
                var userInfo = RuntimeMongoDbContext.GetCurrentDataBase().GetCollection(ConstMgr.CollectionNameUsers)
                               .FindOneAs <BsonDocument>(Query.EQ("user", _modifyName));

                BsonElement role;
                if (userInfo.TryGetElement("roles", out role))
                {
                    var roles = role.Value.AsBsonArray;
                    foreach (var _role in roles)
                    {
                        if (_role.IsBsonDocument)
                        {
                            _roleList.Add(new Role.GrantRole()
                            {
                                Role = _role.AsBsonDocument.GetElement("role").Value.ToString(),
                                Db   = _role.AsBsonDocument.GetElement("db").Value.ToString()
                            });
                        }
                        else
                        {
                            _roleList.Add(new Role.GrantRole()
                            {
                                Role = _role.ToString(),
                            });
                        }
                    }
                }
                RefreshRoles();

                BsonElement custom;
                if (userInfo.TryGetElement("customData", out custom))
                {
                    customData             = custom.Value.AsBsonDocument;
                    lblcustomDocument.Text = "Custom Document:" + customData.ToString();
                }
            }

            GuiConfig.Translateform(this);

            if (!GuiConfig.IsUseDefaultLanguage)
            {
                if (_modifyName == string.Empty)
                {
                    if (!GuiConfig.IsMono)
                    {
                        Icon = GetSystemIcon.ConvertImgToIcon(Resources.AddUserToDB);
                    }
                    Text = GuiConfig.GetText(_isAdmin ? "MainMenu.OperationServerAddUserToAdmin" : "MainMenu.OperationDatabaseAddUser");
                }
                else
                {
                    if (!GuiConfig.IsMono)
                    {
                        Icon = GetSystemIcon.ConvertImgToIcon(Resources.DBkey);
                    }
                    Text = GuiConfig.GetText("CommonChangePassword");
                }
            }
        }
Esempio n. 15
0
        private void frmStatus_Load(object sender, EventArgs e)
        {
            Icon = GetSystemIcon.ConvertImgToIcon(Resources.KeyInfo);
            var strType   = RuntimeMongoDbContext.SelectTagType;
            var docStatus = new BsonDocument();

            cmbChartField.Visible = false;
            chartResult.Visible   = false;
            btnOpCnt.Visible      = false;
            switch (strType)
            {
            case ConstMgr.ServerTag:
            case ConstMgr.SingleDbServerTag:
                if (RuntimeMongoDbContext.GetCurrentServerConfig().LoginAsAdmin)
                {
                    docStatus =
                        CommandHelper.ExecuteMongoSvrCommand(CommandHelper.ServerStatusCommand,
                                                             RuntimeMongoDbContext.GetCurrentServer()).Response;
                    trvStatus.Height = trvStatus.Height * 2;
                }
                if (strType == ConstMgr.ServerTag)
                {
                    btnOpCnt.Visible = true;
                }
                break;

            case ConstMgr.DatabaseTag:
            case ConstMgr.SingleDatabaseTag:
                docStatus             = RuntimeMongoDbContext.GetCurrentDataBase().GetStats().Response.ToBsonDocument();
                cmbChartField.Visible = true;
                chartResult.Visible   = true;

                cmbChartField.Items.Add("AverageObjectSize");
                cmbChartField.Items.Add("DataSize");
                cmbChartField.Items.Add("ExtentCount");
                cmbChartField.Items.Add("IndexCount");
                cmbChartField.Items.Add("LastExtentSize");
                //MaxDocuments仅在CapedCollection时候有效
                //cmbChartField.Items.Add("MaxDocuments");
                cmbChartField.Items.Add("ObjectCount");
                cmbChartField.Items.Add("PaddingFactor");
                cmbChartField.Items.Add("StorageSize");
                cmbChartField.SelectedIndex = 0;
                try
                {
                    RefreshDbStatusChart("StorageSize");
                }
                catch (Exception ex)
                {
                    Utility.ExceptionDeal(ex);
                }
                break;

            case ConstMgr.CollectionTag:
                docStatus = RuntimeMongoDbContext.GetCurrentCollection().GetStats().Response.ToBsonDocument();
                //图形化初始化
                chartResult.Visible = true;

                chartResult.Series.Clear();
                chartResult.Titles.Clear();
                var seriesResult = new Series("Usage");
                var dpDataSize   = new DataPoint(0, RuntimeMongoDbContext.GetCurrentCollection().GetStats().DataSize)
                {
                    LegendText    = "DataSize",
                    LegendToolTip = "DataSize",
                    ToolTip       = "DataSize"
                };
                seriesResult.Points.Add(dpDataSize);

                var dpTotalIndexSize = new DataPoint(0,
                                                     RuntimeMongoDbContext.GetCurrentCollection().GetStats().TotalIndexSize)
                {
                    LegendText    = "TotalIndexSize",
                    LegendToolTip = "TotalIndexSize",
                    ToolTip       = "TotalIndexSize"
                };
                seriesResult.Points.Add(dpTotalIndexSize);

                var dpFreeSize = new DataPoint(0,
                                               RuntimeMongoDbContext.GetCurrentCollection().GetStats().StorageSize -
                                               RuntimeMongoDbContext.GetCurrentCollection().GetStats().TotalIndexSize -
                                               RuntimeMongoDbContext.GetCurrentCollection().GetStats().DataSize)
                {
                    LegendText    = "FreeSize",
                    LegendToolTip = "FreeSize",
                    ToolTip       = "FreeSize"
                };
                seriesResult.Points.Add(dpFreeSize);

                seriesResult.ChartType = SeriesChartType.Pie;
                chartResult.Series.Add(seriesResult);
                chartResult.Titles.Add("Usage");

                break;

            default:
                if (RuntimeMongoDbContext.GetCurrentServerConfig().LoginAsAdmin)
                {
                    docStatus =
                        CommandHelper.ExecuteMongoSvrCommand(CommandHelper.ServerStatusCommand,
                                                             RuntimeMongoDbContext.GetCurrentServer()).Response;
                    trvStatus.Height = trvStatus.Height * 2;
                }
                break;
            }
            GuiConfig.Translateform(this);
            UiHelper.FillDataToTreeView(strType, trvStatus, docStatus);
            trvStatus.DatatreeView.Nodes[0].Expand();
        }