コード例 #1
0
        private void btnRunAction_Click(object sender, EventArgs e)
        {
            if (dgActions.SelectedRows.Count > 0 && dgActions.SelectedRows[0].Tag != null && Client != null)
            {
                if (MessageBox.Show("真的要执行吗?", "提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    try
                    {
                        //构造消息
                        SpeakerLibrary.Message.DebugMessage dm = new SpeakerLibrary.Message.DebugMessage();
                        dm.Command = CommandConst.ActionRun;
                        dm.MsgId   = Guid.NewGuid().ToString();
                        SpeakerLibrary.Message.ActionObject actionObject = new SpeakerLibrary.Message.ActionObject();
                        actionObject.Action   = (Robot_Actions)dgActions.SelectedRows[0].Tag;
                        actionObject.StepList = DBInstance.DbHelper.table("Robot_Steps").where ("ActionId=?", new object[] { actionObject.Action.Id }).select("*").getList <Robot_Steps>(new Robot_Steps()).ToArray();
                        dm.Content            = actionObject;

                        //发送消息
                        SocketLibrary.Connection connection;
                        Client.Connections.TryGetValue(Client.ClientName, out connection);
                        if (connection != null)
                        {
                            SocketLibrary.Message message = new SocketLibrary.Message(SocketLibrary.Message.CommandType.SendMessage, SpeakerLibrary.Message.DebugMessage.ToJson(dm));
                            connection.messageQueue.Enqueue(message);
                        }

                        MessageBox.Show("发送完成");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("发送失败!");
                    }
                }
            }
        }
コード例 #2
0
 private static void sendMsg()
 {
     SocketLibrary.Connection connection;
     client.Connections.TryGetValue(client.ClientName, out connection);
     if (connection != null)
     {
         SocketLibrary.Message message = new SocketLibrary.Message(SocketLibrary.Message.CommandType.SendMessage, "消息体");
         connection.messageQueue.Enqueue(message);
     }
     else
     {
         Console.WriteLine("发送失败!");
     }
 }
コード例 #3
0
 private static void SendMsg()
 {
     i += 1;
     SocketLibrary.Connection connection = null;
     foreach (var keyValue in _server.Connections)
     {
         if ("192.168.3.150".Equals(keyValue.Value.NickName))
         {
             connection = keyValue.Value;
         }
     }
     if (connection != null)
     {
         SocketLibrary.Message message = new SocketLibrary.Message(SocketLibrary.Message.CommandType.SendMessage, i + "服务端发送消息体");
         connection.messageQueue.Enqueue(message);
     }
     else
     {
         Console.WriteLine("发送失败!");
     }
 }
コード例 #4
0
        private void btnUploadData_Click(object sender, EventArgs e)
        {
            if (Client != null && Client.Connections.Count >= 1)
            {
                if (MessageBox.Show("真的要同步吗?", "提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    DebugMessage dm = new DebugMessage();
                    dm.Command = CommandConst.UploadDataBase;
                    dm.MsgId   = Guid.NewGuid().ToString();
                    dm.Content = Convert.ToBase64String(File.ReadAllBytes(Path.Combine(Application.StartupPath, "static.db")));

                    SocketLibrary.Connection conn = null;
                    Client.Connections.TryGetValue(Client.ClientName, out conn);
                    if (conn != null)
                    {
                        SocketLibrary.Message msg = new SocketLibrary.Message(SocketLibrary.Message.CommandType.SendMessage, DebugMessage.ToJson(dm));
                        conn.messageQueue.Enqueue(msg);
                    }

                    MessageBox.Show("同步完成!");
                }
            }
        }