public IPageList<EMileageReportDay> SearchMileageReportDays(int deviceId, DateTime st, DateTime et, string orderName, string orderType, int pageIndex, int pageSize)
        {

            if (et > DateTime.Now)
            {
                et = DateTime.Now;
            }

            //生成查询时间段
            var day = (et - st).TotalDays;
            var dts = new List<DateTime>();
            for (var i = 0; i <= day; i++)
            {
                dts.Add(st.AddDays(i).GetDayStartTime());
            }

            var sp = new Spec<EMileageReportDay>();
            sp.And(p => p.DeviceId == deviceId && p.ReportDay >= st.GetDayStartTime() && p.ReportDay <= et.GetDayStartTime());

            //获取已经生成的数据
            var haveddks =
                _rep.GetList<EMileageReportDay>(0, sp,
                    p => new Columns(p.ReportDay)).Select(p => p.ReportDay.GetDayStartTime()).ToList();

            foreach (var ddk in dts)
            {
                if (!haveddks.Contains(ddk))
                {
                    //发现当前日期的数据没有生成 那么开始生成
                    CreateMileageReportDayByReportDay(deviceId, ddk);
                }
            }

            var cp = new CSpec<EMileageReportDay>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }
            return _rep.GetPageList<EMileageReportDay>(pageIndex, pageSize, sp, cp);
        }
Beispiel #2
1
        /// <summary>
        /// ËÑË÷
        /// </summary>
        /// <returns></returns>
        public IPageList<EGuestbook> SearchGuestbooks(int? userId, string searchKeyword, string searchType, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<EGuestbook> sp = new Spec<EGuestbook>();
            if (searchKeyword.HasValue())
            {
                if (!searchType.HasValue())
                {
                    sp.And(p => p.NickName.Like(searchKeyword))
                        //.Or(p => p.Phone.Like(searchKeyword))
                        //.Or(p => p.Email.Like(searchKeyword))
                        //.Or(p => p.Fax.Like(searchKeyword))
                        //.Or(p => p.Mobile.Like(searchKeyword))
                        //.Or(p => p.Phone.Like(searchKeyword))
                        //.Or(p => p.ReplyContent.Like(searchKeyword))
                        //.Or(p => p.ReplyUserName.Like(searchKeyword))
                        .Or(p => p.Content.Like(searchKeyword));
                }
                else
                {
                    sp.And(p => p.Column(searchType).Like(searchKeyword));
                }
            }

            if (userId.HasValue)
            {
                sp.And(p => p.UserId == userId);
            }

            var cp = new CSpec<EGuestbook>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.GetPageList<EGuestbook>(pageIndex, pageSize, sp, cp);
        }
        public IPageList<ESiteMessage> SearchSiteMessages(int? userId, bool? isRead, string searchKeyword, string searchType, DateTime? startTime, DateTime? endTime, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<ESiteMessage> sp = new Spec<ESiteMessage>();
            if (searchKeyword.HasValue())
            {
                if (!searchType.HasValue())
                {
                    sp.And(p => p.Title.Like(searchKeyword)).Or(p => p.Content.Like(searchKeyword));
                }
                else
                {
                    sp.And(p => p.Column(searchType).Like(searchKeyword));
                }
            }

            if (isRead.HasValue)
            {
                sp.And(p => p.IsRead == isRead);
            }

            if (userId.HasValue)
            {
                var userIds = _rep.GetList<EUser>(0, p => p.ParentUserId == userId, p => new Columns(p.Id))
                    .Select(p => p.Id)
                    .ToList();
                userIds.Add(userId.Value);

                sp.And(p => p.ReceiveUserId.In(string.Join(",", userIds)));
            }

            if (startTime.HasValue) sp.And(p => p.CreateTime >= startTime);
            if (endTime.HasValue) sp.And(p => p.CreateTime <= endTime);

            var cp = new CSpec<ESiteMessage>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.GetPageList<ESiteMessage>(pageIndex, pageSize, sp, cp);
        }
