protected override object OnExecute(CommandContext context) { if (context.Expression.Arguments.Length == 0) { throw new CommandException(ResourceUtility.GetString("Text.Message.MissingCommandArguments")); } var result = new PluginTreeNode[context.Expression.Arguments.Length]; for (int i = 0; i < context.Expression.Arguments.Length; i++) { result[i] = _pluginContext.PluginTree.Find(context.Expression.Arguments[i]); if (result[i] == null) { context.Output.WriteLine(CommandOutletColor.DarkRed, ResourceUtility.GetString("Text.Message.PluginNodeNotFound", context.Expression.Arguments[i])); } Utility.PrintPluginNode(context.Output, result[i], context.Expression.Options.GetValue <ObtainMode>("obtain"), context.Expression.Options.GetValue <int>("maxDepth")); } if (result.Length == 1) { return(result[0]); } return(result); }
protected override object OnExecute(CommandContext context) { var server = ServerCommandBase.GetServer(context.CommandNode); if (server == null) { throw new CommandException(ResourceUtility.GetString("Text.CannotObtainCommandTarget", "Server")); } if (server.IsListening) { context.Output.WriteLine(ResourceUtility.GetString("Text.ServerHasBeenStarted")); return(false); } server.Start(); if (server.IsListening) { context.Output.WriteLine(CommandOutletColor.Green, ResourceUtility.GetString("Text.CommandExecuteSucceed")); } else { context.Output.WriteLine(CommandOutletColor.Red, ResourceUtility.GetString("Text.CommandExecuteFailed")); } return(server.IsListening); }
protected override object OnExecute(CommandContext context) { var optionProvider = OptionsCommand.GetOptionProvider(context.CommandNode); if (optionProvider == null) { throw new CommandException(ResourceUtility.GetString("Text.CannotObtainCommandTarget", "OptionProvider")); } object result = null; if (context.Expression.Arguments.Length == 0) { throw new CommandException(ResourceUtility.GetString("Text.Command.MissingArguments")); } if (context.Expression.Arguments.Length == 1) { result = optionProvider.GetOptionValue(context.Expression.Arguments[0]); } else { result = new object[context.Expression.Arguments.Length]; for (int i = 0; i < context.Expression.Arguments.Length; i++) { ((object[])result)[i] = optionProvider.GetOptionValue(context.Expression.Arguments[i]); } } //打印获取的结果信息 context.Output.WriteLine(Zongsoft.Runtime.Serialization.Serializer.Text.Serialize(result)); return(result); }
protected override object OnExecute(CommandContext context) { if (context.Expression.Arguments.Length == 0) { throw new CommandException(ResourceUtility.GetString("Text.Command.MissingArguments")); } for (int i = 0; i < context.Expression.Arguments.Length; i++) { var filePath = context.Expression.Arguments[i]; var message = string.Empty; var succeed = FileSystem.File.Delete(filePath); if (succeed) { message = ResourceUtility.GetString("Text.FileDeleteSucceed.Message"); } else { message = ResourceUtility.GetString("Text.FileDeleteFailed.Message"); } context.Output.WriteLine((succeed ? CommandOutletColor.Green : CommandOutletColor.Red), $"[{i+1}] `{filePath}` {message}"); } return(null); }
protected override object OnExecute(CommandContext context) { var client = TcpClientCommand.GetClient(context.CommandNode); if (client == null) { throw new CommandException(ResourceUtility.GetString("Text.CannotObtainCommandTarget", "Client")); } if (context.Expression.Options.Contains("async")) { client.Connected += Client_Connected; client.Failed += Client_Failed; client.ConnectAsync(context); } else { if (client.Connect()) { context.Output.WriteLine(CommandOutletColor.Green, ResourceUtility.GetString("Text.CommandExecuteSucceed")); } else { context.Output.WriteLine(CommandOutletColor.Red, ResourceUtility.GetString("Text.CommandExecuteFailed")); } } return(null); }
private void DisplayListenerInfo(IListener listener, ICommandOutlet output) { if (listener is TcpServer) { output.Write(CommandOutletColor.DarkYellow, ResourceUtility.GetString("${ListenAddress}") + ": "); output.Write("{0}", ((Zongsoft.Communication.Net.TcpServer)listener).Address); } output.Write(CommandOutletColor.DarkGray, " ["); if (listener.IsListening) { output.Write(CommandOutletColor.Green, ResourceUtility.GetString("${Listening}")); } else { output.Write(CommandOutletColor.Red, ResourceUtility.GetString("${Stopped}")); } output.Write(CommandOutletColor.DarkGray, "]"); if (listener is IWorker && ((IWorker)listener).Enabled) { output.WriteLine(); } else { output.WriteLine(CommandOutletColor.DarkMagenta, "({0})", ResourceUtility.GetString("${Disabled}")); } }
protected override object OnExecute(CommandContext context) { if (context.Parameter == null && context.Expression.Arguments.Length == 0) { throw new CommandException(ResourceUtility.GetString("Text.MissingCommandArguments")); } var destination = context.Expression.Options.GetValue <string>("target"); if (string.IsNullOrWhiteSpace(destination)) { throw new CommandOptionMissingException("target"); } var settings = new PushingSenderSettings(context.Expression.Options.GetValue <PushingType>("type"), context.Expression.Options.GetValue <PushingDeviceType>("deviceType"), context.Expression.Options.GetValue <PushingTargetType>("targetType"), context.Expression.Options.GetValue <int>("expiry")); var results = new List <ICommandResult>(); if (context.Parameter != null) { var content = this.GetContent(context.Parameter); var result = this.Send( context.Expression.Options.GetValue <string>("name"), context.Expression.Options.GetValue <string>("title"), content, destination, settings, _ => context.Error.WriteLine(ResourceUtility.GetString("Text.NotificationSendCommand.Faild"))); if (result != null) { results.Add(result.ToCommandResult()); } } foreach (var argument in context.Expression.Arguments) { var result = this.Send( context.Expression.Options.GetValue <string>("name"), context.Expression.Options.GetValue <string>("title"), argument, destination, settings, _ => context.Error.WriteLine(ResourceUtility.GetString("Text.NotificationSendCommand.Faild"))); if (result != null) { results.Add(result.ToCommandResult()); } } if (results.Count == 0) { return(null); } else if (results.Count == 1) { return(results[0]); } return(results); }
protected override object OnExecute(CommandContext context) { var listener = ListenerCommand.GetListener(context.CommandNode); if (listener == null) { throw new CommandException(ResourceUtility.GetString("Text.CannotObtainCommandTarget", "Server")); } if (listener.IsListening) { listener.Stop(); } if (listener.IsListening) { context.Output.WriteLine(CommandOutletColor.Red, ResourceUtility.GetString("Text.CommandExecuteFailed")); } else { context.Output.WriteLine(CommandOutletColor.Green, ResourceUtility.GetString("Text.CommandExecuteSucceed")); } return(!listener.IsListening); }
protected override object OnExecute(CommandContext context) { var node = context.Parameter as PluginTreeNode; if (node == null) { if (context.Parameter != null) { throw new CommandException(ResourceUtility.GetString("Text.Message.InvalidCommandParameter", context.CommandNode.FullPath)); } if (context.Expression.Arguments.Length == 0) { throw new CommandException(ResourceUtility.GetString("Text.Message.MissingCommandArguments")); } if (context.Expression.Arguments.Length > 1) { throw new CommandException(ResourceUtility.GetString("Text.Message.CommandArgumentsTooMany")); } node = _pluginContext.PluginTree.Find(context.Expression.Arguments[0]); if (node == null) { context.Output.WriteLine(CommandOutletColor.DarkRed, ResourceUtility.GetString("Text.Message.PluginNodeNotFound", context.Expression.Arguments[0])); return(null); } } this.WritePluginTree(context.Output, node, context.Expression.Options.GetValue <int>("maxDepth"), 0, 0, context.Expression.Options.Contains("fullPath")); return(node); }
protected override void OnExecute(TerminalCommandContext context) { if (context.Arguments.Length < 1) { foreach (var node in context.Executor.Root.Children) { this.DisplayCommandNode(context, node, 0); } return; } foreach (var argument in context.Arguments) { if (argument == "?") { CommandHelper.DisplayCommandInfo(context.Terminal, this); continue; } CommandTreeNode node = context.Executor.Find(argument); if (node == null) { context.Terminal.WriteLine(TerminalColor.Red, ResourceUtility.GetString("CommandNotFound", argument)); continue; } if (node != null && node.Command != null) { context.Terminal.WriteLine(node.FullPath); CommandHelper.DisplayCommandInfo(context.Terminal, node.Command); } } }
protected override object OnExecute(CommandContext context) { if (context.Expression.Arguments.Length == 0) { throw new CommandException(ResourceUtility.GetString("Text.Command.MissingArguments")); } bool DeleteFile(string path) { var existed = FileSystem.File.Exists(path); if (existed) { context.Output.WriteLine(CommandOutletColor.Green, ResourceUtility.GetString("Text.FileExisted", path)); } else { context.Output.WriteLine(CommandOutletColor.Red, ResourceUtility.GetString("Text.FileNotExisted", path)); } return(existed); } if (context.Expression.Arguments.Length == 1) { return(DeleteFile(context.Expression.Arguments[0])); } else { return(context.Expression.Arguments.Select(path => DeleteFile(path)).ToArray()); } }
protected override object OnExecute(CommandContext context) { if (context.Expression.Arguments.Length == 0) { throw new CommandException(ResourceUtility.GetString("Text.Command.MissingArguments")); } FileInfo GetInfo(string path) { var info = FileSystem.File.GetInfo(path); if (info == null) { context.Output.WriteLine(CommandOutletColor.Red, ResourceUtility.GetString("Text.FileNotExisted", path)); } else { context.Output.WriteLine(Runtime.Serialization.Serializer.Json.Serialize(info, new Runtime.Serialization.TextSerializationSettings() { Indented = true })); } return(info); } if (context.Expression.Arguments.Length == 1) { return(GetInfo(context.Expression.Arguments[0])); } else { return(context.Expression.Arguments.Select(path => GetInfo(path)).ToArray()); } }
private void Client_Connected(object sender, ChannelAsyncEventArgs e) { ((TcpClient)sender).Connected -= Client_Connected; var context = (CommandContext)e.AsyncState; context.Output.WriteLine(CommandOutletColor.Red, ResourceUtility.GetString("Text.CommandExecuteFailed")); }
private void BtnTrainPatmax_Click(object sender, EventArgs e) { var tag = GetTag(ResourceUtility.GetString("RtInspPanelTrainButton")); if (tag != null) { InsightClickButton(tag.Location); } }
private void BtnGetValue_Click(object sender, EventArgs e) { var tag = GetTag(ResourceUtility.GetString("RtInspPanelThreshold")); if (tag != null) { float threshold = (float)GetValue(tag.Location); } }
private void BtnPanelSearchRegion_Click(object sender, EventArgs e) { var tag = GetTag(ResourceUtility.GetString("RtInspPanelSearchRegion")); if (tag != null) { EditCellGraphic(tag.Location); } }
/// <summary> /// 初始化 <see cref="RegularExpressionValidatorAttribute"/> 类的新实例。 /// </summary> /// <param name="pattern">用于验证数据字段值的正则表达式。</param> public RegularExpressionValidatorAttribute(string pattern) : base(ResourceUtility.GetString("${Text.RegularExpressionValidator.ValidationError}")) { if (string.IsNullOrEmpty(pattern)) { throw new ArgumentNullException(pattern); } _regularExpressionAttribute = new RegularExpressionAttribute(pattern); }
public CompareValidatorAttribute(string otherProperty) : base(ResourceUtility.GetString("${Text.CompareValidator.MustMatch}")) { if (string.IsNullOrWhiteSpace(otherProperty)) { throw new ArgumentNullException("otherProperty"); } this.OtherProperty = otherProperty; }
private void btnTrainPMR_Click(object sender, EventArgs e) { string nameTag = string.Format("RtInsp{0}TrainButtonR", mFinderTypeName); var tag = GetTag(ResourceUtility.GetString(nameTag)); if (tag != null) { InsightClickButton(tag.Location); } }
public EnumValidatorAttribute(Type enumType) : base("Enumeration") { if (enumType == null) { throw new ArgumentNullException("enumType"); } this.EnumType = enumType; this.ErrorMessage = ResourceUtility.GetString("${Text.EnumValidator.ValidationError}"); }
private void btnSearchRegionR_Click(object sender, EventArgs e) { string nameTag = string.Format("RtInsp{0}SearchRegionR", mFinderTypeName); var tag = GetTag(ResourceUtility.GetString(nameTag)); if (tag != null) { EditCellGraphic(tag.Location); } }
private void btnMaximizeRegion_Click(object sender, EventArgs e) { string nameTag = "RtIntrisicMaximizeRegion"; var tag = GetTag(ResourceUtility.GetString(nameTag)); if (tag != null) { InsightClickButton(tag.Location); } MessageLoggerManager.Log.Info(String.Format("[Action] Click Maximize Region")); }
private void btnPanelSearchRegionR_Click(object sender, EventArgs e) { string nameTag = string.Format("RtInsp{0}PanelSearchRegionR_{1}", mFinderTypeName, cbxPanelNumb.Text); var tag = GetTag(ResourceUtility.GetString(nameTag)); if (tag != null) { EditCellGraphic(tag.Location); } MessageLoggerManager.Log.Info(String.Format("[Action] Click Panel Search RegionR")); }
private void btnSearchRegionTrayRProperty_Click(object sender, EventArgs e) { string nameTag = string.Format("RtInsp{0}SearchRegionR", mFinderTypeName); var tag = GetTag(ResourceUtility.GetString(nameTag)); if (tag != null) { mCvsInsightDisplay.OpenPropertySheet(tag.Location, null); } MessageLoggerManager.Log.Info(String.Format("[Action] Eidt Property Search RegionR")); }
private void btnTrainRegion_Click(object sender, EventArgs e) { string nameTag = "RtIntrisicTrainRegion"; var tag = GetTag(ResourceUtility.GetString(nameTag)); if (tag != null) { EditCellGraphic(tag.Location); } MessageLoggerManager.Log.Info(String.Format("[Action] Click Train Region")); }
private void cbxUnit_SelectedIndexChanged(object sender, EventArgs e) { string nameTag = "RtIntrisicUnit"; var tag = GetTag(ResourceUtility.GetString(nameTag)); if (tag != null) { InsightSetListBox(tag.Location, (int)cbxUnit.SelectedIndex); } MessageLoggerManager.Log.Info(String.Format("[Action] Unit: " + cbxUnit.SelectedItem)); }
protected override object OnExecute(CommandContext context) { if (context.Expression.Arguments.Length != 2) { throw new CommandException(ResourceUtility.GetString("Text.Command.RequiresCountOfArguments", "2")); } FileSystem.File.Move(context.Expression.Arguments[0], context.Expression.Arguments[1]); return(null); }
private void numShowGraphic_ValueChanged(object sender, EventArgs e) { string nameTag = "RtIntrisicShowGraphic"; var tag = GetTag(ResourceUtility.GetString(nameTag)); if (tag != null) { InsightSetValue(tag.Location, (int)numShowGraphic.Value); } MessageLoggerManager.Log.Info(String.Format("[Action] Show Graphic: " + (float)numShowGraphic.Value)); }
private void btnPanelSearchRegionRProperty_Click(object sender, EventArgs e) { string sPanel = cbxPanelNumb.Text; string nameTag = string.Format("RtInsp{0}PanelSearchRegionR_{1}", mFinderTypeName, sPanel); var tag = GetTag(ResourceUtility.GetString(nameTag)); if (tag != null) { mCvsInsightDisplay.OpenPropertySheet(tag.Location, null); } MessageLoggerManager.Log.Info(String.Format("[Action] Click Panel Search Region Property R")); }
private void btnTraySearchRegion_Click(object sender, EventArgs e) { var tag = GetTag(ResourceUtility.GetString("RtInspTraySearchRegion")); //<<<<<<< HEAD //======= // ContentQueue.gOnly.Info("RtInspTraySearchRegion: " + tag.Name); //>>>>>>> 1602afb7180481b005393225a6e2f682a20085cf if (tag != null) { EditCellGraphic(tag.Location); } }