Example #1
0
        /// <summary>
        /// 设备不存在就新增一个设备,返回设备id
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public int getDeviceId(int collectorID, string deviceAddress)
        {
            string key = collectorID + "_" + deviceAddress;//设备的采集器数据id和设备地址能唯一识别设备
            object id  = deviceCodeIdHash[key];

            if (id == null)
            {
                Device tmp = _deviceDao.GetDeviceByCollector2Address(collectorID, deviceAddress);
                if (tmp == null)
                {
                    return(0);
                }
                else
                {
                    id = tmp.id;
                    deviceCodeIdHash[key] = id;
                }
            }
            return(int.Parse(id.ToString()));
        }