Beispiel #4
1
        /// <summary>
        /// 搜索内容分组内容
        /// </summary>
        /// <returns></returns>
        public IPageList<EContentsGroupContents> SearchContentsGroupContents(int? contentsGroupId, string searchKeyword, string searchType, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<EContentsGroupContents, EContents, ENode> sp = new Spec<EContentsGroupContents, EContents, ENode>();

            if (searchKeyword.HasValue())
            {
                if (!searchType.HasValue())
                {
                    sp.And((cgc, c, n) => c.Title.Like(searchKeyword));
                }
                else
                {
                    sp.And((cgc, c, n) => c.Column(searchType).Like(searchKeyword));
                }
            }

            if (contentsGroupId.HasValue)
            {
                sp.And(p => p.ContentsGroupId == contentsGroupId);
            }

            CSpec<EContentsGroupContents> cp = new CSpec<EContentsGroupContents>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            var query = DMContext.Query<EContentsGroupContents, EContents, ENode, EContentsGroupContents>()
                .LeftJoin<EContents>((cgc, c) => cgc.ContentsId == c.Id)
                .LeftJoin<EContents, ENode>((c, n) => c.NodeId == n.Id)
                .Select((cgc, c, n) => new Columns(cgc, c.Title, c.DefaultImageUrl, c.NodeId, c.CreateTime, c.LastUpdateTime, c.ContentStatus, n.NodeName))
                .Where(sp)
                .OrderBy(cp);

            return query.ToPageList(pageIndex, pageSize);
        }
Beispiel #5
0
        public IPageList<ELine> SearchLines(int userId, EnumMapCoordinates coordinates, string searchKeyword, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<ELine> sp = new Spec<ELine>();
            sp.And(p => p.UserId == userId);
            if (searchKeyword.HasValue())
            {
                sp.And(p => p.LineName.Like(searchKeyword));
            }

            CSpec<ELine> csp = new CSpec<ELine>();

            if (orderName.HasValue())
            {
                csp.And(orderName, orderType);
            }

            var list = _rep.GetPageList<ELine>(pageIndex, pageSize, sp, csp);
            switch (coordinates)
            {
                case EnumMapCoordinates.Gcj02:
                    foreach (var item in list.List)
                    {
                        item.LinePoints = _mapService.Wgs84ToGcj02(item.LinePoints.ToObject<IList<EMapPoint>>().ToArray()).ToJson();
                    }
                    break;
                case EnumMapCoordinates.Bd09:
                    foreach (var item in list.List)
                    {
                        item.LinePoints = _mapService.Wgs84ToBd09(item.LinePoints.ToObject<IList<EMapPoint>>().ToArray()).ToJson();
                    }
                    break;
                default:
                    break;
            }
            return list;
        }
Beispiel #6
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <returns></returns>
        public IPageList<EUser> SearchUsers(int? parentUserId, string searchKeyword, string searchType, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<EUser> sp = new Spec<EUser>();

            if (searchKeyword.HasValue())
            {
                if (!searchType.HasValue())
                {
                    sp.And(p => p.NickName.Like(searchKeyword))
                        .Or(p => p.Mobile.Like(searchKeyword))
                        .Or(p => p.QQ.Like(searchKeyword))
                        .Or(p => p.UserName.Like(searchKeyword))
                        .Or(p => p.Address.Like(searchKeyword));
                }
                else
                {
                    sp.And(p => p.Column(searchType).Like(searchKeyword));
                }
            }

            if (parentUserId.HasValue)
            {
                sp.And(p => p.ParentUserId == parentUserId);
            }

            CSpec<EUser> cp = new CSpec<EUser>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.GetPageList<EUser>(pageIndex, pageSize, sp, cp);
        }
Beispiel #7
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <returns></returns>
        public IPageList<ERole> SearchRoles(string searchKeyword, string searchType, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<ERole> sp = new Spec<ERole>();
            if (searchKeyword.HasValue())
            {
                if (!searchType.HasValue())
                {
                    sp.And(p => p.RoleName.Like(searchKeyword))
                        .Or(p => p.RoleDesc.Like(searchKeyword));
                }
                else
                {
                    sp.And(p => p.Column(searchType).Like(searchKeyword));
                }
            }

            CSpec<ERole> cp = new CSpec<ERole>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.GetPageList<ERole>(pageIndex, pageSize, sp, cp);
        }
Beispiel #8
0
        public IList<EContents> GetContentsByNodeId(int nodeId, int top, string orderName, string orderType)
        {
            Spec<EContents> sp = new Spec<EContents>();
            sp.And(p => p.NodeId == nodeId).And(p => p.ContentStatus == EnumContentStatus.PassAudit);

            CSpec<EContents> cp = new CSpec<EContents>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }
            return _rep.GetList<EContents>(top, sp, cp);
        }
Beispiel #9
0
        /// <summary>
        /// 搜索内容 排除指定内容分组
        /// </summary>
        /// <returns></returns>
        public IPageList<EContents> SearchNoHaveContentsByContentsGroupId(int contentsGroupId, string searchKeyword, string searchType, string orderName, string orderType, int pageIndex, int pageSize)
        {
            var hasIds = _rep.GetList<EContentsGroupContents>(0, p => p.ContentsGroupId == contentsGroupId).Select(p => p.ContentsId);

            Spec<EContents> sp = new Spec<EContents>();
            if (searchKeyword.HasValue())
            {
                if (!searchType.HasValue())
                {
                    sp.And(p => p.Title.Like(searchKeyword));
                }
                else
                {
                    sp.And(p => p.Column(searchType).Like(searchKeyword));
                }
            }

            if (hasIds.Count() > 0)
            {
                sp.And(p => p.Id.NotIn(string.Join(",", hasIds)));
            }

            CSpec<EContents> cp = new CSpec<EContents>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.GetPageList<EContents>(pageIndex, pageSize, sp, cp);
        }
