protected void AddBtn_Click(object sender, EventArgs e) { string name = Input1.Value.ToString(); string value = Text2.Value.ToString(); Messages.Message m = new Messages.Message(name, value); sendMessage(m); }
public void sendMessage(Messages.Message m) { var factory = getFactory(); using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare("Add", false, false, false, null); channel.BasicPublish("", "Add", true, null, Messages.Message.SerializeToByte(m)); } }
public async Task Text_NoMatch() { var message = new Messages.Message(); message.Text = "hello world"; var matcher = new TextMatcher("test"); var matches = await matcher.GetMatches(message); Assert.Null(matches); }
public async Task Predicate_NoMatch() { var message = new Messages.Message(); message.Text = "hello world"; var matcher = new PredicateMatcher(msg => msg.Text == "test"); var matches = await matcher.GetMatches(message); Assert.Null(matches); }
public async Task Text_Match() { var message = new Messages.Message(); message.Text = "hello world"; var matcher = new TextMatcher("hello world"); var matches = await matcher.GetMatches(message); Assert.Equal(1, matches.Length); Assert.Equal("hello world", matches[0].Text); }
public async Task Predicate_Match() { var message = new Messages.Message(); message.Text = "hello world"; var matcher = new PredicateMatcher(msg => msg.Text.Equals("HELLO WORLD", StringComparison.OrdinalIgnoreCase)); var matches = await matcher.GetMatches(message); Assert.Equal(1, matches.Length); Assert.Equal(message.Text, matches[0].Text); }
public void HandleMessage(object sender, Messages.Message msg) { if (msg.Kind == Message.MessageType.InputMessage) { InputMessage ipmsg = (InputMessage)msg; if (ipmsg.Kind == InputMessage.MessageType.ControlsConsole && ipmsg.Pressed) { Enabled = !Enabled; Visible = !Visible; } } }
public override EventArgs Create(Messages.Message message, EventContext context) { var eventArgsAttr = message.GetType().GetTypeInfo().GetCustomAttribute <EventArgsAttribute>(); if (eventArgsAttr != null) { return(eventArgsAttr.Create()); } else { return(new SimpleEventArgs(message, context)); } }
public async Task Regex_Simple() { var message = new Messages.Message(); message.Text = "hello world"; var matcher = new RegexMatcher("world$"); var matches = await matcher.GetMatches(message); Assert.Equal(1, matches.Length); Assert.Equal("world", matches[0].Text); Assert.Equal("0", matches[0].Category); }
public void testExecutive() { Console.WriteLine("*******Requirement 13: Running Test execuitive to demonstrate requirements "); //upload files List <string> listFiles = new List <string>(System.IO.Directory.GetFiles(System.IO.Path.GetFullPath(repoPath) + "\\", "*.dll")); if (listFiles.Count > 0) { if (Repochannel == null) { createRepoChannel(); } foreach (string file in listFiles) { Console.WriteLine("**********Requirement 2 & 6: library file {0} sent to repository", file); //uploadFileToRepo(file, file.Substring(file.LastIndexOf("\\") + 1)); } //send test request XDocument testRquestDoc = new XDocument(); testRquestDoc = XDocument.Load(System.IO.Path.GetFullPath(testRequestPath)); TestRequest TRobj = testRquestDoc.ToString().FromXml <TestRequest>(); Messages.Message msg = new Messages.Message(); msg.body = testRquestDoc.ToString(); msg.type = "TestRequest"; msg.from = Comm <Client3> .makeEndPoint(url, clientPort); msg.to = Comm <Client3> .makeEndPoint(url, THport); msg.time = DateTime.Now; msg.author = TRobj.author; Console.WriteLine("**********Requirement 2 & 6: Test Request sent to TestHarness"); Console.WriteLine(msg.body); objComm.sndr.PostMessage(msg); //query for logs LogRequest objlogRequest = new LogRequest(); objlogRequest.author = authorName.Text; objlogRequest.TestRequestName = TestRequestQuery.Text; Messages.Message logMessage = new Messages.Message(); logMessage.author = authorName.Text; logMessage.body = objlogRequest.ToXml(); logMessage.to = Comm <Client3> .makeEndPoint(url, repoPort); logMessage.from = Comm <Client3> .makeEndPoint(url, clientPort); logMessage.type = "LogRequest"; logMessage.time = DateTime.Now; objComm.sndr.PostMessage(logMessage); } }
void rcvThreadProc() { while (true) { // get message out of receive queue - will block if queue is empty Messages.Message rcvdMsg = new Messages.Message(); rcvdMsg = objComm.rcvr.GetMessage(); // call window functions on UI thread this.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, OnNewMessage, rcvdMsg); } }
private void Report_NotificationEvent(Messages.Message msg) { #if NETFRAMEWORK var dict = new Dictionary <Status, MessageBoxIcon>() { { Status.Error, MessageBoxIcon.Error }, { Status.Info, MessageBoxIcon.Information }, { Status.Success, MessageBoxIcon.Information }, { Status.Warning, MessageBoxIcon.Warning }, }; MessageBox.Show(text: $"{msg.Head}{Environment.NewLine}{msg.Text}", caption: msg.Caption, icon: dict[msg.Status], buttons: MessageBoxButtons.OK); #else PopUpMessage.Show(msg, Settings <IrradiationSettings> .CurrentSettings.DefaultPopUpMessageTimeoutSeconds); #endif }
/// <summary></summary> public SendmsgRequest(MessageType messageType, long target_id, Messages.Message toSend, bool isRateLimited = false) : base("/send_msg", isRateLimited) { if (!isRateLimited) { this.response = new Results.SendmsgResult(); } else { this.response = new EmptyResult(); } this.messageType = messageType; this.message = toSend; this.target_id = target_id; }
public async Task Regex_NamedGroup() { var message = new Messages.Message(); message.Text = "hello world"; var matcher = new RegexMatcher("wor(?<g1>ld)$"); var matches = await matcher.GetMatches(message); Assert.Equal(2, matches.Length); Assert.Equal("world", matches[0].Text); Assert.Equal("0", matches[0].Category); Assert.Equal("ld", matches[1].Text); Assert.Equal("g1", matches[1].Category); }
private void CopyMessagesToClipboard() { try { IEnumerable items = default(IEnumerable); if (lvErrorCollector.SelectedItems.Count > 0) { items = lvErrorCollector.SelectedItems; } else { items = lvErrorCollector.Items; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("----------"); lvErrorCollector.BeginUpdate(); Messages.Message message = default(Messages.Message); foreach (ListViewItem item in items) { message = item.Tag as Messages.Message; if (message == null) { continue; } stringBuilder.AppendLine(message.MsgClass.ToString()); stringBuilder.AppendLine(message.MsgDate.ToString()); stringBuilder.AppendLine(message.MsgText); stringBuilder.AppendLine("----------"); } Clipboard.SetText(stringBuilder.ToString()); } catch (Exception ex) { Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "UI.Window.ErrorsAndInfos.CopyMessagesToClipboard() failed." + Environment.NewLine + ex.Message, true); } finally { lvErrorCollector.EndUpdate(); } }
private void lvErrorCollector_SelectedIndexChanged(System.Object sender, System.EventArgs e) { try { if (this.lvErrorCollector.SelectedItems.Count == 0 || this.lvErrorCollector.SelectedItems.Count > 1) { this.pnlErrorMsg_ResetDefaultStyle(); return; } ListViewItem sItem = this.lvErrorCollector.SelectedItems[0]; Messages.Message eMsg = (Messages.Message)sItem.Tag; switch (eMsg.MsgClass) { case Messages.MessageClass.InformationMsg: this.pbError.Image = global::My.Resources.Resources.Information; this.pnlErrorMsg.BackColor = Color.LightSteelBlue; this.txtMsgText.BackColor = Color.LightSteelBlue; break; case Messages.MessageClass.WarningMsg: this.pbError.Image = global::My.Resources.Resources.Warning; this.pnlErrorMsg.BackColor = Color.Gold; this.txtMsgText.BackColor = Color.Gold; break; case Messages.MessageClass.ErrorMsg: this.pbError.Image = global::My.Resources.Resources._Error; this.pnlErrorMsg.BackColor = Color.IndianRed; this.txtMsgText.BackColor = Color.IndianRed; break; } this.lblMsgDate.Text = eMsg.MsgDate.ToString(); this.txtMsgText.Text = eMsg.MsgText; } catch (Exception ex) { Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, (string) ("lvErrorCollector_SelectedIndexChanged (UI.Window.ErrorsAndInfos) failed" + Constants.vbNewLine + ex.Message), true); } }
//called on UI thread, updates the appropriate list boxes void OnNewMessageHandler(Messages.Message msg) { if (msg.type == "LogResult") { if (msg.body == "LogsNotfound") { Logs.Items.Insert(0, "Log not found"); } else { Logs.Items.Insert(0, msg.body); } } else if (msg.type == "TestResult") { Results.Items.Insert(0, msg.body); } }
//gets logs from the repository private void GetLogsButton_Click(object sender, RoutedEventArgs e) { LogRequest objlogRequest = new LogRequest(); objlogRequest.author = authorName.Text; objlogRequest.TestRequestName = TestRequestQuery.Text; Messages.Message logMessage = new Messages.Message(); logMessage.author = authorName.Text; logMessage.body = objlogRequest.ToXml(); logMessage.to = Comm <Client3> .makeEndPoint(url, repoPort); logMessage.from = Comm <Client3> .makeEndPoint(url, clientPort); logMessage.type = "LogRequest"; logMessage.time = DateTime.Now; objComm.sndr.PostMessage(logMessage); Console.WriteLine(""); }
private static void ShowMessageBox(Messages.Message Msg) { switch (Msg.MsgClass) { case Messages.MessageClass.InformationMsg: MessageBox.Show(Msg.MsgText, string.Format(Language.strTitleInformation, Msg.MsgDate), MessageBoxButtons.OK, MessageBoxIcon.Information); break; case Messages.MessageClass.WarningMsg: MessageBox.Show(Msg.MsgText, string.Format(Language.strTitleWarning, Msg.MsgDate), MessageBoxButtons.OK, MessageBoxIcon.Warning); break; case Messages.MessageClass.ErrorMsg: MessageBox.Show(Msg.MsgText, string.Format(Language.strTitleError, Msg.MsgDate), MessageBoxButtons.OK, MessageBoxIcon.Error); break; } }
//sends test request to Test Harness private void submitTestRequestButton_Click(object sender, RoutedEventArgs e) { XDocument testRquestDoc = new XDocument(); testRquestDoc = XDocument.Load(TestRequest.Text); TestRequest TRobj = testRquestDoc.ToString().FromXml <TestRequest>(); Messages.Message msg = new Messages.Message(); msg.body = testRquestDoc.ToString(); msg.type = "TestRequest"; msg.from = Comm <Client3> .makeEndPoint(url, clientPort); msg.to = Comm <Client3> .makeEndPoint(url, THport); msg.time = DateTime.Now; msg.author = TRobj.author; Console.WriteLine("**********Requirement 2 & 6: Test Request sent to TestHarness"); Console.WriteLine(msg.body); objComm.sndr.PostMessage(msg); }
private Messages.Message ParseHandshakeResponse(string data) { Dictionary <string, object> response = BestHTTP.JSON.Json.Decode(data) as Dictionary <string, object>; if (response == null) { return(null); } Messages.Message msg = new Messages.Message(); msg.type = Messages.MessageTypes.Handshake; object error; if (response.TryGetValue("error", out error)) { msg.error = error.ToString(); } return(msg); }
static void Main(string[] args) { try { Console.WriteLine("Service"); string connStr = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"]; // Listen for a session based message. QueueClient qClientResponse = QueueClient.CreateFromConnectionString(connStr, "MyQueueRequest"); qClientResponse.OnMessage(message => { Console.WriteLine("I've Received a Message."); Console.WriteLine($"Message ID: {message.MessageId} - {message.ReplyToSessionId}"); var receivedPayload = message.GetBody <Messages.Message>(); var sessionToRelyTo = message.ReplyToSessionId; Console.WriteLine($"Message from client - {receivedPayload.MyMessage}"); var responsePayload = new Messages.Message(); receivedPayload.MyMessage = "Bye bye world!!!!!!!"; BrokeredMessage bm = new BrokeredMessage(receivedPayload); bm.SessionId = sessionToRelyTo; QueueClient qClient = QueueClient.CreateFromConnectionString(connStr, "MyQueueResponse"); qClient.Send(bm); Console.WriteLine("Sent Message!"); }); } catch (Exception e) { Console.WriteLine(e); } Console.ReadLine(); }
public void Publish(Messages.Message message, Action <Action> marshal) { eventAggregator.Publish(message, marshal); }
/// <summary> /// 初始化事件参数 /// </summary> public abstract EventArgs Create(Messages.Message message, EventContext context);
public void PublishOnUiThread(Messages.Message message) { eventAggregator.PublishOnUIThread(message); }
public abstract IEventPipeline Construct(Messages.Message message);
public void AddMessage(Messages.MessageClass MsgClass, string MsgText, bool OnlyLog = false) { Messages.Message nMsg = new Messages.Message(); nMsg.MsgClass = MsgClass; nMsg.MsgText = MsgText; nMsg.MsgDate = DateTime.Now; if (Settings.Default.SwitchToMCOnInformation && nMsg.MsgClass == Messages.MessageClass.InformationMsg) { Debug.Print("Info: " + nMsg.MsgText); if (Settings.Default.WriteLogFile) { Runtime.Log.Info(nMsg.MsgText); } if (OnlyLog) { return; } if (Settings.Default.ShowNoMessageBoxes) { ECTimer.Enabled = true; } else { ShowMessageBox(nMsg); } } if (Settings.Default.SwitchToMCOnWarning && nMsg.MsgClass == Messages.MessageClass.WarningMsg) { Debug.Print("Warning: " + nMsg.MsgText); if (Settings.Default.WriteLogFile) { Runtime.Log.Warn(nMsg.MsgText); } if (OnlyLog) { return; } if (Settings.Default.ShowNoMessageBoxes) { ECTimer.Enabled = true; } else { ShowMessageBox(nMsg); } } if (Settings.Default.SwitchToMCOnError && nMsg.MsgClass == Messages.MessageClass.ErrorMsg) { Debug.Print("Error: " + nMsg.MsgText); // Always log error messages Runtime.Log.Error(nMsg.MsgText); if (OnlyLog) { return; } if (Settings.Default.ShowNoMessageBoxes) { ECTimer.Enabled = true; } else { ShowMessageBox(nMsg); } } if (nMsg.MsgClass == MessageClass.ReportMsg) { Debug.Print("Report: " + nMsg.MsgText); if (Settings.Default.WriteLogFile) { Runtime.Log.Info(nMsg.MsgText); } return; } ListViewItem lvItem = new ListViewItem(); lvItem.ImageIndex = System.Convert.ToInt32(nMsg.MsgClass); lvItem.Text = nMsg.MsgText.Replace(Constants.vbNewLine, " "); lvItem.Tag = nMsg; AddToList(lvItem); }
/// <summary> /// This is called when we receive a line from MUD. It is called AFTER triggers are done with it. If /// a trigger gagged the line this will not be called. /// </summary> /// <param name="Msg"></param> public virtual void OnReceivedLineAfter(Messages.Message Msg) { }
/// <summary> /// This is called when we receive a line from MUD. It is called BEFORE triggers are done with it. /// </summary> /// <param name="Msg"></param> public virtual void OnReceivedLineBefore(Messages.Message Msg) { }
/// <param name="reply">回复的消息内容</param> /// <param name="auto_escape">是否将字符串转义(一般不用)</param> public PrivateMessageResponse(Messages.Message reply, bool auto_escape = false) : base(reply, auto_escape) { }