Exemple #1
0
        private List <RemoteStartAudioOutputCode> listRemoteStartAudioOutputCode()
        {
            var list = new List <RemoteStartAudioOutputCode>();

            for (int i = 0; i < dgvRemote.Rows.Count; i++)
            {
                if (dgvRemote.Rows[i].Cells["isAccept"].Value.ToString() == "否")
                {
                    continue;
                }

                var DestMac = dgvRemote.Rows[i].Cells["MAC"].Value.ToString();
                if (list.Any(l => l.DestMac == DestMac))
                {
                    continue;
                }
                var code = new RemoteStartAudioOutputCode()
                {
                    Guid         = this.Guid,
                    SrcMac       = Setting.authorizationInfo.MachineCode,
                    SrcStetName  = this.ucTextBoxEx1.Text,
                    DestStetName = dgvRemote.Rows[i].Cells["StetName"].Value.ToString(),
                    DestMac      = dgvRemote.Rows[i].Cells["MAC"].Value.ToString()
                };
                list.Add(code);
            }
            return(list);
        }
Exemple #2
0
        public void HandleMessage(RemoteStartAudioOutputCode message)
        {
            if (this.IsDisposed || this.Disposing)
            {
                return;
            }
            if (message.Guid != this.Guid)
            {
                return;
            }
            this.Invoke(new MethodInvoker(() =>
            {
                var rows = this.DgvTable.Select("MAC='" + Setting.authorizationInfo.MachineCode + "'");

                foreach (DataRow row in rows)
                {
                    var stetName = row["StetName"] + "";
                    Mediator.ShowMsg(string.Format("远程听诊开始接收数据,编号为{0}", this.Guid));
                    var stethoscopeArr = StethoscopeManager.StethoscopeList.Where(s => s.Name == stetName);
                    if (!stethoscopeArr.Any())
                    {
                        throw new Exception("目前没有检测到听诊器,请检测设备设置!");
                    }
                    var stethoscope = stethoscopeArr.First();
                    if (!stethoscope.IsConnected)
                    {
                        Mediator.ShowMsg(string.Format("听诊器 {0} 尚未连接", stethoscope.Name));
                        return;
                    }
                    else
                    {
                        stethoscope.StartAudioOutput();
                    }
                }
            }));
            //本机远程
            if (message.SrcMac == Setting.authorizationInfo.MachineCode)
            {
                return;
            }
            // Mediator.isBusy = true;
            Thread thread = new Thread(() =>
            {
                this.Invoke(new MethodInvoker(() =>
                {
                    var formProcessBar = new FrmProcessBar(true)
                    {
                        BtnText          = "停止远程",
                        CancelBtnVisible = true
                    };
                    OnReceivedEvent += ((b) =>
                    {
                        if (!b)
                        {
                            this.Invoke(new MethodInvoker(() =>
                            {
                                if (!formProcessBar.IsDisposed)
                                {
                                    formProcessBar.Close();
                                }
                            }));
                        }
                    });
                    formProcessBar.OnActiveClose += () =>
                    {
                        this.Invoke(new MethodInvoker(() =>
                        {
                            var rows = this.DgvTable.Select("MAC='" + Setting.authorizationInfo.MachineCode + "'");
                            foreach (DataRow row in rows)
                            {
                                var stetName       = row["StetName"] + "";
                                var stethoscopeArr = StethoscopeManager.StethoscopeList.Where(s => s.Name == stetName);
                                if (!stethoscopeArr.Any())
                                {
                                    throw new Exception("目前没有检测到听诊器,请检测设备设置!");
                                }
                                var stethoscope = stethoscopeArr.First();
                                if (!stethoscope.IsConnected)
                                {
                                    Mediator.ShowMsg(string.Format("听诊器 {0} 尚未连接", stethoscope.Name));
                                    return;
                                }
                                else
                                {
                                    stethoscope.StopAudioOutput();
                                }
                            }
                            Mediator.ShowMsg(string.Format("主动退出听诊器,编号为{0}", this.Guid));
                            this.Close();
                        }));
                    };
                    formProcessBar.TimerCallBackEvent += () =>
                    {
                        Invoke(new MethodInvoker(() =>
                        {
                            formProcessBar.Title = string.Format("远程教学中... {0} 秒", formProcessBar.Times);
                        }));
                    };
                    formProcessBar.ShowDialog();
                }));
            });

            thread.Start();
        }