Пример #1
0
        public void Convert(string origFile, string fromFile, string outputDir, string processedDir, string callerRef, string sentTo)
        {
            try
            {
                FileInfo fileInfo = new FileInfo(fromFile);
                if (!fileInfo.Exists)
                {
                    _logFile.WriteToLog("TifCopier Converter: " + fromFile + " does not exist ");
                    return;
                }
                string srcFileName = fileInfo.Name;
                string outputFileName = outputDir + @"\" + srcFileName.Substring(0, srcFileName.IndexOf(".")) +"_"+ DateTime.Now.ToString("yyyyMMddhh24mmss")+ ".tif";
                _logFile.WriteToLog("TifCopier Converter - Started; src = " + srcFileName);

                FileUtils.CopyToDir(fileInfo, outputFileName);

                //jvc insert Inbound - Data Access here
                InboundController ibController = new InboundController();
                ibController._logFile = _logFile;
                ibController.ProcessFile(outputFileName, fromFile, callerRef, sentTo);
                if (Properties.Settings.Default.DeleteTIFEnabled)
                {
                    File.Delete(outputFileName);
                }

                _logFile.WriteToLog("TifCopier Converter - Completed; src = " + srcFileName);

            }
            catch (Exception e)
            {
                _logFile.WriteToLog("TifCopier - ERROR: " + e.Message + " Stack - " + e.StackTrace);
                throw e;
            }
            finally
            {
             
            }
        }
Пример #2
0
        public void Convert(string origFile, string fromFile, string outputDir, string processedDir, string callerRef, string sentTo)
        {
            try
            {
                FileInfo fileInfo = new FileInfo(fromFile);
                if (!fileInfo.Exists)
                {
                    _logFile.WriteToLog("TifCopier Converter: " + fromFile + " does not exist ");
                    return;
                }
                string srcFileName    = fileInfo.Name;
                string outputFileName = outputDir + @"\" + srcFileName.Substring(0, srcFileName.IndexOf(".")) + "_" + DateTime.Now.ToString("yyyyMMddhh24mmss") + ".tif";
                _logFile.WriteToLog("TifCopier Converter - Started; src = " + srcFileName);

                FileUtils.CopyToDir(fileInfo, outputFileName);

                //jvc insert Inbound - Data Access here
                InboundController ibController = new InboundController();
                ibController._logFile = _logFile;
                ibController.ProcessFile(outputFileName, fromFile, callerRef, sentTo);
                if (Properties.Settings.Default.DeleteTIFEnabled)
                {
                    File.Delete(outputFileName);
                }

                _logFile.WriteToLog("TifCopier Converter - Completed; src = " + srcFileName);
            }
            catch (Exception e)
            {
                _logFile.WriteToLog("TifCopier - ERROR: " + e.Message + " Stack - " + e.StackTrace);
                throw e;
            }
            finally
            {
            }
        }
Пример #3
0
        public void Convert(string origFile, string fromFile, string outputDir, string processedDir, string callerRef, string sentTo)
        {
            RasterImage image = null;

            try
            {
                FileInfo fileInfo = new FileInfo(fromFile);
                if (!fileInfo.Exists)
                {
                    _logFile.WriteToLog("Lead Tool Converter - ERROR: " + fromFile + " does not exist.");
                    return;
                }

                string srcFileName = fileInfo.Name;
                _logFile.WriteToLog("Lead Tool Converter: Conversion starting.");
                string srcFileNameWithoutExt = Path.GetFileNameWithoutExtension(srcFileName);
                string outputFileName        = outputDir + @"\" + srcFileNameWithoutExt + "_" + DateTime.Now.ToString("yyyyMMddhh24mmss") + ".tif";


                string fileExt = fileInfo.Extension.ToLower();
                LoadOptionValues(codec, fileExt);
                CodecsImageInfo info = codec.GetInformation(fromFile, true);

                image = codec.Load(fromFile, 0, CodecsLoadByteOrder.Bgr, 1, info.TotalPages);

                codec.Save(image, outputFileName, RasterImageFormat.Tif, 1, 1, info.TotalPages, 1, CodecsSavePageMode.Overwrite);

                _logFile.WriteToLog("Lead Tool Converter: Conversion completed.");
                //jvc insert Inbound - Data Access here
                InboundController ibController = new InboundController();
                ibController._logFile = _logFile;
                _logFile.WriteToLog("InboundController Started: Saving Info to Database for source file:" + origFile + " and converted file: " + outputFileName);
                ibController.ProcessFile(outputFileName, origFile, callerRef, sentTo); //jvc tif and original source format
                if (Properties.Settings.Default.DeleteTIFEnabled)
                {
                    File.Delete(outputFileName);
                }
                _logFile.WriteToLog("InboundController Completed: File Info saved to Database.");
            }
            catch (RasterException ex)
            {
                string erMsg = "";
                if (ex.Code == RasterExceptionCode.FileFormat)
                {
                    erMsg = "The file ''" + fromFile + "'' does not contain an image format recognizable by LEADTOOLS;" + Environment.NewLine + ex.Message;
                }
                else if (ex.Code == RasterExceptionCode.InvalidFormat)
                {
                    erMsg = "The file ''" + fromFile + "'' does not contain an format recognizable by LEADTOOLS;" + Environment.NewLine + ex.Message;
                }
                else
                {
                    erMsg = "Could not load the file ''" + fromFile + "''; " + Environment.NewLine + "Leadtools code:  " + ex.Code + "; message:  " + ex.Message;
                }
                _logFile.WriteToLog(erMsg);
                throw new Exception(erMsg);
            }
            catch (Exception e)
            {
                _logFile.WriteToLog("Lead Tool Converter - ERROR: " + e.Message + "; Stack - " + e.StackTrace);
                throw e;
            }
            finally
            {
                if (image != null)
                {
                    image.Dispose();
                }
            }
        }
