示例#1
0
        /// <summary> Constructor for the CD_Packer class. </summary>
        /// <param name="directory"> The directory in which to pack these CDs. </param>
        /// <param name="firstCD"> The number for the first CD to pack. </param>
        /// <param name="CD_Capacity"> Capacity for the media (in MB) </param>
        public CD_Packer(string directory, int firstCD, int CD_Capacity)
        {
            // Save all the properties to the private variables
            this.directory   = directory;
            this.firstCD     = firstCD;
            this.cD_Capacity = CD_Capacity;

            // Make sure the provided directory exists, otherwise create it
            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            // Check to see if there is an incomplete CD
            nextCD = incompleteCD();
            if (nextCD == -1)
            {
                currentCD = firstCD;
            }
            else
            {
                currentCD = nextCD;
            }

            // Create new lists to hold all the textual and visual items
            packedTextBibIds  = new StringCollection();
            packedImageBibIds = new StringCollection();

            // Create the current newCdObject for the CD
            thisCD = new newCdObject(cD_Capacity, currentCD, directory);

            // Set the number of NewCdsPacked to zero initially
            NewCdsPacked = 0;
        }
示例#2
0
        /// <summary> Helper method will make the folder for the next CD, etc.  Checks to make
        /// sure that no more than 500 CD's are ever packed in one session. </summary>
        /// <returns></returns>
        /// <exception cref="CD_Packer_Exception"> Throws a CD_Packer_Exception if more than 50 CD's were
        /// packed in one session.   This prevents run away processes from creating thousands of new CD
        /// folders.  </exception>
        private void createNextCD()
        {
            if (NewCdsPacked > 50)
            {
                throw new CD_Packer_Exception("Attempted to pack more than 50 CD's in one session.");
            }
            else
            {
                thisCD = new newCdObject(cD_Capacity, currentCD, directory);

                // Trigger the event that a new CD was created
                if (this.New_CD_Created != null)
                {
                    New_CD_Created(thisCD.CdNumber);
                }

                // Increment the number of cd's which have been packed
                NewCdsPacked++;
            }
        }