public string GetList(HttpContext pContext) { try { WMaterialTextEntity entity = pContext.Request["form"].DeserializeJSONTo <WMaterialTextEntity>(); int pageSize = pContext.Request["limit"].ToInt(); int pageIndex = pContext.Request["page"].ToInt(); DataSet ds = new WMaterialTextBLL(CurrentUserInfo).GetWMaterialTextPage(entity.Title, entity.ModelId, pageSize, pageIndex - 1); //return string.Format("{{\"totalCount\":'{0}',\"topics\":{1}}}", // ds.Tables[1].Rows[0][0], ds.Tables[0].ToJSON()); return(string.Format("{{\"totalCount\":{1},\"topics\":{0}}}", ds.Tables[0].ToJSON(), ds.Tables[1].Rows[0][0])); } catch (Exception) { return(string.Format("{{\"totalCount\":'',\"topics\":''}}")); } }
/// <summary> /// Web列表获取 /// </summary> public IList <WMaterialTextEntity> GetWebList(WMaterialTextEntity entity, int Page, int PageSize) { if (PageSize <= 0) { PageSize = 15; } IList <WMaterialTextEntity> list = new List <WMaterialTextEntity>(); DataSet ds = new DataSet(); ds = _currentDAO.GetWebList(entity, Page, PageSize); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { list = DataTableToObject.ConvertToList <WMaterialTextEntity>(ds.Tables[0]); } return(list); }
/// <summary> /// 列表数量获取 /// </summary> public int GetWebListCount(WMaterialTextEntity entity) { return(_currentDAO.GetWebListCount(entity)); }
public void CreateH5QRCode(SetCTWEventRP para, WApplicationInterfaceEntity wapentity, out string strQRCode, out string QRCodeUrl, out string RedirectUrl) { #region 图文,二维码 #region 生成图文素材 #region 获取Page信息 var pageBll = new SysPageBLL(loggingSessionInfo); var textBll = new WMaterialTextBLL(loggingSessionInfo); //组织图文实体 var entity = new WMaterialTextEntity() { ApplicationId = wapentity.ApplicationId, //用自己取出来的 CoverImageUrl = para.MaterialText.ImageUrl, //图片地址 PageId = Guid.NewGuid(), //页面模块的标识 PageParamJson = para.MaterialText.PageParamJson, //这个比较重要 Text = para.MaterialText.Text, TextId = "", //为空时在后面保存时生成 Title = para.MaterialText.Title, TypeId = para.MaterialText.TypeId }; #endregion #region 生成URL var Domain = ConfigurationManager.AppSettings["interfacehost"].Replace("http://", ""); var Domain1 = ConfigurationManager.AppSettings["interfacehost1"].Replace("http://", ""); string URL = string.Empty; bool IsAuth = false; URL = ConfigurationManager.AppSettings["LinKinUrl"] + "id=" + para.EventThemeInfo.WorksId; entity.IsAuth = Convert.ToInt32(IsAuth); entity.PageParamJson = para.MaterialText.PageParamJson; #endregion #endregion entity.OriginalUrl = URL;//图文素材要跳转到的页面 RedirectUrl = URL; #endregion #region 保存 var unionMappingBll = new WModelTextMappingBLL(loggingSessionInfo); entity.TextId = Guid.NewGuid().ToString("N"); textBll.Create(entity);//创建图文素材 #endregion string strQRCodeObjectId = Guid.NewGuid().ToString(); //活动的二维码自己查找QRCodeId var wqrCodeManagerEntity = new WQRCodeManagerBLL(loggingSessionInfo).QueryByEntity(new WQRCodeManagerEntity() { ObjectId = strQRCodeObjectId }, null).FirstOrDefault(); Guid QRCodeId; if (wqrCodeManagerEntity == null) { #region 生成二维码 var wqrentity = new WQRCodeTypeBLL(loggingSessionInfo).QueryByEntity( new WQRCodeTypeEntity { TypeCode = "CreativeCode" } , null).FirstOrDefault(); var wxCode = CretaeWxCode(); var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo); QRCodeId = Guid.NewGuid(); if (!string.IsNullOrEmpty(wxCode.ImageUrl)) { wqrCodeManagerEntity = new WQRCodeManagerEntity() { QRCodeId = QRCodeId, QRCode = wxCode.MaxWQRCod.ToString(), QRCodeTypeId = wqrentity.QRCodeTypeId, IsUse = 1, ObjectId = strQRCodeObjectId, CreateBy = loggingSessionInfo.UserID, ApplicationId = wapentity.ApplicationId, IsDelete = 0, ImageUrl = wxCode.ImageUrl, CustomerId = loggingSessionInfo.ClientID }; WQRCodeManagerbll.Create(wqrCodeManagerEntity); } else { throw new APIException(wxCode.msg) { ErrorCode = 342 }; } #endregion //throw new APIException("活动没有生成二维码!") { ErrorCode = 342 }; } QRCodeId = (Guid)wqrCodeManagerEntity.QRCodeId;//活动二维码的标识 ////根据二维码标识查找是否有他的关键字回复 var WKeywordReplyentity = new WKeywordReplyBLL(loggingSessionInfo).QueryByEntity(new WKeywordReplyEntity() { Keyword = QRCodeId.ToString() //二维码的标识 }, null).FirstOrDefault(); var ReplyBLL = new WKeywordReplyBLL(loggingSessionInfo); var ReplyId = Guid.NewGuid().ToString();//创建临时 if (WKeywordReplyentity == null) { ReplyBLL.Create(new WKeywordReplyEntity() { ReplyId = ReplyId, Keyword = QRCodeId.ToString(), ReplyType = 3, //用图文素材 KeywordType = 4, //标识 IsDelete = 0, CreateBy = loggingSessionInfo.UserID, ApplicationId = wapentity.ApplicationId, }); } else { ReplyId = WKeywordReplyentity.ReplyId; //用取出来的数据查看 WKeywordReplyentity.Text = ""; WKeywordReplyentity.ReplyType = 3; //图文素材 ReplyBLL.Update(WKeywordReplyentity); } #region 添加图文消息 WMenuMTextMappingBLL MenuMTextMappingServer = new WMenuMTextMappingBLL(loggingSessionInfo); WMenuMTextMappingEntity MappingEntity = new WMenuMTextMappingEntity(); MappingEntity.MenuId = ReplyId; MappingEntity.TextId = entity.TextId; // 用图文素材标识****** MappingEntity.DisplayIndex = 1; //排列顺序 MappingEntity.CustomerId = loggingSessionInfo.ClientID; MappingEntity.MappingId = Guid.NewGuid(); MenuMTextMappingServer.Create(MappingEntity); strQRCode = QRCodeId.ToString(); QRCodeUrl = wqrCodeManagerEntity.ImageUrl; #endregion }
public void Update(WMaterialTextEntity pEntity, bool pIsUpdateNullField, IDbTransaction pTran) { _currentDAO.Update(pEntity, pIsUpdateNullField, pTran); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Update(WMaterialTextEntity pEntity, IDbTransaction pTran) { Update(pEntity, true, pTran); }
/// <summary> /// 在事务内创建一个新实例 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Create(WMaterialTextEntity pEntity, IDbTransaction pTran) { _currentDAO.Create(pEntity, pTran); }
/// <summary> /// 创建一个新实例 /// </summary> /// <param name="pEntity">实体实例</param> public void Create(WMaterialTextEntity pEntity) { _currentDAO.Create(pEntity); }
/// <summary> /// 分页根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public PagedQueryResult <WMaterialTextEntity> PagedQueryByEntity(WMaterialTextEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex) { return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex)); }
/// <summary> /// 根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public WMaterialTextEntity[] QueryByEntity(WMaterialTextEntity pQueryEntity, OrderBy[] pOrderBys) { return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys)); }
/// <summary> /// 删除 /// </summary> /// <param name="pEntity"></param> public void Delete(WMaterialTextEntity pEntity) { _currentDAO.Delete(pEntity); }
public void Update(WMaterialTextEntity pEntity, bool pIsUpdateNullField) { _currentDAO.Update(pEntity, pIsUpdateNullField); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> public void Update(WMaterialTextEntity pEntity) { Update(pEntity, true); }
/// <summary> /// 获取商品信息 /// </summary> public string GetItemInfoById() { var itemService = new ItemService(CurrentUserInfo); ItemInfo data = new ItemInfo(); string content = string.Empty; string key = string.Empty; if (Request("item_id") != null && Request("item_id") != string.Empty) { key = Request("item_id").ToString().Trim(); } data = itemService.GetItemInfoById(CurrentUserInfo, key); WQRCodeManagerBLL wQRCodeManagerBLL = new WQRCodeManagerBLL(CurrentUserInfo); var entity = wQRCodeManagerBLL.QueryByEntity(new WQRCodeManagerEntity { ObjectId = key , IsDelete = 0 }, null).FirstOrDefault(); #region 图文|二维码 if (entity != null) { data.imageUrl = entity.ImageUrl; var WKeywordReplyentity = new WKeywordReplyBLL(this.CurrentUserInfo).QueryByEntity(new WKeywordReplyEntity() { Keyword = entity.QRCodeId.ToString() }, null).FirstOrDefault(); if (WKeywordReplyentity != null) { if (WKeywordReplyentity.ReplyType == 1) { data.ReplyType = "1"; data.Text = WKeywordReplyentity.Text; } else if (WKeywordReplyentity.ReplyType == 3) { data.ReplyType = "3"; WMenuMTextMappingBLL bll = new WMenuMTextMappingBLL(this.CurrentUserInfo); WMaterialTextBLL wmbll = new WMaterialTextBLL(this.CurrentUserInfo); OrderBy[] pOrderBys = new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Asc } }; var textMapping = bll.QueryByEntity(new WMenuMTextMappingEntity { MenuId = WKeywordReplyentity.ReplyId, IsDelete = 0 }, pOrderBys); if (textMapping != null && textMapping.Length > 0) { List <WMaterialTextEntity> list = new List <WMaterialTextEntity>(); foreach (var item in textMapping) { WMaterialTextEntity WMaterialTextentity = wmbll.QueryByEntity(new WMaterialTextEntity { TextId = item.TextId, IsDelete = 0 }, null)[0]; list.Add(WMaterialTextentity); } data.listMenutext = list; } } } } #endregion var jsonData = new JsonData(); jsonData.totalCount = data == null ? "0" : "1"; jsonData.data = data; content = jsonData.ToJSON(); return(content); }
/// <summary> /// 获取商品信息 /// </summary> public string GetItemInfoById() { var itemService = new ItemService(CurrentUserInfo); ItemInfo data = new ItemInfo(); string content = string.Empty; string key = string.Empty; if (Request("item_id") != null && Request("item_id") != string.Empty) { key = Request("item_id").ToString().Trim(); } data = itemService.GetItemInfoById(CurrentUserInfo, key); if (data.ifservice == 0) { data.ItemDeliverySettings = new T_Item_Delivery_MappingBLL(CurrentUserInfo).QueryByEntity(new T_Item_Delivery_MappingEntity() { Item_Id = data.Item_Id }, null); } else if (data.ifservice == 1) { data.VirtualItems = new T_VirtualItemTypeSettingBLL(CurrentUserInfo).QueryByEntity(new T_VirtualItemTypeSettingEntity() { ItemId = data.Item_Id }, null); } //图片信息 //根据实体条件查询实体 var imageService = new ObjectImagesBLL(CurrentUserInfo); var itemObj = imageService.QueryByEntity(new ObjectImagesEntity() { ObjectId = key }, null); if (itemObj != null && itemObj.Length > 0) { //itemObj竟然是个数组,把自动生成的产品二维码给过滤掉,不显示出来 itemObj = itemObj.Where <ObjectImagesEntity>(t => t.Description != "自动生成的产品二维码").ToArray <ObjectImagesEntity>(); data.ItemImageList = itemObj.OrderBy(item => item.DisplayIndex).ToList(); } WQRCodeManagerBLL wQRCodeManagerBLL = new WQRCodeManagerBLL(CurrentUserInfo); var entity = wQRCodeManagerBLL.QueryByEntity(new WQRCodeManagerEntity { ObjectId = key , IsDelete = 0 }, null).FirstOrDefault(); #region 图文|二维码 if (entity != null) { data.imageUrl = entity.ImageUrl; var WKeywordReplyentity = new WKeywordReplyBLL(this.CurrentUserInfo).QueryByEntity(new WKeywordReplyEntity() { Keyword = entity.QRCodeId.ToString() }, null).FirstOrDefault(); if (WKeywordReplyentity != null) { if (WKeywordReplyentity.ReplyType == 1) { data.ReplyType = "1"; data.Text = WKeywordReplyentity.Text; } else if (WKeywordReplyentity.ReplyType == 3) { data.ReplyType = "3"; WMenuMTextMappingBLL bll = new WMenuMTextMappingBLL(this.CurrentUserInfo); WMaterialTextBLL wmbll = new WMaterialTextBLL(this.CurrentUserInfo); OrderBy[] pOrderBys = new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Asc } }; var textMapping = bll.QueryByEntity(new WMenuMTextMappingEntity { MenuId = WKeywordReplyentity.ReplyId, IsDelete = 0 }, pOrderBys); if (textMapping != null && textMapping.Length > 0) { List <WMaterialTextEntity> list = new List <WMaterialTextEntity>(); foreach (var item in textMapping) { WMaterialTextEntity WMaterialTextentity = wmbll.QueryByEntity(new WMaterialTextEntity { TextId = item.TextId, IsDelete = 0 }, null)[0]; list.Add(WMaterialTextentity); } data.listMenutext = list; } } } } #endregion var jsonData = new JsonData(); jsonData.totalCount = data == null ? "0" : "1"; jsonData.data = data; content = jsonData.ToJSON(); return(content); }
protected override SetMaterialTextRD ProcessRequest(APIRequest <SetMaterialTextRP> pRequest) { SetMaterialTextRD rd = new SetMaterialTextRD(); var para = pRequest.Parameters; #region 获取Page信息 var pageBll = new SysPageBLL(CurrentUserInfo); var textBll = new WMaterialTextBLL(CurrentUserInfo); //组织图文实体 var entity = new WMaterialTextEntity() { ApplicationId = para.MaterialText.ApplicationId, CoverImageUrl = para.MaterialText.ImageUrl, PageId = para.MaterialText.PageID, PageParamJson = para.MaterialText.PageParamJson, Text = para.MaterialText.Text, TextId = para.MaterialText.TextId, Title = para.MaterialText.Title, TypeId = para.MaterialText.TypeId, Author = para.MaterialText.Abstract,//摘要使用原来的字段 IsTitlePageImage = para.MaterialText.IsTitlePageImage }; #endregion #region 生成URL var Domain = ConfigurationManager.AppSettings["interfacehost"].Replace("http://", ""); var Domain1 = ConfigurationManager.AppSettings["interfacehost1"].Replace("http://", ""); string URL = string.Empty; switch (para.MaterialText.UnionTypeId) { case "1": //链接 #region 链接 URL = para.MaterialText.OriginalUrl; #endregion break; case "2": //详情 #region 详情 URL = string.Format("http://{0}/Module/WeiXin/MaterialTextDetail.aspx?news_id=#TextId#&customerId=#cutomerId#&interfacehost={1}", Domain1.Trim('/'), ConfigurationManager.AppSettings["interfacehost1"]); #endregion break; case "3": //系统模块 #region 系统模块 var pages = pageBll.GetPageByID(para.MaterialText.PageID); //通过pageid查找syspage信息 if (pages.Length == 0) { throw new APIException("未找到Page:" + para.MaterialText.PageID) { ErrorCode = 341 } } ; SysPageEntity CurrentPage; string path = string.Empty; //要替换的路径 string urlTemplate = pages[0].URLTemplate; //模板URL string json = pages[0].JsonValue; // JSON体 var jsonDic = json.DeserializeJSONTo <Dictionary <string, object> >(); //转换后的字典 var htmls = jsonDic["htmls"].ToJSON().DeserializeJSONTo <Dictionary <string, object>[]>().ToList(); //所有的Html模板 Dictionary <string, object> html = null; //选择的html信息 var defaultHtmlId = jsonDic["defaultHtml"].ToString(); html = htmls.Find(t => t["id"].ToString() == defaultHtmlId); //默认的htmlid***** if (html != null) { path = html["path"].ToString(); } //判断高级oauth认证 var scope = "snsapi_base"; if (jsonDic.ContainsKey("scope")) { scope = (jsonDic["scope"] == null || jsonDic["scope"] == "") ? "snsapi_base" : "snsapi_userinfo"; } //判断是否有定制,没有则取JSON体中的默认 //找出订制内容 var customerPages = pages.ToList().FindAll(t => t.CustomerID == CurrentUserInfo.ClientID); if (customerPages.Count > 0) { //看是否有htmls的定制(Node值=2) CurrentPage = customerPages.Find(t => t.Node == "2"); if (CurrentPage != null) { var nodeValue = CurrentPage.NodeValue; //在Json解析后的集合中找到path html = htmls.Find(t => t["id"].ToString() == nodeValue); if (html != null) { path = html["path"].ToString(); } } else { CurrentPage = pages[0]; } } else { CurrentPage = pages[0]; } //读取配置信息域名,检查不用http://开头,如果有则去除 var IsAuth = false; //TODO:判断页面是否需要Auth认证,如果页面需要证则再判断这个客户有没有Auth认证,Type=3 if (CurrentPage.IsAuth == 1) { //判断这个客户是否是认证客户,type=3 var applicationBll = new WApplicationInterfaceBLL(CurrentUserInfo); var application = applicationBll.GetByID(para.MaterialText.ApplicationId); if (application.WeiXinTypeId == "3") { IsAuth = true; } } //替换URL模板 #region 替换URL模板 urlTemplate = urlTemplate.Replace("_pageName_", path); var paraDic = para.MaterialText.PageParamJson.DeserializeJSONTo <Dictionary <string, object>[]>(); foreach (var item in paraDic) //这里key和value对于活动来说,其实就是活动的eventId,和eventId的值 { if (item.ContainsKey("key") && item.ContainsKey("value")) { urlTemplate = urlTemplate.Replace("{" + item["key"] + "}", item["value"].ToString()); } } #endregion //根据规则组织URL #region 组织URL //读取配置文件中的域名 if (string.IsNullOrEmpty(Domain)) { throw new APIException("微信管理:未配置域名,请在web.config中添加<add key='host' value=''/>") { ErrorCode = 342 } } ; if (IsAuth) { //需要认证,并加上scope类型 URL = string.Format("http://{0}/WXOAuth/AuthUniversal.aspx?customerId={1}&applicationId={2}&goUrl={3}&scope={4}", Domain.Trim('/'), CurrentUserInfo.ClientID, para.MaterialText.ApplicationId, HttpUtility.UrlEncode(string.Format("{0}{1}", Domain.Trim('/'), urlTemplate)), scope); } else { //不需要认证 URL = string.Format("http://{0}/WXOAuth/NoAuthGoto.aspx?customerId={1}&goUrl={2}", Domain.Trim('/'), CurrentUserInfo.ClientID, HttpUtility.UrlEncode(string.Format("{0}{1}", Domain.Trim('/'), urlTemplate.Trim('/')))); } entity.IsAuth = Convert.ToInt32(IsAuth); entity.PageParamJson = para.MaterialText.PageParamJson; #endregion #endregion break; default: break; } entity.OriginalUrl = URL;//图文素材 #endregion #region 保存 var unionMappingBll = new WModelTextMappingBLL(CurrentUserInfo); //检查图文素材是否重复 if (textBll.CheckName(entity.ApplicationId, entity.Title, entity.TextId)) { throw new APIException("标题重复,请重新输入.") { ErrorCode = ERROR_CODES.INVALID_REQUEST }; } if (string.IsNullOrEmpty(entity.TextId)) { entity.TextId = Guid.NewGuid().ToString("N"); #region 图文详情要对占位符#TextId#和#customerId#进行替换 entity.OriginalUrl = entity.OriginalUrl.Replace("#TextId#", entity.TextId).Replace("#cutomerId#", CurrentUserInfo.ClientID); #endregion textBll.Create(entity); var mapping = new WModelTextMappingEntity() { MappingId = Guid.NewGuid().ToString("N"), ModelId = entity.TypeId, TextId = entity.TextId, }; unionMappingBll.Create(mapping); } else { #region 图文详情要对占位符#textId和#customerId进行替换 entity.OriginalUrl = entity.OriginalUrl.Replace("#TextId#", entity.TextId).Replace("#cutomerId#", CurrentUserInfo.ClientID); #endregion textBll.Update(entity); } #region 图文分类和图文Mapping关系,先删除再增加 var modelMappingBll = new WModelTextMappingBLL(CurrentUserInfo); modelMappingBll.DeleteByTextId(entity.TextId); var modelMapping = new WModelTextMappingEntity() { MappingId = Guid.NewGuid().ToString("N"), ModelId = entity.TypeId, //模板的标识竟然是和图文类型的标识 TextId = entity.TextId }; modelMappingBll.Create(modelMapping); #endregion #endregion rd.MaterialTextId = entity.TextId; return(rd); }