/// <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);
                }
            }
        }
        /// <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("Processing file " + m_originalFileName);

                CreatePowerPointAppClass();
                OpenDocument();
                SaveDocument();

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

                m_log.Log("Converted successfully to " + m_newFileName);
            }
            catch (Exception e)
            {
                Logger.LogError("PowerPoint XP Conversion Failed", e);
                StatusFile.WriteErrorStatus(m_statusFileName, e, (int)1);
            }
            finally
            {
                DeleteInputFile(p_fileName);
            }
        }
        public void Convert(string p_filename, string p_srcLanguage)
        {
            Process p = null;

            try
            {
                DetermineConversionValues(p_filename);

                m_statusFileName = m_baseFileName + "status";


                m_log.Log("Processing file " + m_originalFileName);

                CleanResultFile();
                CleanTempFiles();
                p = OpenDoc();

                if (m_newFileName.EndsWith("pdf"))
                {
                    Thread tpsThread = new Thread(new ThreadStart(CheckTps));
                    tpsThread.Start();
                }

                WaitResultFile();

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

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

                try
                {
                    if (p != null)
                    {
                        p.Kill();
                    }
                }
                catch { }

                CloseDistiller();

                CleanTempFiles();
            }
        }
        /// <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("Processing file " + m_originalFileName);

                GfxdataHandler handler = null;
                if (!m_newFileName.EndsWith(".pdf"))
                {
                    string htmFile = m_conversionType == ConversionType.IMPORT ? m_newFileName : m_originalFileName;
                    handler = new GfxdataHandler(htmFile, OfficeFormat.Pptx, m_log);

                    if (m_handleGfxdata && m_conversionType == ConversionType.EXPORT)
                    {
                        handler.HandleConvertBack();
                    }
                }

                CreatePowerPointAppClass();
                OpenDocument();
                SaveDocument();

                if (handler != null && m_handleGfxdata && m_conversionType == ConversionType.IMPORT)
                {
                    handler.HandleConvert();
                }

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

                m_log.Log("Converted successfully to " + m_newFileName);
            }
            catch (Exception e)
            {
                Logger.LogError(m_log, "PowerPoint Conversion Failed", e);
                StatusFile.WriteErrorStatus(m_statusFileName, e, (int)1);
            }
            finally
            {
                DeleteInputFile(p_fileName);
            }
        }
Esempio n. 5
0
        private void DoConvert(string p_fileName, string p_language, bool retry)
        {
            try
            {
                ResetState();
                m_statusFileName = p_fileName.Substring(
                    0, p_fileName.Length - FILE_EXT_LEN) + "status";
                DetermineConversionValues(p_fileName);

                if (m_newFileName.EndsWith(PDF))
                {
                    m_statusFileName = p_fileName.Substring(
                        0, p_fileName.Length - FILE_EXT_LEN) + "pdf.status";
                }

                m_log.Log("Processing file " + m_originalFileName);

                CreateWordAppClass();
                OpenWordDoc();
                SaveDocument();

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

                m_log.Log("Converted successfully to " + m_newFileName);
            }
            catch (Exception e)
            {
                string emsg = e.StackTrace.ToString();
                if (retry && emsg != null && emsg.Contains("RPC_E_SERVERCALL_RETRYLATER"))
                {
                    // sleep 10 seconds
                    Thread.Sleep(1000 * 10);
                    QuitWord();
                    Thread.Sleep(1000 * 10);

                    m_log.Log("Retry conversion after exception: " + emsg);
                    DoConvert(p_fileName, p_language, false);
                }
                else
                {
                    Logger.LogError(m_log, "Word 2007 Conversion Failed", e);
                    StatusFile.WriteErrorStatus(m_statusFileName, e, (int)1);
                }
            }
        }
Esempio n. 6
0
        /// <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);
                FileInfo      file = new FileInfo(p_fileName);
                DirectoryInfo dir  = file.Directory;

                m_log.Log("Processing file " + m_originalFileName);

                CommandUtil comUtil = new CommandUtil();

                // process files
                if (!m_isConvertBack)
                {
                    List <TranslateUnit3RD> units = Extract(comUtil);
                    String xml = XmlUtil3RD.OutputTranslateUnits(units);
                    XmlUtil3RD.WriteXml(xml, m_xmlFileName, "UTF-8");
                }
                else
                {
                    String xml = XmlUtil3RD.ReadFile(m_xmlFileName, "UTF-8");
                    List <TranslateUnit3RD> units = XmlUtil3RD.ParseTranslateUnits(xml);
                    int c = units.Count;
                    Merge(comUtil, units);
                }

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

                m_log.Log("Converted successfully to " + m_newFileName);
            }
            catch (Exception e)
            {
                Logger.LogError(m_log, "Windows Portable Executable 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, .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);
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Writes out error information to the status file
 /// </summary>
 /// <param name="p_ex">some exception</param>
 public void writeErrorStatus(Exception p_ex)
 {
     StatusFile.WriteErrorStatus(m_baseFileName + ".status", p_ex, m_errorCode);
 }