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
@@ -397,354 +397,8 @@ namespace FineUIPro.Web.PHTGL.BiddingManagement
}
string Id = Grid1.SelectedRowID;
Print(Id);
BLL.PHTGL_ActionPlanFormationService.PrintFile( Id);
}
/// <summary>
/// ActionPlanID
/// </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;
var lwfirwork = PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(Id);
initTemplatePath = "File\\Word\\PHTGL\\施工招标实施计划审批表.docx";
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);
///更新书签
var getFireWork = PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(Id);
var Act = PHTGL_ActionPlanReviewService.GetPHTGL_ActionPlanReviewByActionPlanID(Id);
var list = PHTGL_ActionPlanFormation_Sch1Service.GetListPHTGL_ActionPlanFormation_Sch1ById(Id);
Document doc = new Aspose.Words.Document(newUrl);
Bookmark txtActionPlanCode = doc.Range.Bookmarks["ActionPlanCode"];
Bookmark txtBidProject = doc.Range.Bookmarks["txtBidProject"];
Bookmark txtName = doc.Range.Bookmarks["txtName"];
Bookmark txtCreateTime = doc.Range.Bookmarks["CreateTime"];
Bookmark txtProjectName = doc.Range.Bookmarks["txtProjectName"];
Bookmark txtUnit = doc.Range.Bookmarks["txtUnit"];
Bookmark txtConstructionSite = doc.Range.Bookmarks["txtConstructionSite"];
Bookmark txtBiddingProjectScope = doc.Range.Bookmarks["txtBiddingProjectScope"];
Bookmark txtBiddingProjectContent = doc.Range.Bookmarks["txtBiddingProjectContent"];
Bookmark txtTimeRequirements = doc.Range.Bookmarks["txtTimeRequirements"];
Bookmark txtQualityRequirement = doc.Range.Bookmarks["txtQualityRequirement"];
Bookmark txtHSERequirement = doc.Range.Bookmarks["txtHSERequirement"];
Bookmark txtTechnicalRequirement = doc.Range.Bookmarks["txtTechnicalRequirement"];
Bookmark txtCurrentRequirement = doc.Range.Bookmarks["txtCurrentRequirement"];
Bookmark txtSub_Selection = doc.Range.Bookmarks["txtSub_Selection"];
Bookmark txtBid_Selection = doc.Range.Bookmarks["txtBid_Selection"];
Bookmark txtContractingMode_Select = doc.Range.Bookmarks["txtContractingMode_Select"];
Bookmark txtPriceMode_Select = doc.Range.Bookmarks["txtPriceMode_Select"];
Bookmark txtMaterialsDifferentiate = doc.Range.Bookmarks["txtMaterialsDifferentiate"];
Bookmark txtImportExplain = doc.Range.Bookmarks["txtImportExplain"];
Bookmark txtShortNameList = doc.Range.Bookmarks["txtShortNameList"];
Bookmark txtEvaluationMethods = doc.Range.Bookmarks["txtEvaluationMethods"];
Bookmark txtEvaluationPlan = doc.Range.Bookmarks["txtEvaluationPlan"];
Bookmark txtBiddingMethods_Select = doc.Range.Bookmarks["txtBiddingMethods_Select"];
Bookmark txtSchedulePlan = doc.Range.Bookmarks["txtSchedulePlan"];
#region
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
for (int i = 1; i < 14; i++)
{
string txtPlanningContent = "txtPlanningContent" + Convert.ToString(i);
string txtRemarks = "txtRemarks" + Convert.ToString(i);
string value_ActionPlan = "";
string value_Remarks = "";
var model = list.Find(e => e.SortIndex == Convert.ToString(i));
if (model != null)
{
value_ActionPlan = model.ActionPlan;
value_Remarks = model.Remarks;
}
string[] key = { txtPlanningContent, txtRemarks };
object[] value = { value_ActionPlan, value_Remarks };
doc.MailMerge.Execute(key, value);
}
#endregion
if (txtActionPlanCode != null)
{
if (getFireWork != null)
{
txtActionPlanCode.Text = getFireWork.ActionPlanCode;
}
}
if (txtName != null)
{
if (getFireWork != null)
{
txtName.Text = getFireWork.ProjectShortName;
}
}
if (txtBidProject != null)
{
if (getFireWork != null)
{
txtBidProject.Text = getFireWork.BidProject;
}
}
if (txtCreateTime != null)
{
if (getFireWork != null)
{
txtCreateTime.Text = string.Format("{0:D}", getFireWork.CreateTime);
}
}
if (Act != null)
{
if (Act.State == Const.ContractReview_Complete)
{
AsposeWordHelper.InsertImg(doc, rootPath, "Approval_Construction", Act.Approval_Construction, "");
AsposeWordHelper.InsertImg(doc, rootPath, "ConstructionManager", Act.ConstructionManager, "");
AsposeWordHelper.InsertImg(doc, rootPath, "DeputyGeneralManager", Act.DeputyGeneralManager, "");
AsposeWordHelper.InsertImg(doc, rootPath, "ProjectManager", Act.ProjectManager, "");
}
}
if (txtProjectName != null)
{
if (getFireWork != null)
{
txtProjectName.Text = getFireWork.ProjectName;
}
}
if (txtUnit != null)
{
if (getFireWork != null)
{
txtUnit.Text = getFireWork.Unit;
}
}
if (txtConstructionSite != null)
{
if (getFireWork != null)
{
txtConstructionSite.Text = getFireWork.ConstructionSite;
}
}
if (txtBiddingProjectScope != null)
{
if (getFireWork != null)
{
txtBiddingProjectScope.Text = getFireWork.BiddingProjectScope;
}
}
if (txtBiddingProjectContent != null)
{
if (getFireWork != null)
{
txtBiddingProjectContent.Text = getFireWork.BiddingProjectContent;
}
}
if (txtTimeRequirements != null)
{
if (getFireWork != null)
{
txtTimeRequirements.Text = getFireWork.TimeRequirements;
}
}
if (txtQualityRequirement != null)
{
if (getFireWork != null)
{
txtQualityRequirement.Text = getFireWork.QualityRequirement;
}
}
if (txtHSERequirement != null)
{
if (getFireWork != null)
{
txtHSERequirement.Text = getFireWork.HSERequirement;
}
}
if (txtTechnicalRequirement != null)
{
if (getFireWork != null)
{
txtTechnicalRequirement.Text = getFireWork.TechnicalRequirement;
}
}
if (txtCurrentRequirement != null)
{
if (getFireWork != null)
{
txtCurrentRequirement.Text = getFireWork.CurrentRequirement;
}
}
if (txtSub_Selection != null)
{
if (getFireWork != null)
{
txtSub_Selection.Text = getFireWork.Sub_Selection;
}
}
if (txtBid_Selection != null)
{
if (getFireWork != null)
{
txtBid_Selection.Text = getFireWork.Bid_Selection;
}
}
if (txtContractingMode_Select != null)
{
if (getFireWork != null)
{
txtContractingMode_Select.Text = getFireWork.ContractingMode_Select;
}
}
if (txtPriceMode_Select != null)
{
if (getFireWork != null)
{
txtPriceMode_Select.Text = getFireWork.PriceMode_Select;
}
}
if (txtMaterialsDifferentiate != null)
{
if (getFireWork != null)
{
txtMaterialsDifferentiate.Text = getFireWork.MaterialsDifferentiate;
}
}
if (txtImportExplain != null)
{
if (getFireWork != null)
{
txtImportExplain.Text = getFireWork.ImportExplain;
}
}
if (txtShortNameList != null)
{
if (getFireWork != null)
{
txtShortNameList.Text = getFireWork.ShortNameList;
}
}
if (txtEvaluationMethods != null)
{
if (getFireWork != null)
{
txtEvaluationMethods.Text = getFireWork.EvaluationMethods;
}
}
if (txtEvaluationPlan != null)
{
if (getFireWork != null)
{
txtEvaluationPlan.Text = getFireWork.EvaluationPlan;
}
}
if (txtBiddingMethods_Select != null)
{
if (getFireWork != null)
{
txtBiddingMethods_Select.Text = getFireWork.BiddingMethods_Select;
}
}
if (txtSchedulePlan != null)
{
if (getFireWork != null)
{
txtSchedulePlan.Text = getFireWork.SchedulePlan;
}
}
if (!string.IsNullOrEmpty(getFireWork.AttachUrlContent))
{
var Path = newUrl.Replace(".docx", "编辑栏.docx"); //word文件保存路径
AsposeWordHelper.HtmlIntoWord(getFireWork.AttachUrlContent, Path);
Document doc2 = new Document(Path);
DocumentBuilder builder = new DocumentBuilder(doc2);
//doc2.FirstSection.PageSetup.SectionStart = SectionStart.OddPage;
builder.PageSetup.PaperSize = PaperSize.A4;
doc.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
doc.UpdateWordCount();
File.Delete(Path);
}
doc.Save(newUrl);
//生成PDF文件
string pdfUrl = newUrl.Replace(".docx", ".pdf");
BLL.AsposeWordHelper.WordIntoPdf(newUrl, pdfUrl);
//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.ActionPlanCode + "施工分包实施计划");
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);
}
#endregion
}