public ActionResult Transfer() { string code = QueryString.SafeQNo("code"); int state = QueryString.IntSafeQ("state"); string behindfix = System.Web.HttpContext.Current.Request.Url.Query; if (state > 0) { WeChatNavigationEntity nav = WeChatNavigationBLL.Instance.GetWeChatNavigation(state); behindfix = behindfix.Replace("state=" + state, "").Replace("code=", "wechatcode="); //CookieBLL.SetWeiXinWebCode(code); if (nav.RedirectUrl.Contains("?")) { behindfix = behindfix.Replace("?", "&"); } return(Redirect(nav.RedirectUrl + behindfix)); } //MemWeChatMsgEntity shortmsg = WeiXinJsSdk.Instance.GetWeChatShortInfo(code); //if(!string.IsNullOrEmpty(shortmsg.OpenId)&& !string.IsNullOrEmpty(shortmsg.UnionId)) //{ // shortmsg.AppId = WeiXinConfig.GetAppId(); // shortmsg.Status =(int)WeChatStatus.ShortInfo; // MemWeChatMsgBLL.Instance.GetMsgByAppUnionId(shortmsg.AppId, shortmsg.UnionId); //} return(View()); }
/// <summary> /// 判断当前节点是否已存在相同的 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int ExistNum(WeChatNavigationEntity entity) { ///id=0,判断总数,ID>0判断除自己之外的总数 string sql = @"Select count(1) from dbo.[WeChatNavigation] WITH(NOLOCK) "; string where = "where "; if (entity.Id == 0) { } else { } sql = sql + where; DbCommand cmd = db.GetSqlStringCommand(sql); if (entity.Id > 0) { db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id); } object identity = db.ExecuteScalar(cmd); if (identity == null || identity == DBNull.Value) { return(0); } return(Convert.ToInt32(identity)); }
public ActionResult WeiXinUrlEdit() { int _id = QueryString.IntSafeQ("id", 0); WeChatNavigationEntity _entity = WeChatNavigationBLL.Instance.GetWeChatNavigation(_id); ViewBag.Entity = _entity; return(View()); }
/// <summary> /// 读取记录列表。 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param> public IList <WeChatNavigationEntity> GetWeChatNavigationList(int pagesize, int pageindex, ref int recordCount, string key) { string where = " where 1=1 "; if (!string.IsNullOrEmpty(key)) { where += " and RedirectUrl like @RedirectUrl "; } string sql = @"SELECT [Id],[WeChatNavCode],[RedirectUrl],[WeChatUrl],[Remark] FROM (SELECT ROW_NUMBER() OVER (ORDER BY Id desc) AS ROWNUMBER, [Id],[WeChatNavCode],[RedirectUrl],WeChatUrl,[Remark] from dbo.[WeChatNavigation] WITH(NOLOCK) " + where + @" ) as temp where rownumber BETWEEN ((@PageIndex - 1) * @PageSize + 1) AND @PageIndex * @PageSize" ; string sql2 = @"Select count(1) from dbo.[WeChatNavigation] with (nolock) " + where; IList <WeChatNavigationEntity> entityList = new List <WeChatNavigationEntity>(); DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageindex); db.AddInParameter(cmd, "@PageSize", DbType.Int32, pagesize); if (!string.IsNullOrEmpty(key)) { db.AddInParameter(cmd, "@RedirectUrl", DbType.String, "%" + key + "%"); } using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { WeChatNavigationEntity entity = new WeChatNavigationEntity(); entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.WeChatNavCode = StringUtils.GetDbInt(reader["WeChatNavCode"]); entity.RedirectUrl = StringUtils.GetDbString(reader["RedirectUrl"]); entity.WeChatUrl = StringUtils.GetDbString(reader["WeChatUrl"]); entity.Remark = StringUtils.GetDbString(reader["Remark"]); entityList.Add(entity); } } cmd = db.GetSqlStringCommand(sql2); if (!string.IsNullOrEmpty(key)) { db.AddInParameter(cmd, "@RedirectUrl", DbType.String, "%" + key + "%"); } using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { recordCount = StringUtils.GetDbInt(reader[0]); } else { recordCount = 0; } } return(entityList); }
/// <summary> /// 根据主键值更新记录的全部字段(注意:该方法不会对自增字段、timestamp类型字段以及主键字段更新!如果要更新主键字段,请使用Update方法)。 /// 如果数据库有数据被更新了则返回True,否则返回False /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="weChatNavigation">待更新的实体对象</param> public int UpdateWeChatNavigation(WeChatNavigationEntity entity) { string sql = @" UPDATE dbo.[WeChatNavigation] SET [WeChatNavCode]=@WeChatNavCode,[RedirectUrl]=@RedirectUrl,[WeChatUrl]=@WeChatUrl,[WeChatUrlType]=@WeChatUrlType,[Remark]=@Remark WHERE [Id]=@id"; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id); db.AddInParameter(cmd, "@WeChatNavCode", DbType.Int32, entity.WeChatNavCode); db.AddInParameter(cmd, "@RedirectUrl", DbType.String, entity.RedirectUrl); db.AddInParameter(cmd, "@WeChatUrl", DbType.String, entity.WeChatUrl); db.AddInParameter(cmd, "@WeChatUrlType", DbType.String, entity.WeChatUrlType); db.AddInParameter(cmd, "@Remark", DbType.String, entity.Remark); return(db.ExecuteNonQuery(cmd)); }
public ActionResult Transfer() { string code = QueryString.SafeQNo("code"); int state = QueryString.IntSafeQ("state"); string behindfix = System.Web.HttpContext.Current.Request.Url.Query; if (state > 0) { WeChatNavigationEntity nav = WeChatNavigationBLL.Instance.GetWeChatNavigation(state); behindfix = behindfix.Replace("state=" + state, "").Replace("code=", "wechatcode="); //CookieBLL.SetWeiXinWebCode(code); if (nav.RedirectUrl.Contains("?")) { behindfix = behindfix.Replace("?", "&"); } return(Redirect(nav.RedirectUrl + behindfix)); } return(View()); }
public bool SendCGUrlToManager(string oldurl, int memid) { bool returnresult = false; string _redirecturl = oldurl; VWMemberEntity _memen = MemberBLL.Instance.GetVWMember(memid); WeChatNavigationEntity _entity = WeChatNavigationBLL.Instance.GetNavigationByUrl(_redirecturl); if (_entity == null || _entity.Id == 0) { _entity.RedirectUrl = _redirecturl; //_entity.Id = WeChatNavigationBLL.Instance.AddWeChatNavigation(_entity); } _entity.WeChatUrlType = (int)WeChatUrTypeEnum.Temp; _entity.Remark = "供应商临时登录报价"; //_entity.WeChatUrl = string.Format(WeiXinConfig.URL_FORMAT_KHRedirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.WeChatWebUrl), _entity.Id); _entity.WeChatUrl = string.Format(WeiXinConfig.URL_WeiXin_Redirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(_redirecturl), _entity.Id); int _result = WeChatNavigationBLL.Instance.UpdateWeChatNavigation(_entity); IList <VWMemberEntity> memlist = MemberBLL.Instance.GetMemByAuthCode(MemberAuthEnum.InquiryOrderQuote); if (memlist != null && memlist.Count > 0) { foreach (VWMemberEntity mem in memlist) { if (!string.IsNullOrEmpty(mem.WeChat)) { MemWeChatMsgEntity wecharmsg = MemWeChatMsgBLL.Instance.GetMsgByAppUnionId(WeiXinConfig.GetAppId(), mem.WeChat); if (wecharmsg != null && !string.IsNullOrEmpty(wecharmsg.OpenId)) { WeiXinCustomerEntity customer = new WeiXinCustomerEntity(); customer.touser = wecharmsg.OpenId; customer.msgtype = WeiXinCustomerMsgtypeEnum.text; WeiXinCustomerTextEntity text = new WeiXinCustomerTextEntity(); text.content = "亲爱的" + _memen.CompanyName + "\n易店心来新的询价单,赶紧点击网址抢单额\n抢单网址:" + _entity.WeChatUrl; customer.text = text; returnresult = WeiXinJsSdk.Instance.SendWeiXinCustomerNote(customer); } } } } return(returnresult); }
/// <summary> /// 插入一条记录到表WeChatNavigation,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="weChatNavigation">待插入的实体对象</param> public int AddWeChatNavigation(WeChatNavigationEntity entity) { string sql = @"insert into WeChatNavigation( [WeChatNavCode],[RedirectUrl],[WeChatUrl],WeChatUrlType,[Remark])VALUES ( @WeChatNavCode,@RedirectUrl,@WeChatUrl,@WeChatUrlType,@Remark); SELECT SCOPE_IDENTITY();" ; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@WeChatNavCode", DbType.Int32, entity.WeChatNavCode); db.AddInParameter(cmd, "@RedirectUrl", DbType.String, entity.RedirectUrl); db.AddInParameter(cmd, "@WeChatUrl", DbType.String, entity.WeChatUrl); db.AddInParameter(cmd, "@WeChatUrlType", DbType.String, entity.WeChatUrlType); db.AddInParameter(cmd, "@Remark", DbType.String, entity.Remark); object identity = db.ExecuteScalar(cmd); if (identity == null || identity == DBNull.Value) { return(0); } return(Convert.ToInt32(identity)); }
/// <summary> /// 读取记录列表。 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param> public IList <WeChatNavigationEntity> GetWeChatNavigationAll() { string sql = @"SELECT [Id],[WeChatNavCode],[RedirectUrl],[Remark] from dbo.[WeChatNavigation] WITH(NOLOCK) "; IList <WeChatNavigationEntity> entityList = new List <WeChatNavigationEntity>(); DbCommand cmd = db.GetSqlStringCommand(sql); using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { WeChatNavigationEntity entity = new WeChatNavigationEntity(); entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.WeChatNavCode = StringUtils.GetDbInt(reader["WeChatNavCode"]); entity.RedirectUrl = StringUtils.GetDbString(reader["RedirectUrl"]); entity.Remark = StringUtils.GetDbString(reader["Remark"]); entityList.Add(entity); } } return(entityList); }
public int WeChatUrlAdd() { string _redirecturl = StringUtils.SafeCodeSmall(FormString.SafeQNo("_url", 200)); int _urltype = FormString.IntSafeQ("_urltype"); string _remark = FormString.SafeQ("_remark", 200); WeChatNavigationEntity _entity = WeChatNavigationBLL.Instance.GetNavigationByUrl(_redirecturl); if (_entity == null || _entity.Id == 0) { _entity.RedirectUrl = _redirecturl; _entity.Id = WeChatNavigationBLL.Instance.AddWeChatNavigation(_entity); } _entity.WeChatUrlType = _urltype; _entity.Remark = _remark; //_entity.WeChatUrl = string.Format(WeiXinConfig.URL_FORMAT_KHRedirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.WeChatWebUrl), _entity.Id); _entity.WeChatUrl = string.Format(WeiXinConfig.URL_WeiXin_Redirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(_redirecturl), _entity.Id); int _result = WeChatNavigationBLL.Instance.UpdateWeChatNavigation(_entity); return(_result); }
public WeChatNavigationEntity GetNavigationByCode(int code) { string sql = @"SELECT [Id],[WeChatNavCode],[RedirectUrl],[Remark] FROM dbo.[WeChatNavigation] WITH(NOLOCK) WHERE [WeChatNavCode]=@WeChatNavCode" ; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@WeChatNavCode", DbType.String, code); WeChatNavigationEntity entity = new WeChatNavigationEntity(); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.WeChatNavCode = StringUtils.GetDbInt(reader["WeChatNavCode"]); entity.RedirectUrl = StringUtils.GetDbString(reader["RedirectUrl"]); entity.Remark = StringUtils.GetDbString(reader["Remark"]); } } return(entity); }
/// <summary> /// 更新一条WeChatNavigation记录。 /// 该方法提供给界面等UI层调用 /// </summary> /// <param name="weChatNavigation">待更新的实体对象</param> /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param> public int UpdateWeChatNavigation(WeChatNavigationEntity weChatNavigation) { return(WeChatNavigationDA.Instance.UpdateWeChatNavigation(weChatNavigation)); }
/// <summary> /// 插入一条记录到表WeChatNavigation,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。 /// 该方法提供给界面等UI层调用 /// </summary> /// <param name="weChatNavigation">要添加的WeChatNavigation数据实体对象</param> public int AddWeChatNavigation(WeChatNavigationEntity weChatNavigation) { return(WeChatNavigationDA.Instance.AddWeChatNavigation(weChatNavigation)); }
/// <summary> /// 判断对象是否存在 /// </summary> /// <param name="dicEnum"></param> /// <returns></returns> public bool IsExist(WeChatNavigationEntity weChatNavigation) { return(WeChatNavigationDA.Instance.ExistNum(weChatNavigation) > 0); }