Esempio n. 1
0
        /// <summary>
        /// Async method for processing files
        /// </summary>
        /// <param name="cf">
        /// A <see cref="CrawlerFile"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        private MediaFile Processor(CrawlerFile cf)
        {
            //Log.Debug(">>> Process file: {0}\n", cf.File.FullName);
            FileHandler h = null;
            switch (cf.MediaType.Mimetype)
            {
                case "image/bmp":
                case "image/jpeg":
                case "image/tiff":
                case "image/gif":
                case "image/png":
                    h = new IMGHandler(cf.File, cf.MediaType);
                    break;

                case "image/x-eps":
                case "application/illustrator":
                    h =  new EPSHandler(cf.File, cf.MediaType);
                    break;

                case "image/svg+xml":
                    h =  new SVGHandler(cf.File, cf.MediaType);
                    break;

                case "application/pdf":
                    h =  new PDFHandler(cf.File, cf.MediaType);
                    break;

                default:
                    Log.Debug("Unhandled file detected: {0}\n", cf.File.FullName);
                    return null;
            }

            h.Process();
            cf = null;
            MediaFile m = h.MediaFile;
            h.Dispose();
            h = null;
            return m;
        }
Esempio n. 2
0
        /// <summary>
        /// Can we release a new thread
        /// </summary>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        private bool isBusy(CrawlerFile cf)
        {
            if (taken >= slots)
                return true;

            return Process.GetCurrentProcess().PrivateMemorySize64 +
                     cf.File.Length >= maxbytes && taken > 0;
        }