Esempio n. 1
0
 private void btnRestart_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem item in this.listView1.SelectedItems)
     {
         var rData = new ResponseData
         {
             method = "Restart",
             code   = "0",
             result = ""
         };
         this.service.SendWSMessage((IntPtr)item.Tag, rData.ToBytes());
     }
 }
Esempio n. 2
0
        HandleResult Service_OnWSMessageBody(IntPtr connId, byte[] data)
        {
            try
            {
                if (BitConverter.ToString(data) == BitConverter.ToString(btDisConn))
                {
                    return(HandleResult.Ignore);
                }
                var         strData     = Encoding.UTF8.GetString(data);
                RequestData requestData = null;
                try
                {
                    requestData = convert.Deserialize <RequestData>(strData);
                }
                catch
                {
                    return(HandleResult.Ignore);
                }
                var method = requestData.method.Trim().ToLower();
                switch (method)
                {
                case "gethtml":
                {
                    var rData = new ResponseData
                    {
                        code   = "0",
                        result = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "ScreenDisplay.html")
                    };
                    this.SendWSMessage(connId, rData.ToBytes());
                }
                break;

                case "getconfig":
                {
                    var rData = new ResponseData {
                        code = "0", result = ""
                    };
                    var ip     = this.deviceList.Get(connId).IP;
                    var config = screeList.Where(s => s.IP == ip).FirstOrDefault();
                    if (config != null)
                    {
                        var param = convert.DeserializeObject(config.Config);
                        rData.result = param;
                        this.SendWSMessage(connId, rData.ToBytes());
                    }
                }
                break;

                case "getqueuelist":
                {
                    var rData = new ResponseData {
                        code = "0", result = ""
                    };
                    //var param = convert.DeserializeObject(requestData.param) as Dictionary<string, object>;
                    //var winAreaNo = param["winArea"].ToString();
                    var winAreaNo = "1";
                    rData.result = GetCallByArea(winAreaNo);
                    var btQueueInfo = rData.ToBytes();
                    this.SendWSMessage(connId, btQueueInfo);
                }
                break;

                default:
                {
                    var rData = new ResponseData
                    {
                        code   = "999",
                        result = "未知指令"
                    };
                    this.SendWSMessage(connId, rData.ToBytes());
                }
                break;
                }
            }
            catch (Exception ex)
            {
                this.SDK_OnError(this, connId, ex);
            }
            return(HandleResult.Ok);
        }
Esempio n. 3
0
        HandleResult Service_OnWSMessageBody(IntPtr connId, byte[] data)
        {
            if (BitConverter.ToString(data) == BitConverter.ToString(btDisConn))
            {
                return(HandleResult.Ignore);
            }
            var         strData     = Encoding.UTF8.GetString(data);
            RequestData requestData = null;

            try
            {
                requestData = convert.Deserialize <RequestData>(strData);
            }
            catch
            {
                return(HandleResult.Ignore);
            }
            var method = requestData.method.Trim().ToLower();

            switch (method)
            {
            case "gethtml":
            {
                var rData = new ResponseData
                {
                    method = requestData.method,
                    code   = "0",
                    result = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "ScreenDisplay.html").Replace("0.0.0.0:0000", requestData.param.ToString())
                };
                this.SendWSMessage(connId, rData.ToBytes());
            }
            break;

            case "getconfig":
            {
                var rData = new ResponseData {
                    code = "0", method = requestData.method, result = ""
                };
                var device = this.deviceList.Get(connId);
                var ip     = device.IP;
                var config = screeList.Where(s => s.IP == ip).FirstOrDefault();
                if (config != null)
                {
                    device.DeviceName = config.Name;
                    this.deviceList.Set(connId, device);
                    rData.result = convert.DeserializeObject(config.Config);
                    this.SendWSMessage(connId, rData.ToBytes());
                }
                else
                {
                    device.DeviceName = "未配置的设备";
                    this.deviceList.Set(connId, device);
                    rData.code   = "-1";
                    rData.result = "未获取到该设备的配置内容";
                    this.SendWSMessage(connId, rData.ToBytes());
                }
            }
            break;

            case "getqueuelist":
            {
                var rData = new ResponseData {
                    code = "0", method = requestData.method, result = ""
                };
                var param = requestData.param as Dictionary <string, object>;
                rData.result = GetCallByArea(param["winArea"].ToString());
                this.SendWSMessage(connId, rData.ToBytes());
            }
            break;

            default:
            {
                var rData = new ResponseData
                {
                    method = requestData.method,
                    code   = "999",
                    result = "未知指令"
                };
                this.SendWSMessage(connId, rData.ToBytes());
            }
            break;
            }
            return(HandleResult.Ok);
        }