/// <summary> Imports the records from the indicated source file </summary>
        protected void Import_Records()
        {
            // Step through each constant map control
            Constant_Fields constantCollection = new Constant_Fields();

            foreach (Constant_Assignment_Control thisConstant in constant_map_inputs)
            {
                constantCollection.Add(thisConstant.Mapped_Field, thisConstant.Mapped_Constant);
            }

            // METS files are not created from the MARC Importer; set flag to false.
            bool create_mets = false;
            bool deriveCopyrightStatusFromMARC = false;

            // validate the form
            if (!Validate_Import_MARC_Form())
            {
                this.Enable_FormControls();
                return;
            }

            // disable some of the form controls
            this.Disable_FormControls();

            // Show the progress bar
            this.progressBar1.Visible = true;
            this.progressBar1.Maximum = 10;
            this.progressBar1.Value   = 0;

            // reset the status label
            labelStatus.Text = "";

            try
            {
                // Create the Processor and assign the Delegate method for event processing.
                processor = new MARC_Importer_Processor(this.sourceTextBox.Text, justSaveMarcXmlCheckBox.Checked, "", constantCollection, previewCheckBox.Checked, workingFolder + "\\ERROR");
                processor.New_Progress += new New_Importer_Progress_Delegate(processor_New_Progress);
                processor.Complete     += new New_Importer_Progress_Delegate(processor_Complete);

                // Create the thread to do the processing work, and start it.
                processThread = new Thread(new ThreadStart(processor.Do_Work));
                processThread.SetApartmentState(ApartmentState.STA);
                processThread.Start();
            }
            catch (Exception e)
            {
                // display the error message
                DLC.Tools.Forms.ErrorMessageBox.Show("Error encountered while processing!\n\n" + e.Message, "DLC Importer Error", e);

                // enable form controls on the Importer form
                this.Enable_FormControls();

                this.Cursor        = Cursors.Default;
                progressBar1.Value = progressBar1.Minimum;
            }
        }
        /// <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;
        }
