protected baseImporter_Processor(Constant_Fields constantCollection)
        {
            // Create the objects to keep track of errors and items processed
            report = new Importer_Report();
            errors = new List<string>();
            warnings = new List<string>();

            // Save the parameters
            this.constantCollection = constantCollection;

            // Set some constants;
            recordsSavedToDB = 0;
            recordsProcessed = 0;
            recordsSkipped = 0;
            errorCnt = 0;
            preview_counter = 1;
            allow_overlay = false;

            // Load the data tables needed
            //     TrackingDB.CS_TrackingDatabase.Refresh_Bib_Table();
            allInstitutions = SobekCM.Library.Database.SobekCM_Database.Get_Codes_Item_Aggregations(null);

            // Declare the lists which will hold the new bib id and receiving id information
            Provided_Bib_To_New_Bib = new Dictionary<string, string>();
            Provided_Bib_To_New_Receiving = new Dictionary<string, int>();
            New_Bib_IDs = new List<string>();

            // Set some defaults
            default_projects = new List<string>();
            default_material_type = String.Empty;
        }
        /// <summary> Constructor for a new instance of this class </summary>
        /// <param name="fields"> Fields which will be added to each record created </param>
        /// <param name="inputFile"> Text of the input file </param>
        /// <param name="outputFile"> Text for the output file as well </param>
        public MARC_Importer_Processor(string inputFile, bool JustSaveMarcXML, string ProjectCode, Constant_Fields constantCollection, bool Preview_Mode, string Error_Folder )
            : base(constantCollection)
        {
            // Save the parameters
            this.inputFile = inputFile;
            this.JustSaveMarcXML = JustSaveMarcXML;
            this.projectCode = ProjectCode;
            this.preview_mode = Preview_Mode;
            this.error_folder = Error_Folder;

            // Allow overlay from MARC records
            base.allow_overlay = true;

            // Create the parser
            parser = new MARC21_Exchange_Format_Parser();

            // Set the MARC directory and the error directory
            marc_directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\SMaRT\\MarcXML\\";
            error_folder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\SMaRT\\Temporary\\";

            // Ensure both folders exist
            if (!Directory.Exists(marc_directory))
                Directory.CreateDirectory(marc_directory);
            if (!Directory.Exists(error_folder))
                Directory.CreateDirectory(error_folder);
        }
        protected baseImporter_Processor(Constant_Fields constantCollection)
        {
            // Create the objects to keep track of errors and items processed
            report   = new Importer_Report();
            errors   = new List <string>();
            warnings = new List <string>();

            // Save the parameters
            this.constantCollection = constantCollection;

            // Set some constants;
            recordsSavedToDB = 0;
            recordsProcessed = 0;
            recordsSkipped   = 0;
            errorCnt         = 0;
            preview_counter  = 1;
            allow_overlay    = false;

            // Load the data tables needed
            //     TrackingDB.CS_TrackingDatabase.Refresh_Bib_Table();
            allInstitutions = SobekCM.Library.Database.SobekCM_Database.Get_Codes_Item_Aggregations(null);

            // Declare the lists which will hold the new bib id and receiving id information
            Provided_Bib_To_New_Bib       = new Dictionary <string, string>();
            Provided_Bib_To_New_Receiving = new Dictionary <string, int>();
            New_Bib_IDs = new List <string>();

            // Set some defaults
            default_projects      = new List <string>();
            default_material_type = String.Empty;
        }
        /// <summary> Constructor for a new instance of this class </summary>
        /// <param name="InputDataTable">Table from the Excel spreadsheet being processed</param>
        /// <param name="Mapping">Arraylist of 'enum Mapped_Fields' members.</param>
        public SpreadSheet_Importer_Processor(DataTable InputDataTable, List<Mapped_Fields> Mapping, Constant_Fields constantCollection, bool PreView_Mode)
            : base(constantCollection)
        {
            // Save the parameters
            this.inputDataTbl = InputDataTable;
            this.mapping = Mapping;
            this.preview_mode = PreView_Mode;

            // If this is preview mode, get ready to continue by cleaning any preview mets files
            if (preview_mode)
            {
                string temp_folder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\SMaRT\\Temporary";

                try
                {
                    if (Directory.Exists(temp_folder))
                    {
                        string[] preview_mets = System.IO.Directory.GetFiles(temp_folder, "*_PREVIEW.mets");
                        int mets_cleanup_errors = 0;
                        foreach (string thisPreviewMets in preview_mets)
                        {
                            try
                            {
                                File.Delete(thisPreviewMets);
                            }
                            catch
                            {
                                mets_cleanup_errors++;
                            }

                            if (mets_cleanup_errors > 5)
                                break;
                        }

                        if (mets_cleanup_errors > 5)
                        {
                            MessageBox.Show("Error cleaning old preview METS from temporary folder.\n\n" + temp_folder);
                        }
                    }
                    else
                    {
                        Directory.CreateDirectory(temp_folder);
                    }
                }
                catch
                {
                    MessageBox.Show("Error cleaning old preview METS from temporary folder.\n\n" + temp_folder);
                }
            }
        }
