Example #1
0
        /// <summary>
        /// 获取路线分页列表
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="rowCount"></param>
        /// <returns></returns>
        public RouteViewEntity[] GetRouteList(RouteViewEntity entity, int pageIndex, int pageSize, out int rowCount)
        {
            List <OrderBy> orderbys = new List <OrderBy>();

            orderbys.Add(new OrderBy()
            {
                FieldName = "CreateTime", Direction = OrderByDirections.Desc
            });

            PagedQueryResult <RouteViewEntity> pEntity = this._currentDAO.GetRouteList(entity, orderbys.ToArray(), pageIndex, pageSize);

            rowCount = pEntity.RowCount;
            return(pEntity.Entities);
        }
Example #2
0
        public string GetRouteList(NameValueCollection rParams)
        {
            RouteViewEntity entity = rParams["form"].DeserializeJSONTo <RouteViewEntity>();

            if (!string.IsNullOrEmpty(rParams["ClientStructureID"]))
            {
                entity.ClientStructureID = Guid.Parse(rParams["ClientStructureID"]);
            }
            entity.ClientUserID = rParams["ClientUserID"].ToInt();
            int pageSize  = rParams["limit"].ToInt();
            int pageIndex = rParams["page"].ToInt();
            int rowCount  = 0;

            return(string.Format("{{\"totalCount\":{1},\"topics\":{0}}}",
                                 new RouteBLL(CurrentUserInfo).GetRouteList(entity, pageIndex, pageSize, out rowCount).ToJSON(),
                                 rowCount));
        }
Example #3
0
        /// <summary>
        /// 获取路线分页列表
        /// </summary>
        /// <param name="pWhereConditions"></param>
        /// <param name="pOrderBys"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public PagedQueryResult <RouteViewEntity> GetRouteList(RouteViewEntity entity, OrderBy[] pOrderBys, int pageIndex, int pageSize)
        {
            StringBuilder sqlWhere = new StringBuilder();

            if (entity != null &&
                entity.RouteName != null &&
                !string.IsNullOrEmpty(entity.RouteName.ToString()))
            {
                sqlWhere.AppendFormat(" and A.RouteName like '%{0}%'", entity.RouteName);
            }
            if (entity != null &&
                entity.ClientStructureID != null &&
                !string.IsNullOrEmpty(entity.ClientStructureID.ToString()))
            {
                sqlWhere.AppendFormat(" and C.ClientStructureID in (select StructureID from dbo.fnGetStructure('{0}',1))", entity.ClientStructureID);
            }
            if (entity != null &&
                entity.ClientUserID != null &&
                Convert.ToInt32(entity.ClientUserID) > 0)
            {
                sqlWhere.AppendFormat(" and C.ClientUserID='{0}'", entity.ClientUserID);
            }

            StringBuilder sqlOrder = new StringBuilder();

            if (pOrderBys != null && pOrderBys.Length > 0)
            {
                foreach (var item in pOrderBys)
                {
                    sqlOrder.AppendFormat(" {0} {1},", item.FieldName, item.Direction == OrderByDirections.Asc ? "asc" : "desc");
                }
                sqlOrder.Remove(sqlOrder.Length - 1, 1);
            }

            StringBuilder sql = new StringBuilder();

            sql.AppendFormat(@"select distinct A.*,B.ClientUserID,C.Name as UserName,D.PositionName
            from [Route] A
            inner join RouteUserMapping B on A.RouteID=B.RouteID
            INNER JOIN fnGetClientUser({2}, 1) S ON B.ClientUserID = S.ClientUserID
            left join ClientUser C on B.ClientUserID=C.ClientUserID
            left join ClientPosition D on C.ClientPositionID=D.ClientPositionID
            where A.IsDelete=0 and A.ClientID='{0}' and A.ClientDistributorID={1}" + sqlWhere.ToString(), CurrentUserInfo.ClientID, CurrentUserInfo.ClientDistributorID, CurrentUserInfo.UserID);

            //通用分页查询
            UtilityEntity model = new UtilityEntity();

            model.TableName = "(" + sql.ToString() + ") as A";
            model.PageIndex = pageIndex;
            model.PageSize  = pageSize;
            model.PageSort  = sqlOrder.ToString();
            new UtilityDAO(this.CurrentUserInfo).PagedQuery(model);

            //返回值
            PagedQueryResult <RouteViewEntity> pEntity = new PagedQueryResult <RouteViewEntity>();

            pEntity.RowCount = model.PageTotal;
            if (model.PageDataSet != null &&
                model.PageDataSet.Tables != null &&
                model.PageDataSet.Tables.Count > 0)
            {
                pEntity.Entities = DataLoader.LoadFrom <RouteViewEntity>(model.PageDataSet.Tables[0], new DirectPropertyNameMapping());
            }
            return(pEntity);
        }