예제 #1
0
        public static bool Convert(string srcFile, string desFile,
                                   UniConversion.Converter.ConvertOption convertOption)
        {
            bool success = false;

            string fileType = srcFile.Substring(srcFile.LastIndexOf('.'));

            try
            {
                switch (fileType)
                {
                case ".txt": TextConverter.Convert(desFile, convertOption);
                    success = true;
                    break;

                case ".xml": XMLConverter.Convert(desFile, convertOption);
                    success = true;
                    break;

                case ".xls": ExcelConverter.Convert(openExcel(desFile), convertOption);
                    excelApp.ActiveWorkbook.Save();
                    success = true;
                    break;

                case ".doc": WordConverter.Convert("TempXml.xml", convertOption);

                    //wordApp.ActiveDocument.Save();
                    success = true;
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
            }
            return(success);
        }
예제 #2
0
        public static bool Convert(string srcFile, string desFile,
                                   UnicodeConverter.Converter.ConvertOption convertOption)
        {
            bool success = false;

            string fileType = srcFile.Substring(srcFile.LastIndexOf('.'));

            try
            {
                switch (fileType)
                {
                case ".txt": TextConverter.Convert(desFile, convertOption);
                    success = true;
                    break;

                case ".sql": TextConverter.ConvertSql(desFile, convertOption);
                    success = true;
                    break;

                case ".xml": XMLConverter.ConvertSimpleXml(srcFile, desFile, convertOption);
                    success = true;
                    break;

                case ".xls": ExcelConverter.Convert(openExcel(desFile));
                    excelApp.ActiveWorkbook.Save();

                    success = true;
                    break;

                case ".xlsx": ExcelConverter.Convert(openExcel(desFile));
                    excelApp.ActiveWorkbook.Save();

                    success = true;
                    break;

                case ".doc":     //WordConverter.Convert(openWord(desFile), convertOption);
                    //Console.WriteLine("To Convert doc file as xml");
                    try
                    {
                        WordConverter.Convert(srcFile, convertOption, desFile);
                        //Logging.WriteLog();
                        openWord((Object)desFile);
                        success = true;
                    }
                    catch (Exception e)
                    {
                        Logging.logger += "Error End...0";
                        Logging.WriteLog();
                    }
                    break;

                case ".docx":     //WordConverter.Convert(openWord(desFile), convertOption);
                    //Console.WriteLine("To Convert doc file as xml");
                    try
                    {
                        WordConverter.Convert(srcFile, convertOption, desFile);
                        //Logging.WriteLog();
                        openWord((Object)desFile);
                        success = true;
                    }
                    catch (Exception e)
                    {
                        Logging.logger += "Error End...0";
                        Logging.WriteLog();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Logging.logger += "Error End...1";
                Logging.WriteLog();
                Console.WriteLine(ex.Message);
            }
            finally
            {
            }
            return(success);
        }