public override void InsertRecords(string tableName, IEnumerable <Record> records) { var collection = new RecordCollection(); collection.AddRange(records); using (var excel = ExcelOpenXmlDocument.Load(ConnectionDetails.Database)) { var data = collection.ToDataTable(); excel.Import(data, tableName, true, (uint)(excel.GetRowCount(tableName) + 1)); } }
//------------------------- ОКРЫТЬ И ЗАГРУЗИТЬ В КОЛЛЕКЦИЮ СПИСОК ФАЙЛОВ --------------------------------- private void OpenFolderAndLoadSound() { FileDialogViewModel DialogViewModel = new FileDialogViewModel(); DialogViewModel.CurrentFolder = Directory.GetCurrentDirectory(); DialogViewModel.Extension = "*.mp3"; DialogViewModel.Filter = "Wave file|*.wav|Mp3 file|*.mp3|All Files(.*)|*.*"; DialogViewModel.Title = "Выбор медиа файла"; if (DialogViewModel.OpenCommand.CanExecute(null)) { DialogViewModel.OpenCommand.Execute(null); } RecordCollection.AddRange(DialogViewModel.FileNames); MyRecords = new ObservableCollection <Record>(RecordCollection.GetList()); OnPropertyChanged("MyRecords"); }
// 获得记录 // 确保一定可以获得nCount个 int DoPresent( ZConnection connection, string strResultSetName, int nStart, int nCount, string strElementSetName, string strPreferredRecordSyntax, out RecordCollection records, out string strError) { records = new RecordCollection(); if (nCount == 0) { strError = "nCount为0"; return 0; } int nGeted = 0; for (; ; ) { RecordCollection temprecords = null; int nRet = DoOncePresent( connection, strResultSetName, nStart + nGeted, nCount - nGeted, strElementSetName, strPreferredRecordSyntax, out temprecords, out strError); if (nRet == -1) return -1; if (temprecords == null) break; nGeted += temprecords.Count; if (temprecords.Count > 0) records.AddRange(temprecords); if (nGeted >= nCount || temprecords.Count == 0) break; } return 0; }