예제 #1
0
        protected void PrintLog(string strLog)
        {
            DelegatePara dp = new DelegatePara();

            dp.strLog = strLog;
            deles.Refresh(dp);
        }
예제 #2
0
        //注意:路径中不能有空格
        public bool _html2pdf(string fileName)
        {
            string strPdfSavedPath = m_strPath;

            if (!Directory.Exists(strPdfSavedPath))         //判断是否存在
            {
                Directory.CreateDirectory(strPdfSavedPath); //创建新路径
            }

            if (!File.Exists(strPdfSavedPath + fileName + ".pdf"))
            {
                string strHtmlSavedPath = m_strPath;
                string file_flvbind     = Application.StartupPath + @"\PDFLIB\wkhtmltopdf.exe";
                //MoveFolderTo(fileName, Application.StartupPath + @"\PDFLIB\");
                //生成ProcessStartInfo
                ProcessStartInfo pinfo = new ProcessStartInfo(file_flvbind);
                //pinfo.WorkingDirectory = Application.StartupPath + @"\PDFLIB\";
                pinfo.WorkingDirectory = strHtmlSavedPath;
                //设置参数
                StringBuilder sb = new StringBuilder();
                sb.Append("--footer-line ");
                sb.Append("--footer-center \"powered by 际为软件事务所(http://www.cnblogs.com/ice-river)\" ");
                sb.Append("\"" + "index.html\"");

                sb.Append(" \"" + strPdfSavedPath + fileName + ".pdf" + "\"");

                pinfo.Arguments = sb.ToString();
                //隐藏窗口
                pinfo.WindowStyle = ProcessWindowStyle.Hidden;
                //启动程序

                Process p = Process.Start(pinfo);
                p.WaitForExit();
                //DeleteFiles(Application.StartupPath + @"\PDFLIB\");
                if (p.ExitCode == 0)
                {
                    DelegatePara dp = new DelegatePara();
                    dp.strLog = "生成 [" + fileName + ".pdf] 成功!\n";

                    m_delesPDF.Refresh(dp);
                    return(true);
                }
                else
                {
                    DelegatePara dp = new DelegatePara();
                    dp.strLog = "生成 [" + fileName + ".pdf] 失败!\n";
                    m_delesPDF.Refresh(dp);
                    return(false);
                }
            }
            else
            {
                DelegatePara dp = new DelegatePara();
                dp.strLog = "生成 [" + fileName + ".pdf] 成功!\n";
                m_delesPDF.Refresh(dp);
                return(true);
            }
        }
예제 #3
0
        public void RefreshTask(DelegatePara dp)
        {
            //如果需要在安全的线程上下文中执行
            if (this.InvokeRequired)
            {
                this.Invoke(new ccTaskDelegate(RefreshTask), dp);
                return;
            }

            //转换参数
            string strLog = (string)dp.strLog;

            WriteLog(strLog);
        }