Пример #5
0
        /// <summary> Constructor for a new instance of this class </summary>
        /// <param name="InputDataTable">Table from the Excel spreadsheet being processed</param>
        /// <param name="Mapping">Arraylist of 'enum Mapped_Fields' members.</param>
        public SpreadSheet_Importer_Processor(DataTable InputDataTable, List <Mapped_Fields> Mapping, Constant_Fields constantCollection, bool PreView_Mode)
            : base(constantCollection)
        {
            // Save the parameters
            this.inputDataTbl = InputDataTable;
            this.mapping      = Mapping;
            this.preview_mode = PreView_Mode;

            // If this is preview mode, get ready to continue by cleaning any preview mets files
            if (preview_mode)
            {
                string temp_folder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\SMaRT\\Temporary";

                try
                {
                    if (Directory.Exists(temp_folder))
                    {
                        string[] preview_mets        = System.IO.Directory.GetFiles(temp_folder, "*_PREVIEW.mets");
                        int      mets_cleanup_errors = 0;
                        foreach (string thisPreviewMets in preview_mets)
                        {
                            try
                            {
                                File.Delete(thisPreviewMets);
                            }
                            catch
                            {
                                mets_cleanup_errors++;
                            }

                            if (mets_cleanup_errors > 5)
                            {
                                break;
                            }
                        }

                        if (mets_cleanup_errors > 5)
                        {
                            MessageBox.Show("Error cleaning old preview METS from temporary folder.\n\n" + temp_folder);
                        }
                    }
                    else
                    {
                        Directory.CreateDirectory(temp_folder);
                    }
                }
                catch
                {
                    MessageBox.Show("Error cleaning old preview METS from temporary folder.\n\n" + temp_folder);
                }
            }
        }
        /// <summary> Constructor for a new instance of this class </summary>
        /// <param name="fields"> Fields which will be added to each record created </param>
        /// <param name="inputFile"> Text of the input file </param>
        /// <param name="outputFile"> Text for the output file as well </param>
        public MARC_Importer_Processor(string inputFile, bool JustSaveMarcXML, string ProjectCode, Constant_Fields constantCollection, bool Preview_Mode, string Error_Folder) : base(constantCollection)
        {
            // Save the parameters
            this.inputFile       = inputFile;
            this.JustSaveMarcXML = JustSaveMarcXML;
            this.projectCode     = ProjectCode;
            this.preview_mode    = Preview_Mode;
            this.error_folder    = Error_Folder;

            // Allow overlay from MARC records
            base.allow_overlay = true;

            // Create the parser
            parser = new MARC21_Exchange_Format_Parser();

            // Set the MARC directory and the error directory
            marc_directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\SMaRT\\MarcXML\\";
            error_folder   = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\SMaRT\\Temporary\\";

            // Ensure both folders exist
            if (!Directory.Exists(marc_directory))
            {
                Directory.CreateDirectory(marc_directory);
            }
            if (!Directory.Exists(error_folder))
            {
                Directory.CreateDirectory(error_folder);
            }
        }