/// <summary> /// ServicesLog /// </summary> /// <param name="actionType"></param> /// <param name="logInfo"></param> public void WXPushLog(string actionType, string logInfo) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_WXServicePush_Log("); strSql.Append("sysnumber,logTime,actionType,logInfo,MsgType,Event)"); strSql.Append(" values ("); strSql.Append("@sysnumber,@logTime,@actionType,@logInfo,@MsgType,@Event)"); SqlParameter[] parameters = { new SqlParameter("@sysnumber", SqlDbType.VarChar, 50), new SqlParameter("@logTime", SqlDbType.DateTime), new SqlParameter("@actionType", SqlDbType.VarChar, 50), new SqlParameter("@logInfo", SqlDbType.Text), new SqlParameter("@MsgType", SqlDbType.VarChar, 50), new SqlParameter("@Event", SqlDbType.VarChar, 50), }; parameters[0].Value = Guid.NewGuid().ToString(); parameters[1].Value = DateTime.Now; parameters[2].Value = actionType; parameters[3].Value = logInfo; parameters[4].Value = GetMsgField(logInfo, "MsgType"); parameters[5].Value = GetMsgField(logInfo, "Event"); StarTech.DBUtility.AdoHelper adoHelper = StarTech.DBUtility.AdoHelper.CreateHelper("DB_Instance"); adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters); }
protected void btnSave_Click(object sender, EventArgs e) { if (Request["MorePropertyId_AllIds"] != null && Request["MorePropertyId_AllIds"] != "") { StarTech.DBUtility.AdoHelper ado = StarTech.DBUtility.AdoHelper.CreateHelper(AppConfig.DBInstance); ado.ExecuteSqlNonQuery("delete T_Goods_MoreProperty where goodsId='" + this.id + "'"); foreach (string s in Request["MorePropertyId_AllIds"].Split(',')) { if (Request[s] != null) { string k = s.Replace("MorePropertyId_", ""); string v = Request[s]; string sqladd = "insert into T_Goods_MoreProperty(sysnumber,GoodsId,PropertyId,PropertyValue)"; sqladd += "values('" + Guid.NewGuid().ToString() + "','" + this.id + "','" + k + "','" + v + "')"; ado.ExecuteSqlNonQuery(sqladd); } } UpdateGoodsTable(this.id); } ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存成功');window.returnValue=1;window.close();</script>"); }
/// <summary> /// 更新任务表中的自定义集合字段(把所有自定义字段拼接成一个大字符串保存) /// </summary> protected void UpdateGoodsTable(string goodsId) { string info = ""; StarTech.DBUtility.AdoHelper ado = StarTech.DBUtility.AdoHelper.CreateHelper(AppConfig.DBInstance); DataSet ds = ado.ExecuteSqlDataset("select * from T_Goods_MoreProperty where goodsId='" + this.id + "'"); DataSet dsSet = ado.ExecuteSqlDataset("select * from T_Goods_MorePropertySet"); foreach (DataRow row in ds.Tables[0].Rows) { DataRow[] rowsSet = dsSet.Tables[0].Select("PropertyId='" + row["PropertyId"].ToString() + "'"); if (rowsSet.Length > 0) { info += "{" + row["PropertyId"].ToString() + "$" + rowsSet[0]["propertyName"].ToString() + "$" + row["PropertyValue"].ToString().Replace("'", "’") + "}"; } } ado.ExecuteSqlNonQuery("update T_Goods_Info set MorePropertys='" + info + "' where goodsId='" + goodsId + "'"); }
/// <summary> /// 邦定推广用户的公众号 /// </summary> /// <param name="MsgType"></param> /// <param name="wxMsg"></param> /// <returns></returns> public void BindUser(string MsgType, string wxMsg) { /* * <xml> * <ToUserName><![CDATA[gh_384b77007ac6]]></ToUserName> * <FromUserName><![CDATA[oKiw2t92-9nwoTj4QXgMiAb1fsnQ]]></FromUserName> * <CreateTime>1519282100</CreateTime> * <MsgType><![CDATA[event]]></MsgType> * <Event><![CDATA[subscribe]]></Event> * <EventKey><![CDATA[qrscene_oKiw2t92-9nwoTj4QXgMiAb1fsnQ]]></EventKey> * <Ticket><![CDATA[gQGJ8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyTWJFbzFrR0k4U1QxMDAwMGcwNy0AAgT4Zo5aAwQAAAAA]]></Ticket> * </xml> */ if (MsgType == "event") { string Event = GetMsgField(wxMsg, "Event"); //if (Event == "subscribe" || Event == "SCAN") if (Event == "subscribe") { //邦定推广用户的公众号 string myOpenId = GetMsgField(wxMsg, "EventKey").Replace("qrscene_", ""); string firendNewOpenId = GetMsgField(wxMsg, "FromUserName"); JObject userObj = NG.WeiXin.NGWeiXinUser.GetUserInfoByOpenId(firendNewOpenId); string nickname = userObj == null ? "" : userObj["nickname"].ToString(); string sex = userObj == null ? "" : userObj["sex"].ToString(); string headimgurl = userObj == null ? "" : userObj["headimgurl"].ToString(); //入库 StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_WXQRCodeShare_Log("); strSql.Append("sysnumber,logTime,myOpenId,firendNewOpenId,firendNewNickname,firendNewSex,firendNewHeader,scanInfo,remarks)"); strSql.Append(" values ("); strSql.Append("@sysnumber,@logTime,@myOpenId,@firendNewOpenId,@firendNewNickname,@firendNewSex,@firendNewHeader,@scanInfo,@remarks)"); SqlParameter[] parameters = { new SqlParameter("@sysnumber", SqlDbType.VarChar, 50), new SqlParameter("@logTime", SqlDbType.DateTime), new SqlParameter("@myOpenId", SqlDbType.VarChar, 50), new SqlParameter("@firendNewOpenId", SqlDbType.VarChar, 50), new SqlParameter("@firendNewNickname", SqlDbType.VarChar, 50), new SqlParameter("@firendNewSex", SqlDbType.VarChar, 50), new SqlParameter("@firendNewHeader", SqlDbType.VarChar, 500), new SqlParameter("@scanInfo", SqlDbType.VarChar, 4000), new SqlParameter("@remarks", SqlDbType.VarChar, 500), }; parameters[0].Value = Guid.NewGuid().ToString(); parameters[1].Value = DateTime.Now; parameters[2].Value = myOpenId; parameters[3].Value = firendNewOpenId; parameters[4].Value = nickname; parameters[5].Value = sex; parameters[6].Value = headimgurl; parameters[7].Value = wxMsg; parameters[8].Value = "我的二维码推广"; StarTech.DBUtility.AdoHelper adoHelper = StarTech.DBUtility.AdoHelper.CreateHelper("DB_Instance"); adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters); //消息通知分享推广人 if (myOpenId != "") { WXSendShare(myOpenId, nickname); } //赠送优惠券 if (myOpenId != "") { object objMemberId = adoHelper.ExecuteSqlScalar("select MemberId from T_Member_Info where WXOpenId='" + myOpenId + "'"); if (objMemberId != null) { GetCouponShareBat(objMemberId.ToString()); } } } } }