Exemplo n.º 1
0
 private void OnNotify(DataAgent agent, NotifyEvents notifyEvent, Notify p)
 {
     this.SafeInvoke(() =>
     {
         this.OnNotifyAtUIThread(agent, notifyEvent, p);
     });
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="agent"></param>
        /// <param name="notifyEvent"></param>
        /// <param name="msg"></param>
        private void OnNotifyAtUIThread(DataAgent agent, NotifyEvents ne, Notify p)
        {
            string msg = string.Format("{0}: {1}", DateTime.Now, p.Message);

            if (ne == NotifyEvents.UploadFileOK)
            {
                fileUploadInfoListBox.Items.Add(msg);
            }
            else if (ne == NotifyEvents.UploadFileFailed)
            {
                fileUploadInfoListBox.Items.Add(msg);
            }
            else if (ne == NotifyEvents.DebugMessage)
            {
                this.debugConsole.Text += string.Format("{0}\n", p.Message);
            }
            else if (ne == NotifyEvents.EventMessage)
            {
                mainListBox.Items.Add(msg);
            }
            else if (ne == NotifyEvents.SendDataOK)
            {
                this.UpdateSendDataRecord(p.DeviceKey, false);
            }
            else if (ne == NotifyEvents.SendDataFailed)
            {
                //this.UpdateSendDataRecord(p.DeviceKey, false);
            }
            else if (ne == NotifyEvents.HistoryData)
            {
                this.HandleHistoryData(p.Payload);
            }
        }
Exemplo n.º 3
0
        private bool InitializeAgent()
        {
            Settings.AgentXml = this.IsSecond ? Settings.AgentXml + ".2" : Settings.AgentXml;
            Settings.Instance.LoadSettings();
            Settings s = Settings.Instance;

            if (s.DataCenters.Count() == 0)
            {
                MessageBox.Show("配置错误");
                this.pingLabel.Text = "配置错误";
                return(false);
            }

            Settings.DataCenter2 dc = s.DataCenters[0];
            this.agent              = new DataAgent(dc);
            this.agent.NotifyEvent += this.OnNotify;
            this.agent.DoAuth();

            this.IsDBEnable                = true;
            this.statusLabel.Text          = string.Format("开始:[{0}]", DateTime.Now);
            this.DBTestStripButton.Enabled = false;

            this.addressLabel.Text = string.Format("已连接{0}", dc.BaseUrl);
            this.counterLabel.Text = string.Format("已发送: 0");
            this.uploadLabel.Text  = string.Format("实时数据最后上传时间: {0}", FormatTime(DateTime.Now));

            return(true);
        }
Exemplo n.º 4
0
        private bool InitializeAgent()
        {
            Settings.Instance.LoadSettings();
            Settings s = Settings.Instance;

            if (s.DataCenters.Count() == 0)
            {
                this.pingLabel.Text = "配置错误";
                return(false);
            }

            Settings.DataCenter2 dc = s.DataCenters[0];
            this.agent              = new DataAgent(dc);
            this.agent.NotifyEvent += this.OnNotify;
            this.agent.DoAuth();

            this.statusLabel.Text  = string.Format("开始:[{0}]", DateTime.Now);
            this.addressLabel.Text = string.Format("已连接{0}", dc.BaseUrl);
            this.counterLabel.Text = string.Format("已发送: 0");
            this.uploadLabel.Text  = string.Format("实时数据最后上传时间: {0}", FormatTime(DateTime.Now));
            return(true);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="agent"></param>
 /// <param name="notifyEvent"></param>
 /// <param name="msg"></param>
 private void OnNotifyAtUIThread(DataAgent agent, NotifyEvents ne, Notify p)
 {
     string msg = string.Format("{0}: {1}", DateTime.Now, p.Message);
     if (ne == NotifyEvents.UploadFileOK)
     {
         fileUploadInfoListBox.Items.Add(msg);
     }
     else if (ne == NotifyEvents.UploadFileFailed)
     {
         fileUploadInfoListBox.Items.Add(msg);
     }
     else if (ne == NotifyEvents.DebugMessage)
     {
         this.debugConsole.Text += string.Format("{0}\n", p.Message);
     }
     else if (ne == NotifyEvents.EventMessage)
     {
         mainListBox.Items.Add(msg);
     }
     else if (ne == NotifyEvents.SendDataOK)
     {
         this.UpdateSendDataRecord(p.DeviceKey, false);
     }
     else if (ne == NotifyEvents.SendDataFailed)
     {
         //this.UpdateSendDataRecord(p.DeviceKey, false);
     }
     else if (ne == NotifyEvents.HistoryData)
     {
         this.HandleHistoryData(p.Payload);
     }
 }
Exemplo n.º 6
0
 private void OnNotify(DataAgent agent, NotifyEvents notifyEvent, Notify p)
 {
     this.SafeInvoke(() =>
     {
         this.OnNotifyAtUIThread(agent, notifyEvent, p);
     });
 }
Exemplo n.º 7
0
        private bool InitializeAgent()
        {
            Settings.Instance.LoadSettings();
            Settings s = Settings.Instance;

            if (s.DataCenters.Count() == 0)
            {
                this.pingLabel.Text = "配置错误";
                return false;
            }

            Settings.DataCenter2 dc = s.DataCenters[0];
            this.agent = new DataAgent(dc);
            this.agent.NotifyEvent += this.OnNotify;
            this.agent.DoAuth();

            this.statusLabel.Text = string.Format("开始:[{0}]", DateTime.Now);
            this.addressLabel.Text = string.Format("已连接{0}", dc.BaseUrl);
            this.counterLabel.Text = string.Format("已发送: 0");
            this.uploadLabel.Text = string.Format("实时数据最后上传时间: {0}", FormatTime(DateTime.Now));
            return true;
        }