Exemplo n.º 1
0
        /// <summary>
        /// 下载会签单信息文件
        /// </summary>
        private void DownloadContractFile(Socket socketClient, String contractId)
        {
            //  首先生成会签单信息
            String filePath = MSWordTools.DEFAULT_HDJCONTRACT_PATH + contractId + ".pdf";

            if (!(File.Exists((String)filePath)))     // 首先检测文件是否存在
            {
                String      wordPath = MSWordTools.DEFAULT_HDJCONTRACT_PATH + contractId + ".doc";
                HDJContract contract = DALHDJContract.GetHDJContactAgree(contractId);       // 获取待生成的会签单信息
                MSWordTools.CreateHDJContractWordWithReplace(contract, wordPath);
                MSWordTools.WordConvertToPdf(wordPath, filePath);

                File.Delete((String)wordPath);
                MSWordTools.KillWordProcess();
            }
            DALSignatureStatus.SetAgreeContractDownload(contractId);

            FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Read);

            Console.WriteLine("开始下载文件{0}", filePath);
            byte[]       fssize = new byte[fs.Length];
            BinaryReader reader = new BinaryReader(fs);

            reader.Read(fssize, 0, fssize.Length - 1);
            socketClient.Send(fssize);
            fs.Flush();
            fs.Close();
            Console.WriteLine("下载文件结束");

            //dict.Remove(socketClient.RemoteEndPoint.ToString());
            //socketClient.Close();
        }
Exemplo n.º 2
0
        public static void CreateHDJContractTrigger(object conId)
        {
            String pdfPath = MSWordTools.DEFAULT_HDJCONTRACT_PATH + conId + ".pdf";

            if (!(File.Exists((String)pdfPath)))     // 首先检测文件是否存在
            {
                String      wordPath = MSWordTools.DEFAULT_HDJCONTRACT_PATH + conId + ".doc";
                HDJContract contract = DALHDJContract.GetHDJContactAgree((string)conId);       // 获取待生成的会签单信息
                MSWordTools.CreateHDJContractWordWithReplace(contract, wordPath);
                MSWordTools.WordConvertToPdf(wordPath, pdfPath);

                File.Delete((String)wordPath);
                MSWordTools.KillWordProcess();
            }
        }