Ejemplo n.º 1
0
        /// <summary>
        /// 异步运行计划
        /// </summary>
        /// <param name="parameter">参数</param>
        public void Run(object parameter)
        {
            //获取参数
            object[] parameters    = parameter as object[];
            String   id            = parameters[0].ToString();
            String   commandString = parameters[1].ToString();

            SetLastResult(id, "正在执行");
            try
            {
                UIXml uiXml = new UIXml();
                uiXml.CreateNative();
                CIndicator indicator = CFunctionEx.CreateIndicator(id, commandString, uiXml);
                indicator.Dispose();
                uiXml.Dispose();
            }
            catch (Exception ex)
            {
                SetLastResult(id, "失败:" + ex.Message + "\r\n" + ex.StackTrace);
                return;
            }
            SetLastResult(id, "成功");
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 设置脚本
 /// </summary>
 /// <param name="text">脚本</param>
 public void SetText(String text)
 {
     m_text = text;
     m_gaia = CFunctionEx.CreateIndicator("", text, m_xml);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 发送全体消息
        /// </summary>
        private void SendAll()
        {
            byte[]       fileBytes   = null;
            RadioButtonA rbBarrage   = GetRadioButton("rbBarrage");
            RadioButtonA rbText      = GetRadioButton("rbText");
            RadioButtonA rbFile      = GetRadioButton("rbFile");
            RadioButtonA rbAttention = GetRadioButton("rbAttention");
            String       text        = GetTextBox("txtSend").Text;
            String       sayText     = text;

            if (rbFile.Checked)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    text      = "sendfile('" + new FileInfo(openFileDialog.FileName).Name + "');";
                    fileBytes = File.ReadAllBytes(openFileDialog.FileName);
                    sayText   = text;
                }
                else
                {
                    return;
                }
            }
            else
            {
                if (text == null || text.Trim().Length == 0)
                {
                    MessageBox.Show("请输入你想说的内容!", "提示");
                }
            }
            if (rbBarrage.Checked)
            {
                text = "addbarrage('" + text + "');";
            }
            else if (rbText.Checked)
            {
                text = "addtext('" + text + "');";
            }
            else if (rbAttention.Checked)
            {
                text = "how('" + GetTextBox("txtUserName").Text + "喊:" + text + "');";
            }
            ChatData chatData = new ChatData();

            chatData.m_content = text;
            if (fileBytes != null)
            {
                chatData.m_body       = fileBytes;
                chatData.m_bodyLength = fileBytes.Length;
            }
            chatData.m_from = DataCenter.UserName;
            DataCenter.SendAll(chatData);
            if (rbBarrage.Checked)
            {
                CIndicator indicator = CFunctionEx.CreateIndicator("", text, this);
                indicator.Clear();
                indicator.Dispose();
            }
            TextBoxA txtReceive = GetTextBox("txtReceive");

            txtReceive.Text += "我说:\r\n" + sayText + "\r\n";
            txtReceive.Invalidate();
            if (txtReceive.VScrollBar != null && txtReceive.VScrollBar.Visible)
            {
                txtReceive.VScrollBar.ScrollToEnd();
                txtReceive.Update();
                txtReceive.Invalidate();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 发送消息
        /// </summary>
        private void Send(List <GridRow> rows)
        {
            byte[]       fileBytes   = null;
            String       text        = GetTextBox("txtSend").Text;
            RadioButtonA rbBarrage   = GetRadioButton("rbBarrage");
            RadioButtonA rbText      = GetRadioButton("rbText");
            RadioButtonA rbFile      = GetRadioButton("rbFile");
            RadioButtonA rbAttention = GetRadioButton("rbAttention");
            String       sayText     = text;

            if (rbFile.Checked)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    text      = "sendfile('" + new FileInfo(openFileDialog.FileName).Name + "');";
                    fileBytes = File.ReadAllBytes(openFileDialog.FileName);
                    sayText   = text;
                }
                else
                {
                    return;
                }
            }
            else
            {
                if (text == null || text.Trim().Length == 0)
                {
                    MessageBox.Show("请输入你想说的内容!", "提示");
                }
            }
            if (rbBarrage.Checked)
            {
                text = "addbarrage('" + text + "');";
            }
            else if (rbText.Checked)
            {
                text = "addtext('" + text + "');";
            }
            else if (rbAttention.Checked)
            {
                text = "how('" + GetTextBox("txtUserName").Text + "喊:" + text + "');";
            }
            int  rowsSize = rows.Count;
            bool sendAll  = false;

            if (rowsSize > 0)
            {
                for (int i = 0; i < rowsSize; i++)
                {
                    GridRow     thisRow     = rows[i];
                    String      ip          = thisRow.GetCell("colP1").GetString();
                    int         port        = thisRow.GetCell("colP2").GetInt();
                    String      userID      = thisRow.GetCell("colP3").GetString();
                    ChatService chatService = null;
                    String      key         = ip + ":" + CStr.ConvertIntToStr(port);
                    chatService = DataCenter.GetClientChatService(key);
                    if (chatService != null)
                    {
                        if (!chatService.Connected)
                        {
                            int socketID = OwLib.BaseService.Connect(ip, port);
                            if (socketID != -1)
                            {
                                chatService.Connected = true;
                                chatService.SocketID  = socketID;
                                chatService.Enter();
                            }
                            else
                            {
                                sendAll = true;
                            }
                        }
                    }
                    else
                    {
                        int type = thisRow.GetCell("colP5").GetInt();
                        if (type == 1)
                        {
                            continue;
                        }
                        else
                        {
                            int socketID = OwLib.BaseService.Connect(ip, port);
                            if (socketID != -1)
                            {
                                chatService            = new ChatService();
                                chatService.SocketID   = socketID;
                                chatService.ServerIP   = ip;
                                chatService.ServerPort = port;
                                chatService.ToServer   = false;
                                DataCenter.AddClientChatService(key, chatService);
                                BaseService.AddService(chatService);
                            }
                            else
                            {
                                sendAll = true;
                            }
                        }
                    }
                    ChatData chatData = new ChatData();
                    chatData.m_content = text;
                    if (fileBytes != null)
                    {
                        chatData.m_body       = fileBytes;
                        chatData.m_bodyLength = fileBytes.Length;
                    }
                    chatData.m_from = DataCenter.UserName;
                    if (sendAll)
                    {
                        chatData.m_to = userID;
                        DataCenter.SendAll(chatData);
                    }
                    else
                    {
                        chatService.Send(chatData);
                    }
                    if (rbBarrage.Checked)
                    {
                        CIndicator indicator = CFunctionEx.CreateIndicator("", text, this);
                        indicator.Clear();
                        indicator.Dispose();
                    }
                    TextBoxA txtReceive = GetTextBox("txtReceive");
                    txtReceive.Text += "我说:\r\n" + sayText + "\r\n";
                    txtReceive.Invalidate();
                    if (txtReceive.VScrollBar != null && txtReceive.VScrollBar.Visible)
                    {
                        txtReceive.VScrollBar.ScrollToEnd();
                        txtReceive.Update();
                        txtReceive.Invalidate();
                    }
                }
            }
        }