예제 #1
0
        /// <summary>
        /// 耗时的网络调用方法
        /// </summary>
        /// <returns></returns>
        private bool UpData()
        {
            var resExist = BaiduData.QueryExist(_macAddress);

            if (string.IsNullOrEmpty(resExist))
            {
                return(false);
            }
            JObject exitable = JObject.Parse(resExist);

            if (exitable["status"].Value <string>() == "0")
            {
                if (exitable["total"].Value <int>() > 0)
                {
                    //存在插入的数据
                    return(true);
                }
                else //插入
                {
                    var locationModel = BaiduData.GetLocation();    //获取位置信息
                    var latitude      = locationModel.Latitude;
                    var longitude     = locationModel.Longitude;
                    var res           = JObject.Parse(BaiduData.InsertARecord(latitude, longitude, _ipAddress, "170560", _macAddress, _userInfo));
                    if (res["status"].Value <string>() == "0")   //插入成功
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            return(false);
        }