public Importer_Form(string default_institution_code, string default_institution_statement)
        {
            InitializeComponent();

            baseImporter_Processor.Default_Institution_Code      = default_institution_code;
            baseImporter_Processor.Default_Institution_Statement = default_institution_statement;

            Constant_Assignment_Control.Set_Aggregation_Table(SobekCM.Library.Database.SobekCM_Database.Get_Codes_Item_Aggregations(true, null));
        }
        /// <summary> Browse to the source file to import </summary>
        protected void Browse_Source()
        {
            // reset the status label
            labelStatus.Text = "";

            // Launch the open file dialog
            if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                // Save this file name
                this.sourceTextBox.Text = openFileDialog1.FileName;

                // Determine the output file
                FileInfo inputInfo = new FileInfo(this.sourceTextBox.Text);

                // Enable the ok button
                this.executeButton.Button_Enabled = true;

                // populate the Contants Tab if the constant_map_inputs collection is empty
                if (this.constant_map_inputs.Count == 0)
                {
                    // 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(sourceTextBox.Text);
                    string   name     = fileInfo.Name.Replace(fileInfo.Extension, "");
                    if (name.ToUpper() == "ODDLOTS")
                    {
                        name = name + DateTime.Now.Year + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0');
                    }
                    constant_map_inputs[3].Mapped_Constant = name;
                }

                // show step 2 instructions
                show_step_2();
            }
            else
            {
                // Clear the current file
                this.sourceTextBox.Clear();
                this.executeButton.Button_Enabled = false;

                // show step 1 instructions
                show_step_1();
            }
        }
Beispiel #3
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";
        }
Beispiel #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();
            }
        }
        /// <summary> Browse to the source file to import </summary>
        protected void Browse_Source()
        {
            // reset the status label
            labelStatus.Text = "";

            // Launch the open file dialog
            if ( this.openFileDialog1.ShowDialog() == DialogResult.OK )
            {
                // Save this file name
                this.sourceTextBox.Text = openFileDialog1.FileName;

                // Determine the output file
                FileInfo inputInfo = new FileInfo( this.sourceTextBox.Text );

                // Enable the ok button
                this.executeButton.Button_Enabled = true;

                // populate the Contants Tab if the constant_map_inputs collection is empty
                if (this.constant_map_inputs.Count == 0)
                {
                    // 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(sourceTextBox.Text);
                    string name = fileInfo.Name.Replace(fileInfo.Extension, "");
                    if ( name.ToUpper() == "ODDLOTS" )
                        name = name + DateTime.Now.Year + DateTime.Now.Month.ToString().PadLeft(2,'0') + DateTime.Now.Day.ToString().PadLeft(2,'0');
                    constant_map_inputs[3].Mapped_Constant = name;
                }

                // show step 2 instructions
                show_step_2();
            }
            else
            {
                // Clear the current file
                this.sourceTextBox.Clear();
                this.executeButton.Button_Enabled = false;

                // show step 1 instructions
                show_step_1();
            }
        }
        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();
            }
        }