2023-03-03 合同打印修改,在线编辑文档控件增加
This commit is contained in:
@@ -416,99 +416,99 @@ namespace FineUIPro.Web.PHTGL.BiddingManagement
|
||||
/// BidDocumentsReviewId
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
public void Print(string Id)
|
||||
{
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string initTemplatePath = string.Empty;
|
||||
string uploadfilepath = string.Empty;
|
||||
string newUrl = string.Empty;
|
||||
string filePath = string.Empty;
|
||||
initTemplatePath = "File\\Word\\PHTGL\\招标文件审批表.docx";
|
||||
var lwfirwork = PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(Id);
|
||||
if (lwfirwork != null)
|
||||
{
|
||||
if (PHTGL_ActionPlanReviewService.IsSpecialProject(lwfirwork.ProjectId))
|
||||
{
|
||||
initTemplatePath = "File\\Word\\PHTGL\\招标文件审批表LW.docx";
|
||||
//public void Print(string Id)
|
||||
//{
|
||||
// string rootPath = Server.MapPath("~/");
|
||||
// string initTemplatePath = string.Empty;
|
||||
// string uploadfilepath = string.Empty;
|
||||
// string newUrl = string.Empty;
|
||||
// string filePath = string.Empty;
|
||||
// initTemplatePath = "File\\Word\\PHTGL\\招标文件审批表.docx";
|
||||
// var lwfirwork = PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(Id);
|
||||
// if (lwfirwork != null)
|
||||
// {
|
||||
// if (PHTGL_ActionPlanReviewService.IsSpecialProject(lwfirwork.ProjectId))
|
||||
// {
|
||||
// initTemplatePath = "File\\Word\\PHTGL\\招标文件审批表LW.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);
|
||||
Document doc = new Aspose.Words.Document(newUrl);
|
||||
// }
|
||||
// }
|
||||
// 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);
|
||||
// Document doc = new Aspose.Words.Document(newUrl);
|
||||
|
||||
///更新书签
|
||||
var getFireWork = PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(Id);
|
||||
var Act = PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(getFireWork.ActionPlanID);
|
||||
var model_ConstructionManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.ConstructionManager);
|
||||
var model_ControlManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.ControlManager);
|
||||
var model_Approval_Construction = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.Approval_Construction);
|
||||
var model_ProjectManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.ProjectManager);
|
||||
// ///更新书签
|
||||
// var getFireWork = PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(Id);
|
||||
// var Act = PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(getFireWork.ActionPlanID);
|
||||
// var model_ConstructionManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.ConstructionManager);
|
||||
// var model_ControlManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.ControlManager);
|
||||
// var model_Approval_Construction = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.Approval_Construction);
|
||||
// var model_ProjectManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.ProjectManager);
|
||||
|
||||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||||
Dic_File.Add("txtCode", string.Format("{0:yyyyMMdd}", Convert.ToDateTime(getFireWork.CreatTime)));
|
||||
Dic_File.Add("txtBidDocumentCode", getFireWork.BidDocumentsCode);
|
||||
Dic_File.Add("txtProjectName", Act.ProjectShortName);
|
||||
Dic_File.Add("txtProjectCode", Act.ProjectCode);
|
||||
Dic_File.Add("txtBidContent", getFireWork.BidContent);
|
||||
Dic_File.Add("txtBidType", getFireWork.BidType);
|
||||
Dic_File.Add("txtBidDocumentsName", getFireWork.BidDocumentsName);
|
||||
Dic_File.Add("Bidding_SendTime", string.Format("{0:D}", getFireWork.Bidding_SendTime));
|
||||
Dic_File.Add("Bidding_StartTime", string.Format("{0:D}", getFireWork.Bidding_StartTime));
|
||||
// Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||||
// Dic_File.Add("txtCode", string.Format("{0:yyyyMMdd}", Convert.ToDateTime(getFireWork.CreatTime)));
|
||||
// Dic_File.Add("txtBidDocumentCode", getFireWork.BidDocumentsCode);
|
||||
// Dic_File.Add("txtProjectName", Act.ProjectShortName);
|
||||
// Dic_File.Add("txtProjectCode", Act.ProjectCode);
|
||||
// Dic_File.Add("txtBidContent", getFireWork.BidContent);
|
||||
// Dic_File.Add("txtBidType", getFireWork.BidType);
|
||||
// Dic_File.Add("txtBidDocumentsName", getFireWork.BidDocumentsName);
|
||||
// Dic_File.Add("Bidding_SendTime", string.Format("{0:D}", getFireWork.Bidding_SendTime));
|
||||
// Dic_File.Add("Bidding_StartTime", string.Format("{0:D}", getFireWork.Bidding_StartTime));
|
||||
|
||||
if (getFireWork.State == Const.ContractReview_Complete)
|
||||
{
|
||||
Dic_File.Add("ConstructionManagerTime", string.Format("{0:D}", DateTime.Parse(model_ConstructionManager.ApproveDate)));
|
||||
Dic_File.Add("ControlManagerTime", string.Format("{0:D}", DateTime.Parse(model_ControlManager.ApproveDate)));
|
||||
Dic_File.Add("Approval_ConstructionTime", string.Format("{0:D}", DateTime.Parse(model_Approval_Construction.ApproveDate)));
|
||||
Dic_File.Add("ProjectManagerTime", string.Format("{0:D}", DateTime.Parse(model_ProjectManager.ApproveDate)));
|
||||
// if (getFireWork.State == Const.ContractReview_Complete)
|
||||
// {
|
||||
// Dic_File.Add("ConstructionManagerTime", string.Format("{0:D}", DateTime.Parse(model_ConstructionManager.ApproveDate)));
|
||||
// Dic_File.Add("ControlManagerTime", string.Format("{0:D}", DateTime.Parse(model_ControlManager.ApproveDate)));
|
||||
// Dic_File.Add("Approval_ConstructionTime", string.Format("{0:D}", DateTime.Parse(model_Approval_Construction.ApproveDate)));
|
||||
// Dic_File.Add("ProjectManagerTime", string.Format("{0:D}", DateTime.Parse(model_ProjectManager.ApproveDate)));
|
||||
|
||||
AsposeWordHelper.InsertImg(doc, rootPath, "Approval_Construction", getFireWork.Approval_Construction, "");
|
||||
AsposeWordHelper.InsertImg(doc, rootPath, "ConstructionManager", getFireWork.ConstructionManager, "");
|
||||
AsposeWordHelper.InsertImg(doc, rootPath, "ControlManager", getFireWork.ControlManager, "");
|
||||
AsposeWordHelper.InsertImg(doc, rootPath, "ProjectManager", getFireWork.ProjectManager, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
Dic_File.Add("ConstructionManagerTime", " 年 月 日");
|
||||
Dic_File.Add("ControlManagerTime", " 年 月 日");
|
||||
Dic_File.Add("Approval_ConstructionTime", " 年 月 日");
|
||||
Dic_File.Add("ProjectManagerTime", " 年 月 日");
|
||||
}
|
||||
foreach (var item in Dic_File)
|
||||
{
|
||||
string[] key = { item.Key };
|
||||
object[] value = { item.Value };
|
||||
doc.MailMerge.Execute(key, value);
|
||||
// AsposeWordHelper.InsertImg(doc, rootPath, "Approval_Construction", getFireWork.Approval_Construction, "");
|
||||
// AsposeWordHelper.InsertImg(doc, rootPath, "ConstructionManager", getFireWork.ConstructionManager, "");
|
||||
// AsposeWordHelper.InsertImg(doc, rootPath, "ControlManager", getFireWork.ControlManager, "");
|
||||
// AsposeWordHelper.InsertImg(doc, rootPath, "ProjectManager", getFireWork.ProjectManager, "");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Dic_File.Add("ConstructionManagerTime", " 年 月 日");
|
||||
// Dic_File.Add("ControlManagerTime", " 年 月 日");
|
||||
// Dic_File.Add("Approval_ConstructionTime", " 年 月 日");
|
||||
// Dic_File.Add("ProjectManagerTime", " 年 月 日");
|
||||
// }
|
||||
// foreach (var item in Dic_File)
|
||||
// {
|
||||
// string[] key = { item.Key };
|
||||
// object[] value = { item.Value };
|
||||
// doc.MailMerge.Execute(key, value);
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
doc.Save(newUrl);
|
||||
//生成PDF文件
|
||||
string pdfUrl = newUrl.Replace(".doc", ".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(filePath).Replace("招标文件审批表", getFireWork.BidDocumentsCode + "招标文件审批表");
|
||||
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);
|
||||
}
|
||||
// doc.Save(newUrl);
|
||||
// //生成PDF文件
|
||||
// string pdfUrl = newUrl.Replace(".doc", ".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(filePath).Replace("招标文件审批表", getFireWork.BidDocumentsCode + "招标文件审批表");
|
||||
// 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);
|
||||
//}
|
||||
|
||||
protected void btnPrinter_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -518,7 +518,7 @@ namespace FineUIPro.Web.PHTGL.BiddingManagement
|
||||
return;
|
||||
}
|
||||
string Id = Grid1.SelectedRowID;
|
||||
Print(Id);
|
||||
BLL.PHTGL_BidDocumentsReviewService.PrintFile(Id);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user