Beispiel #10
0
        public IPageList<EDeviceLog> SearchDeviceLogs(int? deviceId, EnumDeviceLogType? deviceLogType, DateTime? startTime, DateTime? endTime, string searchKeyword, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<EDeviceLog> sp = new Spec<EDeviceLog>();

            if (searchKeyword.HasValue())
            {
                sp.And(p => p.LogContent.Like(searchKeyword));
            }

            if (deviceId.HasValue)
            {
                sp.And(p => p.DeviceId == deviceId);
            }

            if (deviceLogType.HasValue)
            {
                sp.And(p => p.LogType == deviceLogType);
            }

            if (startTime.HasValue)
            {
                sp.And(p => p.CreateTime > startTime);
            }

            if (endTime.HasValue)
            {
                sp.And(p => p.CreateTime < endTime);
            }

            CSpec<EDeviceLog> cp = new CSpec<EDeviceLog>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.GetPageList<EDeviceLog>(pageIndex, pageSize, sp, cp);
        }
Beispiel #11
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <returns></returns>
        public IPageList<EContents> SearchContents(int? nodeId, DateTime? startTime, DateTime? endTime, EnumContentStatus? contentStatus, string searchKeyword, string searchType, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<EContents> sp = new Spec<EContents>();
            if (searchKeyword.HasValue())
            {
                sp.And(p => p.Title.Like(searchKeyword));
            }

            if (nodeId.HasValue)
            {
                sp.And(p => p.NodeId == nodeId);
            }

            if (startTime.HasValue)
            {
                sp.And(p => p.LastUpdateTime > startTime);
            }

            if (endTime.HasValue)
            {
                sp.And(p => p.LastUpdateTime < endTime);
            }

            if (contentStatus.HasValue)
            {
                sp.And(p => p.ContentStatus == (EnumContentStatus)contentStatus);
            }

            CSpec<EContents> cp = new CSpec<EContents>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.GetPageList<EContents>(pageIndex, pageSize, sp, cp);
        }
Beispiel #12
0
        public IPageList<VDevice> SearchDevices(IList<int> userIds, int? userId, int? deviceTypeId, int? deviceGpsTypeId, int? deviceExpireTime, DateTime? startTime, DateTime? endTime, string searchKeyword, string orderName, string orderType, int pageIndex, int pageSize)
        {

            Spec<EDevice> sp = new Spec<EDevice>();

            if (searchKeyword.HasValue())
            {
                sp.And(p => p.DeviceName.Like(searchKeyword) || p.DeviceGpsSimNo.Like(searchKeyword) || p.DeviceGpsCode.Like(searchKeyword) || p.DeviceGpsNo.Like(searchKeyword));
            }

            if (deviceTypeId.HasValue)
            {
                sp.And(p => p.DeviceTypeId == deviceTypeId);
            }

            if (deviceGpsTypeId.HasValue)
            {
                sp.And(p => p.DeviceGpsTypeId == deviceGpsTypeId);
            }

            if (userIds != null)
            {
                sp.And(p => p.UserId.In(string.Join(",", userIds)));
            }

            if (userId.HasValue)
            {
                sp.And(p => p.UserId == userId);
            }

            if (startTime.HasValue)
            {
                sp.And(p => p.CreateTime > startTime);
            }

            if (endTime.HasValue)
            {
                sp.And(p => p.CreateTime < endTime);
            }

            if (deviceExpireTime.HasValue) 
            {
                if (deviceExpireTime.Value == 0)
                {
                    //未过期
                    sp.And(p => p.DeviceExpireTime > DateTime.Now || p.DeviceExpireTime.IsDBNull());
                }
                else 
                {
                    //已过期
                    sp.And(p => p.DeviceExpireTime < DateTime.Now && p.DeviceExpireTime.IsNotDBNull());
                }
            }

            CSpec<EDevice> cp = new CSpec<EDevice>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.Query<EDevice, EDeviceType, EDeviceGpsType, EUser, VDevice>()
                .LeftJoin<EDeviceType>((d, dt) => d.DeviceTypeId == dt.Id)
                .LeftJoin<EDeviceGpsType>((d, dgt) => d.DeviceGpsTypeId == dgt.Id)
                .LeftJoin<EUser>((d, u) => d.UserId == u.Id)
                .Where(sp)
                .OrderBy(cp)
                .Select((d, dt, dgt, u) => new Columns(
                    d,
                    dt.DeviceTypeName,
                    dgt.DeviceGpsTypeName,
                    dgt.DeviceGpsTypeProtocol,
                    dgt.DeviceGpsTypeGpsCodeCreateRule,
                    u.UserName,
                    u.NickName
                    )).ToPageList(pageIndex, pageSize);
        }
