2023-03-03 合同打印修改,在线编辑文档控件增加

This commit is contained in:
2023-03-03 10:46:14 +08:00
parent 1cf35eb878
commit 1a8b21b64f
38 changed files with 3465 additions and 695 deletions
@@ -1,4 +1,9 @@
using System.Collections.Generic;
using Aspose.Words;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
namespace BLL
@@ -13,7 +18,6 @@ namespace BLL
return Funs.DB.PHTGL_BidApproveUserReview.FirstOrDefault(e => e.ApproveUserReviewID == ApproveUserReviewID);
}
public static void AddPHTGL_BidApproveUserReview(Model.PHTGL_BidApproveUserReview newtable)
{
Model.PHTGL_BidApproveUserReview table = new Model.PHTGL_BidApproveUserReview();
@@ -34,7 +38,6 @@ namespace BLL
Funs.DB.SubmitChanges();
}
public static void UpdatePHTGL_BidApproveUserReview(Model.PHTGL_BidApproveUserReview newtable)
{
Model.PHTGL_BidApproveUserReview table = Funs.DB.PHTGL_BidApproveUserReview.FirstOrDefault(e => e.ApproveUserReviewID == newtable.ApproveUserReviewID);
@@ -119,6 +122,101 @@ namespace BLL
return list;
}
public static Document Print(string Id)
{
string rootPath = Funs.RootPath;
string initTemplatePath = string.Empty;
string uploadfilepath = string.Empty;
string newUrl = string.Empty;
string filePath = string.Empty;
initTemplatePath = "File\\Word\\PHTGL\\施工招标评标小组名单审批表.docx";
uploadfilepath = rootPath + initTemplatePath;
newUrl = uploadfilepath.Replace(".docx", string.Format("{0:yyyy-MM}", DateTime.Now) + ".docx");
filePath = initTemplatePath.Replace(".docx", string.Format("{0:yyyy-MM}", DateTime.Now) + ".pdf");
if (File.Exists(newUrl))
{
File.Delete(newUrl);
}
File.Copy(uploadfilepath, newUrl);
///更新书签
var getFireWork = PHTGL_BidApproveUserReviewService.GetPHTGL_BidApproveUserReviewById(Id);
var Bid = PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(getFireWork.BidDocumentsReviewId);
var Act = BLL.PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(Bid.ActionPlanID);
#region
string strSql = @" SELECT Number = row_number() over(order by ID)
,APP.ApproveUserName as Name
,APP.ApproveUserSpecial as Special
,APP.ApproveUserUnit as Unit
,APP.Remarks as Remarks"
+ @" FROM PHTGL_BidApproveUserReview_Sch1 AS APP "
+ @"where 1=1 AND ApproveUserReviewID = @ApproveUserReviewID ";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ApproveUserReviewID", Id));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
tb.TableName = "Table";
Document doc = new Aspose.Words.Document(newUrl);
doc.MailMerge.ExecuteWithRegions(tb);
#endregion
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
Dic_File.Add("txtProjectName", Act.ProjectShortName);
Dic_File.Add("txtBidProject", getFireWork.BidProject);
Dic_File.Add("txtBidDocumentCode", Bid.BidDocumentsCode);
foreach (var item in Dic_File)
{
string[] key = { item.Key };
object[] value = { item.Value };
doc.MailMerge.Execute(key, value);
}
if (getFireWork.State == Const.ContractReview_Complete)
{
AsposeWordHelper.InsertImg(doc, rootPath, "Approval_Construction", getFireWork.Approval_Construction, "");
AsposeWordHelper.InsertImg(doc, rootPath, "ConstructionManager", getFireWork.ConstructionManager, "");
AsposeWordHelper.InsertImg(doc, rootPath, "DeputyGeneralManager", getFireWork.DeputyGeneralManager, "");
AsposeWordHelper.InsertImg(doc, rootPath, "ProjectManager", getFireWork.ProjectManager, "");
}
doc.Save(newUrl);
Document doc1 = new Aspose.Words.Document(newUrl);
File.Delete(newUrl);
return doc1;
}
public static void PrintFile( string Id)
{
string rootPath = Funs.RootPath;
string newUrl = string.Empty;
newUrl = rootPath + "File\\Word\\PHTGL\\施工招标评标小组名单审批表.docx";
newUrl = newUrl.Replace(".docx", string.Format("{0:yyyy-MM}", DateTime.Now) + ".docx");
if (File.Exists(newUrl))
{
File.Delete(newUrl);
}
var doc = Print( Id);
doc.Save(newUrl);
//生成PDF文件
string pdfUrl = newUrl.Replace(".docx", ".pdf");
Document doc1 = new Aspose.Words.Document(newUrl);
//验证参数
if (doc1 == null) { throw new Exception("Word文件无效"); }
doc1.Save(pdfUrl, Aspose.Words.SaveFormat.Pdf);//还可以改成其它格式
string fileName = Path.GetFileName(pdfUrl);
FileInfo info = new FileInfo(pdfUrl);
long fileSize = info.Length;
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
System.Web.HttpContext.Current.Response.TransmitFile(pdfUrl, 0, fileSize);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.Close();
File.Delete(newUrl);
File.Delete(pdfUrl);
}
}
}