예제 #1
0
        protected override GetTagsByTypeNameRD ProcessRequest(DTO.Base.APIRequest <GetTagsByTypeNameRP> pRequest)
        {
            var rd   = new GetTagsByTypeNameRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; //登录状态信息
            var tagsTypeBLL        = new TagsTypeBLL(loggingSessionInfo);       //标签分类业务对象实例化
            var tagsBLL            = new TagsBLL(loggingSessionInfo);           //标签业务对象实例化

            //获取标签类型对象
            var tagsTypeEntity = tagsTypeBLL.QueryByEntity(new TagsTypeEntity()
            {
                TypeName = para.TypeName
            }, null).FirstOrDefault();

            if (tagsTypeEntity != null)
            {
                //排序字段
                var orderBy = new OrderBy[] { new OrderBy()
                                              {
                                                  FieldName = "CreateTime", Direction = OrderByDirections.Asc
                                              } };
                //获取标签列表
                var tagsList = tagsBLL.QueryByEntity(new TagsEntity()
                {
                    TypeId = tagsTypeEntity.TypeId
                }, orderBy);
                //返回数据转换
                rd.TagsList = tagsList.Select(t => new TagsInfo()
                {
                    TagsID = t.TagsId, TagsName = t.TagsName
                }).ToList();
            }
            return(rd);
        }
