コード例 #1
0
        void _cedaSubscribe_OnCedaMessage(com.adaptiveMQ2.message.Message msg)
        {
            CedaObject co = CedaObject.ToCedaObject(msg);

            ListMONSvr listRes = MsgHelper.Deserialize <ListMONSvr>(co.MessageBody);

            setGridView(listRes);
            string str = string.Format("地址:{2}:{3}  Topic={0},MessageBody=\n{1}", co.Topic, co.MessageBody, ip, port);

            LogHelper.Info(str);
        }
コード例 #2
0
        private void setGridView(ListMONSvr listRes)
        {
            if (this.InvokeRequired)
            {
                delSetGridView del = new delSetGridView(setGridView);
                this.Invoke(del, new object[] { listRes });
            }
            else
            {
                List <MON_Svr> listTemp = new List <MON_Svr>();
                foreach (MON_Svr item in listRes.MON_Svr)
                {
                    if (item.stat == 0)
                    {
                        item.Status = Resources.sad;
                    }
                    else if (item.stat == 1)
                    {
                        item.Status = Resources.smile;
                    }
                    listTemp.Add(item);
                }

                List <MON_Price> listTempPrice = new List <MON_Price>();
                int i = 0;
                foreach (MON_Price item in listRes.MON_Price)
                {
                    if (item.alert == 0)
                    {
                        item.Alerts = Resources.smile;
                    }
                    else if (item.alert == 1)
                    {
                        item.Alerts = Resources.sad;
                    }
                    if (configInfo.AlertState != 0)
                    {
                        if (item.nochange >= configInfo.AlertState)
                        {
                            i++;
                        }
                    }
                    else
                    {
                        if (item.nochange >= 60)
                        {
                            i++;
                        }
                    }
                    listTempPrice.Add(item);
                }

                //SoundPlayer warnSoundPlayer = new SoundPlayer();
                if (i > 3)
                {
                    //warnSoundPlayer.SoundLocation = Application.StartupPath + configInfo.SoundAlert;
                    device.addSecondaryBufferAndPlay(Application.StartupPath + configInfo.SoundAlert, "SymbolPriceDelay");
                    label1.Text = "产品报价延迟!";
                    //if (warnSoundPlayer != null)
                    //{
                    //    warnSoundPlayer.Play();
                    //}
                }
                else
                {
                    // warnSoundPlayer.Stop();
                    device.stopSecondaryBufferByName("SymbolPiceDelay");
                    label1.Text = "";
                }

                //colTemp.Visible = false;
                dataGridView1.DataSource = listTemp;
                dataGridView2.DataSource = listTempPrice;
                num++;
                string ipMsg = " 地址:" + ip + ":" + port + "  " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                //txtMsg.Text = num % 2 == 0 ? ipMsg + "  数据正在接收。" : ipMsg + "  数据正在接收。。。。";
                string tempInt = "";
                if (num > 9)
                {
                    tempInt = num.ToString().Substring(num.ToString().Length - 1, 1);
                }
                else
                {
                    tempInt = num.ToString();
                }

                string[] one   = { "1", "4", "7" };
                string[] two   = { "2", "5", "8" };
                string[] three = { "0", "3", "6", "9" };

                if (one.Contains(tempInt))
                {
                    txtMsg.Text = ipMsg + "  数据正在接收。";
                }
                else if (two.Contains(tempInt))
                {
                    txtMsg.Text = ipMsg + "  数据正在接收。。。";
                }
                else if (three.Contains(tempInt))
                {
                    txtMsg.Text = ipMsg + "  数据正在接收。。。。。";
                }
            }
        }