private static void ImportData <T> (ImporterCallback <T> callback, bool usesLocation) { IDataImporter importer; string filename; long? locationId; BusinessDomain.FeedbackProvider.TrackEvent("Import data", typeof(T).Name.CamelSpace()); using (ImportObjects <T> dialog = new ImportObjects <T> (usesLocation)) { if (dialog.Run() != ResponseType.Ok) { return; } importer = dialog.Importer; filename = dialog.FileName; locationId = dialog.Location != null ? dialog.Location.Id : (long?)null; } if (importer.UsesFile && !File.Exists(filename)) { MessageError.ShowDialog(Translator.GetString("Please select a valid source file to import!")); return; } try { PropertyMap propertyMap; using (ImportObjectsMapping <T> dialog = new ImportObjectsMapping <T> (importer, filename)) { if (dialog.Run() != ResponseType.Ok) { return; } propertyMap = dialog.PropertyMap; } ExchangeHelper.ImportObjects(importer, filename, propertyMap, locationId, callback); MessageError.ShowDialog(Translator.GetString("Import completed successfully."), ErrorSeverity.Information); } catch (LicenseLimitationException ex) { MessageError.ShowDialog(ex.Message, ErrorSeverity.Warning, ex); } catch (IOException ex) { MessageError.ShowDialog(Translator.GetString("The selected source file is in use by another application! Please close all other applications and try again."), ErrorSeverity.Warning, ex); } catch (Exception ex) { MessageError.ShowDialog(Translator.GetString("Error occurred while performing import."), ErrorSeverity.Warning, ex); } }