Ejemplo n.º 1
0
        private void LoadComboBox(ComboBox BoxToLoad, string InstanceName)
        {
            if (String.IsNullOrWhiteSpace(InstanceName))
            {
                BoxToLoad.ItemsSource = null;
                SetVisibility(PageToShow.Instructions);
            }
            else if (InstanceName == CurrentPrimaryInstanceName)
            {
                //Don't need to reload the list.
                return;
            }
            else
            {
                //We need to reload the list, so hide any grids or errors that might be there already.
                SetVisibility(PageToShow.Waiting);

                UpdateDatabaseComboBoxDelegate      dg = new UpdateDatabaseComboBoxDelegate(GetDatabaseListingByInstanceName);
                System.Windows.Threading.Dispatcher d  = this.Dispatcher;

                //Set up a worker
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    string Instance = e.Argument.ToString();

                    try
                    {
                        //Populate the dropdown list.
                        IEnumerable <Database> Databases = Database.GetByServerName(InstanceName);
                        Dispatcher.Invoke(dg, BoxToLoad, Databases);

                        //Now update the display
                        UpdateDisplayDelegate refresh = new UpdateDisplayDelegate(SetVisibility);
                        d.BeginInvoke(refresh, PageToShow.Instructions);
                    }
                    catch (Exception ex)
                    {
                        ShowErrorDelegate error = new ShowErrorDelegate(ShowErrorMessage);
                        d.BeginInvoke(error, ex.Message);
                    }
                };
                worker.RunWorkerAsync(InstanceName);
            }
        }
Ejemplo n.º 2
0
 public void UnsubscribeUpdateDisplayEvent(UpdateDisplayDelegate eventHandler)
 {
     UpdateDisplay -= eventHandler;
 }
Ejemplo n.º 3
0
 public void SubScribeUpdateDisplayEvent(UpdateDisplayDelegate eventHandler)
 {
     UpdateDisplay += eventHandler;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 监听端口 有数据传输则刷新显示屏以及语音朗诵
        /// </summary>
        /// <param name="port">端口号</param>
        public void SocketListen(int port, RelationalDatabase _DataBase, Fz_Zq zq,
                                 Socket listener, VoiceHelp _voice, ref Socket socket)
        {
            string rq1 = DateManager.ServerDateTimeByDBType(_DataBase).ToShortDateString() + " 00:00:00";
            string rq2 = DateManager.ServerDateTimeByDBType(_DataBase).ToShortDateString() + " 23:59:59";

            Hjcs = int.Parse(zq.Zqhjcs);
            string msg = "";

            _voice.InitializeVoiceLib();
            _voice.VoiceSpeak(zq.Zqname, ref msg);
            IPEndPoint address = new IPEndPoint(IPAddress.Any, port);

            try
            {
                while (true)
                {
                    if (new SystemCfg(3103).Config == "1")
                    {
                        UpdateDisplayDelegate callDisplay = new UpdateDisplayDelegate(UpdateDisplay);
                        callDisplay("正在等待呼叫。。。", zq.Zqid, _DataBase);
                    }
                    if (listener != null)
                    {
                        if (listener.LocalEndPoint == null)
                        {
                            listener.Bind(address);
                        }
                    }

                    listener.Listen(0);
                    socket = listener.Accept();
                    Stream netStream = new NetworkStream(socket);

                    StreamReader reader = new StreamReader(netStream);
                    string       result = reader.ReadToEnd();//收到呼叫的信息
                    lock (objLockHelper)
                    {
                        ts_mzys_class.MZHS_FZJL p   = new ts_mzys_class.MZHS_FZJL();
                        System.Xml.XmlDocument  doc = new System.Xml.XmlDocument();
                        bool valid = false;
                        try
                        {
                            doc.LoadXml(result);
                            valid = true;
                        }
                        catch
                        {
                            UpdateDisplayDelegate _callDisplay = new UpdateDisplayDelegate(UpdateDisplay);
                            _callDisplay("无效的呼叫信息!", zq.Zqid, _DataBase);
                        }
                        if (valid)
                        {
                            System.Xml.XmlNodeList nodes = doc.GetElementsByTagName("PATIENT")[0].ChildNodes;
                            /*反射生成病人对象*/
                            foreach (System.Xml.XmlNode node in nodes)
                            {
                                try
                                {
                                    System.Reflection.PropertyInfo pi = p.GetType().GetProperty(node.Name); //定义一个属性对象,并且设置类型(需要反射目的对象的某个属性名称)
                                    object objValue = Convert.ChangeType(node.InnerText, pi.PropertyType);  //通过一个object对象获取属性的值与属性的类型
                                    p.GetType().GetProperty(node.Name).SetValue(p, objValue, null);         //对反射对象进行赋值,第一个参数为反射对象,第二参数为反射对象所需的值与类型信息
                                }
                                catch
                                {
                                    continue;
                                }
                            }
                            lstCalledPatient.Insert(0, p);
                            //将当前呼叫的病人发送到显示窗口
                            if (refreshScreenDisplay != null)
                            {
                                int sort = 0;
                                int hour = Convert.ToInt32(_DataBase.GetDataResult("select DATEPART(hh, GETDATE())"));
                                if (hour >= 8 && hour <= 12)
                                {
                                    sort = 1;
                                }
                                else if (hour > 12 && hour < 18)
                                {
                                    sort = 2;
                                }

                                DataSet          ds    = MZHS_FZJL.Select_yfzpat(zq.Zqid, rq1, rq2, 0, "", "", sort, _DataBase);//得到最新的候诊列表
                                List <MZHS_FZJL> _list = new List <MZHS_FZJL>();
                                foreach (DataRow dr in ds.Tables[0].Rows)
                                {
                                    _list.Add(MZHS_FZJL.DataRowToFZjl(dr));
                                }
                                refreshScreenDisplay(p, _list);
                            }
                            CallPatient(lstCalledPatient);
                        }
                    }
                }
            }
            catch (Exception ea)
            {
                MessageBox.Show(ea.Message);
            }
        }