/// <summary>
        /// Converts the file from one format to another.
        /// </summary>
        /// <param name="p_filename">The command file
        /// (.im_command, .ex_command, .pv_command)</param>
        /// <param name="p_language">the language of the directory
        /// the file was written in</param>
        public void Convert(string p_fileName, string p_language)
        {
            lock (locker)
            {
                try
                {
                    ResetState();
                    m_statusFileName = p_fileName.Substring(
                        0, p_fileName.Length - FILE_EXT_LEN) + "status";
                    DetermineConversionValues(p_fileName);

                    m_log.Log("[Idml]: The converter will process file: " + m_originalFileName);
                    InDesignApplication indesignApp = InDesignApplication.getInstance();

                    //The status name will be changed to *.pv_status from *.status
                    //when execute the preview command(*.pv_command) file
                    indesignApp.ConvertInddToPDF(m_originalFileName, m_newFileName, m_masterTranslated, m_translateHiddenLayer);


                    StatusFile.WriteSuccessStatus(m_statusFileName,
                                                  m_originalFileName + " was converted successfully.");

                    m_log.Log("[Idml]: Converted successfully to: " + m_newFileName);
                }
                catch (Exception e)
                {
                    Logger.LogError("[Idml]: Idml Conversion Failed", e);
                    StatusFile.WriteErrorStatus(m_statusFileName, e, (int)1);
                }
                finally
                {
                    DeleteInputFile(p_fileName);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Stop this service.
 /// </summary>
 protected override void OnStop()
 {
     // TODO: Add code here to perform any tear-down necessary to stop your service.
     m_log.Log("InDesign Converter shutting down.");
     m_importConverterRunner.Stop();
     m_exportConverterRunner.Stop();
     m_InDesignApp.CloseInDesignApp();
     m_InDesignApp    = null;
     m_alreadyStarted = false;
 }
Beispiel #3
0
        /// <summary>
        /// Set things in motion so your service can do its work.
        /// </summary>
        protected override void OnStart(string[] args)
        {
            if (m_alreadyStarted == true)
            {
                return;
            }

            m_alreadyStarted = true;

            try
            {
                m_watchDirName = RegistryUtil.GetGlobalSightRegistryValue(
                    "InDesignConvDir") + @"\indd";
                DirectoryInfo watchDir = new DirectoryInfo(m_watchDirName);
                watchDir.Create();
                Logger.Initialize(m_watchDirName + @"\InDesignConverter.log");

                m_log = Logger.GetLogger();
                m_log.Log("GlobalSight InDesign Converter starting up.");
                m_log.Log("Creating and starting threads to watch directory " +
                          m_watchDirName);

                m_importConverterRunner = new ConverterRunner(
                    new InDesignConverterImpl(InDesignConverterImpl.ConversionType.IMPORT),
                    m_watchDirName);
                m_exportConverterRunner = new ConverterRunner(
                    new InDesignConverterImpl(InDesignConverterImpl.ConversionType.EXPORT),
                    m_watchDirName);

                m_importConverterRunner.Start();
                m_exportConverterRunner.Start();

                if (AllowInteractWithDesktop())
                {
                    m_InDesignApp = InDesignApplication.getInstance();
                }
                else
                {
                    throw new Exception("InDesign Converter Service needs to interact with desktop."
                                        + " The properties of InDesign Converter Service needs to "
                                        + "be changed to allow sevice to interact with desktop.");
                }
            }
            catch (Exception e)
            {
                string msg = "GlobalSight InDesign Converter failed to initialize because of: " +
                             e.Message + "\r\n" + e.StackTrace;
                EventLog.WriteEntry(msg, EventLogEntryType.Error);
                Logger.LogWithoutException(msg);
                throw e;
            }
        }
        public static InDesignApplication getInstance()
        {
            if (m_InDesign == null)
            {
                m_InDesign = new InDesignApplication();
            }

            if (!HasInDesignAppWindow())
            {
                m_InDesign.ReopenInDesignApp();
            }

            return(m_InDesign);
        }
        /// <summary>
        /// Converts the file from one format to another.
        /// </summary>
        /// <param name="p_filename">The command file
        /// (.im_command, .ex_command, .pv_command)</param>
        /// <param name="p_language">the language of the directory
        /// the file was written in</param>
        public void Convert(string p_fileName, string p_language)
        {
            try
            {
                ResetState();
                m_statusFileName = p_fileName.Substring(
                    0, p_fileName.Length - FILE_EXT_LEN) + "status";
                DetermineConversionValues(p_fileName);

                m_log.Log("[Indesign]: The converter will process file: " + m_originalFileName + "\r\n");

                InDesignApplication indesignApp = InDesignApplication.getInstance();
                if (m_conversionType == ConversionType.EXPORT)
                {
                    indesignApp.ConvertXmlToIndd(m_originalFileName, m_newFileName, m_masterTranslated);
                }
                else if (m_conversionType == ConversionType.PREVIEW)
                {
                    //The status name will be changed to *.pv_status from *.status
                    //when execute the preview command(*.pv_command) file
                    m_statusFileName = m_statusFileName.Substring(0,
                                                                  m_statusFileName.LastIndexOf(".")) + ".pv_status";
                    indesignApp.ConvertInddToPDF(m_originalFileName, m_newFileName, m_masterTranslated);
                }
                else
                {
                    indesignApp.ConvertInddToXml(m_originalFileName, m_newFileName, m_masterTranslated);
                }

                StatusFile.WriteSuccessStatus(m_statusFileName,
                                              m_originalFileName + " was converted successfully.");

                m_log.Log("[Indesign]: Converted successfully to: " + m_newFileName);
            }
            catch (Exception e)
            {
                Logger.LogError("[Indesign]: InDesign Conversion Failed", e);
                StatusFile.WriteErrorStatus(m_statusFileName, e, (int)1);
            }
            finally
            {
                DeleteInputFile(p_fileName);
            }
        }
        /// <summary>
        /// Converts the file from one format to another.
        /// </summary>
        /// <param name="p_filename">The command file
        /// (.im_command, .ex_command)</param>
        /// <param name="p_language">the language of the directory
        /// the file was written in</param>
        public void Convert(string p_fileName, string p_language)
        {
            try
            {
                ResetState();
                m_statusFileName = p_fileName.Substring(
                    0, p_fileName.Length - FILE_EXT_LEN) + "status";
                DetermineConversionValues(p_fileName);

                m_log.Log("The converter will process file: " + m_originalFileName + "\r\n");

                InDesignApplication indesignApp = InDesignApplication.getInstance();
                if (m_conversionType == ConversionType.EXPORT)
                {
                    indesignApp.ConvertXmlToIndd(m_originalFileName, m_newFileName);
                }
                else
                {
                    indesignApp.ConvertInddToXml(m_originalFileName, m_newFileName);
                }

                StatusFile.WriteSuccessStatus(m_statusFileName,
                                              m_originalFileName + " was converted successfully.");

                m_log.Log("Converted successfully to: " + m_newFileName);
            }
            catch (Exception e)
            {
                Logger.LogError("InDesign Conversion Failed", e);
                StatusFile.WriteErrorStatus(m_statusFileName, e, (int)1);
            }
            finally
            {
                DeleteInputFile(p_fileName);
            }
        }