314 lines
9.8 KiB
C#
314 lines
9.8 KiB
C#
using Apache.NMS;
|
|
using Apache.NMS.ActiveMQ;
|
|
using Microsoft.Win32;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
|
|
namespace SOH.FenZhen.Client
|
|
{
|
|
public partial class FrmCall : Form
|
|
{
|
|
HotKeys h = new HotKeys();
|
|
IConnectionFactory factory;
|
|
IConnection connection;
|
|
ISession session;
|
|
public List<kstjMessage> pdlist = new List<kstjMessage>();
|
|
string ksname;
|
|
FrmShow fs;
|
|
public FrmCall()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void FrmCall_Load(object sender, EventArgs e)
|
|
{
|
|
this.TopMost = true;
|
|
try
|
|
{
|
|
kjqd();
|
|
}
|
|
catch { }
|
|
Setting();
|
|
h.Regist(this.Handle, (int)HotKeys.HotkeyModifiers.Control + (int)HotKeys.HotkeyModifiers.Alt, Keys.X, showme);
|
|
h.Regist(this.Handle, (int)HotKeys.HotkeyModifiers.Control + (int)HotKeys.HotkeyModifiers.Alt, Keys.C, showsetting);
|
|
fs = new FrmShow();
|
|
Point mf = new Point();
|
|
foreach (var s in Screen.AllScreens)
|
|
{
|
|
if (!s.Primary)
|
|
{
|
|
mf = s.Bounds.Location;
|
|
fs.Location = mf;
|
|
fs.TopLevel = true;
|
|
fs.TopMost = true;
|
|
fs.ksname = ksname;
|
|
fs.Owner = this;
|
|
fs.WindowState = FormWindowState.Maximized;
|
|
fs.StartPosition = FormStartPosition.Manual;
|
|
fs.Show();
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void Setting()
|
|
{
|
|
System.Configuration.Configuration congf = SOH.Configuration.LocalConfig.Config;
|
|
if (congf.AppSettings.Settings.AllKeys.Contains("wlks"))
|
|
{
|
|
string wlks = congf.AppSettings.Settings["wlks"].Value;
|
|
if (wlks != "")
|
|
{
|
|
if (congf.AppSettings.Settings.AllKeys.Contains("serverurl"))
|
|
{
|
|
string serverurl = congf.AppSettings.Settings["serverurl"].Value;
|
|
|
|
if (serverurl != "")
|
|
{
|
|
int a = 0;
|
|
aa:
|
|
factory = new ConnectionFactory(serverurl);
|
|
connection = factory.CreateConnection();
|
|
connection.ClientId = System.Net.Dns.GetHostName();
|
|
connection.Start();
|
|
//Create the Session
|
|
session = connection.CreateSession();
|
|
//Create the Consumer
|
|
try
|
|
{
|
|
IMessageConsumer consumer = session.CreateDurableConsumer(new Apache.NMS.ActiveMQ.Commands.ActiveMQTopic("kstj"), "kstj", "ks='" + wlks + "'", false);
|
|
consumer.Listener += new MessageListener(consumer_Listener);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageBox.Show(ex.Message);
|
|
Thread.Sleep(1000);
|
|
a++;
|
|
if (a < 30)
|
|
goto aa;
|
|
else
|
|
{
|
|
MessageBox.Show("无法连接排队服务器,请联系管理员!");
|
|
}
|
|
}
|
|
// Console.ReadLine();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("没有设置排队服务器!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("没有设置排队服务器!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("没有设置排队科室!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("没有设置排队科室!");
|
|
}
|
|
if (congf.AppSettings.Settings.AllKeys.Contains("wlksname"))
|
|
ksname = congf.AppSettings.Settings["wlksname"].Value;
|
|
}
|
|
|
|
|
|
private void consumer_Listener(IMessage message)
|
|
{
|
|
//throw new NotImplementedException();
|
|
ITextMessage itm = message as ITextMessage;
|
|
//MessageBox.Show(itm.Text);
|
|
var kstj = Newtonsoft.Json.JsonConvert.DeserializeObject<kstjMessage>(System.Web.HttpUtility.UrlDecode(itm.Text));
|
|
if (!pdlist.Where(t => t.pdid == kstj.pdid).Any())
|
|
{
|
|
if (kstj.zxzt != 2)
|
|
{
|
|
pdlist.Add(kstj);
|
|
if (kstj.zxzt == 1)
|
|
{
|
|
//pdlist.ForEach(t =>
|
|
//{
|
|
// if (t.zxzt == 1 && t.pdid != kstj.pdid)
|
|
//
|
|
// pdlist.Remove(pdlist.First(x => x.pdid == t.pdid));
|
|
//}
|
|
//});
|
|
pdlist.Where(t => t.zxzt == 1 && t.pdid != kstj.pdid).ToList()
|
|
.ForEach(t => {
|
|
pdlist.Remove(t);
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (kstj.zxzt == 1)
|
|
{
|
|
pdlist.Where(t => t.zxzt == 1 && t.pdid != kstj.pdid).ToList()
|
|
.ForEach(t => {
|
|
pdlist.Remove(t);
|
|
});
|
|
|
|
pdlist.Where(t => t.pdid == kstj.pdid).First().zxzt = 1;
|
|
|
|
}
|
|
else if (kstj.zxzt == 2)
|
|
{
|
|
pdlist.Where(t => t.pdid == kstj.pdid).ToList()
|
|
.ForEach(t => {
|
|
pdlist.Remove(t);
|
|
});
|
|
}
|
|
else if (kstj.zxzt == 0)
|
|
{
|
|
pdlist.Where(t => t.pdid == kstj.pdid).ToList()
|
|
.ForEach(t => {
|
|
t.pdsj = kstj.pdsj;
|
|
});
|
|
}
|
|
}
|
|
string strPdxms = "";
|
|
for (int i = 0; i < pdlist.Count; i++)
|
|
{
|
|
strPdxms += pdlist[i].xm + "|";
|
|
}
|
|
label1.Text = strPdxms;
|
|
fs.shuaxin();
|
|
}
|
|
|
|
|
|
private void close()
|
|
{
|
|
if (connection.IsStarted)
|
|
{
|
|
connection.Stop();
|
|
connection.Close();
|
|
}
|
|
}
|
|
|
|
private void showsetting()
|
|
{
|
|
//throw new NotImplementedException();
|
|
FrmCallSetting fcs = new FrmCallSetting();
|
|
fcs.ShowDialog();
|
|
if (connection != null)
|
|
{
|
|
close();
|
|
}
|
|
Setting();
|
|
}
|
|
|
|
private void kjqd()
|
|
{
|
|
//string path = Application.ExecutablePath;
|
|
//RegistryKey rk = Registry.LocalMachine;
|
|
//RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
|
|
//rk2.SetValue("SOH.FenZhen", path);
|
|
//rk2.Close();
|
|
//rk.Close();
|
|
|
|
}
|
|
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
h.ProcessHotKey(m);
|
|
base.WndProc(ref m);
|
|
}
|
|
private void showme()
|
|
{
|
|
//throw new NotImplementedException();
|
|
this.TopMost = true;
|
|
if (!this.Visible)
|
|
this.Show();
|
|
//Setting();
|
|
}
|
|
|
|
bool _mousedown = false;
|
|
Point _louselocation = new Point();
|
|
private void FrmCall_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
_mousedown = true;
|
|
_louselocation = PointToScreen(e.Location);
|
|
}
|
|
|
|
private void FrmCall_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
_mousedown = false;
|
|
}
|
|
|
|
private void FrmCall_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
if (_mousedown)
|
|
{
|
|
Point cp = PointToScreen(e.Location);
|
|
Point fp = new Point();
|
|
fp.X = this.Location.X + cp.X - _louselocation.X;
|
|
fp.Y = this.Location.Y + cp.Y - _louselocation.Y;
|
|
_louselocation = cp;
|
|
this.Location = fp;
|
|
}
|
|
}
|
|
|
|
private void btn_hidden_Click(object sender, EventArgs e)
|
|
{
|
|
this.Hide();
|
|
}
|
|
|
|
private void FrmCall_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
close();
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
this.Hide();
|
|
}
|
|
|
|
private void button1_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
FrmJiaohao fjh = new FrmJiaohao();
|
|
fjh.Show(this);
|
|
}
|
|
|
|
private void label1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
public class kstjMessage
|
|
{
|
|
public string xm { get; set; }
|
|
|
|
public string xb { get; set; }
|
|
public int pdid { get; set; }
|
|
|
|
public DateTime pdsj { get; set; }
|
|
|
|
public byte zxzt
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
}
|
|
}
|