예제 #2
0
        /// <summary>
        /// 销售(服务)订单
        /// </summary>
        public string GetTagTypeAndTags(string pRequest)
        {
            var    rp         = pRequest.DeserializeJSONTo <APIRequest <GetTagTypeAndTagsRP> >();//不需要参数
            string userId     = rp.UserID;
            string customerId = rp.CustomerID;

            var pageSize  = rp.Parameters.PageSize;
            var pageIndex = rp.Parameters.PageIndex;

            LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);
            //var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            TagsTypeBLL bll = new TagsTypeBLL(loggingSessionInfo);

            var rd = new GetTagTypeAndTagsRD();
            var ds = bll.GetAll2(pageIndex ?? 1, pageSize ?? 15, rp.Parameters.OrderBy, rp.Parameters.OrderType);
            List <TagsTypeEntity> tagTypeList = new List <TagsTypeEntity>();

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                tagTypeList   = DataTableToObject.ConvertToList <TagsTypeEntity>(ds.Tables[1]);//直接根据所需要的字段反序列化
                rd.TotalCount = ds.Tables[0].Rows.Count;
                rd.TotalPages = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(ds.Tables[0].Rows.Count * 1.00 / (pageSize ?? 15) * 1.00)));
            }
            //标签
            TagsBLL             _TagsBLL = new TagsBLL(loggingSessionInfo);
            List <TagsTypeInfo> ls       = new List <TagsTypeInfo>();

            if (tagTypeList != null && tagTypeList.Count() > 0)
            {
                foreach (TagsTypeEntity en in tagTypeList)
                {
                    TagsTypeInfo _TagsTypeInfo = new TagsTypeInfo();
                    _TagsTypeInfo.TypeId   = en.TypeId;
                    _TagsTypeInfo.TypeName = en.TypeName;
                    var ds2 = _TagsBLL.GetTagsList(en.TypeId, rp.CustomerID);
                    if (ds2 != null && ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                    {
                        _TagsTypeInfo.TagsList = DataTableToObject.ConvertToList <TagsInfo>(ds2.Tables[0]);//直接根据所需要的字段反序列化
                    }
                    ls.Add(_TagsTypeInfo);
                }
            }


            rd.TagTypesAndTags = ls;
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
예제 #3
0
        /// <summary>
        /// 删除
        /// </summary>
        public string DeleteTagsType(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <DeleteTagsTypeRP> >();
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var rd = new DeleteTagsTypeRD();//返回值

            var TypeId = rp.Parameters.TypeId;

            if (string.IsNullOrEmpty(TypeId))
            {
                throw new APIException("缺少参数【TypeId】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            TagsTypeBLL    TagsTypeBLL = new TagsTypeBLL(loggingSessionInfo);
            TagsTypeEntity TagsTypeEn  = TagsTypeBLL.GetByID(TypeId);

            if (TagsTypeEn == null)
            {
                throw new APIException("没有找到对应的标签类型")
                      {
                          ErrorCode = 135
                      };
            }
            var rsp = new SuccessResponse <IAPIResponseData>(rd);
            //查看标签是否已经被使用
            DataSet ds = TagsTypeBLL.HasUse(TypeId);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                rsp.ResultCode = 310;
                rsp.Message    = "该标签类型下面的标签已经被使用";
                return(rsp.ToJSON());
            }

            //虚拟删除标签类型和下面的标签
            TagsTypeBLL.DeleteTagsType(TypeId);


            return(rsp.ToJSON());
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        public string GetTagsTypeData()
        {
            var billService = new TagsTypeBLL(new SessionManager().CurrentUserLoginInfo);

            var queryEntity = new TagsTypeEntity();

            queryEntity.CustomerId = CurrentUserInfo.CurrentUser.customer_id;

            var list = billService.GetList(queryEntity, 0, 100);

            string content = string.Empty;

            var jsonData = new JsonData();

            jsonData.totalCount = list.Count.ToString();
            jsonData.data       = list;

            content = jsonData.ToJSON();
            return(content);
        }
예제 #5
0
        public string SaveTagsType(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <SaveTagsTypeRP> >();
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var rd = new SaveTagsTypeRD();//返回值

            var _TagsTypeInfo = rp.Parameters.TagsTypeInfo;

            if (string.IsNullOrEmpty(_TagsTypeInfo.TypeName))
            {
                throw new APIException("缺少参数【TypeName】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            TagsTypeEntity TagsTypeEn = new TagsTypeEntity();
            bool           isNew      = false;

            if (string.IsNullOrEmpty(_TagsTypeInfo.TypeId))
            {
                _TagsTypeInfo.TypeId = Guid.NewGuid().ToString();
                isNew = true;
            }
            TagsTypeEn.TypeId   = _TagsTypeInfo.TypeId;
            TagsTypeEn.TypeName = _TagsTypeInfo.TypeName;

            TagsTypeEn.LastUpdateBy   = loggingSessionInfo.UserID;
            TagsTypeEn.LastUpdateTime = DateTime.Now;
            TagsTypeEn.IsDelete       = 0;
            string error = "";
            //service.SaveProp(propInfo, ref error);
            TagsTypeBLL TagsTypeBLL = new TagsTypeBLL(loggingSessionInfo);

            if (isNew)
            {
                TagsTypeEn.CreateBy   = loggingSessionInfo.UserID;
                TagsTypeEn.CreateTime = DateTime.Now;
                TagsTypeBLL.Create(TagsTypeEn);
            }
            else
            {
                TagsTypeBLL.Update(TagsTypeEn, false);
            }
            TagsBLL TagsBLL = new TagsBLL(loggingSessionInfo);

            if (!isNew)//不是新的
            {
                string propIds = "";
                foreach (var itemInfo in _TagsTypeInfo.TagsList)//数组,更新数据
                {
                    if (!string.IsNullOrEmpty(itemInfo.TagsId))
                    {
                        if (propIds != "")
                        {
                            propIds += ",";
                        }
                        propIds += "'" + itemInfo.TagsId + "'";
                    }
                }
                //删除不在这个里面的
                if (!string.IsNullOrEmpty(propIds))
                {
                    TagsBLL.DeleteByIds(propIds, TagsTypeEn);
                }
            }


            foreach (var itemInfo in _TagsTypeInfo.TagsList)//数组,更新数据
            {
                TagsEntity TagsEn = new TagsEntity();

                TagsEn.TagsName       = itemInfo.TagsName;
                TagsEn.TagsDesc       = itemInfo.TagsName;
                TagsEn.LastUpdateBy   = rp.UserID;
                TagsEn.LastUpdateTime = DateTime.Now;
                TagsEn.IsDelete       = 0;
                TagsEn.CustomerId     = loggingSessionInfo.ClientID;
                TagsEn.TypeId         = TagsTypeEn.TypeId;

                if (string.IsNullOrEmpty(itemInfo.TagsId))
                {
                    TagsEn.TagsId     = Guid.NewGuid().ToString();
                    TagsEn.CreateBy   = rp.UserID;
                    TagsEn.CreateTime = DateTime.Now;
                    TagsBLL.Create(TagsEn);
                }
                else
                {
                    TagsEn.TagsId = itemInfo.TagsId;
                    TagsBLL.Update(TagsEn, false);
                }
            }



            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }