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,7 @@
using System.Collections.Generic;
using Aspose.Words;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web.UI.WebControls;
@@ -27,8 +30,6 @@ namespace BLL
return Funs.DB.PHTGL_ActionPlanFormation.FirstOrDefault(e => e.ActionPlanCode == actionPlanCode);
}
/// <summary>
/// 添加
/// </summary>
@@ -226,6 +227,366 @@ namespace BLL
}
}
/// <summary>
/// ActionPlanID
/// </summary>
/// <param name="Id"></param>
public static Document Print( string Id)
{
string rootPath = Funs.RootPath;
//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);
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 q = PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(Id);
var doc = BLL.PHTGL_ActionPlanFormationService.Print( Id);
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(pdfUrl).Replace("施工招标实施计划审批表", q.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);
}
}
}
@@ -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);
}
}
}
@@ -1,4 +1,7 @@
using System.Collections.Generic;
using Aspose.Words;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BLL
@@ -157,7 +160,120 @@ 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";
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);
///更新书签
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));
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);
}
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;
var q = GetPHTGL_BidDocumentsReviewById(Id);
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).Replace("招标文件审批表", q.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);
}
}
}
@@ -1,4 +1,10 @@
using System.Collections.Generic;
using Aspose.Words;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web.UI.WebControls;
@@ -16,7 +22,6 @@ namespace BLL
/// </summary>
public const int Type_MinPrice = 1;
public const string BidReport = "SetSubReview_sch";
public static ListItem[] GetCreateType()
{
@@ -166,6 +171,224 @@ namespace BLL
select x).ToList();
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;
string strSql = "";
var getFireWork = PHTGL_SetSubReviewService.GetPHTGL_SetSubReviewById(Id);
var BidUser = PHTGL_BidApproveUserReviewService.GetPHTGL_BidApproveUserReviewById(getFireWork.ApproveUserReviewID);
var BidDoc = PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(BidUser.BidDocumentsReviewId);
var Act = BLL.PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(BidDoc.ActionPlanID);
switch (getFireWork.Type)
{
case PHTGL_SetSubReviewService.Type_ConEvaluation:
if (Act != null)
{
if (PHTGL_ActionPlanReviewService.IsSpecialProject(Act.ProjectID))
{
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于综合评估法)LW.docx";
}
else
{
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于综合评估法).docx";
}
}
strSql = @" SELECT
Sch2.Company as Company
,Sch2.Price_ReviewResults as Price_ReviewResults
,Sch2.Skill_ReviewResults as Skill_ReviewResults
,Sch2.Business_ReviewResults as Business_ReviewResults
,Sch2.Synthesize_ReviewResults as Synthesize_ReviewResults
,Sch2.Remarks as Remarks "
+ @" FROM PHTGL_SetSubReview_Sch2 AS Sch2 "
+ @"where 1=1 AND SetSubReviewID = @SetSubReviewID order by SortIndex ";
break;
case PHTGL_SetSubReviewService.Type_MinPrice:
if (Act != null)
{
if (PHTGL_ActionPlanReviewService.IsSpecialProject(Act.ProjectID))
{
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于经评审的最低投标报价法)LW.docx";
}
else
{
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于经评审的最低投标报价法).docx";
}
}
strSql = @" SELECT
Sch1.Company as Company
,Sch1.ReviewResults as ReviewResults
,Sch1.Remarks as Remarks "
+ @" FROM PHTGL_SetSubReview_Sch1 AS Sch1 "
+ @"where 1=1 AND SetSubReviewID = @SetSubReviewID order by SortIndex ";
break;
}
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);
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@SetSubReviewID", 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);
var model_ConstructionManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.ConstructionManager);
var model_ProjectManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.ProjectManager);
var model_Approval_Construction = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.Approval_Construction);
var model_DeputyGeneralManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(Id, getFireWork.DeputyGeneralManager);
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
Dic_File.Add("txtSetSubReviewCode", getFireWork.SetSubReviewCode);
Dic_File.Add("txtBidDocumentsCode", BidDoc.BidDocumentsCode);
Dic_File.Add("txtProjectName", Act.ProjectShortName);
Dic_File.Add("txtBidContent", BidDoc.BidContent);
Dic_File.Add("txtBidding_StartTime", string.Format("{0:D}", BidDoc.Bidding_StartTime));
if (getFireWork.State == Const.ContractReview_Complete)
{
Dic_File.Add("txtConstructionManagerIdea", model_ConstructionManager.ApproveIdea.Length > 3 ? model_ConstructionManager.ApproveIdea : "同意");
Dic_File.Add("ConstructionManagerTime", string.Format("{0:D}", DateTime.Parse(model_ConstructionManager.ApproveDate)));
Dic_File.Add("txtApproval_ConstructionIdea", model_Approval_Construction.ApproveIdea.Length > 3 ? model_Approval_Construction.ApproveIdea : "同意");
Dic_File.Add("Approval_ConstructionTime", string.Format("{0:D}", DateTime.Parse(model_Approval_Construction.ApproveDate)));
Dic_File.Add("ProjectManagerIdea", model_ProjectManager.ApproveIdea.Length > 3 ? model_ProjectManager.ApproveIdea : "同意");
Dic_File.Add("ProjectManagerTime", string.Format("{0:D}", DateTime.Parse(model_ProjectManager.ApproveDate)));
Dic_File.Add("txtDeputyGeneralManagerIdea", model_DeputyGeneralManager.ApproveIdea.Length > 3 ? model_DeputyGeneralManager.ApproveIdea : "同意");
Dic_File.Add("DeputyGeneralManagerTime", string.Format("{0:D}", DateTime.Parse(model_DeputyGeneralManager.ApproveDate)));
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, "");
}
else
{
Dic_File.Add("txtConstructionManagerIdea", "");
Dic_File.Add("ConstructionManagerTime", " 年 月 日");
Dic_File.Add("txtApproval_ConstructionIdea", "");
Dic_File.Add("Approval_ConstructionTime", " 年 月 日");
Dic_File.Add("ProjectManagerIdea", "");
Dic_File.Add("ProjectManagerTime", " 年 月 日");
Dic_File.Add("txtDeputyGeneralManagerIdea", "");
Dic_File.Add("DeputyGeneralManagerTime", " 年 月 日");
}
foreach (var item in Dic_File)
{
string[] key = { item.Key };
object[] value = { item.Value };
doc.MailMerge.Execute(key, value);
}
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;
string initTemplatePath = string.Empty;
var getFireWork = PHTGL_SetSubReviewService.GetPHTGL_SetSubReviewById(Id);
var BidUser = PHTGL_BidApproveUserReviewService.GetPHTGL_BidApproveUserReviewById(getFireWork.ApproveUserReviewID);
var BidDoc = PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(BidUser.BidDocumentsReviewId);
var Act = BLL.PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(BidDoc.ActionPlanID);
switch (getFireWork.Type)
{
case PHTGL_SetSubReviewService.Type_ConEvaluation:
if (Act != null)
{
if (PHTGL_ActionPlanReviewService.IsSpecialProject(Act.ProjectID))
{
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于综合评估法)LW.docx";
}
else
{
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于综合评估法).docx";
}
}
break;
case PHTGL_SetSubReviewService.Type_MinPrice:
if (Act != null)
{
if (PHTGL_ActionPlanReviewService.IsSpecialProject(Act.ProjectID))
{
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于经评审的最低投标报价法)LW.docx";
}
else
{
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于经评审的最低投标报价法).docx";
}
}
break;
}
newUrl = rootPath + initTemplatePath;
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);
}
}
}
@@ -268,7 +268,7 @@ namespace BLL
/// 合同评审、审批表
/// </summary>
/// <param name="contractId"></param>
public static void Print(string ContractReviewId)
public static Document Print(string ContractReviewId)
{
string rootPath = Funs.RootPath;
string initTemplatePath = string.Empty;
@@ -281,7 +281,6 @@ namespace BLL
{
initTemplatePath = "File\\Word\\PHTGL\\合同评审、审批表Old.docx";
}
else
{
@@ -542,7 +541,7 @@ namespace BLL
{
File.Delete(newUrl);
}
return;
return null;
}
@@ -576,17 +575,35 @@ namespace BLL
}
}
var table0 = docc.GetChildNodes(NodeType.Table, true)[0] as Aspose.Words.Tables.Table;
docc.Save(newUrl);
Document doc1 = new Aspose.Words.Document(newUrl);
File.Delete(newUrl);
return doc1;
}
public static void PrintFile( string ContractReviewId)
{
string rootPath = Funs.RootPath;
var ReviewModel = BLL.PHTGL_ContractReviewService.GetPHTGL_ContractReviewById(ContractReviewId);
var getFireWork = BLL.ContractService.GetContractById(ReviewModel.ContractId);
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(ContractReviewId);
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("合同评审", txtContractNum + "合同评审");
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).Replace("合同评审", getFireWork.ContractNum + "合同评审");
FileInfo info = new FileInfo(pdfUrl);
long fileSize = info.Length;
System.Web.HttpContext.Current.Response.Clear();
@@ -598,6 +615,37 @@ namespace BLL
System.Web.HttpContext.Current.Response.Close();
File.Delete(newUrl);
File.Delete(pdfUrl);
}
public static void PrintApprovalForm(string ContractReviewId)
{
var ReviewModel = BLL.PHTGL_ContractReviewService.GetPHTGL_ContractReviewById(ContractReviewId);
var getFireWork = BLL.ContractService.GetContractById(ReviewModel.ContractId);
switch (getFireWork.ConfirmWay)
{
case "1":
break;
case "2":
break;
case "3":
break;
case "4":
break;
case "5":
break;
case "6":
break;
}
}
public static void PrintApprovalFormType_Act()
{
}
public static void PrintApprovalFormType_SetSub()
{
}
public static void PrintApprovalFormType__Con()
{
}
/// <summary>
/// 分包合同协议书
@@ -969,8 +1017,6 @@ namespace BLL
return doc;
}
#region
public static Document sch1(string AttachUrlId, int schnumber)
{