public static bool Add(WX_InteractionInfo model) { if (model == null) { throw new ArgumentNullException("model"); } IWXInteractionInfo factory = WXInteractionInfoFactory.GetFactory(); return(factory.Add(model)); }
public override void OnExecuted() { try { WX_InteractionInfo model = new WX_InteractionInfo { OpenID = OpenId, CreateTime = DateTime.Now, MsgType = (WxMsgType)((int)Request.MsgType), InteractionContent = RequestDocument.ToString(), CompanyID = config.CompanyID }; bool result = false; if ((int)Request.MsgType != 6) { result = WXInteractionInfoServices.Add(model); if (!result) { string msg = string.Format("保存微信和平台交换信息失败:OpenID:{0};CreateTime:{1}:MsgType:{2};Content:{3}", model.OpenID, model.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), model.MsgType.GetDescription(), model.InteractionContent); TxtLogServices.WriteTxtLogEx("WeiXinConversation", msg); } } if (ResponseDocument != null) { int replyId = 0; if (result) { replyId = WXInteractionInfoServices.QueryMaxIdByOpenId(OpenId); } //回复给用户的消息 WX_InteractionInfo respModel = new WX_InteractionInfo { OpenID = OpenId, CreateTime = DateTime.Now, MsgType = (WxMsgType)((int)Request.MsgType), InteractionContent = ResponseDocument.ToString(), ReplyID = replyId.ToString(), CompanyID = config.CompanyID }; WXInteractionInfoServices.Add(respModel); } } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, string.Format("保存微信交互消息失败,OPENID:{0}", OpenId), LogFrom.WeiXin); TxtLogServices.WriteTxtLogEx("WeiXinConversation", ex); } }
public bool Add(WX_InteractionInfo model) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into WX_InteractionInfo(ReplyID,OpenID,MsgType,InteractionContent,CreateTime,CompanyID)"); strSql.Append(" values(@ReplyID,@OpenID,@MsgType,@InteractionContent,@CreateTime,@CompanyID)"); dbOperator.ClearParameters(); dbOperator.AddParameter("ReplyID", model.ReplyID); dbOperator.AddParameter("OpenID", model.OpenID); dbOperator.AddParameter("MsgType", model.MsgType); dbOperator.AddParameter("InteractionContent", model.InteractionContent); dbOperator.AddParameter("CreateTime", model.CreateTime); dbOperator.AddParameter("CompanyID", model.CompanyID); return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0); } }