// public static Dictionary<string, Dictionary<string, string>> userLocation=new Dictionary<string,Dictionary<string,string>>(); /// <summary> /// 设置自动上发的地址 /// ygh 2014/3/12 /// </summary> /// <param name="openid"></param> /// <param name="location"></param> public static void setLocation(string openid,string location) { JavaScriptSerializer a = new JavaScriptSerializer(); Dictionary<string, object> o = (Dictionary<string, object>)a.DeserializeObject(location); WEC_WZ_LOCATION userLocation = new WEC_WZ_LOCATION(); userLocation.OPENID = openid; userLocation.LATITUDE=(string)o["Latitude"]; userLocation.LONGITUDE=(string)o["Longitude"]; userLocation.PRECISION=(string)o["Precision"]; userLocation.ADDTIME = DateTime.Now; BLLTable<WEC_WZ_LOCATION>.Insert(userLocation,WEC_WZ_LOCATION.Attribute.ID); }
// public static Dictionary<string, Dictionary<string, string>> userLocation=new Dictionary<string,Dictionary<string,string>>(); /// <summary> /// 设置自动上发的地址 /// ygh 2014/3/12 /// </summary> /// <param name="openid"></param> /// <param name="location"></param> public static void setLocation(string openid, string location) { JavaScriptSerializer a = new JavaScriptSerializer(); Dictionary <string, object> o = (Dictionary <string, object>)a.DeserializeObject(location); WEC_WZ_LOCATION userLocation = new WEC_WZ_LOCATION(); userLocation.OPENID = openid; userLocation.LATITUDE = (string)o["Latitude"]; userLocation.LONGITUDE = (string)o["Longitude"]; userLocation.PRECISION = (string)o["Precision"]; userLocation.ADDTIME = DateTime.Now; BLLTable <WEC_WZ_LOCATION> .Insert(userLocation, WEC_WZ_LOCATION.Attribute.ID); }
/// <summary> /// 保存用户信息 /// ygh 2014/3/16 /// </summary> /// <param name="openid"></param> /// <param name="type"></param> /// <param name="content"></param> /// <param name="channelid"></param> public void saveUserMessage(string openid, int type, string content, int channelid, string toUserName) { string access_token = HttpUtil.getAccessToken(this.APPID, this.APPSECRET); string user_info = HttpUtil.httpForm("", "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + access_token + "&openid=" + openid + "&lang=zh_CN", "GET"); JavaScriptSerializer jss = new JavaScriptSerializer(); Dictionary <string, object> map = (Dictionary <string, object>)jss.DeserializeObject(user_info); WEC_XX_MESSAGE message = new WEC_XX_MESSAGE(); message.OPENID = openid; message.TYPE = type; WEC_PUBLICLIST conf = new WEC_PUBLICLIST(); conf.PLC_SOURCEID = toUserName; WEC_PUBLICLIST publiclist = BLLTable <WEC_PUBLICLIST> .GetRowData(new WEC_PUBLICLIST(), conf); message.AID = publiclist.AID;//公众号编号, message.ADDTIME = DateTime.Now; if (type != 1) { if (map.ContainsKey("province")) { message.PROVINCE = (string)map["province"]; message.CITY = (string)map["city"]; message.COUNTRY = (string)map["country"]; message.HEADIMGURL = (string)map["headimgurl"]; message.CHANNELID = channelid; } } if (type == 2 || type == 3) { message.S_CONTENT = content; WEC_WZ_LOCATION conf2 = new WEC_WZ_LOCATION(); conf2.OPENID = openid; conf2.af_WhereSQL = " ORDER BY ADDTIME"; WEC_WZ_LOCATION location = BLLTable <WEC_WZ_LOCATION> .GetRowData(new WEC_WZ_LOCATION(), conf2); if (location != null) { message.LATITUDE = location.LATITUDE; message.LONGITUDE = location.LONGITUDE; message.PRECISION = location.PRECISION; message.CHANNELID = channelid; } } BLLTable <WEC_XX_MESSAGE> .Insert(message, WEC_XX_MESSAGE.Attribute.ID); }