Пример #4
0
        public void Convert(string origFile, string fromFile, string outputDir, string processedDir, string callerRef, string sentTo)
        {
            RasterImage image = null;
            try
            {
                FileInfo fileInfo = new FileInfo(fromFile);
                if (!fileInfo.Exists)
                {
                    _logFile.WriteToLog("Lead Tool Converter - ERROR: " + fromFile + " does not exist.");
                    return;
                }

                string srcFileName = fileInfo.Name;
                _logFile.WriteToLog("Lead Tool Converter: Conversion starting.");
                string srcFileNameWithoutExt = Path.GetFileNameWithoutExtension(srcFileName);
                string outputFileName = outputDir + @"\" + srcFileNameWithoutExt + "_" + DateTime.Now.ToString("yyyyMMddhh24mmss") + ".tif";


                string fileExt = fileInfo.Extension.ToLower();
                LoadOptionValues(codec, fileExt);
                CodecsImageInfo info = codec.GetInformation(fromFile, true);

                image = codec.Load(fromFile, 0, CodecsLoadByteOrder.Bgr, 1, info.TotalPages);

                codec.Save(image, outputFileName, RasterImageFormat.Tif, 1, 1, info.TotalPages, 1, CodecsSavePageMode.Overwrite);

                _logFile.WriteToLog("Lead Tool Converter: Conversion completed.");
                //jvc insert Inbound - Data Access here
                InboundController ibController = new InboundController();
                ibController._logFile = _logFile;
                _logFile.WriteToLog("InboundController Started: Saving Info to Database for source file:" + origFile + " and converted file: " + outputFileName);
                ibController.ProcessFile(outputFileName, origFile, callerRef, sentTo); //jvc tif and original source format
                if (Properties.Settings.Default.DeleteTIFEnabled)
                {
                    File.Delete(outputFileName);
                }
                _logFile.WriteToLog("InboundController Completed: File Info saved to Database.");

            }
            catch (RasterException ex)
            {
                string erMsg = "";
                if (ex.Code == RasterExceptionCode.FileFormat)
                    erMsg = "The file ''" + fromFile + "'' does not contain an image format recognizable by LEADTOOLS;" + Environment.NewLine + ex.Message;
                else if (ex.Code == RasterExceptionCode.InvalidFormat)
                    erMsg = "The file ''" + fromFile + "'' does not contain an format recognizable by LEADTOOLS;" + Environment.NewLine + ex.Message;
                else
                    erMsg = "Could not load the file ''" + fromFile + "''; " + Environment.NewLine + "Leadtools code:  " + ex.Code + "; message:  " + ex.Message;
                _logFile.WriteToLog(erMsg);
                throw new Exception(erMsg);
            }
            catch (Exception e)
            {
                _logFile.WriteToLog("Lead Tool Converter - ERROR: " + e.Message + "; Stack - " + e.StackTrace);
                throw e;
            }
            finally
            {
                if (image != null)
                {
                    image.Dispose();
                }
            }
        }