Example #1
0
 /// <summary>
 /// Generate a PDF file for the document.
 /// </summary>
 public void Generate()
 {
     try
     {
         UI.Log("Generating PDF file", ChmLogLevel.INFO);
         if (Project.PdfGeneration == ChmProject.PdfGenerationWay.OfficeAddin)
         {
             MSWord word = new MSWord();
             if (!word.SaveWordToPdf(MainSourceFilePath, Project.PdfPath))
             {
                 UI.Log("Warning: There was a time out waiting to close the word document", ChmLogLevel.WARNING);
             }
         }
         else
         {
             PdfPrinter pdfPrinter = new PdfPrinter();
             pdfPrinter.ConvertToPdf(MainSourceFilePath, Project.PdfPath);
         }
     }
     catch (Exception ex)
     {
         if (Project.PdfGeneration == ChmProject.PdfGenerationWay.OfficeAddin)
         {
             UI.Log("Something wrong happened with the PDF generation. Remember you must to have Microsoft Office 2007 and the" +
                    "pdf/xps generation add-in (http://www.microsoft.com/downloads/details.aspx?FamilyID=4D951911-3E7E-4AE6-B059-A2E79ED87041&displaylang=en)", ChmLogLevel.ERROR);
         }
         else
         {
             UI.Log("Something wrong happened with the PDF generation. Remember you must to have PdfCreator (VERSION " + PdfPrinter.SUPPORTEDVERSION +
                    " AND ONLY THIS VERSION) installed into your computer to " +
                    "generate a PDF file. You can download it from http://www.pdfforge.org/products/pdfcreator/download", ChmLogLevel.ERROR);
         }
         UI.Log(ex);
     }
 }
Example #2
0
        public static int Main(string[] args)
        {
            string paperType = "本科";

            paperType = "硕士";
            //paperType = "博士";
            DateTime start = DateTime.Now;

            Util.paperPath = Util.environmentDir + "\\Papers\\王晨晨.docx";
            if (args.Length > 0)
            {
                Util.paperPath = args[0];
            }
            if (args.Length > 1)
            {
                Util.masterType = (args[1] == "0") ? "学术型硕士" : "专业学位硕士";
            }
            //获取页码
            Console.WriteLine("正在获取页码...");
            MSWord msword = new MSWord();

            if (Util.paperPath.EndsWith(".doc"))
            {
                Console.WriteLine("正在将doc文件转为docx...");
                Util.paperPath = msword.DocToDocx(Util.paperPath);
                Console.WriteLine("文件转换成功!");
            }
            Util.pageDic = msword.getPage(Util.paperPath);
            foreach (var item in Util.pageDic)
            {
                //Util.printError(item.Key + "  " + item.Value);
                Console.WriteLine(item.Key + "  " + item.Value);
            }
            Console.WriteLine("成功获取页码信息!");

            Undergraduate.PaperDetection UndergraduatePD = null;
            Master.PaperDetection        MasterPD        = null;
            Doctor.PaperDetection        DoctorPD        = null;
            if (paperType.Equals("本科"))
            {
                UndergraduatePD = new Undergraduate.PaperDetection(Util.paperPath);
            }
            else if (paperType.Equals("硕士"))
            {
                MasterPD = new Master.PaperDetection(Util.paperPath);
            }
            else if (paperType.Equals("博士"))
            {
                DoctorPD = new Doctor.PaperDetection(Util.paperPath);
            }

            DateTime end = DateTime.Now;
            TimeSpan ts  = end - start;

            Console.WriteLine("");
            Console.WriteLine(" <= 检测用时: " + ts.TotalSeconds + " =>");
            //Console.ReadKey();
            return(0);
        }
Example #3
0
        private void button8_Click(object sender, EventArgs e)
        {
            //tbResultData.Text = MSWord.ModifyMSWordDoc(@"F:\Dropbox\Project\DOCX", "*.docx");
            var returnList = DirectoryFileIOOperations.GetFileNamesinList(@"F:\Dropbox\Project\DOCX - Copy", "*.docx");

            foreach (var item in returnList)
            {
                tbResultData.Text += item.ToString();
                tbResultData.Text += Environment.NewLine;
                MSWord.ModifyMSWordDoc(item);
            }
        }
Example #4
0
        private void button9_Click(object sender, EventArgs e)
        {
            var returnList = DirectoryFileIOOperations.GetFileNamesinList(@"F:\Dropbox\Project\DOCX - Copy", "*.docx");

            foreach (var item in returnList)
            {
                int counter = 1;
                tbResultData.Text += "[" + counter + "] " + item.ToString();
                tbResultData.Text += Environment.NewLine;
                //MSWord.ModifyMSWordDoc(item);
                MSWord.PrintWordDocument(item);
                Thread.Sleep(5000);
                counter++;
            }
        }
Example #5
0
 public bool CreateLogFile(String applicationName, String version, String environment)
 {
     try
     {
         MSWord msWord = new MSWord();
         String screenshotLogFileName = FeatureContext.Current.FeatureInfo.Title + "_" + FeatureContext.Current["RunFolder"] + "_" + "ScreenshotLog";
         String reportFoldersPath     = FeatureContext.Current["ReportsFolderPath"].ToString();
         msWord.CreateScreenshotLogFromTemplate(screenshotLogFileName, reportFoldersPath, applicationName, version, environment);
         String screenshotLogFilePath = FeatureContext.Current["ReportsFolderPath"].ToString() + "\\" + screenshotLogFileName + ".docx";
         FeatureContext.Current.Add("ScreenshotLog", screenshotLogFilePath);
         return(true);
     }
     catch (Exception e)
     {
     }
     return(false);
 }
Example #6
0
 /// <summary>
 /// Generate a XPS file for the document.
 /// </summary>
 public void Generate()
 {
     UI.Log("Generating XPS file", ChmLogLevel.INFO);
     try
     {
         MSWord word = new MSWord();
         if (!word.SaveWordToXps(MainSourceFilePath, Project.XpsPath))
         {
             UI.Log("Warning: There was a time out waiting to close the word document", ChmLogLevel.WARNING);
         }
     }
     catch (Exception ex)
     {
         UI.Log("Something wrong happened with the XPS generation. Remember you must to have Microsoft Office 2007 and the " +
                "pdf/xps generation add-in (http://www.microsoft.com/downloads/details.aspx?FamilyID=4D951911-3E7E-4AE6-B059-A2E79ED87041&displaylang=en)", ChmLogLevel.ERROR);
         UI.Log(ex);
     }
 }
        public bool CreateLogFile(String applicationName, String version, String environment)
        {
            try
            {
                String resDocName = FeatureContext.Current.FeatureInfo.Title + "_" + FeatureContext.Current["RunFolder"] + "_" + "OELog";
                FeatureContext.Current.Add("OELog", resDocName);
                String reportsFolderPath = FeatureContext.Current["ReportsFolderPath"].ToString();

                MSWord msWord = new MSWord();
                msWord.CreateOELogFromTemplate(resDocName, reportsFolderPath, applicationName, version, environment);
                FeatureContext.Current.Add("TableCounter", 1);
                FeatureContext.Current.Add("OELog_TableList", new TableList());
                return(true);
            }
            catch (Exception e)
            {
            }
            return(false);
        }