示例#1
0
        public static void ProcessFile(string filePath, Logger parentLogger)
        {
            string fullTextPath = filePath.Replace(".docx", ".txt");
            string logPath      = filePath.Replace(".docx", ".log" + ExtractFootnotes.Timestamp + ".txt");

            FilesBeingProcessed++;

            Logger logger = new Logger(logPath);

            logger.log(String.Format("Start Process (Processing count = {0})", FilesBeingProcessed), true);

            Application application = new Application();

            application.DisplayAlerts = WdAlertLevel.wdAlertsNone;

            Logger documentLogger = new Logger(logPath);

            Document document = null;

            try
            {
                document = application.Documents.Open(filePath);

                document.SaveAs(fullTextPath, WdSaveFormat.wdFormatText);
                document.Close(false);
                Marshal.ReleaseComObject(document);

                document = application.Documents.Open(filePath);
                ExtractFootnotes.Process(document, application, documentLogger);
            }
            catch (Exception ex)
            {
                parentLogger.log(ex.ToString() + " " + ex.Message);
            }

            document.Close(false);
            Marshal.ReleaseComObject(document);
            application.Quit(false);
            Marshal.ReleaseComObject(application);

            FilesBeingProcessed--;

            logger.log(String.Format("Finish Process (Processing count = {0})", FilesBeingProcessed), true);
        }
        private void process(Word.Document Doc)
        {
            if (Doc.FullName.Contains("__openlawnz_from_pdf"))
            {
                this.Application.ScreenUpdating = false;
                this.Application.DisplayAlerts  = Word.WdAlertLevel.wdAlertsNone;

                string logPath = Doc.FullName.Replace(".docx", ".txt");
                Logger logger  = new Logger(logPath);
                try
                {
                    ExtractFootnotes.Process(Doc, this.Application, logger);
                }
                catch
                {
                }
                this.Application.ScreenUpdating = true;
                this.Application.Quit(false);
            }
        }