private void continueButton_Button_Pressed(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim().Length > 0)
            {
                oaiUrl = textBox1.Text.Trim();

                repositoryInfo = OAI_Repository_Stream_Reader.Identify(oaiUrl);
                if (repositoryInfo.Is_Valid)
                {
                    OAI_Repository_Stream_Reader.List_Metadata_Formats(repositoryInfo);
                    if (!repositoryInfo.Metadata_Formats.Contains("oai_dc"))
                    {
                        MessageBox.Show(repositoryInfo.Name + " does not support 'oai_dc' metadata format.    ", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MetaTemplate_UserSettings.Last_OAI_URL = oaiUrl;
                        MetaTemplate_UserSettings.Save();
                        DialogResult = DialogResult.OK;
                        Close();
                    }
                }
                else
                {
                    MessageBox.Show("Unable to connect to the OAI-PMH repository listed.\n\nTry checking the URL or your network connections.    ", "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Enter the OAI-PMH Repository URL to continue.  ", "Missing Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public Repository_Details_Form(OAI_Repository_Information Repository)
        {
            InitializeComponent();

            nameLabel.Text         = Repository.Name;
            idLabel.Text           = Repository.Repository_Identifier;
            urlLabel.Text          = Repository.Base_URL;
            protocolLabel.Text     = Repository.Protocol_Version;
            granularityLabel.Text  = Repository.Granularity;
            deleteRecordLabel.Text = Repository.Deleted_Record;
            delimiterLabel.Text    = Repository.Delimiter;
            datestampLabel.Text    = Repository.Earliest_Date_Stamp;
            emailLabel.Text        = Repository.Admin_Email;
            sampleIdLabel.Text     = Repository.Sample_Identifier;

            if (Repository.Metadata_Formats.Count > 0)
            {
                StringBuilder builder = new StringBuilder(Repository.Metadata_Formats[0]);
                for (int i = 1; i < Repository.Metadata_Formats.Count; i++)
                {
                    builder.Append(", " + Repository.Metadata_Formats[i]);
                }
                metadataLabel.Text = builder.ToString();
            }
            else
            {
                metadataLabel.Text = "(none)";
            }

            foreach (KeyValuePair <string, string> thisSet in Repository.Sets)
            {
                listView1.Items.Add(new ListViewItem(new[] { thisSet.Key, thisSet.Value }));
            }
        }
        /// <summary> Constructor for a new instance of the OAI_PMH_Importer_Processor </summary>
        /// <param name="Constant_Collection"> Collection of constant fields and values to be applied to the resulting metadata file</param>
        /// <param name="Destination_Folder"> Destination folder where all metadata should be written </param>
        /// <param name="Repository"> Information about the OAI-PMH repository </param>
        /// <param name="Set_To_Import"> Name of the set of records to import </param>
        /// <param name="BibID_Start"> First portion of the resulting BibID's (i.e., 'UF', 'TEST', etc.. )</param>
        /// <param name="First_BibID"> First numeric value for the resulting BibIDs</param>
        /// <param name="Mappings_Directory"> Directory where the resulting mappings file should be written</param>
        /// <remarks> Each new metadata file will have a BibID which is ten digits long and composed of the BibID_Start and then the next numeric value </remarks>
        public OAI_PMH_Importer_Processor(Constant_Fields Constant_Collection, string Destination_Folder, OAI_Repository_Information Repository, string Set_To_Import, string BibID_Start, int First_BibID, string Mappings_Directory)
        {
            constantCollection = Constant_Collection;
            destination_folder = Destination_Folder;
            repository         = Repository;
            set_to_import      = Set_To_Import;
            mapping_directory  = Mappings_Directory;

            bibid_start        = BibID_Start;
            next_bibid_counter = First_BibID;
        }
        private void testButton_Button_Pressed(object sender, EventArgs e)
        {
            OAI_Repository_Information repositoryInfo = OAI_Repository_Stream_Reader.Identify(textBox1.Text.Trim());

            if (repositoryInfo.Is_Valid)
            {
                OAI_Repository_Stream_Reader.List_Metadata_Formats(repositoryInfo);
                if (repositoryInfo.Metadata_Formats.Contains("oai_dc"))
                {
                    MessageBox.Show("Connection to '" + repositoryInfo.Name + "' successful!  ", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(repositoryInfo.Name + " does not support 'oai_dc' metadata format.    ", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Unable to connect to the OAI-PMH repository listed.\n\nTry checking the URL or your network connections.    ", "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 5
0
        public OAI_PMH_Record_Import_Form(OAI_Repository_Information Repository)
        {
            CheckForIllegalCrossThreadCalls = false;

            InitializeComponent();

            // Try to create a directory under the application first
            try
            {
                mappings_directory = Application.StartupPath + "\\OAI";
                if (!Directory.Exists(mappings_directory))
                {
                    Directory.CreateDirectory(mappings_directory);
                }
                StreamWriter testWriter = new StreamWriter(mappings_directory + "\\test.txt");
                testWriter.WriteLine("PERMISSIONS TEST");
                testWriter.Flush();
                testWriter.Close();
                File.Delete(mappings_directory + "\\test.txt");
            }
            catch (Exception ee)
            {
                try
                {
                    mappings_directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\METS Editor\\OAI";
                    if (!Directory.Exists(mappings_directory))
                    {
                        Directory.CreateDirectory(mappings_directory);
                    }
                    StreamWriter testWriter = new StreamWriter(mappings_directory + "\\test.txt");
                    testWriter.WriteLine("PERMISSIONS TEST");
                    testWriter.Flush();
                    testWriter.Close();
                    File.Delete(mappings_directory + "\\test.txt");
                }
                catch (Exception e)
                {
                    mappings_directory = String.Empty;
                }
            }

            repository = Repository;

            // Get the list of sets
            bool setPullSuccess = OAI_Repository_Stream_Reader.List_Sets(Repository);

            foreach (KeyValuePair <string, string> set in Repository.Sets)
            {
                setComboBox.Items.Add(set.Key + " ( " + set.Value + " )");
            }

            step1Label.ForeColor = ControlPaint.Dark(SystemColors.ActiveCaption);
            step2Label.ForeColor = ControlPaint.LightLight(SystemColors.ActiveCaption);

            constant_map_inputs = new List <Constant_Assignment_Control>();

            // Create the constants mapping custom control
            // Add eight constant user controls to panel
            for (int i = 1; i < 9; i++)
            {
                Constant_Assignment_Control thisConstantCtrl = new Constant_Assignment_Control();
                thisConstantCtrl.Location = new Point(10, 10 + ((i - 1) * 30));
                pnlConstants.Controls.Add(thisConstantCtrl);
                constant_map_inputs.Add(thisConstantCtrl);
            }

            // set some of the constant columns to required tracking fields
            constant_map_inputs[0].Mapped_Name = "First BibID";
            constant_map_inputs[1].Mapped_Name = "Aggregation Code";
        }