Esempio n. 1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            ip         = System.Configuration.ConfigurationManager.AppSettings["IP"];
            port       = System.Configuration.ConfigurationManager.AppSettings["Port"];
            ini        = new OperateIni(System.Windows.Forms.Application.StartupPath + @"\WindowConfig.ini");
            windowNo   = ini.ReadString("WindowSet", "WindwoNo");
            windowName = ini.ReadString("WindowSet", "WindowName");
            f1         = ini.ReadString("Shortcutkey", "Fuction1");
            f2         = ini.ReadString("Shortcutkey", "Fuction2");
            f3         = ini.ReadString("Shortcutkey", "Fuction3");
            f4         = ini.ReadString("Shortcutkey", "Fuction4");
            f5         = ini.ReadString("Shortcutkey", "Fuction5");
            f6         = ini.ReadString("Shortcutkey", "Fuction6");
            f7         = ini.ReadString("Shortcutkey", "Fuction7");
            f8         = ini.ReadString("Shortcutkey", "Fuction8");
            if (windowNo == "")
            {
                frmConfig frm = new frmConfig();
                frm.ShowDialog();
                Application.ExitThread();
                return;
            }
            qList       = new List <BQueueModel>();
            windowModel = wBll.GetModelList().Where(w => w.State == "1" && w.Number == windowNo).FirstOrDefault();
            if (windowModel == null)
            {
                frmConfig frm = new frmConfig();
                frm.ShowDialog();
                Application.ExitThread();
                return;
            }
            wbList           = wbBll.GetModelList();
            baList           = baBll.GetModelList();
            windowBusys      = new List <TWindowBusinessModel>();
            windowBusyGreens = new List <TWindowBusinessModel>();
            var busyList = wbList.Where(b => b.WindowID == windowModel.ID).ToList().OrderBy(o => o.priorityLevel).ToList();

            if (busyList != null && busyList.Count > 0)
            {
                windowBusys.AddRange(busyList);
                var gbList = new List <TWindowBusinessModel>();
                foreach (var bs in busyList)
                {
                    var gb = baList.Where(b => b.unitSeq == bs.unitSeq && b.busiSeq == bs.busiSeq && b.isGreenChannel == 1).FirstOrDefault();
                    if (gb != null)
                    {
                        gbList.Add(bs);
                    }
                }
                windowBusyGreens.AddRange(gbList);
            }
            else
            {
                MessageBox.Show("当前窗口未绑定业务,无法叫号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
            }
            client.ServerIP       = ip;
            client.ServerPort     = ushort.Parse(port);
            client.ClientType     = ClientType.CallClient;
            client.ClientName     = windowName;
            this.client.OnResult += (msgType, msgText) =>
            {
                this.messageIndicator1.SetState(StateType.Success, msgText);
            };
            this.client.OnConnect += () =>
            {
                this.client.SendMessage(new ClientQueryMessage());
            };
            this.client.OnDisconnect += () =>
            {
                this.messageIndicator1.SetState(StateType.Error, "未连接");
            };
            this.client.OnRestart += () =>
            {
                ini.WriteString("WindowSet", "Restart", "true");
            };
            this.client.OnMessage += new Action <QueueMessage.Message>(client_OnMessage);
            client.Start();
            this.ShowInTaskbar = false;
            this.Hide();
            this.ShowInTaskbar = true;
            #region
            var act = new Func <string, Keys>(f =>
            {
                switch (f)
                {
                case "F1":
                    return(Keys.F1);

                case "F2":
                    return(Keys.F2);

                case "F3":
                    return(Keys.F3);

                case "F4":
                    return(Keys.F4);

                case "F5":
                    return(Keys.F5);

                case "F6":
                    return(Keys.F6);

                case "F7":
                    return(Keys.F7);

                case "F8":
                    return(Keys.F8);

                case "F9":
                    return(Keys.F9);

                case "F10":
                    return(Keys.F10);

                case "F11":
                    return(Keys.F11);

                case "F12":
                    return(Keys.F12);

                default:
                    {
                        return(Keys.F);
                    }
                }
            });
            #endregion
            //设置ShowInTaskbar以后Handle会变化,所以热键绑定要放在最后面
            hotkey = new Hotkey(this.Handle);
            if (f1 != "")
            {
                this.btnCall.Text = "呼叫(" + f1 + ")";
                hkCall            = hotkey.RegisterHotkey(act(f1), Hotkey.KeyFlags.MOD_NONE);
            }
            if (f2 != "")
            {
                this.btnReCall.Text = "重呼(" + f2 + ")";
                hkRecall            = hotkey.RegisterHotkey(act(f2), Hotkey.KeyFlags.MOD_NONE);
            }
            if (f3 != "")
            {
                this.btnEv.Text = "评价(" + f3 + ")";
                hkEv            = hotkey.RegisterHotkey(act(f3), Hotkey.KeyFlags.MOD_NONE);
            }
            if (f4 != "")
            {
                this.btnCance.Text = "弃号(" + f4 + ")";
                hkGiveUp           = hotkey.RegisterHotkey(act(f4), Hotkey.KeyFlags.MOD_NONE);
            }
            if (f5 != "")
            {
                this.btnPause.Text = "暂停(" + f5 + ")";
                hkpause            = hotkey.RegisterHotkey(act(f5), Hotkey.KeyFlags.MOD_NONE);
            }
            if (f6 != "")
            {
                this.btnMove.Text = "转移(" + f6 + ")";
                hkMove            = hotkey.RegisterHotkey(act(f6), Hotkey.KeyFlags.MOD_NONE);
            }
            if (f7 != "")
            {
                this.btnHang.Text = "挂起(" + f7 + ")";
                hkHang            = hotkey.RegisterHotkey(act(f7), Hotkey.KeyFlags.MOD_NONE);
            }
            if (f8 != "")
            {
                this.btnBackCall.Text = "回呼(" + f8 + ")";
                hkCallBack            = hotkey.RegisterHotkey(act(f8), Hotkey.KeyFlags.MOD_NONE);
            }
            hotkey.OnHotkey += new HotkeyEventHandler(OnHotkey);
            timer1.Enabled   = true;
            timer1.Start();
        }
Esempio n. 2
0
        private void btnConfig_Click(object sender, EventArgs e)
        {
            frmConfig frm = new frmConfig();

            frm.ShowDialog();
        }