Beispiel #13
0
        /// <summary>
        /// 搜索 广告
        /// </summary>
        /// <returns></returns>
        public IPageList<EAd> SearchAds(int? adZoneId, string searchKeyword, string searchType, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<EAd> sp = new Spec<EAd>();
            if (searchKeyword.HasValue())
            {
                if (!searchType.HasValue())
                {
                    sp.And(p => p.AdName.Like(searchKeyword))
                        .Or(p => p.AdDesc.Like(searchKeyword));
                }
                else
                {
                    sp.And(p => p.Column(searchType).Like(searchKeyword));
                }
            }

            if (adZoneId.HasValue)
            {
                sp.And(p => p.AdZoneId == adZoneId);
            }

            CSpec<EAd> cp = new CSpec<EAd>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.GetPageList<EAd>(pageIndex, pageSize, sp, cp);
        }
Beispiel #14
0
        public IPageList<EShowItem> SearchShowItems(int? showItemCategoryId, string searchKeyword, string searchType, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<EShowItem> sp = new Spec<EShowItem>();
            if (searchKeyword.HasValue())
            {
                if (!searchType.HasValue())
                {
                    sp.And(p => p.ShowItemName.Like(searchKeyword))
                        .Or(p => p.ShowItemDesc.Like(searchKeyword));
                }
                else
                {
                    sp.And(p => p.Column(searchType).Like(searchKeyword));
                }
            }

            if (showItemCategoryId.HasValue) 
            {
                sp.And(p => p.ShowItemCategoryId == showItemCategoryId);
            }


            CSpec<EShowItem> cp = new CSpec<EShowItem>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.GetPageList<EShowItem>(pageIndex, pageSize, sp, cp);
        }
Beispiel #15
0
        public IPageList<EFriendlyLink> SearchFriendlyLinks(int? friendlyLinkCategoryId, string searchKeyword, string searchType, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<EFriendlyLink> sp = new Spec<EFriendlyLink>();
            if (searchKeyword.HasValue())
            {
                if (!searchType.HasValue())
                {
                    sp.And(p => p.FriendlyLinkName.Like(searchKeyword))
                        .Or(p => p.FriendlyLinkDesc.Like(searchKeyword));
                }
                else
                {
                    sp.And(p => p.Column(searchType).Like(searchKeyword));
                }
            }

            if (friendlyLinkCategoryId.HasValue) 
            {
                sp.And(p => p.FriendlyLinkCategoryId == friendlyLinkCategoryId);
            }


            CSpec<EFriendlyLink> cp = new CSpec<EFriendlyLink>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.GetPageList<EFriendlyLink>(pageIndex, pageSize, sp, cp);
        }
Beispiel #16
0
        public IPageList<ETravel> SearchTravels(IList<int> userIds, int? userId, bool? isPraise, bool? isGood,
            string searchKeyword, string orderName, string orderType, int pageIndex, int pageSize)
        {
            Spec<ETravel> sp = new Spec<ETravel>();
            sp.And(p => p.TravelCover.IsNotDBNull());


            if (searchKeyword.HasValue())
            {
                sp.And(p => p.TravelName.Like(searchKeyword));
            }

            if (userId.HasValue)
            {
                sp.And(p => p.UserId == userId.Value);
            }

            if (userIds != null)
            {
                sp.And(p => p.UserId.In(string.Join(",", userIds)));
            }

            if (isPraise.HasValue)
            {
                sp.And(p => p.TravelIsPraise == isPraise.Value);
            }

            if (isGood.HasValue)
            {
                sp.And(p => p.TravelIsGood == isGood.Value);
            }

            CSpec<ETravel> cp = new CSpec<ETravel>();

            if (orderType.HasValue())
            {
                cp.And(orderName, orderType);
            }

            return _rep.Query<ETravel, EUser, ETravel>()
                .LeftJoin<EUser>((t, u) => t.UserId == u.Id)
                .Select((t, u) => new Columns(t, u.NickName.As("ExtNickName"), u.UserAvatar.As("ExtUserAvatar")))
                .Where(sp).OrderBy(cp).ToPageList(pageIndex, pageSize);
        }