예제 #1
0
        /// <summary>
        /// Web列表获取
        /// </summary>
        public IList <WKeywordReplyEntity> GetWebWKeywordReply(WKeywordReplyEntity entity, int Page, int PageSize)
        {
            if (PageSize <= 0)
            {
                PageSize = 15;
            }

            IList <WKeywordReplyEntity> list = new List <WKeywordReplyEntity>();
            DataSet ds = new DataSet();

            ds = _currentDAO.GetWebWKeywordReply(entity, Page, PageSize);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                list = DataTableToObject.ConvertToList <WKeywordReplyEntity>(ds.Tables[0]);
            }
            return(list);
        }
예제 #2
0
 /// <summary>
 /// 列表数量获取
 /// </summary>
 public int GetWebWKeywordReplyCount(WKeywordReplyEntity entity)
 {
     return(_currentDAO.GetWebWKeywordReplyCount(entity));
 }
예제 #3
0
        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);
        }
예제 #4
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(WKeywordReplyEntity pEntity, IDbTransaction pTran)
 {
     Update(pEntity, true, pTran);
 }
예제 #5
0
 public void Update(WKeywordReplyEntity pEntity, bool pIsUpdateNullField, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField, pTran);
 }
예제 #6
0
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(WKeywordReplyEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
예제 #7
0
 /// <summary>
 /// 在事务内创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Create(WKeywordReplyEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Create(pEntity, pTran);
 }
예제 #8
0
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <WKeywordReplyEntity> PagedQueryByEntity(WKeywordReplyEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }
예제 #9
0
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public WKeywordReplyEntity[] QueryByEntity(WKeywordReplyEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
예제 #10
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(WKeywordReplyEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
예제 #11
0
 public void Update(WKeywordReplyEntity pEntity, bool pIsUpdateNullField)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField);
 }
예제 #12
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(WKeywordReplyEntity pEntity)
 {
     Update(pEntity, true);
 }