protected override DeleteKeyWordRD ProcessRequest(DTO.Base.APIRequest <DeleteKeyWordRP> pRequest) { var rd = new DeleteKeyWordRD(); string replyId = pRequest.Parameters.ReplyId; var bll = new WKeywordReplyBLL(CurrentUserInfo); var entity = bll.QueryByEntity(new WKeywordReplyEntity() { ReplyId = replyId }, null); if (entity != null) { bll.Delete(entity); } else { throw new APIException("无效的关键字标识") { ErrorCode = 120 }; } return(rd); }
protected override SearchKeyWordRD ProcessRequest(DTO.Base.APIRequest <SearchKeyWordRP> pRequest) { var rd = new SearchKeyWordRD(); string applicationId = pRequest.Parameters.ApplicationId; string keyword = pRequest.Parameters.KeyWord; int?pageIndex = pRequest.Parameters.PageIndex; int?pageSize = pRequest.Parameters.PageSize; var bll = new WKeywordReplyBLL(CurrentUserInfo); var ds = bll.GetKeyWordList(applicationId, keyword, pageSize ?? 15, pageIndex ?? 0); var dsCount = bll.GetKeyWordList(applicationId, keyword, Int32.MaxValue, 0); int totalCount = dsCount.Tables[0].Rows.Count; if (ds.Tables[0].Rows.Count == 0) { rd.SearchKeyList = null; rd.TotalPages = 0; } else { var temp = ds.Tables[0].AsEnumerable().Select(t => new SearchKeyWordInfo() { DisplayIndex = Convert.ToInt32(t["_row"]), KeyWord = t["keyword"].ToString(), ReplyId = t["replyId"].ToString() }).ToArray(); rd.TotalPages = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(totalCount * 1.00 / (pageSize ?? 15) * 1.00))); rd.SearchKeyList = temp; } return(rd); }
protected override GetKeyWordRD ProcessRequest(DTO.Base.APIRequest <GetKeyWordRP> pRequest) { var rd = new GetKeyWordRD(); string replyId = pRequest.Parameters.ReplyId; var bll = new WKeywordReplyBLL(CurrentUserInfo); var ds = bll.GetKeyWordListByReplyId(replyId); var textDs = bll.GetWMaterialTextByReplyId(replyId); if (ds.Tables[0].Rows.Count > 0) { var temp = ds.Tables[0].AsEnumerable().Select(t => new KeyWordInfo() { ApplicationId = string.IsNullOrEmpty(t["ApplicationId"].ToString()) ? "" : t["ApplicationId"].ToString(), ReplyId = string.IsNullOrEmpty(t["ReplyId"].ToString()) ? "" : t["ReplyId"].ToString(), KeyWord = string.IsNullOrEmpty(t["Keyword"].ToString()) ? "" : t["Keyword"].ToString(), Text = string.IsNullOrEmpty(t["text"].ToString()) ? "" : t["text"].ToString(), BeLinkedType = string.IsNullOrEmpty(t["BeLinkedType"].ToString()) ? 0 : Convert.ToInt32(t["BeLinkedType"]), DisplayIndex = string.IsNullOrEmpty(t["DisplayIndex"].ToString()) ? -1 : Convert.ToInt32(t["DisplayIndex"]), ReplyType = string.IsNullOrEmpty(t["ReplyType"].ToString()) ? 0 : Convert.ToInt32(t["ReplyType"].ToString()), KeywordType = string.IsNullOrEmpty(t["KeywordType"].ToString()) ? 0 : Convert.ToInt32(t["KeywordType"].ToString()), MaterialTextIds = textDs.Tables[0].AsEnumerable().Select(tt => new MaterialTextIdInfo() { TestId = string.IsNullOrEmpty(tt["TextId"].ToString()) ? "" : tt["TextId"].ToString(), DisplayIndex = string.IsNullOrEmpty(tt["DisplayIndex"].ToString()) ? 0 : Convert.ToInt32(tt["DisplayIndex"]), ImageUrl = string.IsNullOrEmpty(tt["CoverImageUrl"].ToString()) ? "" : tt["CoverImageUrl"].ToString(), Title = string.IsNullOrEmpty(tt["Title"].ToString()) ? "" : tt["Title"].ToString(), Author = string.IsNullOrEmpty(tt["Author"].ToString()) ? "" : tt["Author"].ToString(), Text = string.IsNullOrEmpty(tt["Text"].ToString()) ? "" : tt["Text"].ToString(), OriginalUrl = string.IsNullOrEmpty(tt["OriginalUrl"].ToString()) ? "" : tt["OriginalUrl"].ToString() }).DefaultIfEmpty().ToArray() }); rd.KeyWordList = temp.FirstOrDefault(); } else { throw new APIException("无效的关键字标识") { ErrorCode = 120 }; } return(rd); }
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 }
protected override SaveDefaultKeyWordRD ProcessRequest(DTO.Base.APIRequest <SaveDefaultKeyWordRP> pRequest) { var rd = new SaveDefaultKeyWordRD(); var keywordList = pRequest.Parameters.KeyWordList; if (string.IsNullOrEmpty(keywordList.ApplicationId)) { throw new APIException("微信公众号不能为空") { ErrorCode = 124 }; } if (keywordList.BeLinkedType == 0) { throw new APIException("关联类型不能为空") { ErrorCode = 125 }; } if (keywordList.ReplyType == 0) { throw new APIException("回复类型不能为空") { ErrorCode = 126 }; } var bll = new WKeywordReplyBLL(CurrentUserInfo); var entity = new WKeywordReplyEntity//实体对象数据,含有文本信息 { ApplicationId = keywordList.ApplicationId, Keyword = keywordList.KeyWord, ReplyType = keywordList.ReplyType, Text = keywordList.Text }; if (keywordList.ReplyType == 1) { if (string.IsNullOrEmpty(keywordList.Text) || keywordList.Text == "") { //内容为空相当于关闭自动回复 - bob 2014-08-11**** //throw new APIException("文本不能为空") { ErrorCode = 120 }; entity.ReplyId = keywordList.ReplyId; bll.Delete(entity); } if (Encoding.Default.GetBytes(keywordList.Text).Length > 2048) { throw new APIException("文本超过了最大限制(2M)") { ErrorCode = 121 }; } } if (keywordList.ReplyType == 3) { if (keywordList.MaterialTextIds == null || keywordList.MaterialTextIds.Any() == false) { throw new APIException("图文消息不能为空") { ErrorCode = 124 }; } if (keywordList.MaterialTextIds.Any() == true && keywordList.MaterialTextIds.Length > 10) { throw new APIException("图文消息最大不能超过10条数据") { ErrorCode = 125 }; } } if (string.IsNullOrEmpty(keywordList.ReplyId)) { //var keywordEntity = bll.QueryByEntity(new WKeywordReplyEntity() //{ // ApplicationId = keywordList.ApplicationId //}, null); //if (keywordEntity != null && keywordEntity.Length > 0) //{ // bll.Delete(keywordEntity); //} var replyId = Utils.NewGuid();//新建 entity.ReplyId = replyId; bll.Create(entity); rd.ReplyId = replyId; } else { entity.ReplyId = keywordList.ReplyId;//修改 bll.Update(entity); rd.ReplyId = keywordList.ReplyId; } bll.UpdateWkeywordReplyByReplyId(rd.ReplyId, keywordList.BeLinkedType, keywordList.KeywordType, -1); if (keywordList.ReplyType == 3) { var mappingBll = new WMenuMTextMappingBLL(CurrentUserInfo); var mappingEntity = mappingBll.QueryByEntity(new WMenuMTextMappingEntity() { MenuId = rd.ReplyId }, null); if (mappingEntity.Length > 0) { mappingBll.Delete(mappingEntity);//每一次都先删除,然后再添加 } var textMappingEntity = new WMenuMTextMappingEntity(); foreach (var materialTextIdInfo in keywordList.MaterialTextIds) { textMappingEntity.MappingId = Guid.NewGuid(); textMappingEntity.MenuId = rd.ReplyId; textMappingEntity.DisplayIndex = materialTextIdInfo.DisplayIndex; textMappingEntity.TextId = materialTextIdInfo.TestId; textMappingEntity.CustomerId = CurrentUserInfo.ClientID; mappingBll.Create(textMappingEntity); } } return(rd); }
/// <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); }
protected override SetKeyWordRD ProcessRequest(DTO.Base.APIRequest <SetKeyWordRP> pRequest) { var rd = new SetKeyWordRD(); var keywordList = pRequest.Parameters.KeyWordList; if (keywordList.DisplayIndex == 0) { throw new APIException("序号不能为空或为零") { ErrorCode = 122 }; } if (string.IsNullOrEmpty(keywordList.KeyWord)) { throw new APIException("关键字不能为空") { ErrorCode = 123 }; } if (string.IsNullOrEmpty(keywordList.ApplicationId)) { throw new APIException("微信公众号不能为空") { ErrorCode = 124 }; } if (keywordList.BeLinkedType == 0) { throw new APIException("关联类型不能为空") { ErrorCode = 125 }; } if (keywordList.ReplyType == 0) { throw new APIException("回复类型不能为空") { ErrorCode = 126 }; } var bll = new WKeywordReplyBLL(CurrentUserInfo); #region 关键字不能重复 WKeywordReplyEntity wKeywordReplyEntity = new WKeywordReplyEntity() { Keyword = keywordList.KeyWord, ApplicationId = keywordList.ApplicationId }; var queryByEntityArray = bll.QueryByEntity(wKeywordReplyEntity, null); if (string.IsNullOrEmpty(keywordList.ReplyId)) { if (queryByEntityArray.Length != 0) { throw new APIException("关键字不能重复") { ErrorCode = 127 }; } } else { if (queryByEntityArray.Length != 0 && queryByEntityArray[0].ReplyId != keywordList.ReplyId) { throw new APIException("关键字不能重复") { ErrorCode = 127 }; } } #endregion var entity = new WKeywordReplyEntity { ApplicationId = keywordList.ApplicationId, Keyword = keywordList.KeyWord, ReplyType = keywordList.ReplyType, Text = keywordList.Text }; if (keywordList.ReplyType == 1) { if (string.IsNullOrEmpty(keywordList.Text) || keywordList.Text == "") { throw new APIException("文本不能为空") { ErrorCode = 120 }; } if (Encoding.Default.GetBytes(keywordList.Text).Length > 2048) { throw new APIException("文本超过了最大限制(2M)") { ErrorCode = 121 }; } } if (keywordList.ReplyType == 3) { if (keywordList.MaterialTextIds == null || keywordList.MaterialTextIds.Any() == false) { throw new APIException("图文消息不能为空") { ErrorCode = 124 }; } if (keywordList.MaterialTextIds.Any() == true && keywordList.MaterialTextIds.Length > 10) { throw new APIException("图文消息最大不能超过10条数据") { ErrorCode = 125 }; } } if (string.IsNullOrEmpty(keywordList.ReplyId)) { var replyId = Utils.NewGuid(); entity.ReplyId = replyId; bll.Create(entity); rd.ReplyId = replyId; } else { entity.ReplyId = keywordList.ReplyId; bll.Update(entity); rd.ReplyId = keywordList.ReplyId; } bll.UpdateWkeywordReplyByReplyId(rd.ReplyId, keywordList.BeLinkedType, keywordList.KeywordType, keywordList.DisplayIndex); if (keywordList.ReplyType == 3) { var mappingBll = new WMenuMTextMappingBLL(CurrentUserInfo); var mappingEntity = mappingBll.QueryByEntity(new WMenuMTextMappingEntity() { MenuId = rd.ReplyId }, null); if (mappingEntity.Length > 0) { mappingBll.Delete(mappingEntity); } var textMappingEntity = new WMenuMTextMappingEntity(); foreach (var materialTextIdInfo in keywordList.MaterialTextIds) { textMappingEntity.MappingId = Guid.NewGuid(); textMappingEntity.MenuId = rd.ReplyId; textMappingEntity.DisplayIndex = materialTextIdInfo.DisplayIndex; textMappingEntity.TextId = materialTextIdInfo.TestId; textMappingEntity.CustomerId = CurrentUserInfo.ClientID; mappingBll.Create(textMappingEntity); } } return(rd); }
/// <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); }