Example #3
0
        private void executeButton_Button_Pressed(object sender, EventArgs e)
        {
            // Step through each constant map control
            Constant_Fields constantCollection = new Constant_Fields();
            string          first_bibid        = String.Empty;

            foreach (Constant_Assignment_Control thisConstant in constant_map_inputs)
            {
                if (thisConstant.Mapped_Name == "First BibID")
                {
                    first_bibid = thisConstant.Mapped_Constant;
                }
                else
                {
                    constantCollection.Add(thisConstant.Mapped_Field, thisConstant.Mapped_Constant);
                }
            }

            // validate the form
            if ((folderTextBox.Text.Trim().Length == 0) || (!Directory.Exists(folderTextBox.Text.Trim())))
            {
                MessageBox.Show("Enter a valid destination folder.   ", "Invalid Destination Folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (first_bibid.Length < 3)
            {
                MessageBox.Show("You must enter a constant for the 'First BibID' value and it must begin with two letters.   \n\nThis is the first ObjectID that will be used for the resulting METS files.      ", "Choose First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (first_bibid.Length > 10)
            {
                MessageBox.Show("The complete BibID/ObjectID cannot be longer than 10 digits.      ", "Invalid First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Pad the bibid to 10 digits, in case it is not 10
            first_bibid = first_bibid.PadRight(10, '0');

            // First two must be characters
            if ((!Char.IsLetter(first_bibid[0])) || (!Char.IsLetter(first_bibid[1])))
            {
                MessageBox.Show("You must enter a constant for the 'First BibID' value and it must begin with two letters.   \n\nThis is the first ObjectID that will be used for the resulting METS files.      ", "Choose First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check that it ends in numbers
            if ((!Char.IsNumber(first_bibid[9])) || (!Char.IsNumber(first_bibid[8])) || (!Char.IsNumber(first_bibid[7])) || (!Char.IsNumber(first_bibid[6])))
            {
                MessageBox.Show("The last four digits of the BibID must be numeric.    \n\nTry shortening the length or changing trailing characters to numers.      ", "Invalid First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Try to break the first_bibid up into character portion and number portion
            int numbers_start = 9;

            for (int i = 9; i >= 0; i--)
            {
                if (!Char.IsNumber(first_bibid[i]))
                {
                    numbers_start = i + 1;
                    break;
                }
            }
            string bibid_start     = first_bibid.Substring(0, numbers_start);
            int    first_bibid_int = Convert.ToInt32(first_bibid.Substring(numbers_start));

            executeButton.Button_Enabled = false;

            string set_to_import = setComboBox.Text;

            if (set_to_import.IndexOf("(") > 0)
            {
                set_to_import = set_to_import.Substring(0, set_to_import.IndexOf("(")).Trim();
            }

            // Show the progress bar
            progressBar1.Visible = true;
            progressBar1.Maximum = 10;
            progressBar1.Value   = 0;

            // reset the status label
            labelStatus.Text = "";

            try
            {
                // Create the Processor and assign the Delegate method for event processing.
                OAI_PMH_Importer_Processor processor = new OAI_PMH_Importer_Processor(constantCollection, folderTextBox.Text.Trim(), repository, set_to_import, bibid_start, first_bibid_int, mappings_directory);
                processor.New_Progress += processor_New_Progress;
                processor.Complete     += processor_Complete;

                // Create the thread to do the processing work, and start it.
                processThread = new Thread(processor.Do_Work);
                processThread.SetApartmentState(ApartmentState.STA);
                processThread.Start();
            }
            catch (Exception ee)
            {
                // display the error message

                ErrorMessageBox.Show("Error encountered while processing!\n\n" + ee.Message, "METS Editor Error", ee);

                Cursor             = Cursors.Default;
                progressBar1.Value = progressBar1.Minimum;

                executeButton.Button_Enabled = true;
            }
        }
Example #4
0
        private void sheetComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ExcelBibliographicReader read = new ExcelBibliographicReader();

            try
            {
                // Make sure there is a filename and a sheet name
                if ((fileTextBox.Text.Length > 0) && (sheetComboBox.SelectedIndex >= 0))
                {
                    // reset the status label
                    labelStatus.Text = "";

                    read.Sheet    = sheetComboBox.Text;
                    read.Filename = fileTextBox.Text;

                    // Declare constant fields
                    Constant_Fields constants = new Constant_Fields();

                    columnNamePanel.Controls.Clear();
                    column_map_inputs.Clear();

                    pnlConstants.Controls.Clear();
                    constant_map_inputs.Clear();

                    columnNamePanel.Enabled = true;
                    pnlConstants.Enabled    = true;

                    // Display an hourglass cursor:
                    this.Cursor = Cursors.WaitCursor;


                    // Try reading data from the selected Excel Worksheet
                    bool readFlag = true;

                    while (readFlag)
                    {
                        try
                        {
                            if (!read.Check_Source())
                            {
                                ResetFormControls();
                                return;
                            }
                            else
                            {
                                readFlag = false;
                            }
                        }
                        catch (Exception ex)
                        {
                            DLC.Tools.Forms.ErrorMessageBox.Show(ex.Message, "Unexpected Error", ex);
                        }
                    }


                    // change cursor back to default
                    this.Cursor = Cursors.Default;

                    this.excelDataTbl = read.excelData;

                    if (read.excelData.Rows.Count > 0 || read.excelData.Columns.Count > 0)
                    {
                        int column_counter = 1;
                        foreach (DataColumn thisColumn in excelDataTbl.Columns)
                        {
                            // Create the column mapping custom control
                            Column_Assignment_Control thisColControl = new Column_Assignment_Control();

                            // Get the column name
                            string thisColumnName = thisColumn.ColumnName;
                            thisColControl.Column_Name = thisColumnName;
                            if (thisColumnName == "F" + column_counter)
                            {
                                thisColControl.Empty = true;
                            }

                            thisColControl.Location = new Point(10, 10 + ((column_counter - 1) * 30));
                            this.columnNamePanel.Controls.Add(thisColControl);
                            this.column_map_inputs.Add(thisColControl);

                            // Select value in list control that matches to a Column Name
                            thisColControl.Select_List_Item(thisColumnName);

                            // Increment for the next column
                            column_counter++;
                        }


                        // 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));
                            this.pnlConstants.Controls.Add(thisConstantCtrl);
                            this.constant_map_inputs.Add(thisConstantCtrl);
                        }

                        // set some of the constant columns to required tracking fields
                        constant_map_inputs[0].Mapped_Name = "Material Type";
                        constant_map_inputs[1].Mapped_Name = "Aggregation Code";
                        constant_map_inputs[2].Mapped_Name = "Visibility";
                        constant_map_inputs[3].Mapped_Name = "Tickler";
                        FileInfo fileInfo = new FileInfo(fileTextBox.Text);
                        constant_map_inputs[3].Mapped_Constant = fileInfo.Name.Replace(fileInfo.Extension, "");

                        // Move to STEP 3
                        show_step_3();

                        if (column_map_inputs.Count > 0)
                        {
                            // Move to STEP 4
                            show_step_4();
                        }
                    }


                    // Close the reader
                    read.Close();
                }
            }
            catch (Exception ex)
            {
                DLC.Tools.Forms.ErrorMessageBox.Show(ex.Message, "Unexpected Error", ex);
            }
            finally
            {
                // change cursor back to default
                this.Cursor = Cursors.Default;

                // Close the reader
                read.Close();
            }
        }
Example #5
0
        private void write_mappings_and_constants(DataTable inputFile, List <SobekCM.Resource_Object.Mapped_Fields> mapping, Constant_Fields constantCollection)
        {
            try
            {
                string       mapping_name  = filename + ".importdata";
                StreamWriter mappingWriter = new StreamWriter(mapping_name, false);
                mappingWriter.WriteLine("MAPPING:");
                int column = 0;
                foreach (SobekCM.Resource_Object.Mapped_Fields mappedField in mapping)
                {
                    mappingWriter.WriteLine("\t\"" + inputFile.Columns[column].ColumnName.Replace("\"", "&quot;") + "\" --> " + SobekCM.Resource_Object.Bibliographic_Mapping.Mapped_Field_To_String(mappedField));
                    column++;
                }
                mappingWriter.WriteLine();
                mappingWriter.WriteLine("CONSTANTS:");
                foreach (Constant_Field_Data constantData in constantCollection.constantCollection)
                {
                    if ((constantData.Data.Length > 0) && (constantData.Field != SobekCM.Resource_Object.Mapped_Fields.None))
                    {
                        mappingWriter.WriteLine("\t" + SobekCM.Resource_Object.Bibliographic_Mapping.Mapped_Field_To_String(constantData.Field) + " <-- \"" + constantData.Data.Replace("\"", "&quot;"));
                    }
                }

                mappingWriter.Flush();
                mappingWriter.Close();
            }
            catch (Exception ee)
            {
                MessageBox.Show("Unable to save the import data for this job.    \n\n" + ee.ToString(), "Error saving mapping", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #6
0
        /// <summary> Imports the records from the indicated source file </summary>
        protected void Import_Records(System.Data.DataTable inputFile)
        {
            // update class variable
            this.excelDataTbl = inputFile;

            // Display an hourglass cursor and set max value on the ProgressBar
            this.Cursor          = Cursors.WaitCursor;
            progressBar1.Maximum = this.Total_Records;

            // Step through each column map control
            List <SobekCM.Resource_Object.Mapped_Fields> mapping = new List <SobekCM.Resource_Object.Mapped_Fields>();

            foreach (Column_Assignment_Control thisColumn in column_map_inputs)
            {
                mapping.Add(thisColumn.Mapped_Field);
            }

            // Step through each constant map control
            Constant_Fields constantCollection = new Constant_Fields();

            foreach (Constant_Assignment_Control thisConstant in constant_map_inputs)
            {
                constantCollection.Add(thisConstant.Mapped_Field, thisConstant.Mapped_Constant);
            }

            //add columns to the input data table
            if (!excelDataTbl.Columns.Contains("New BIB ID"))
            {
                excelDataTbl.Columns.Add("New BIB ID");
            }
            else
            {
                excelDataTbl.Columns.Remove("New BIB ID");
                excelDataTbl.Columns.Add("New BIB ID");
            }

            if (!excelDataTbl.Columns.Contains("New VID ID"))
            {
                excelDataTbl.Columns.Add("New VID ID");
            }
            else
            {
                excelDataTbl.Columns.Remove("New VID ID");
                excelDataTbl.Columns.Add("New VID ID");
            }

            if (!excelDataTbl.Columns.Contains("Messages"))
            {
                excelDataTbl.Columns.Add("Messages");
            }
            else
            {
                excelDataTbl.Columns.Remove("Messages");
                excelDataTbl.Columns.Add("Messages");
            }

            // disable some of the form controls
            this.Disable_FormControls();

            // enable the Stop button
            this.executeButton.Button_Enabled = true;

            // Show the progress bar
            this.progressBar1.Visible = true;
            progressBar1.Value        = progressBar1.Minimum;

            // reset the status label
            labelStatus.Text = "";

            this.previewCheckBox.Enabled = false;

            // Write the current mappings, etc..
            write_mappings_and_constants(inputFile, mapping, constantCollection);

            try
            {
                // Create the Processor and assign the Delegate method for event processing.
                processor = new SpreadSheet_Importer_Processor(inputFile, mapping, constantCollection, previewCheckBox.Checked);
                processor.New_Progress += new New_Importer_Progress_Delegate(processor_New_Progress);
                processor.Complete     += new New_Importer_Progress_Delegate(processor_Complete);

                // Create the thread to do the processing work, and start it.
                processThread = new Thread(new ThreadStart(processor.Do_Work));
                processThread.SetApartmentState(ApartmentState.STA);
                processThread.Start();
            }
            catch (Exception e)
            {
                // display the error message
                DLC.Tools.Forms.ErrorMessageBox.Show("Error encountered while processing!\n\n" + e.Message, "DLC Importer Error", e);

                // enable form controls on the Importer form
                this.Enable_FormControls();

                this.Cursor        = Cursors.Default;
                progressBar1.Value = progressBar1.Minimum;
            }
        }
        /// <summary> Imports the records from the indicated source file </summary>
        protected void Import_Records()
        {
            // Step through each constant map control
            Constant_Fields constantCollection = new Constant_Fields();

            foreach (Constant_Assignment_Control thisConstant in constant_map_inputs)
            {
                constantCollection.Add(thisConstant.Mapped_Field, thisConstant.Mapped_Constant);
            }

            // METS files are not created from the MARC Importer; set flag to false.
            bool create_mets = false;
            bool deriveCopyrightStatusFromMARC = false;

            // validate the form
            if (!Validate_Import_MARC_Form())
            {
                this.Enable_FormControls();
                return;
            }

            // disable some of the form controls
            this.Disable_FormControls();

            // Show the progress bar
            this.progressBar1.Visible = true;
            this.progressBar1.Maximum = 10;
            this.progressBar1.Value = 0;

            // reset the status label
            labelStatus.Text = "";

            try
            {
                // Create the Processor and assign the Delegate method for event processing.
                processor = new MARC_Importer_Processor(this.sourceTextBox.Text, justSaveMarcXmlCheckBox.Checked, "", constantCollection, previewCheckBox.Checked, workingFolder + "\\ERROR" );
                processor.New_Progress += new New_Importer_Progress_Delegate(processor_New_Progress);
                processor.Complete += new New_Importer_Progress_Delegate(processor_Complete);

                // Create the thread to do the processing work, and start it.
                processThread = new Thread(new ThreadStart(processor.Do_Work));
                processThread.SetApartmentState(ApartmentState.STA);
                processThread.Start();
            }
            catch (Exception e)
            {
                // display the error message
                DLC.Tools.Forms.ErrorMessageBox.Show("Error encountered while processing!\n\n" + e.Message, "DLC Importer Error", e);

                // enable form controls on the Importer form
                this.Enable_FormControls();

                this.Cursor = Cursors.Default;
                progressBar1.Value = progressBar1.Minimum;
            }
        }
        private void sheetComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ExcelBibliographicReader read = new ExcelBibliographicReader();

            try
            {

                // Make sure there is a filename and a sheet name
                if ((fileTextBox.Text.Length > 0) && (sheetComboBox.SelectedIndex >= 0))
                {
                    // reset the status label
                    labelStatus.Text = "";

                    read.Sheet = sheetComboBox.Text;
                    read.Filename = fileTextBox.Text;

                    // Declare constant fields
                    Constant_Fields constants = new Constant_Fields();

                    columnNamePanel.Controls.Clear();
                    column_map_inputs.Clear();

                    pnlConstants.Controls.Clear();
                    constant_map_inputs.Clear();

                    columnNamePanel.Enabled = true;
                    pnlConstants.Enabled = true;

                    // Display an hourglass cursor:
                    this.Cursor = Cursors.WaitCursor;

                    // Try reading data from the selected Excel Worksheet
                    bool readFlag = true;

                    while (readFlag)
                    {

                        try
                        {
                            if (!read.Check_Source())
                            {
                                ResetFormControls();
                                return;
                            }
                            else
                            {
                                readFlag = false;
                            }
                        }
                        catch (Exception ex)
                        {
                            DLC.Tools.Forms.ErrorMessageBox.Show(ex.Message, "Unexpected Error", ex);
                        }
                    }

                    // change cursor back to default
                    this.Cursor = Cursors.Default;

                    this.excelDataTbl = read.excelData;

                    if (read.excelData.Rows.Count > 0 || read.excelData.Columns.Count > 0)
                    {

                        int column_counter = 1;
                        foreach (DataColumn thisColumn in excelDataTbl.Columns)
                        {

                            // Create the column mapping custom control
                            Column_Assignment_Control thisColControl = new Column_Assignment_Control();

                            // Get the column name
                            string thisColumnName = thisColumn.ColumnName;
                            thisColControl.Column_Name = thisColumnName;
                            if (thisColumnName == "F" + column_counter)
                            {
                                thisColControl.Empty = true;
                            }

                            thisColControl.Location = new Point(10, 10 + ((column_counter - 1) * 30));
                            this.columnNamePanel.Controls.Add(thisColControl);
                            this.column_map_inputs.Add(thisColControl);

                            // Select value in list control that matches to a Column Name
                            thisColControl.Select_List_Item(thisColumnName);

                            // Increment for the next column
                            column_counter++;
                        }

                        // 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));
                            this.pnlConstants.Controls.Add(thisConstantCtrl);
                            this.constant_map_inputs.Add(thisConstantCtrl);
                        }

                        // set some of the constant columns to required tracking fields
                        constant_map_inputs[0].Mapped_Name = "Material Type";
                        constant_map_inputs[1].Mapped_Name = "Aggregation Code";
                        constant_map_inputs[2].Mapped_Name = "Visibility";
                        constant_map_inputs[3].Mapped_Name = "Tickler";
                        FileInfo fileInfo = new FileInfo(fileTextBox.Text);
                        constant_map_inputs[3].Mapped_Constant = fileInfo.Name.Replace(fileInfo.Extension,"");

                        // Move to STEP 3
                        show_step_3();

                        if (column_map_inputs.Count > 0)
                            // Move to STEP 4
                            show_step_4();
                    }

                    // Close the reader
                    read.Close();

                }

            }
            catch (Exception ex)
            {
                DLC.Tools.Forms.ErrorMessageBox.Show(ex.Message, "Unexpected Error", ex);
            }
            finally
            {
                // change cursor back to default
                this.Cursor = Cursors.Default;

                // Close the reader
                read.Close();
            }
        }
        /// <summary> Imports the records from the indicated source file </summary>
        protected void Import_Records(System.Data.DataTable inputFile)
        {
            // update class variable
            this.excelDataTbl = inputFile;

            // Display an hourglass cursor and set max value on the ProgressBar
            this.Cursor = Cursors.WaitCursor;
            progressBar1.Maximum = this.Total_Records;

            // Step through each column map control
            List<SobekCM.Resource_Object.Mapped_Fields> mapping = new List<SobekCM.Resource_Object.Mapped_Fields>();
            foreach (Column_Assignment_Control thisColumn in column_map_inputs)
            {
                mapping.Add(thisColumn.Mapped_Field);
            }

            // Step through each constant map control
            Constant_Fields constantCollection = new Constant_Fields();

            foreach (Constant_Assignment_Control thisConstant in constant_map_inputs)
            {
                constantCollection.Add(thisConstant.Mapped_Field, thisConstant.Mapped_Constant);
            }

            //add columns to the input data table
            if (!excelDataTbl.Columns.Contains("New BIB ID"))
                excelDataTbl.Columns.Add("New BIB ID");
            else
            {
                excelDataTbl.Columns.Remove("New BIB ID");
                excelDataTbl.Columns.Add("New BIB ID");
            }

            if (!excelDataTbl.Columns.Contains("New VID ID"))
                excelDataTbl.Columns.Add("New VID ID");
            else
            {
                excelDataTbl.Columns.Remove("New VID ID");
                excelDataTbl.Columns.Add("New VID ID");
            }

            if (!excelDataTbl.Columns.Contains("Messages"))
                excelDataTbl.Columns.Add("Messages");
            else
            {
                excelDataTbl.Columns.Remove("Messages");
                excelDataTbl.Columns.Add("Messages");
            }

            // disable some of the form controls
            this.Disable_FormControls();

            // enable the Stop button
            this.executeButton.Button_Enabled = true;

            // Show the progress bar
            this.progressBar1.Visible = true;
            progressBar1.Value = progressBar1.Minimum;

            // reset the status label
            labelStatus.Text = "";

            this.previewCheckBox.Enabled = false;

            // Write the current mappings, etc..
            write_mappings_and_constants( inputFile, mapping, constantCollection);

            try
            {
                // Create the Processor and assign the Delegate method for event processing.
                processor = new SpreadSheet_Importer_Processor(inputFile, mapping, constantCollection, previewCheckBox.Checked );
                processor.New_Progress += new New_Importer_Progress_Delegate(processor_New_Progress);
                processor.Complete += new New_Importer_Progress_Delegate(processor_Complete);

                // Create the thread to do the processing work, and start it.
                processThread = new Thread(new ThreadStart(processor.Do_Work));
                processThread.SetApartmentState(ApartmentState.STA);
                processThread.Start();
            }
            catch (Exception e)
            {
                // display the error message
                DLC.Tools.Forms.ErrorMessageBox.Show("Error encountered while processing!\n\n" + e.Message, "DLC Importer Error", e);

                // enable form controls on the Importer form
                this.Enable_FormControls();

                this.Cursor = Cursors.Default;
                progressBar1.Value = progressBar1.Minimum;
            }
        }
        private void write_mappings_and_constants(DataTable inputFile, List<SobekCM.Resource_Object.Mapped_Fields> mapping, Constant_Fields constantCollection)
        {
            try
            {
                string mapping_name = filename + ".importdata";
                StreamWriter mappingWriter = new StreamWriter(mapping_name, false);
                mappingWriter.WriteLine("MAPPING:");
                int column = 0;
                foreach (SobekCM.Resource_Object.Mapped_Fields mappedField in mapping)
                {
                    mappingWriter.WriteLine("\t\"" + inputFile.Columns[column].ColumnName.Replace("\"", "&quot;") + "\" --> " + SobekCM.Resource_Object.Bibliographic_Mapping.Mapped_Field_To_String(mappedField));
                    column++;
                }
                mappingWriter.WriteLine();
                mappingWriter.WriteLine("CONSTANTS:");
                foreach (Constant_Field_Data constantData in constantCollection.constantCollection )
                {
                    if ((constantData.Data.Length > 0) && (constantData.Field != SobekCM.Resource_Object.Mapped_Fields.None))
                    {
                        mappingWriter.WriteLine("\t" + SobekCM.Resource_Object.Bibliographic_Mapping.Mapped_Field_To_String(constantData.Field) + " <-- \"" + constantData.Data.Replace("\"", "&quot;"));
                    }
                }

                mappingWriter.Flush();
                mappingWriter.Close();
            }
            catch (Exception ee)
            {
                MessageBox.Show("Unable to save the import data for this job.    \n\n" + ee.ToString(), "Error saving mapping", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }