Example #1
0
        /// <summary>
        /// 获得所有的库位
        /// </summary>
        /// <returns></returns>
        public List <LocationEntity> GetList()
        {
            string Key = string.Format(CacheKey.JOOSHOW_LOCATION_CACHE, this.CompanyID);
            List <LocationEntity> listResult = CacheHelper.Get <List <LocationEntity> >(Key);

            if (!listResult.IsNullOrEmpty())
            {
                return(listResult);
            }
            LocationEntity entity = new LocationEntity();

            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete)
            .And(a => a.CompanyID == this.CompanyID);
            entity.IncludeAll();
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            listResult = this.Location.GetList(entity);

            if (!listResult.IsNullOrEmpty())
            {
                StorageProvider      storageProvider = new StorageProvider(this.CompanyID);
                List <StorageEntity> listStorage     = storageProvider.GetList();
                listStorage = listStorage.IsNull() ? new List <StorageEntity>() : listStorage;
                foreach (LocationEntity item in listResult)
                {
                    StorageEntity storage = listStorage.FirstOrDefault(a => a.SnNum == item.StorageNum);
                    if (storage != null)
                    {
                        item.StorageName = storage.StorageName;
                    }
                }
                CacheHelper.Insert(Key, listResult);
            }
            return(listResult);
        }
Example #2
0
 /// <summary>
 /// 查询分页
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="pageInfo"></param>
 /// <returns></returns>
 public List <LocationEntity> GetList(LocationEntity entity, ref PageInfo pageInfo)
 {
     try
     {
         entity.IncludeAll();
         entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
         entity.OrderBy(a => a.ID, EOrderBy.DESC);
         int rowCount = 0;
         List <LocationEntity> listResult = this.Location.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);
         pageInfo.RowCount = rowCount;
         if (!listResult.IsNullOrEmpty())
         {
             StorageProvider      storageProvider = new StorageProvider();
             List <StorageEntity> listStorage     = storageProvider.GetList();
             listStorage = listStorage.IsNull() ? new List <StorageEntity>() : listStorage;
             foreach (LocationEntity item in listResult)
             {
                 StorageEntity storage = listStorage.FirstOrDefault(a => a.StorageNum == item.StorageNum);
                 if (storage != null)
                 {
                     item.StorageName = storage.StorageName;
                 }
                 else
                 {
                     item.StorageName = "";
                 }
             }
         }
         return(listResult);
     }
     catch (Exception e)
     {
         log.Error(e.Message);
     }
     return(null);
 }