Ejemplo n.º 1
0
        private ConvertResult ConvertOoxToDaisy(string inputFile, string outputFile, Hashtable listMathMl, Hashtable table, string control, string output_Pipeline)
        {
            try
            {
                using (ConverterForm form = new ConverterForm(this.converter, inputFile, outputFile, this.resourceManager, true, listMathMl, table, control, output_Pipeline))
                {
                    if (DialogResult.OK != form.ShowDialog())
                    {
                        return(ConvertResult.Cancel());
                    }

                    if (!String.IsNullOrEmpty(form.ValidationError))
                    {
                        OnValidationError(form.ValidationError, inputFile, outputFile);
                        return(ConvertResult.ValidationError(form.ValidationError));
                    }

                    if (form.HasLostElements)
                    {
                        OnLostElements(inputFile, outputFile, form.LostElements);

                        if (!(AddInHelper.IsSingleDaisyTranslate(control) && this.ScriptToExecute == null) && IsContinueDTBookGenerationOnLostElements())
                        {
                            ExecuteScript(outputFile);
                        }
                    }
                    else if (AddInHelper.IsSingleDaisyTranslate(control) && this.ScriptToExecute == null)
                    {
                        OnSuccess();
                    }
                    else
                    {
                        ExecuteScript(outputFile);
                    }
                }
            }
            catch (IOException e)
            {
                // this is meant to catch "file already accessed by another process", though there's no .NET fine-grain exception for this.
                AddinLogger.Error(e);
                OnUnknownError("UnableToCreateOutputLabel", e.Message);
                return(ConvertResult.UnknownError(e.Message + Environment.NewLine + e.StackTrace));
            }
            catch (Exception e)
            {
                AddinLogger.Error(e);
                OnUnknownError("DaisyUnexpectedError", e.GetType() + ": " + e.Message + " (" + e.StackTrace + ")");

                if (File.Exists(outputFile))
                {
                    File.Delete(outputFile);
                }

                return(ConvertResult.UnknownError(e.Message + Environment.NewLine + e.StackTrace));
            }

            return(ConvertResult.Success());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Function to translate all sub documents in the Master Document
        /// </summary>
        /// <param name="outputfilepath">Path of the output File</param>
        /// <param name="subList">List of All documents</param>
        /// <param name="HTable">Document Properties</param>
        /// <param name="tempInputFile">Duplicate for the Input File</param>
        public void OoxToDaisySub(String outputfilepath, ArrayList subList, Hashtable HTable, String tempInputFile, string control, Hashtable listMathMl, string output_Pipeline, ArrayList notTranslatedDoc)
        {
            flag = 0;
            validationErrorMsg = "";
            using (Progress progress = new Progress(this.converter, this.resourceManager, outputfilepath, subList, HTable, tempInputFile, control, listMathMl, output_Pipeline))
            {
                DialogResult dr = progress.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    validationErrorMsg = progress.ValidationError;
                    String messageDocsSkip = DocumentSkipped(notTranslatedDoc);
                    if (!string.IsNullOrEmpty(validationErrorMsg))
                    {
                        validationErrorMsg = validationErrorMsg + messageDocsSkip;
                        OnMasterSubValidationError(validationErrorMsg);
                    }
                    else if (progress.HasLostElements)
                    {
                        OnLostElements(string.Empty, outputfilepath + "\\1.xml", progress.LostElements);

                        if (AddInHelper.PipelineIsInstalled() &&
                            AddInHelper.buttonIsSingleWordToXMLConversion(control) &&
                            ScriptToExecute != null &&
                            IsContinueDTBookGenerationOnLostElements())
                        {
                            try
                            {
                                ExecuteScript(outputfilepath + "\\" + Path.GetFileNameWithoutExtension(tempInputFile) + ".xml");
                            }
                            catch (Exception e)
                            {
                                AddinLogger.Error(e);
                                OnUnknownError(e.Message);
                            }
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(messageDocsSkip))
                        {
                            OnSuccessMasterSubValidation(ResManager.GetString("SucessLabel") + messageDocsSkip);
                        }
                        else
                        {
                            if (AddInHelper.IsSingleDaisyTranslate(control) && ScriptToExecute == null)
                            {
                                OnSuccess();
                            }
                            else
                            {
                                ExecuteScript(outputfilepath + "\\" + Path.GetFileNameWithoutExtension(tempInputFile) + ".xml");
                            }
                        }
                    }
                }
                else if (dr == DialogResult.Cancel)
                {
                    DeleteDTBookFilesIfExists(outputfilepath);
                }
                else
                {
                    validationErrorMsg = progress.ValidationError;
                    if (!string.IsNullOrEmpty(validationErrorMsg))
                    {
                        OnMasterSubValidationError(validationErrorMsg);
                    }
                }
            }
            DeleteTemporaryImages();
        }