public bool Update(WX_UserLocation model) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { dbOperator.ClearParameters(); string strSql = "update WX_UserLocation set Latitude=@Latitude,Longitude=@Longitude,[Precision]=@Precision,LastReportedTime=@LastReportedTime where openid=@openid"; dbOperator.AddParameter("openId", model.OpenId); dbOperator.AddParameter("Latitude", model.Latitude); dbOperator.AddParameter("Longitude", model.Longitude); dbOperator.AddParameter("Precision", model.Precision); dbOperator.AddParameter("LastReportedTime", model.LastReportedTime); int result = dbOperator.ExecuteNonQuery(strSql); return(result > 0); } }
public bool Create(WX_UserLocation model) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { string strSql = "insert into WX_UserLocation(OpenId,Latitude,Longitude,[Precision],LastReportedTime,CompanyID) values(@OpenId,@Latitude,@Longitude,@Precision,@LastReportedTime,@CompanyID)"; dbOperator.AddParameter("OpenId", model.OpenId); dbOperator.AddParameter("Latitude", model.Latitude); dbOperator.AddParameter("Longitude", model.Longitude); dbOperator.AddParameter("Precision", model.Precision); dbOperator.AddParameter("LastReportedTime", model.LastReportedTime); dbOperator.AddParameter("CompanyID", model.CompanyID); int result = dbOperator.ExecuteNonQuery(strSql); return(result > 0); } }
public static bool AddOrUpdate(WX_UserLocation model) { if (model == null) { throw new ArgumentNullException("model"); } IWXUserLocation factory = WXUserLocationFactory.GetFactory(); WX_UserLocation old = factory.QueryByOpenId(model.CompanyID, model.OpenId); if (old != null) { return(factory.Update(model)); } return(factory.Create(model)); }
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 = "查找车场失败" })); } }
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); } }