public void GatewayManager_Set_TagValue(cls_ProcRecv_CollectData ProcRecv_CollectData)
        {
            string _GateWayID = ProcRecv_CollectData.GateWayID;
            string _DeviceID  = ProcRecv_CollectData.Device_ID;

            cls_Gateway_Info Gateway = GatewayManager.gateway_list.Where(p => p.gateway_id == _GateWayID).FirstOrDefault();

            if (Gateway != null)
            {
                cls_Device_Info Device = Gateway.device_info.Where(p => p.device_name == _DeviceID).FirstOrDefault();
                if (Device != null)
                {
                    Tuple <string, string> _tag = null;
                    while (ProcRecv_CollectData.Prod_EDC_Data.TryDequeue(out _tag))
                    {
                        if (Device.tag_info.ContainsKey(_tag.Item1))
                        {
                            cls_Tag tag = Device.tag_info[_tag.Item1];
                            tag.Value = _tag.Item2;
                            Device.tag_info.AddOrUpdate(_tag.Item1, tag, (key, oldvalue) => tag);
                        }
                    }
                }
                else
                {
                    //   NLogManager.Logger.LogError("Service", GetType().Name, MethodInfo.GetCurrentMethod().Name, string.Format("Device {0} Not Exist, So Skip Update Tag Value", _DeviceID));
                }
            }
            else
            {
                //   NLogManager.Logger.LogError("Service", GetType().Name, MethodInfo.GetCurrentMethod().Name, string.Format("Gateway {0} Not Exist, So Skip Update Tag Value", _GateWayID));
            }
        }
        public void GatewayManager_Config(string gatewayid, string deviceid, string Json)
        {
            if (this.GatewayManager == null)
            {
                GatewayManager_Initial();
            }

            cls_Gateway_Info tmp_gw_info = JsonConvert.DeserializeObject <cls_Gateway_Info>(Json);
            var tmp_gateway = this.GatewayManager.gateway_list.Where(o => o.gateway_id.Equals(tmp_gw_info.gateway_id)).FirstOrDefault();

            if (tmp_gateway != null)
            {
                foreach (cls_Device_Info tmp_device in tmp_gw_info.device_info)
                {
                    var exist = tmp_gateway.device_info.Where(o => o.device_name.Equals(tmp_device.device_name)).FirstOrDefault();
                    if (exist == null)
                    {
                        tmp_gateway.device_info.Add(tmp_device);
                    }
                    else
                    {
                        _logger.LogWarning(string.Format("gateway {0} device {1} is Exist, So Skip Update GatewayManagement", gatewayid, deviceid));
                    }
                }
            }
            else
            {
                this.GatewayManager.gateway_list.Add(tmp_gw_info);
            }
        }
        public string GatewayCommand_Json(string _Cmd_Type, string _Report_Interval, string _Trace_ID, string _GateWayID, string _DeviceID)
        {
            cls_Gateway_Info Gateway = GatewayManager.gateway_list.Where(p => p.gateway_id == _GateWayID).FirstOrDefault();

            if (Gateway == null)
            {
                return(null);
            }
            else
            {
                cls_Device_Info Device = Gateway.device_info.Where(p => p.device_name == _DeviceID).FirstOrDefault();
                if (Device == null)
                {
                    return(null);
                }
                else
                {
                    cls_Collect collect_cmd = new cls_Collect(_Cmd_Type, _Report_Interval, _Trace_ID, Device);
                    return(JsonConvert.SerializeObject(collect_cmd, Newtonsoft.Json.Formatting.Indented));
                }
            }
        }