Beispiel #1
0
        public ActionResult Index()
        {
            try
            {
                ViewBag.BaiDuMapAk = baiduMapAk;
                string locationLatLng   = string.Empty;
                bool   IsWeiXinLocation = false;
                string cityName         = string.Empty;
                if (WeiXinUser != null)
                {
                    WX_UserLocation location = WXUserLocationServices.QueryByOpenId(WeiXinUser.OpenID);

                    if (location != null)
                    {
                        double[] latlng = BaiDuMapHelper.wgs2bd(double.Parse(location.Latitude), double.Parse(location.Longitude));
                        locationLatLng   = string.Format("{0},{1}", latlng[0], latlng[1]);
                        IsWeiXinLocation = true;

                        cityName = BaiDuLocationService.GetCity(latlng[0].ToString(), latlng[1].ToString());
                    }
                }
                if (string.IsNullOrWhiteSpace(cityName))
                {
                    BaiDuUserLocation baiduLocation = BaiDuLocationService.GetLocation();

                    if (string.IsNullOrWhiteSpace(locationLatLng))
                    {
                        locationLatLng = string.Format("{0},{1}", baiduLocation.content.point.y, baiduLocation.content.point.x);
                    }

                    cityName = baiduLocation.content.address_detail.city;
                }
                ViewBag.LocationLatLng   = locationLatLng;
                ViewBag.IsWeiXinLocation = IsWeiXinLocation ? "1" : "0";
                ViewBag.CityName         = cityName;
                return(View());
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "查找车场信息失败", ex, LogFrom.WeiXin);
                return(RedirectToAction("Index", "ErrorPrompt", new { message = "查找车场失败" }));
            }
        }
Beispiel #2
0
 protected override IWRespBase DoForRequest_Event_Location(WReqEventLocation request)
 {
     try
     {
         WX_UserLocation location = new WX_UserLocation();
         location.OpenId           = request.FromUserName;
         location.Latitude         = request.Latitude;
         location.Longitude        = request.Longitude;
         location.Precision        = request.Precision;
         location.LastReportedTime = request.CreateTime;
         location.CompanyID        = config.CompanyID;
         WXUserLocationServices.AddOrUpdate(location);
         return(null);
     }
     catch (Exception ex) {
         ExceptionsServices.AddExceptions(ex, string.Format("保存微信用户位置信息失败,OPENID:{0}", OpenId), LogFrom.WeiXin);
         TxtLogServices.WriteTxtLogEx("WeiXinConversation", ex);
         return(null);
     }
 }