Exemple #1
0
 public override IEnumerable<FreeDocument> Generate(IFreeDocument document = null)
 {
     var mount = 0;
     if (Mount < 0)
         mount = int.MaxValue;
     TableInfo table = TableNames.SelectItem;
     if (table != null)
     {
         var con = new VirtualDataCollection(table.GetVirtualProvider<IFreeDocument>());
         foreach (var item in con.ComputeData.Skip(Position).Take(mount).Select(d => d.DictSerialize()))
         {
             yield return item;
         }
     }
 }
Exemple #2
0
        public DataCollection ReadCollection(IDataBaseConnector connector, string tableName, bool isVirtual)
        {
            if (isVirtual)
            {
                IItemsProvider<IFreeDocument> vir = null;
                TableInfo tableInfo = connector.RefreshTableNames().FirstOrDefault(d => d.Name == tableName);

                var enumable = connector as IEnumerableProvider<IFreeDocument>;
                if (enumable != null && enumable.CanSkip(tableInfo.Name) == false)
                {
                    vir = new EnumableVirtualProvider<IFreeDocument>(
                        enumable.GetEnumerable(tableInfo.Name), tableInfo.Size);
                }
                else
                {
                    vir = new DataBaseVirtualProvider<IFreeDocument>(tableInfo.Connector, tableInfo.Name);
                }
                int count = 1000;
                if (connector.TypeName == "网页爬虫连接器")
                    count = 100;
                var col = new VirtualDataCollection( vir, count)
                {
                    Name = tableInfo.Name
                };
                AddDataCollection(col);
                return col;
            }
            else
            {
                Task<List<IFreeDocument>> datas = GetDataFromDB(connector, tableName, true);
                DataCollection col = AddDataCollection(datas.Result);
                return col;
            }
        }