internal static EndnoteDatabaseDetails DetectEndnoteDatabaseDetails()
        {
            EndnoteDatabaseDetails edd = new EndnoteDatabaseDetails();

            foreach (string endnote_database_filename in GetRecentEndnoteDatabases())
            {
                try
                {
                    Logging.Info("Reading Endnote database '{0}'", endnote_database_filename);
                    using (MemoryStream ms = MYDDatabase.OpenMYDDatabase(endnote_database_filename))
                    {
                        ++edd.databases_found;

                        MYDBinaryReader br = new MYDBinaryReader(ms);
                        foreach (MYDRecord record in MYDRecordReader.Records(br))
                        {
                            try
                            {
                                ImportingIntoLibrary.FilenameWithMetadataImport fwmi = ConvertEndnoteToFilenameWithMetadataImport(endnote_database_filename, record);
                                edd.metadata_imports.Add(fwmi);

                                // Update statistics
                                ++edd.documents_found;
                                if (null != fwmi.filename)
                                {
                                    ++edd.pdfs_found;
                                }
                            }

                            catch (Exception ex)
                            {
                                Logging.Warn(ex, "Problem processing Endnote record.");
                            }
                        }
                    }
                }

                catch (Exception ex)
                {
                    Logging.Warn(ex, "Exception while reading Endnote database '{0}'", endnote_database_filename);
                }
            }

            return(edd);
        }
        public static void Test(string enl_filename)
        {
            Logging.Info("Importing from EndNote");

            Dictionary <int, List <string> >       record_types       = new Dictionary <int, List <string> >();
            Dictionary <string, HashSet <string> > field_utilisations = new Dictionary <string, HashSet <string> >();
            {
                for (int i = 0; i < EndnoteConstants.FIELD_NAMES.Length; ++i)
                {
                    field_utilisations[EndnoteConstants.FIELD_NAMES[i]] = new HashSet <string>();
                }
            }

            // Then read each row
            MemoryStream    ms = MYDDatabase.OpenMYDDatabase(enl_filename);
            MYDBinaryReader br = new MYDBinaryReader(ms);

            foreach (MYDRecord record in MYDRecordReader.Records(br))
            {
                if (!record_types.ContainsKey(record.reference_type))
                {
                    record_types[record.reference_type] = new List <string>();
                }

                if (record.fields.ContainsKey("title"))
                {
                    record_types[record.reference_type].Add(record.fields["title"]);
                }

                foreach (var pair in record.fields)
                {
                    field_utilisations[pair.Key].Add(pair.Value);
                }
            }

            foreach (var pair in field_utilisations)
            {
                string sb = "";
                sb += Convert.ToString(pair.Key);
                sb += "\t --> ";
                foreach (var name in pair.Value)
                {
                    sb += name;
                    sb += " ";
                }

                Logging.Info("{0}", sb);
            }

            foreach (var pair in record_types)
            {
                string sb = "";
                sb += Convert.ToString(pair.Key);
                sb += "\t --> ";
                foreach (var name in pair.Value)
                {
                    sb += name;
                    sb += " ";
                }

                Logging.Info("{0}", sb);
            }
        }