public static IEnumerable <IFreeDocument> InserDataCollection(this IDataBaseConnector connector, DataCollection collection, string tableName = null, int batchMount = 1000) { return(collection.ComputeData.BatchDo(data => { if (tableName == null) { tableName = collection.Name; } List <string> columns = new List <string>(); var sample = data.MergeToDocument(); columns = data.GetKeys().ToList(); if (connector.RefreshTableNames().FirstOrDefault(d => d.Name == tableName) == null) { var result = connector.CreateTable(sample, tableName); if (result == false) { throw new Exception(String.Format(GlobalHelper.Get("key_349"), tableName)); } // connector.RefreshTableNames(); } return columns; }, (list, columns) => { connector.BatchInsert(list, (List <string>)columns, collection.Name); })); }
public static IEnumerable <int> InserDataCollection(this IDataBaseConnector connector, DataCollection collection, string tableName = null, int batchMount = 1000) { if (tableName == null) { tableName = collection.Name; } if (connector.RefreshTableNames().FirstOrDefault(d => d.Name == tableName) == null) { connector.CreateTable(collection.ComputeData.First(), tableName); } var i = 0; var list = new List <IFreeDocument>(); while (i < collection.Count) { list.Add(collection.ComputeData[i]); if (list.Count == batchMount) { connector.BatchInsert(list, tableName); list = new List <IFreeDocument>(); yield return(i); } i++; } connector.BatchInsert(list, collection.Name); }
private void RefreshConnect(IDataBaseConnector connector) { if (!connector.ConnectDB()) { MessageBox.Show(connector.Name + "强制刷新连接失败"); return; } connector.RefreshTableNames(); }
private void RefreshConnect(IDataBaseConnector connector) { if (!connector.ConnectDB()) { MessageBox.Show(connector.Name + GlobalHelper.Get("key_259")); return; } connector.RefreshTableNames(); }
private void DropTable(IDataBaseConnector connector, string dataName) { if ( MessageBox.Show( "确定对数据表" + dataName + "执行删除操作吗?", "警告信息", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { connector.DropTable(dataName); connector.RefreshTableNames(); } }
private void DropTable(IDataBaseConnector connector, string dataName) { if ( MessageBox.Show( GlobalHelper.Get("key_257") + dataName + GlobalHelper.Get("key_258"), GlobalHelper.Get("key_151"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) { connector.DropTable(dataName); connector.RefreshTableNames(); } }
public int FetchCount() { if (count == null) { var table = connector.RefreshTableNames().FirstOrDefault(d => d.Name == tableName); if (table != null) { count = table.Size; } return(count.Value); } else { return(count.Value); } }
public static IEnumerable <IFreeDocument> InserDataCollection(this IDataBaseConnector connector, DataCollection collection, string tableName = null, int batchMount = 1000) { return(collection.ComputeData.BatchDo(data => { if (tableName == null) { tableName = collection.Name; } if (connector.RefreshTableNames().FirstOrDefault(d => d.Name == tableName) == null) { connector.CreateTable(data, tableName); } return true; }, list => { connector.BatchInsert(list, collection.Name); })); }
public async Task <List <IFreeDocument> > GetDataFromDB(IDataBaseConnector db, string dataName, bool isNewData, int mount = -1) { if (db == null) { return(null); } var table = db.RefreshTableNames().FirstOrDefault(d => d.Name == dataName); var dataAll = new List <IFreeDocument>(); var task = TemporaryTask.AddTempTask(dataName + "数据导入", db.GetEntities(dataName, mount), dataAll.Add, null, table != null?table.Size:-1, notifyInterval: 1000); processManager.CurrentProcessTasks.Add(task); await Task.Run( () => task.Wait()); return(dataAll); }
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); } }
public async Task<List<IFreeDocument>> GetDataFromDB(IDataBaseConnector db, string dataName, bool isNewData, int mount = -1) { if (db == null) { return null; } var table = db.RefreshTableNames().FirstOrDefault(d => d.Name == dataName); var dataAll = new List<IFreeDocument>(); var task = TemporaryTask.AddTempTask(dataName + "数据导入", db.GetEntities(dataName, typeof (FreeDocument), mount), dataAll.Add,null,table!=null?table.Size:-1,notifyInterval:1000); processManager.CurrentProcessTasks.Add(task); await Task.Run( () => task.Wait()); return dataAll; }
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; } }