public void ExportSelected() { if (documentsContainer.CountSelectedDocuments > 0) { SaveFileDialog sfd = new SaveFileDialog(); sfd.CheckPathExists = true; sfd.Filter = "Archivos JSON (*.json)|*.json|Archivos XML (*.xml)|*.xml"; if (sfd.ShowDialog().Value) { var documents = documentsContainer.GetSelectedDocuments(); var documentWrapper = new CollectionsWrapperDO(); var collection = new CollectionDO(); collection.CollectionName = null; foreach (BsonValue doc in documents) { collection.Documents.Add(JsonSerializer.Serialize(doc)); } documentWrapper.Collections.Add(collection); DataOperationsService.ExportData(documentWrapper, sfd.FileName); } } }
public void ImportSelected() { OpenFileDialog ofd = new OpenFileDialog(); ofd.CheckPathExists = true; ofd.CheckFileExists = true; ofd.Filter = "Archivos JSON (*.json)|*.json|Archivos XML (*.xml)|*.xml"; if (ofd.ShowDialog().Value) { DataOperationsService.ImportData(ofd.FileName, DataOperations.ImportDocuments); } }
public void ExportSelected() { if (dgCollections.SelectedItems.Count > 0) { SaveFileDialog sfd = new SaveFileDialog(); sfd.CheckPathExists = true; sfd.Filter = "Archivos JSON (*.json)|*.json|Archivos XML (*.xml)|*.xml"; if (sfd.ShowDialog().Value) { var collections = new string[dgCollections.SelectedItems.Count]; dgCollections.SelectedItems.CopyTo(collections, 0); DataOperationsService.ExportData(collections, sfd.FileName); } } }