예제 #1
0
        public TitleInfoListResponse SelectTitleInfoList(TitleInfoRequest Request)
        {
            TitleInfoListResponse response = new TitleInfoListResponse();

            try
            {
                using (var entities = new ResKey_dbEntities())
                {
                    var rowCount = Request.PageIndex * Request.PageSize;
                    var pageSize = Request.PageSize;
                    var list     = new List <Expression <Func <Entity.Model.TitleInfo, bool> > >();

                    if (Request.ID.HasValue)
                    {
                        list.Add(c => c.ID == Request.ID.Value);
                    }
                    if (Request.IsHandle.HasValue)
                    {
                        list.Add(c => c.IsHandle == Request.IsHandle);
                    }
                    Expression <Func <Entity.Model.TitleInfo, bool> > entitiesQuery = null;
                    foreach (var expression in list)
                    {
                        entitiesQuery = entitiesQuery == null ? expression : entitiesQuery.And(expression);
                    }
                    var dbset           = entities.TitleInfo;
                    var query           = entitiesQuery == null ? dbset : dbset.Where(entitiesQuery);
                    var mainWindowModel = query.Select(entity => new MainWindowModel
                    {
                        ID               = entity.ID,
                        IsAdd            = entity.IsAdd,
                        IsHandle         = entity.IsHandle,
                        OldID            = entity.OldID,
                        ModificationTime = entity.ModificationTime,
                        NewTitle         = entity.NewTitle,
                        OldTitle         = entity.OldTitle,
                        UpTime           = entity.UpTime
                    });
                    var arrayL = mainWindowModel.OrderBy(c => c.ID)
                                 .Skip(rowCount)
                                 .Take(pageSize)
                                 .ToArray()
                                 .OrderByDescending(c => c.ID).ToArray();
                    response.mainWindowModels = arrayL;
                    response.RowCount         = arrayL.Count();
                    response.PageSize         = pageSize;
                }
            }
            catch (Exception exception)
            {
                //response.Error = new Error
                //{
                //    ErrorMessage = exception.GetBaseException().Message,
                //    ErrorCode = 5001
                //};
            }
            return(response);
        }
예제 #2
0
        /// <summary>
        /// 查询标签下百度图片
        /// </summary>
        /// <param name="Request"></param>
        /// <returns></returns>
        public BaiDuInfoResponse SelectBaiDuInfoList(BaiDuInfoRequest Request)
        {
            BaiDuInfoResponse response = new BaiDuInfoResponse();

            try
            {
                using (var entities = new ResKey_dbEntities())
                {
                    //var list = new List<Expression<Func<Entity.Model.TitleInfo, bool>>>();
                    if (Request.TitleID.HasValue)
                    {
                        //list.Add(c => c.ID == Request.TitleID);
                        //var TitleID = entities.UserInfo.Where(c => c.ID == Request.TitleID).FirstOrDefault().TitleInfoID;
                        var titleInfoModel = entities.TitleInfo.Where(c => c.ID == Request.TitleID).FirstOrDefault();
                        if (titleInfoModel.ID > 0)
                        {
                            response.ID               = titleInfoModel.ID;
                            response.IsAdd            = titleInfoModel.IsAdd;
                            response.IsHandle         = titleInfoModel.IsHandle;
                            response.ModificationTime = titleInfoModel.ModificationTime;
                            response.NewTitle         = titleInfoModel.NewTitle;
                            response.OldID            = titleInfoModel.OldID;
                            response.OldTitle         = titleInfoModel.OldTitle;
                            response.UpTime           = titleInfoModel.UpTime;
                            var userInfo = titleInfoModel.UserInfo.FirstOrDefault(c => c.TitleInfoID == Request.TitleID);
                            response.UserName = userInfo?.UserName;
                            response.UserNo   = userInfo?.UserNo;
                            List <PictureControlModel> PicModelList = new List <PictureControlModel>();
                            var BaiDuInfoList = titleInfoModel.BaiDuInfo.ToList();
                            for (int i = 0; i < BaiDuInfoList.Count; i++)
                            {
                                PictureControlModel pictureModel = new PictureControlModel();
                                pictureModel.Url = BaiDuInfoList[i].BaiDuUrl;
                                //pictureModel.IsCheck = BaiDuInfoList[i].IsEnable;
                                PicModelList.Add(pictureModel);
                            }
                            response.PicModelList = PicModelList;
                        }
                    }
                    else
                    {
                        //return response;
                    }
                }
            }
            catch (Exception exception)
            {
                //response.Error = new Error
                //{
                //    ErrorMessage = exception.GetBaseException().Message,
                //    ErrorCode = 5001
                //};
            }
            return(response);
        }
예제 #3
0
        /// <summary>
        /// 查询所有关键字
        /// </summary>
        /// <param name="Request"></param>
        /// <returns></returns>
        public TitleInfoListResponse SelectAllTitleInfoList(TitleInfoRequest Request)
        {
            TitleInfoListResponse response = new TitleInfoListResponse();

            try
            {
                using (var entities = new ResKey_dbEntities())
                {
                    var rowCount = Request.PageIndex * Request.PageSize;
                    var pageSize = Request.PageSize;
                    var list     = new List <Expression <Func <Entity.Model.TitleInfo, bool> > >();
                    list.Add(c => c.IsHandle == 0);
                    if (!string.IsNullOrWhiteSpace(Request.TitleName))
                    {
                        list.Add(c => c.NewTitle.Contains(Request.TitleName));
                    }
                    Expression <Func <Entity.Model.TitleInfo, bool> > entitiesQuery = null;
                    foreach (var expression in list)
                    {
                        entitiesQuery = entitiesQuery == null ? expression : entitiesQuery.And(expression);
                    }
                    var dbset           = entities.TitleInfo;
                    var query           = entitiesQuery == null ? dbset : dbset.Where(entitiesQuery);
                    var mainWindowModel = query.Select(entity => new MainWindowModel
                    {
                        ID               = entity.ID,
                        IsAdd            = entity.IsAdd,
                        IsHandle         = entity.IsHandle,
                        OldID            = entity.OldID,
                        ModificationTime = entity.ModificationTime,
                        NewTitle         = entity.NewTitle,
                        OldTitle         = entity.OldTitle,
                        UpTime           = entity.UpTime
                    });
                    var arrayL = mainWindowModel.OrderBy(c => c.ID)
                                 .Skip(rowCount)
                                 .Take(pageSize)
                                 .ToArray()
                                 .OrderByDescending(c => c.ID).ToArray();
                    //int c = a % b == 0 ? a / b : a / b + 1;
                    response.PageMax = (mainWindowModel.Count() % Request.PageSize == 0 ? mainWindowModel.Count() / Request.PageSize : mainWindowModel.Count() / Request.PageSize + 1) - 1;
                    //mainWindowModel.Count()/Request.PageSize;
                    response.mainWindowModels = arrayL;
                    response.RowCount         = arrayL.Count();
                    response.PageSize         = pageSize;
                }
            }
            catch (Exception exception)
            {
            }
            return(response);
        }