3083 lines
148 KiB
C#
3083 lines
148 KiB
C#
using Aspose.Words;
|
||
using FineUIPro;
|
||
using Model;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Reflection;
|
||
|
||
namespace BLL
|
||
{
|
||
|
||
public static class PHTGL_ContractReviewService
|
||
{
|
||
|
||
public static Model.PHTGL_ContractReview GetPHTGL_ContractReviewById(string ContractReviewId)
|
||
{
|
||
return Funs.DB.PHTGL_ContractReview.FirstOrDefault(e => e.ContractReviewId == ContractReviewId);
|
||
}
|
||
|
||
public static Model.PHTGL_ContractReview GetPHTGL_ContractReviewByContractId(string ContractId)
|
||
|
||
{
|
||
return Funs.DB.PHTGL_ContractReview.FirstOrDefault(e => e.ContractId == ContractId);
|
||
}
|
||
public static List<PrintModel> GetPrintCountersignModels()
|
||
{
|
||
|
||
List<PrintModel> model = new List<PrintModel>();
|
||
model.Add(new PrintModel { Number = 1, Rolename = "施工经理" });
|
||
model.Add(new PrintModel { Number = 2, Rolename = "HSE经理" });
|
||
model.Add(new PrintModel { Number = 3, Rolename = "质量经理" });
|
||
model.Add(new PrintModel { Number = 4, Rolename = "采购经理" });
|
||
model.Add(new PrintModel { Number = 5, Rolename = "控制经理" });
|
||
model.Add(new PrintModel { Number = 6, Rolename = "财务经理" });
|
||
model.Add(new PrintModel { Number = 7, Rolename = "项目经理" });
|
||
model.Add(new PrintModel { Number = 8, Rolename = "施工管理部" });
|
||
model.Add(new PrintModel { Number = 9, Rolename = "法律合规部" });
|
||
return model;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 获取审批人员
|
||
/// </summary>
|
||
/// <param name="ContractReviewId"></param>
|
||
/// <returns></returns>
|
||
public static List<ApproveManModel> GetApproveManModels(string ContractReviewId)
|
||
{
|
||
|
||
Model.PHTGL_ContractReview table = table = GetPHTGL_ContractReviewById(ContractReviewId);
|
||
|
||
|
||
List<ApproveManModel> approveManModels = new List<ApproveManModel>();
|
||
approveManModels.Add(new ApproveManModel { Number = 7, userid = table.Approval_SubProjectManager, Rolename = "会签项目经理" });
|
||
approveManModels.Add(new ApproveManModel { Number = 8, userid = table.Countersign_Construction, Rolename = "会签施工管理部" });
|
||
approveManModels.Add(new ApproveManModel { Number = 9, userid = table.Countersign_Law, Rolename = "会签法律合规部1" });
|
||
approveManModels.Add(new ApproveManModel { Number = 10, userid = table.Countersign_Law2, Rolename = "会签法律合规部2" });
|
||
approveManModels.Add(new ApproveManModel { Number = 11, userid = table.Approval_Construction, Rolename = "签订施工管理部" });
|
||
approveManModels.Add(new ApproveManModel { Number = 12, userid = table.Approval_Law, Rolename = "签订法律合规部" });
|
||
approveManModels.Add(new ApproveManModel { Number = 13, userid = table.Approval_ProjectManager, Rolename = "签订项目经理" });
|
||
approveManModels.Add(new ApproveManModel { Number = 14, userid = table.Approval_DeputyGeneralManager, Rolename = "分管副总经理" });
|
||
approveManModels.Add(new ApproveManModel { Number = 15, userid = table.Approval_GeneralAccountant, Rolename = "总会计师" });
|
||
approveManModels.Add(new ApproveManModel { Number = 16, userid = table.Approval_GeneralLaw, Rolename = "总法律顾问" });
|
||
approveManModels.Add(new ApproveManModel { Number = 17, userid = table.Approval_GeneralManager, Rolename = "总经理" });
|
||
approveManModels.Add(new ApproveManModel { Number = 18, userid = table.Approval_Chairman, Rolename = "董事长" });
|
||
return approveManModels;
|
||
}
|
||
/// <summary>
|
||
/// 获取会签评审中的会签人员
|
||
/// </summary>
|
||
/// <param name="ContractReviewId"></param>
|
||
/// <returns></returns>
|
||
public static List<ApproveManModel> GetApproveManModels__Countersigner(string ContractReviewId)
|
||
{
|
||
|
||
Model.PHTGL_ContractReview table = table = GetPHTGL_ContractReviewById(ContractReviewId);
|
||
List<ApproveManModel> approveManModels = new List<ApproveManModel>();
|
||
approveManModels.Add(new ApproveManModel { Number = 1, userid = table.Countersign_ConstructionManager, Rolename = "会签施工经理" });
|
||
approveManModels.Add(new ApproveManModel { Number = 2, userid = table.Countersign_HSSEManager, Rolename = "会签HSE经理" });
|
||
approveManModels.Add(new ApproveManModel { Number = 3, userid = table.Countersign_QAManager, Rolename = "会签质量经理" });
|
||
approveManModels.Add(new ApproveManModel { Number = 4, userid = table.Countersign_PurchasingManager, Rolename = "会签采购经理" });
|
||
approveManModels.Add(new ApproveManModel { Number = 5, userid = table.Countersign_ControlManager, Rolename = "会签控制经理" });
|
||
approveManModels.Add(new ApproveManModel { Number = 6, userid = table.Countersign_FinancialManager, Rolename = "会签财务经理" });
|
||
|
||
return approveManModels;
|
||
}
|
||
/// <summary>
|
||
/// 获取审批完成的合同
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static DataTable GetContractReview_CompleteData(string ProjectId)
|
||
{
|
||
string strSql = @" select
|
||
con.ContractId,
|
||
SUBSTRING(Con.ContractNum, 1, CHARINDEX('.', Con.ContractNum) - 1) as ProjectCode,
|
||
Pro.ShortName,
|
||
Con.ContractName,
|
||
Con.ContractNum,
|
||
Sub.SubConstruction,
|
||
Con.Currency,
|
||
Con.ContractAmount,
|
||
Con.EPCCode,
|
||
con.ProjectShortName,
|
||
(convert(varchar(20), Sub.SignedYear) + '年' + convert(varchar(20), Sub.SignedMonth) + '月') as DepartName,
|
||
Sub.Bank1,
|
||
Sub.SubcontractPriceForm,
|
||
Sub.Account1"
|
||
+ @" from PHTGL_Contract as Con "
|
||
+ @" left join PHTGL_SubcontractAgreement as Sub on Sub.ContractId=Con.ContractId "
|
||
+ @" left join Base_Project as Pro on con.ProjectId=Pro.ProjectId "
|
||
+ @" WHERE 1=1 and Con.ApproveState=@ContractReview_Complete";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
|
||
listStr.Add(new SqlParameter("@ContractReview_Complete", Const.ContractReview_Complete));
|
||
|
||
strSql += " and Con.ProjectId =@ProjectId";
|
||
|
||
listStr.Add(new SqlParameter("@ProjectId", ProjectId));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
return tb;
|
||
}
|
||
public static void AddPHTGL_ContractReview(Model.PHTGL_ContractReview newtable)
|
||
{
|
||
Model.PHTGL_ContractReview table = new Model.PHTGL_ContractReview();
|
||
table.ContractReviewId = newtable.ContractReviewId;
|
||
table.Countersign_PurchasingManager = newtable.Countersign_PurchasingManager;
|
||
table.Countersign_ControlManager = newtable.Countersign_ControlManager;
|
||
table.Countersign_FinancialManager = newtable.Countersign_FinancialManager;
|
||
table.Countersign_Construction = newtable.Countersign_Construction;
|
||
table.Countersign_Law = newtable.Countersign_Law;
|
||
table.Approval_Construction = newtable.Approval_Construction;
|
||
table.Approval_Law = newtable.Approval_Law;
|
||
table.Approval_SubProjectManager = newtable.Approval_SubProjectManager;
|
||
table.Approval_ProjectManager = newtable.Approval_ProjectManager;
|
||
table.Approval_DeputyGeneralManager = newtable.Approval_DeputyGeneralManager;
|
||
table.ContractId = newtable.ContractId;
|
||
table.Approval_GeneralAccountant = newtable.Approval_GeneralAccountant;
|
||
table.Approval_GeneralManager = newtable.Approval_GeneralManager;
|
||
table.Approval_Chairman = newtable.Approval_Chairman;
|
||
table.SetSubReviewId = newtable.SetSubReviewId;
|
||
table.DocumentNumber = newtable.DocumentNumber;
|
||
table.State = newtable.State;
|
||
table.CreateUser = newtable.CreateUser;
|
||
table.Countersign_ConstructionManager = newtable.Countersign_ConstructionManager;
|
||
table.Countersign_HSSEManager = newtable.Countersign_HSSEManager;
|
||
table.Countersign_QAManager = newtable.Countersign_QAManager;
|
||
table.Countersign_Law2 = newtable.Countersign_Law2;
|
||
table.Idea = newtable.Idea;
|
||
table.Approval_GeneralLaw = newtable.Approval_GeneralLaw;
|
||
table.DepartId = newtable.DepartId;
|
||
Funs.DB.PHTGL_ContractReview.InsertOnSubmit(table);
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
|
||
public static void UpdatePHTGL_ContractReview(Model.PHTGL_ContractReview newtable)
|
||
{
|
||
Model.PHTGL_ContractReview table = Funs.DB.PHTGL_ContractReview.FirstOrDefault(e => e.ContractReviewId == newtable.ContractReviewId);
|
||
|
||
if (table != null)
|
||
{
|
||
table.ContractReviewId = newtable.ContractReviewId;
|
||
table.Countersign_PurchasingManager = newtable.Countersign_PurchasingManager;
|
||
table.Countersign_ControlManager = newtable.Countersign_ControlManager;
|
||
table.Countersign_FinancialManager = newtable.Countersign_FinancialManager;
|
||
table.Countersign_Construction = newtable.Countersign_Construction;
|
||
table.Countersign_Law = newtable.Countersign_Law;
|
||
table.Approval_Construction = newtable.Approval_Construction;
|
||
table.Approval_Law = newtable.Approval_Law;
|
||
table.Approval_SubProjectManager = newtable.Approval_SubProjectManager;
|
||
table.Approval_ProjectManager = newtable.Approval_ProjectManager;
|
||
table.Approval_DeputyGeneralManager = newtable.Approval_DeputyGeneralManager;
|
||
table.ContractId = newtable.ContractId;
|
||
table.Approval_GeneralAccountant = newtable.Approval_GeneralAccountant;
|
||
table.Approval_GeneralManager = newtable.Approval_GeneralManager;
|
||
table.Approval_Chairman = newtable.Approval_Chairman;
|
||
table.SetSubReviewId = newtable.SetSubReviewId;
|
||
table.DocumentNumber = newtable.DocumentNumber;
|
||
table.State = newtable.State;
|
||
table.CreateUser = newtable.CreateUser;
|
||
table.Countersign_ConstructionManager = newtable.Countersign_ConstructionManager;
|
||
table.Countersign_HSSEManager = newtable.Countersign_HSSEManager;
|
||
table.Countersign_QAManager = newtable.Countersign_QAManager;
|
||
table.Countersign_Law2 = newtable.Countersign_Law2;
|
||
table.Idea = newtable.Idea;
|
||
table.Approval_GeneralLaw = newtable.Approval_GeneralLaw;
|
||
table.DepartId = newtable.DepartId;
|
||
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// 根据主键删除审批信息
|
||
/// </summary>
|
||
/// <param name="contractId"></param>
|
||
public static void DeletePHTGL_ContractReviewById(string contractReviewId)
|
||
{
|
||
Model.PHTGL_ContractReview contract = Funs.DB.PHTGL_ContractReview.FirstOrDefault(e => e.ContractReviewId == contractReviewId);
|
||
if (contract != null)
|
||
{
|
||
Funs.DB.PHTGL_ContractReview.DeleteOnSubmit(contract);
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
}
|
||
|
||
public static DataTable PrintDataTable(string ContractReviewId)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
|
||
DataTable tb = BLL.PHTGL_ApproveService.GetFinalApproveData(ContractReviewId);
|
||
tb.Columns.Add("ApproveNumber", typeof(int));
|
||
tb.Columns.Add("Image", typeof(Byte[]));
|
||
|
||
var ApproveManModels = PHTGL_ContractReviewService.GetApproveManModels(ContractReviewId);
|
||
var ApproveManModels__Countersigner = PHTGL_ContractReviewService.GetApproveManModels__Countersigner(ContractReviewId);
|
||
var allApproveMan = ApproveManModels__Countersigner.Concat(ApproveManModels).ToList();
|
||
|
||
foreach (DataRow dr in tb.Rows)
|
||
{
|
||
string ApproveMan = dr["ApproveMan"].ToString();
|
||
string ApproveIdea = PHTGL_ApproveService.GetApproveManIdea(ContractReviewId, ApproveMan, dr["ApproveType"].ToString());
|
||
var model = allApproveMan.Find(e => e.Rolename == dr["ApproveType"].ToString());
|
||
dr["ApproveIdea"] = ApproveIdea;
|
||
if (model != null)
|
||
{
|
||
dr["ApproveNumber"] = model.Number.ToString();
|
||
|
||
}
|
||
try
|
||
{
|
||
dr["ApproveDate"] = string.Format("{0:D}", DateTime.Parse(dr["ApproveDate"].ToString()));
|
||
|
||
|
||
}
|
||
catch (Exception)
|
||
{
|
||
dr["ApproveDate"] = "";
|
||
}
|
||
if (File.Exists(rootPath + dr["SignatureUrl"]))
|
||
{
|
||
System.IO.FileStream fs = System.IO.File.OpenRead(rootPath + dr["SignatureUrl"]);
|
||
byte[] dt = new byte[fs.Length];
|
||
fs.Read(dt, 0, (int)fs.Length);
|
||
fs.Close();
|
||
// dr["Image"] = Convert.ToBase64String(dt);
|
||
dr["Image"] = dt;
|
||
|
||
}
|
||
else
|
||
{
|
||
dr["Image"] = null;
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
}
|
||
return tb;
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 合同评审、审批表
|
||
/// </summary>
|
||
/// <param name="contractId"></param>
|
||
public static Document Print(string ContractReviewId)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
var ReviewModel = BLL.PHTGL_ContractReviewService.GetPHTGL_ContractReviewById(ContractReviewId);
|
||
var getFireWork = BLL.ContractService.GetContractById(ReviewModel.ContractId);
|
||
if (getFireWork != null && (getFireWork.CreateDate == null || getFireWork.CreateDate < Convert.ToDateTime("2022/4/29 00:00:00")))
|
||
{
|
||
initTemplatePath = "File\\Word\\PHTGL\\合同评审、审批表Old.docx";
|
||
|
||
}
|
||
else
|
||
{
|
||
initTemplatePath = "File\\Word\\PHTGL\\合同评审、审批表.docx";
|
||
if (PHTGL_ActionPlanReviewService.IsSpecialProject(getFireWork.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);
|
||
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
string txtProjectName = "";
|
||
string txtProjectid = "";
|
||
string txtContractName = "";
|
||
string txtContractNum = "";
|
||
string txtParties = "";
|
||
string txtContractAmount = "";
|
||
string txtDepartId = "";
|
||
string txtAgent = "";
|
||
string txtRemark = "";
|
||
string TextArea2 = "";
|
||
string type1 = "□";
|
||
string type2 = "□";
|
||
string type3 = "□";
|
||
string type4 = "□";
|
||
string type5 = "□";
|
||
string node1Time = "";
|
||
string node2Time = "";
|
||
string node3Time = "";
|
||
string node4Time = "";
|
||
string node5Time = "";
|
||
string node6Time = "";
|
||
string node7Time = "";
|
||
string node8Time = "";
|
||
string node9Time = "";
|
||
string node10Time = "";
|
||
string node11Time = "";
|
||
string node12Time = "";
|
||
string node13Time = "";
|
||
string node14Time = "";
|
||
string node15Time = "";
|
||
string node16Time = "";
|
||
string node17Time = "";
|
||
string node18Time = "";
|
||
try
|
||
{
|
||
#region 评审单
|
||
if (getFireWork != null)
|
||
{
|
||
DataTable data = BLL.PHTGL_ApproveService.GetFinalApproveData(ReviewModel.ContractReviewId);
|
||
if (data.Rows != null && data.Rows.Count > 0)
|
||
{
|
||
txtProjectid = string.Format("{0:yyyyMMdd}", Convert.ToDateTime(data.Rows[0]["ApproveDate"].ToString()));
|
||
}
|
||
|
||
txtContractName = getFireWork.ContractName;
|
||
txtContractNum = getFireWork.ContractNum;
|
||
txtParties = getFireWork.Parties;
|
||
txtProjectName = ProjectService.GetProjectNameByProjectId(getFireWork.ProjectId);
|
||
txtContractAmount = getFireWork.ContractAmount.ToString();
|
||
if (!string.IsNullOrEmpty(getFireWork.DepartId))
|
||
{
|
||
txtDepartId = DepartService.getDepartNameById(getFireWork.DepartId);
|
||
}
|
||
if (!string.IsNullOrEmpty(getFireWork.Agent))
|
||
{
|
||
txtAgent = Person_PersonsService.GetPersonsNameById(getFireWork.Agent);
|
||
}
|
||
if (!string.IsNullOrEmpty(getFireWork.Remarks))
|
||
{
|
||
txtRemark = getFireWork.Remarks;
|
||
}
|
||
switch (getFireWork.ContractType)
|
||
{
|
||
case "1":
|
||
type1 = "√";
|
||
break;
|
||
case "2":
|
||
type2 = "√";
|
||
break;
|
||
case "3":
|
||
type3 = "√";
|
||
break;
|
||
case "4":
|
||
type4 = "√";
|
||
break;
|
||
case "5":
|
||
type5 = "√";
|
||
break;
|
||
}
|
||
|
||
}
|
||
DataTable tb = BLL.PHTGL_ApproveService.GetFinalApproveData(ContractReviewId);
|
||
var ApproveManModels = PHTGL_ContractReviewService.GetApproveManModels(ContractReviewId);
|
||
var ApproveManModels__Countersigner = PHTGL_ContractReviewService.GetApproveManModels__Countersigner(ContractReviewId);
|
||
var allApproveMan = ApproveManModels__Countersigner.Concat(ApproveManModels).ToList();
|
||
|
||
foreach (DataRow dr in tb.Rows)
|
||
{
|
||
string ApproveMan = dr["ApproveMan"].ToString();
|
||
string ApproveType = "";
|
||
string ApproveDate = "";
|
||
// string ApproveIdea = dr["ApproveIdea"].ToString();
|
||
string ApproveIdea = PHTGL_ApproveService.GetApproveManIdea(ContractReviewId, ApproveMan, dr["ApproveType"].ToString());
|
||
var model = allApproveMan.Find(e => e.Rolename == dr["ApproveType"].ToString());
|
||
|
||
if (model != null)
|
||
{
|
||
ApproveType = model.Number.ToString();
|
||
|
||
}
|
||
try
|
||
{
|
||
ApproveDate = string.Format("{0:D}", DateTime.Parse(dr["ApproveDate"].ToString()));
|
||
|
||
|
||
}
|
||
catch (Exception)
|
||
{
|
||
ApproveDate = "";
|
||
}
|
||
|
||
switch (ApproveType)
|
||
{
|
||
case "1":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode1", ApproveMan, ApproveIdea);
|
||
node1Time = ApproveDate;
|
||
break;
|
||
case "2":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode2", ApproveMan, ApproveIdea);
|
||
node2Time = ApproveDate;
|
||
break;
|
||
case "3":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode3", ApproveMan, ApproveIdea);
|
||
node3Time = ApproveDate;
|
||
break;
|
||
case "4":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode4", ApproveMan, ApproveIdea);
|
||
node4Time = ApproveDate;
|
||
break;
|
||
case "5":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode5", ApproveMan, ApproveIdea);
|
||
node5Time = ApproveDate;
|
||
break;
|
||
case "6":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode6", ApproveMan, ApproveIdea);
|
||
node6Time = ApproveDate;
|
||
break;
|
||
case "7":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode7", ApproveMan, ApproveIdea);
|
||
node7Time = ApproveDate;
|
||
break;
|
||
case "8":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode8", ApproveMan, ApproveIdea);
|
||
node8Time = ApproveDate;
|
||
break;
|
||
case "9":
|
||
//AsposeWordHelper.InsertImg(doc, rootPath, "txtnode10", ApproveMan, ApproveIdea);
|
||
// node9Time = ApproveDate;
|
||
/*原case 9 为法律合规部一 ,现在将法律合规部一和二意见总结一起。
|
||
*/
|
||
Bookmark bookmarkCreateMan = doc.Range.Bookmarks["txtnode9"];
|
||
bookmarkCreateMan.Text += ApproveIdea;
|
||
break;
|
||
case "10":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode10", ApproveMan, ApproveIdea, true);
|
||
node10Time = ApproveDate;
|
||
break;
|
||
case "11":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode11", ApproveMan, ApproveIdea);
|
||
node11Time = ApproveDate;
|
||
break;
|
||
case "12":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode12", ApproveMan, ApproveIdea);
|
||
node12Time = ApproveDate;
|
||
break;
|
||
case "13":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode13", ApproveMan, ApproveIdea);
|
||
node13Time = ApproveDate;
|
||
break;
|
||
case "14":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode14", ApproveMan, ApproveIdea);
|
||
node14Time = ApproveDate;
|
||
break;
|
||
case "15":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode15", ApproveMan, ApproveIdea);
|
||
node15Time = ApproveDate;
|
||
break;
|
||
case "16":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode16", ApproveMan, ApproveIdea);
|
||
node16Time = ApproveDate;
|
||
break;
|
||
case "17":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode17", ApproveMan, ApproveIdea);
|
||
node17Time = ApproveDate;
|
||
break;
|
||
case "18":
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "txtnode18", ApproveMan, ApproveIdea);
|
||
node18Time = ApproveDate;
|
||
break;
|
||
}
|
||
}
|
||
//if (TextArea2 == "")
|
||
//{
|
||
// TextArea2 = "已按评审意见修改完成,同意签订本合同。";
|
||
|
||
//}
|
||
TextArea2 = ReviewModel.Idea;
|
||
Dic_File.Add("txtProjectName", txtProjectName);
|
||
Dic_File.Add("txtProjectid", txtProjectid);
|
||
Dic_File.Add("txtContractName", txtContractName);
|
||
Dic_File.Add("txtContractNum", txtContractNum);
|
||
Dic_File.Add("txtParties", txtParties);
|
||
Dic_File.Add("txtContractAmount", txtContractAmount);
|
||
Dic_File.Add("txtDepartId", txtDepartId);
|
||
Dic_File.Add("txtAgent", txtAgent);
|
||
Dic_File.Add("txtRemark", txtRemark);
|
||
Dic_File.Add("TextArea2", TextArea2);
|
||
Dic_File.Add("type1", type1);
|
||
Dic_File.Add("type2", type2);
|
||
Dic_File.Add("type3", type3);
|
||
Dic_File.Add("type4", type4);
|
||
Dic_File.Add("type5", type5);
|
||
Dic_File.Add("node1Time", node1Time);
|
||
Dic_File.Add("node2Time", node2Time);
|
||
Dic_File.Add("node3Time", node3Time);
|
||
Dic_File.Add("node4Time", node4Time);
|
||
Dic_File.Add("node5Time", node5Time);
|
||
Dic_File.Add("node6Time", node6Time);
|
||
Dic_File.Add("node7Time", node7Time);
|
||
Dic_File.Add("node8Time", node8Time);
|
||
Dic_File.Add("node9Time", node9Time);
|
||
Dic_File.Add("node10Time", node10Time);
|
||
Dic_File.Add("node11Time", node11Time);
|
||
Dic_File.Add("node12Time", node12Time);
|
||
Dic_File.Add("node13Time", node13Time);
|
||
Dic_File.Add("node14Time", node14Time);
|
||
Dic_File.Add("node15Time", node15Time);
|
||
Dic_File.Add("node16Time", node16Time);
|
||
Dic_File.Add("node17Time", node17Time);
|
||
Dic_File.Add("node18Time", node18Time);
|
||
#endregion
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return null;
|
||
}
|
||
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
|
||
Document docc = new Aspose.Words.Document(newUrl);
|
||
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(docc);
|
||
var TableCount = docc.GetChildNodes(NodeType.Table, true).Count;
|
||
for (int m = 0; m < TableCount; m++)
|
||
{
|
||
var table = docc.GetChildNodes(NodeType.Table, true)[m] as Aspose.Words.Tables.Table;
|
||
for (int i = 0; i < table.Rows.Count; i++)
|
||
{
|
||
for (int j = 0; j < table.Rows[i].Count; j++)
|
||
{
|
||
if (string.IsNullOrEmpty(table.Rows[i].Cells[j].GetText().Replace("\a", "").Trim()))
|
||
{
|
||
Border diagonalBorder = table.Rows[i].Cells[j].CellFormat.Borders[BorderType.DiagonalDown];
|
||
diagonalBorder.Color = Color.Black;
|
||
diagonalBorder.LineStyle = LineStyle.Single;
|
||
diagonalBorder.LineWidth = 0.5;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
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");
|
||
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();
|
||
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);
|
||
|
||
}
|
||
|
||
public static void PrintFileByDocument(Document doc, string name)
|
||
{
|
||
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);
|
||
}
|
||
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("合同评审", name);
|
||
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);
|
||
|
||
}
|
||
|
||
public static void PrintApprovalForm(string ContractReviewId)
|
||
{
|
||
var ReviewModel = BLL.PHTGL_ContractReviewService.GetPHTGL_ContractReviewById(ContractReviewId);
|
||
var getFireWork = BLL.ContractService.GetContractById(ReviewModel.ContractId);
|
||
string projectname = ProjectService.GetProjectNameByProjectId(getFireWork.ProjectId);
|
||
string rootPath = Funs.RootPath;
|
||
|
||
// 清理路径中的非法字符
|
||
string CleanFileName(string input)
|
||
{
|
||
if (string.IsNullOrEmpty(input)) return "Unknown";
|
||
|
||
char[] invalidChars = Path.GetInvalidFileNameChars();
|
||
char[] invalidPathChars = Path.GetInvalidPathChars();
|
||
|
||
string result = input;
|
||
foreach (char c in invalidChars)
|
||
{
|
||
result = result.Replace(c.ToString(), "_");
|
||
}
|
||
foreach (char c in invalidPathChars)
|
||
{
|
||
result = result.Replace(c.ToString(), "_");
|
||
}
|
||
return result;
|
||
}
|
||
|
||
string cleanContractNum = CleanFileName(getFireWork.ContractNum);
|
||
string cleanProjectName = CleanFileName(projectname);
|
||
string cleanContractName = CleanFileName(getFireWork.ContractName);
|
||
|
||
string startPath = rootPath + "File\\Word\\PHTGL\\" + cleanContractNum + "-" + cleanProjectName + "-" + cleanContractName + "-合同管理资料";
|
||
if (!Directory.Exists(startPath))
|
||
{
|
||
Directory.CreateDirectory(startPath);
|
||
}
|
||
string zipPath = rootPath + "File\\Word\\PHTGL\\" + cleanContractNum + "-" + cleanProjectName + "-" + cleanContractName + "-合同管理资料.zip";
|
||
switch (getFireWork.ConfirmWay)
|
||
{
|
||
case "1":
|
||
PrintApprovalFormType_SetSub(ContractReviewId, startPath + "\\");
|
||
break;
|
||
case "2":
|
||
PrintApprovalFormType_SetSub(ContractReviewId, startPath + "\\");
|
||
break;
|
||
case "3":
|
||
PrintApprovalFormType_SetSub(ContractReviewId, startPath + "\\");
|
||
break;
|
||
case "4":
|
||
PrintApprovalFormType_Act(ContractReviewId, startPath + "\\");
|
||
|
||
break;
|
||
case "5":
|
||
PrintApprovalFormType_Act(ContractReviewId, startPath + "\\");
|
||
|
||
break;
|
||
default:
|
||
PrintApprovalFormType__Con(ContractReviewId, startPath + "\\");
|
||
break;
|
||
}
|
||
System.IO.Compression.ZipFile.CreateFromDirectory(startPath, zipPath);
|
||
FileInfo info = new FileInfo(zipPath);
|
||
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(getFireWork.ContractNum + "-" + projectname + "-" + getFireWork.ContractName + "-合同管理资料.zip", System.Text.Encoding.UTF8));
|
||
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
|
||
System.Web.HttpContext.Current.Response.TransmitFile(zipPath, 0, fileSize);
|
||
System.Web.HttpContext.Current.Response.Flush();
|
||
System.Web.HttpContext.Current.Response.Close();
|
||
Funs.DeleteDir(startPath);
|
||
File.Delete(zipPath);
|
||
|
||
}
|
||
/// <summary>
|
||
/// ConfirmWay 4,5
|
||
/// </summary>
|
||
public static void PrintApprovalFormType_Act(string ContractReviewId, string path)
|
||
{
|
||
Model.PHTGL_Contract Contract = new Model.PHTGL_Contract(); //合同信息
|
||
Model.PHTGL_ActionPlanFormation ActPlan = new Model.PHTGL_ActionPlanFormation(); //实施计划编制信息
|
||
Model.PHTGL_ActionPlanFormation ActPlanFormat = new Model.PHTGL_ActionPlanFormation(); //实施计划编制信息
|
||
|
||
var ReviewModel = BLL.PHTGL_ContractReviewService.GetPHTGL_ContractReviewById(ContractReviewId);
|
||
Contract = BLL.ContractService.GetContractById(ReviewModel.ContractId);
|
||
ActPlan = BLL.PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationByCode(Contract.ActionPlanCode);
|
||
ActPlanFormat = PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(ActPlan.ActionPlanID);
|
||
|
||
|
||
var Doc_ActPlan = PHTGL_ActionPlanFormationService.Print(ActPlan.ActionPlanID);
|
||
var Doc_Contract = Print(ContractReviewId);
|
||
|
||
Doc_ActPlan.Save(path + ActPlanFormat.ActionPlanCode + "施工分包实施计划.pdf", SaveFormat.Pdf);
|
||
Doc_Contract.Save(path + Contract.ContractNum + "合同评审.pdf", SaveFormat.Pdf);
|
||
|
||
}
|
||
/// <summary>
|
||
/// ConfirmWay 1,2,3
|
||
/// </summary>
|
||
public static void PrintApprovalFormType_SetSub(string ContractReviewId, string path)
|
||
{
|
||
|
||
Model.PHTGL_Contract Contract = new Model.PHTGL_Contract(); //合同信息
|
||
Model.PHTGL_SetSubReview SetSub = new Model.PHTGL_SetSubReview(); //确认分包商信息
|
||
Model.PHTGL_BidApproveUserReview ApproveUser = new Model.PHTGL_BidApproveUserReview(); //评标小组名单信息
|
||
Model.PHTGL_BidDocumentsReview BidDoc = new Model.PHTGL_BidDocumentsReview();//招标文件信息
|
||
Model.PHTGL_ActionPlanReview ActPlan = new Model.PHTGL_ActionPlanReview();//实施计划信息
|
||
Model.PHTGL_ActionPlanFormation ActPlanFormat = new Model.PHTGL_ActionPlanFormation(); //实施计划编制信息
|
||
|
||
var ReviewModel = BLL.PHTGL_ContractReviewService.GetPHTGL_ContractReviewById(ContractReviewId);
|
||
Contract = BLL.ContractService.GetContractById(ReviewModel.ContractId);
|
||
SetSub = BLL.PHTGL_SetSubReviewService.GetPHTGL_SetSubReviewBySetSubReviewCode(Contract.SetSubReviewCode);
|
||
ApproveUser = BLL.PHTGL_BidApproveUserReviewService.GetPHTGL_BidApproveUserReviewById(SetSub.ApproveUserReviewID);
|
||
BidDoc = BLL.PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(ApproveUser.BidDocumentsReviewId);
|
||
ActPlan = BLL.PHTGL_ActionPlanReviewService.GetPHTGL_ActionPlanReviewById(BidDoc.ActionPlanReviewId);
|
||
ActPlanFormat = PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(ActPlan.ActionPlanID);
|
||
|
||
var Doc_ActPlan = PHTGL_ActionPlanFormationService.Print(ActPlan.ActionPlanID);
|
||
var Doc_BidDoc = PHTGL_BidDocumentsReviewService.Print(BidDoc.BidDocumentsReviewId);
|
||
var Doc_ApproveUser = PHTGL_BidApproveUserReviewService.Print(ApproveUser.ApproveUserReviewID);
|
||
var Doc_SetSub = PHTGL_SetSubReviewService.Print(SetSub.SetSubReviewID);
|
||
var Doc_Contract = Print(ContractReviewId);
|
||
|
||
Doc_ActPlan.Save(path + ActPlanFormat.ActionPlanCode + "施工分包实施计划.pdf", SaveFormat.Pdf);
|
||
Doc_BidDoc.Save(path + BidDoc.BidDocumentsCode + "招标文件审批表.pdf", SaveFormat.Pdf);
|
||
Doc_ApproveUser.Save(path + "施工招标评标小组名单审批表.pdf", SaveFormat.Pdf);
|
||
Doc_SetSub.Save(path + SetSub.SetSubReviewCode + "确定分包商审批表.pdf", SaveFormat.Pdf);
|
||
Doc_Contract.Save(path + Contract.ContractNum + "合同评审.pdf", SaveFormat.Pdf);
|
||
}
|
||
public static void PrintApprovalFormType__Con(string ContractReviewId, string path)
|
||
{
|
||
Model.PHTGL_Contract Contract = new Model.PHTGL_Contract(); //合同信息
|
||
var ReviewModel = BLL.PHTGL_ContractReviewService.GetPHTGL_ContractReviewById(ContractReviewId);
|
||
Contract = BLL.ContractService.GetContractById(ReviewModel.ContractId);
|
||
|
||
var Doc_Contract = Print(ContractReviewId);
|
||
Doc_Contract.Save(path + Contract.ContractNum + "合同评审.pdf", SaveFormat.Pdf);
|
||
|
||
}
|
||
/// <summary>
|
||
/// 分包合同协议书
|
||
/// </summary>
|
||
/// <param name="AttachUrlId"></param>
|
||
/// <returns></returns>
|
||
public static void printContractAgreement(string ContractId)
|
||
{
|
||
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-dd-HH-mm}", DateTime.Now) + ".docx");
|
||
filePath = initTemplatePath.Replace(".docx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".docx");
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
var sub = BLL.SubcontractAgreementService.GetSubcontractAgreementByContractId(ContractId);
|
||
var ContractModel = BLL.ContractService.GetContractById(ContractId);
|
||
if (sub == null)
|
||
{
|
||
Alert.ShowInTop("分包合同协议书未编制,无法导出!", MessageBoxIcon.Warning);
|
||
File.Delete(newUrl);
|
||
return;
|
||
}
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
|
||
#region 定义文本域
|
||
string ContractNum = ContractModel.ContractNum;
|
||
string BuildUnit = ContractModel.BuildUnit;
|
||
string tab2_txtGeneralContractor = sub.GeneralContractor;
|
||
string tab2_txtSubConstruction = sub.SubConstruction;
|
||
string tab2_txtContents = sub.Contents;
|
||
string tab2_txtContractProject = sub.ContractProject;
|
||
string tab2_txtContractProjectOwner = sub.ContractProjectOwner;
|
||
string tab2_txtSubProject = sub.SubProject;
|
||
string tab2_txtSubProjectAddress = sub.SubProjectAddress;
|
||
string tab2_txtFundingSources = sub.FundingSources;
|
||
string tab2_txtSubProjectContractScope = sub.SubProjectContractScope;
|
||
string tab2_txtSubProjectContent = sub.SubProjectContent;
|
||
string tab2_txtPlanStartYear = sub.PlanStartYear.HasValue ? sub.PlanStartYear.ToString() : "";
|
||
string tab2_txtPlanStartMonth = sub.PlanStartMonth.HasValue ? sub.PlanStartMonth.ToString() : "";
|
||
string tab2_txtPlanStartDay = sub.PlanStartDay.HasValue ? sub.PlanStartDay.ToString() : "";
|
||
string tab2_txtPlanEndYear = sub.PlanEndYear.HasValue ? sub.PlanEndYear.ToString() : "";
|
||
string tab2_txtPlanEndMonth = sub.PlanEndMonth.HasValue ? sub.PlanEndMonth.ToString() : "";
|
||
string tab2_txtPlanEndDay = sub.PlanEndDay.HasValue ? sub.PlanEndDay.ToString() : "";
|
||
string tab2_txtLimit = sub.Limit.HasValue ? sub.Limit.ToString() : "";
|
||
string tab2_txtQualityStandards = sub.QualityStandards;
|
||
string tab2_txtHSEManageStandards = sub.HSEManageStandards;
|
||
string tab2_txtSubcontractPriceForm = sub.SubcontractPriceForm;
|
||
string tab2_txtContractPriceCapital = sub.ContractPriceCapital;
|
||
string tab2_txtContractPriceCNY = sub.ContractPriceCNY.HasValue ? sub.ContractPriceCNY.ToString() : "";
|
||
string tab2_txtContractPriceDesc = sub.ContractPriceDesc;
|
||
string tab2_txtInvoice = sub.Invoice;
|
||
string tab2_txtLaw = sub.Law;
|
||
string tab2_txtSignedYear = sub.SignedYear.HasValue ? sub.SignedYear.ToString() : "";
|
||
string tab2_txtSignedMonth = sub.SignedMonth.HasValue ? sub.SignedMonth.ToString() : "";
|
||
string tab2_txtSignedAddress = sub.SignedAddress;
|
||
string tab2_txtAgreementNum = sub.AgreementNum.HasValue ? sub.AgreementNum.ToString() : "";
|
||
string tab2_txtGeneralContractorNum = sub.GeneralContractorNum.HasValue ? sub.GeneralContractorNum.ToString() : "";
|
||
string tab2_txtSubContractorNum = sub.SubContractorNum.HasValue ? sub.SubContractorNum.ToString() : "";
|
||
string tab2_txtSub = sub.SubConstruction;
|
||
string tab2_txtSocialCreditCode1 = sub.SocialCreditCode1;
|
||
string tab2_txtSocialCreditCode2 = sub.SocialCreditCode2;
|
||
string tab2_txtAddress1 = sub.Address1;
|
||
string tab2_txtAddress2 = sub.Address2;
|
||
string tab2_txtZipCode1 = sub.ZipCode1;
|
||
string tab2_txtZipCode2 = sub.ZipCode2;
|
||
string tab2_txtLegalRepresentative1 = sub.LegalRepresentative1;
|
||
string tab2_txtLegalRepresentative2 = sub.LegalRepresentative2;
|
||
string tab2_txtEntrustedAgent1 = sub.EntrustedAgent1;
|
||
string tab2_txtEntrustedAgent2 = sub.EntrustedAgent2;
|
||
string tab2_txtTelephone1 = sub.Telephone1;
|
||
string tab2_txtTelephone2 = sub.Telephone2;
|
||
string tab2_txtFax1 = sub.Fax1;
|
||
string tab2_txtFax2 = sub.Fax2;
|
||
string tab2_txtEmail1 = sub.Email1;
|
||
string tab2_txtEmail2 = sub.Email2;
|
||
string tab2_txtBank1 = sub.Bank1;
|
||
string tab2_txtBank2 = sub.Bank2;
|
||
string tab2_txtAccount1 = sub.Account1;
|
||
string tab2_txtAccount2 = sub.Account2;
|
||
|
||
Dic_File.Add("ContractNum", ContractNum);
|
||
Dic_File.Add("BuildUnit", BuildUnit);
|
||
Dic_File.Add("tab2_txtGeneralContractor", tab2_txtGeneralContractor);
|
||
Dic_File.Add("tab2_txtSubConstruction", tab2_txtSubConstruction);
|
||
Dic_File.Add("tab2_txtContents", tab2_txtContents);
|
||
Dic_File.Add("tab2_txtContractProject", tab2_txtContractProject);
|
||
Dic_File.Add("tab2_txtContractProjectOwner", tab2_txtContractProjectOwner);
|
||
Dic_File.Add("tab2_txtSubProject", tab2_txtSubProject);
|
||
Dic_File.Add("tab2_txtSubProjectAddress", tab2_txtSubProjectAddress);
|
||
Dic_File.Add("tab2_txtFundingSources", tab2_txtFundingSources);
|
||
Dic_File.Add("tab2_txtSubProjectContractScope", tab2_txtSubProjectContractScope);
|
||
Dic_File.Add("tab2_txtSubProjectContent", tab2_txtSubProjectContent);
|
||
Dic_File.Add("tab2_txtPlanStartYear", tab2_txtPlanStartYear);
|
||
Dic_File.Add("tab2_txtPlanStartMonth", tab2_txtPlanStartMonth);
|
||
Dic_File.Add("tab2_txtPlanStartDay", tab2_txtPlanStartDay);
|
||
Dic_File.Add("tab2_txtPlanEndYear", tab2_txtPlanEndYear);
|
||
Dic_File.Add("tab2_txtPlanEndMonth", tab2_txtPlanEndMonth);
|
||
Dic_File.Add("tab2_txtPlanEndDay", tab2_txtPlanEndDay);
|
||
Dic_File.Add("tab2_txtLimit", tab2_txtLimit);
|
||
Dic_File.Add("tab2_txtQualityStandards", tab2_txtQualityStandards);
|
||
Dic_File.Add("tab2_txtHSEManageStandards", tab2_txtHSEManageStandards);
|
||
Dic_File.Add("tab2_txtSubcontractPriceForm", tab2_txtSubcontractPriceForm);
|
||
Dic_File.Add("tab2_txtContractPriceCapital", tab2_txtContractPriceCapital);
|
||
Dic_File.Add("tab2_txtContractPriceCNY", tab2_txtContractPriceCNY);
|
||
Dic_File.Add("tab2_txtContractPriceDesc", tab2_txtContractPriceDesc);
|
||
Dic_File.Add("tab2_txtInvoice", tab2_txtInvoice);
|
||
Dic_File.Add("tab2_txtLaw", tab2_txtLaw);
|
||
Dic_File.Add("tab2_txtSignedYear", tab2_txtSignedYear);
|
||
Dic_File.Add("tab2_txtSignedMonth", tab2_txtSignedMonth);
|
||
Dic_File.Add("tab2_txtSignedAddress", tab2_txtSignedAddress);
|
||
Dic_File.Add("tab2_txtAgreementNum", tab2_txtAgreementNum);
|
||
Dic_File.Add("tab2_txtGeneralContractorNum", tab2_txtGeneralContractorNum);
|
||
Dic_File.Add("tab2_txtSubContractorNum", tab2_txtSubContractorNum);
|
||
Dic_File.Add("tab2_txtSub", tab2_txtSub);
|
||
Dic_File.Add("tab2_txtSocialCreditCode1", tab2_txtSocialCreditCode1);
|
||
Dic_File.Add("tab2_txtSocialCreditCode2", tab2_txtSocialCreditCode2);
|
||
Dic_File.Add("tab2_txtAddress1", tab2_txtAddress1);
|
||
Dic_File.Add("tab2_txtAddress2", tab2_txtAddress2);
|
||
Dic_File.Add("tab2_txtZipCode1", tab2_txtZipCode1);
|
||
Dic_File.Add("tab2_txtZipCode2", tab2_txtZipCode2);
|
||
Dic_File.Add("tab2_txtLegalRepresentative1", tab2_txtLegalRepresentative1);
|
||
Dic_File.Add("tab2_txtLegalRepresentative2", tab2_txtLegalRepresentative2);
|
||
Dic_File.Add("tab2_txtEntrustedAgent1", tab2_txtEntrustedAgent1);
|
||
Dic_File.Add("tab2_txtEntrustedAgent2", tab2_txtEntrustedAgent2);
|
||
Dic_File.Add("tab2_txtTelephone1", tab2_txtTelephone1);
|
||
Dic_File.Add("tab2_txtTelephone2", tab2_txtTelephone2);
|
||
Dic_File.Add("tab2_txtFax1", tab2_txtFax1);
|
||
Dic_File.Add("tab2_txtFax2", tab2_txtFax2);
|
||
Dic_File.Add("tab2_txtEmail1", tab2_txtEmail1);
|
||
Dic_File.Add("tab2_txtEmail2", tab2_txtEmail2);
|
||
Dic_File.Add("tab2_txtBank1", tab2_txtBank1);
|
||
Dic_File.Add("tab2_txtBank2", tab2_txtBank2);
|
||
Dic_File.Add("tab2_txtAccount1", tab2_txtAccount1);
|
||
Dic_File.Add("tab2_txtAccount2", tab2_txtAccount2);
|
||
#endregion
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
#region 拼接word
|
||
Document docGen = printGeneralTermsConditions(); //通用合同条款
|
||
doc.AppendDocument(docGen, ImportFormatMode.UseDestinationStyles);
|
||
Document docSpe = printSpecialTermsConditions(ContractId);
|
||
doc.AppendDocument(docSpe, ImportFormatMode.UseDestinationStyles);
|
||
|
||
var model = BLL.PHTGL_SpecialTermsConditionsService.GetSpecialTermsConditionsByContractId(ContractId);
|
||
var SpecialTermsConditionsId = model.SpecialTermsConditionsId;
|
||
string strSql = @"SELECT Att.AttachUrlId,
|
||
Att.AttachUrlCode,
|
||
Att.AttachUrlName,
|
||
Att.IsBuild,
|
||
Att.IsSelected,
|
||
Att.SortIndex"
|
||
+ @" FROM PHTGL_AttachUrl AS Att"
|
||
+ @" WHERE 1=1 "
|
||
+ @" and Att.SpecialTermsConditionsId=@SpecialTermsConditionsId and Att.IsSelected=1 ORDER BY Att.SortIndex ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@SpecialTermsConditionsId", SpecialTermsConditionsId));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
int schNumber = 0;
|
||
foreach (DataRow dataRow in tb.Rows)
|
||
{
|
||
schNumber += 1;
|
||
string AttachUrlId = dataRow["AttachUrlId"].ToString();
|
||
string AttachUrlName = dataRow["AttachUrlName"].ToString();
|
||
string SortIndex = dataRow["SortIndex"].ToString();
|
||
switch (SortIndex)
|
||
{
|
||
case "1":
|
||
doc.AppendDocument(sch1(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
|
||
break;
|
||
case "2":
|
||
doc.AppendDocument(sch2(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
|
||
case "3":
|
||
doc.AppendDocument(sch3(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "4":
|
||
doc.AppendDocument(sch4(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "5":
|
||
doc.AppendDocument(sch5(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "6":
|
||
doc.AppendDocument(sch6(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "7":
|
||
doc.AppendDocument(sch7(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "8":
|
||
doc.AppendDocument(sch8(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "9":
|
||
doc.AppendDocument(sch9(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "10":
|
||
doc.AppendDocument(sch10(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "11":
|
||
doc.AppendDocument(sch11(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "12":
|
||
doc.AppendDocument(sch12(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "13":
|
||
doc.AppendDocument(sch13(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "14":
|
||
doc.AppendDocument(sch14(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "15":
|
||
doc.AppendDocument(sch15(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "16":
|
||
doc.AppendDocument(sch16(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "17":
|
||
doc.AppendDocument(sch17(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "18":
|
||
doc.AppendDocument(sch18(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "19":
|
||
doc.AppendDocument(sch19(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
case "20":
|
||
doc.AppendDocument(sch20(AttachUrlId, schNumber), ImportFormatMode.UseDestinationStyles);
|
||
break;
|
||
|
||
}
|
||
|
||
}
|
||
#endregion
|
||
doc.UpdateFields();
|
||
doc.Save(newUrl);
|
||
|
||
string pdfUrl = newUrl.Replace(".doc", ".doc");
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
//Document srcDoc = new Document(newUrl);
|
||
//doc1.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles);
|
||
//验证参数
|
||
if (doc1 == null) { throw new Exception("Word文件无效"); }
|
||
doc1.Save(pdfUrl, Aspose.Words.SaveFormat.Docx);//还可以改成其它格式
|
||
string fileName = Path.GetFileName(filePath).Replace("施工合同标准文本", tab2_txtContractProject + tab2_txtSubProject);
|
||
FileInfo info = new FileInfo(pdfUrl);
|
||
long fileSize = info.Length;
|
||
try
|
||
{
|
||
|
||
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);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
File.Delete(newUrl);
|
||
File.Delete(pdfUrl);
|
||
}
|
||
|
||
|
||
}
|
||
/// <summary>
|
||
/// 导出通用合同条款
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static Document printGeneralTermsConditions()
|
||
{
|
||
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");
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
File.Delete(newUrl);
|
||
return doc;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导出专用合同
|
||
/// </summary>
|
||
/// <param name="ContractId"></param>
|
||
/// <returns></returns>
|
||
public static Document printSpecialTermsConditions(string ContractId)
|
||
{
|
||
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");
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
var model = BLL.PHTGL_SpecialTermsConditionsService.GetSpecialTermsConditionsByContractId(ContractId);
|
||
if (model != null)
|
||
{
|
||
string SpecialTermsConditionsId = model.SpecialTermsConditionsId;
|
||
Type type = model.GetType();
|
||
PropertyInfo[] pArray = type.GetProperties();
|
||
foreach (PropertyInfo p in pArray)
|
||
{
|
||
string name = p.Name;
|
||
string value = Convert.ToString(p.GetValue(model, null));
|
||
Dic_File.Add(name, value);
|
||
}
|
||
string strSql = @"SELECT Att.AttachUrlId,
|
||
Att.AttachUrlCode,
|
||
Att.AttachUrlName,
|
||
Att.IsBuild,
|
||
Att.IsSelected,
|
||
Att.SortIndex"
|
||
+ @" FROM PHTGL_AttachUrl AS Att"
|
||
+ @" WHERE 1=1 "
|
||
+ @" and Att.SpecialTermsConditionsId=@SpecialTermsConditionsId and Att.IsSelected=1 ORDER BY Att.SortIndex ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@SpecialTermsConditionsId", SpecialTermsConditionsId));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
int schNumber = 0;
|
||
string txtSch = "";
|
||
foreach (DataRow dataRow in tb.Rows)
|
||
{
|
||
schNumber += 1;
|
||
string AttachUrlId = dataRow["AttachUrlId"].ToString();
|
||
string AttachUrlName = dataRow["AttachUrlName"].ToString();
|
||
string SortIndex = dataRow["SortIndex"].ToString();
|
||
txtSch = txtSch + "附件" + schNumber + " " + AttachUrlName + "\r\n";
|
||
|
||
}
|
||
Dic_File.Add("txtSch", txtSch);
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
File.Delete(newUrl);
|
||
return doc;
|
||
}
|
||
|
||
#region 附件
|
||
public static Document sch1(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件1 工作内容及要求.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");
|
||
try
|
||
{
|
||
|
||
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
|
||
var model = AttachUrl1Service.GetAttachUrl1ById(AttachUrlId);
|
||
if (model == null)
|
||
{
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", "");
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc;
|
||
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", model.AttachUrlContent);
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch2(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件2 合同价格及支付办法.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Document(newUrl);
|
||
#region 旧
|
||
//DocumentBuilder builder = new DocumentBuilder(doc);
|
||
//Section section = doc.Sections[0];
|
||
//Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
//Dic_File.Add("schNumber", schnumber.ToString());
|
||
//var att = BLL.AttachUrl2Service.GetAttachUrlByAttachUrlId(AttachUrlId);
|
||
//if (att!=null)
|
||
//{ string aaa = "";
|
||
// for (int i = 0; i < section.Body.ChildNodes.Count; i++)
|
||
// {
|
||
// aaa = aaa + "@" + i + "@" + section.Body.ChildNodes[i].Range.Text + "/r";
|
||
// }
|
||
// string b = aaa;
|
||
// ArrayList arraylist = new ArrayList();
|
||
// arraylist.Add("1");
|
||
// arraylist.Add("2");
|
||
// arraylist.Add("3");
|
||
// arraylist.Add("4");
|
||
// arraylist.Add("5");
|
||
// arraylist.Add("6");
|
||
// var aa = att.PayMethod.Split(',');
|
||
// foreach (var item in aa)
|
||
// {
|
||
// arraylist.Remove(item);
|
||
|
||
// }
|
||
// for (int i = 0; i < arraylist .Count; i++)
|
||
// {
|
||
// switch (arraylist[i])
|
||
// {
|
||
// case "1":
|
||
// builder.MoveToBookmark("text1");
|
||
// Paragraph paragraph = builder.CurrentParagraph;
|
||
// paragraph.Remove();
|
||
|
||
// // section.Body.ChildNodes[3].Remove();
|
||
|
||
// break;
|
||
// case "2":
|
||
// builder.MoveToBookmark("text2");
|
||
// Paragraph paragraph2 = builder.CurrentParagraph;
|
||
// paragraph2.Remove();
|
||
// // section.Body.ChildNodes[4].Remove();
|
||
|
||
// break;
|
||
// case "3":
|
||
// builder.MoveToBookmark("text3");
|
||
// Paragraph paragraph3 = builder.CurrentParagraph;
|
||
// paragraph3.NextSibling.Remove();
|
||
// paragraph3.NextSibling.Remove();
|
||
// paragraph3.NextSibling.Remove();
|
||
// paragraph3.NextSibling.Remove();
|
||
// paragraph3.NextSibling.Remove();
|
||
// paragraph3.Remove();
|
||
|
||
// //section.Body.ChildNodes[5].Remove();
|
||
// //section.Body.ChildNodes[6].Remove();
|
||
// //section.Body.ChildNodes[7].Remove();
|
||
// //section.Body.ChildNodes[8].Remove();
|
||
// //section.Body.ChildNodes[9].Remove();
|
||
// //section.Body.ChildNodes[10].Remove();
|
||
|
||
// break;
|
||
// case "4":
|
||
// builder.MoveToBookmark("text4");
|
||
// Paragraph paragraph4 = builder.CurrentParagraph;
|
||
// paragraph4.NextSibling.Remove();
|
||
// paragraph4.NextSibling.Remove();
|
||
// paragraph4.NextSibling.Remove();
|
||
// paragraph4.NextSibling.Remove();
|
||
// paragraph4.NextSibling.Remove();
|
||
// paragraph4.Remove();
|
||
// //section.Body.ChildNodes[11].Remove();
|
||
// //section.Body.ChildNodes[12].Remove();
|
||
// //section.Body.ChildNodes[13].Remove();
|
||
// //section.Body.ChildNodes[14].Remove();
|
||
// //section.Body.ChildNodes[15].Remove();
|
||
// //section.Body.ChildNodes[16].Remove();
|
||
|
||
// break;
|
||
// case "5":
|
||
// builder.MoveToBookmark("text5");
|
||
// Paragraph paragraph5 = builder.CurrentParagraph;
|
||
// paragraph5.NextSibling.Remove();
|
||
// paragraph5.NextSibling.Remove();
|
||
// paragraph5.NextSibling.Remove();
|
||
// paragraph5.NextSibling.Remove();
|
||
// paragraph5.NextSibling.Remove();
|
||
// paragraph5.NextSibling.Remove();
|
||
// paragraph5.Remove();
|
||
|
||
// //section.Body.ChildNodes[17].Remove();
|
||
// //section.Body.ChildNodes[18].Remove();
|
||
// //section.Body.ChildNodes[19].Remove();
|
||
// //section.Body.ChildNodes[20].Remove();
|
||
// //section.Body.ChildNodes[21].Remove();
|
||
// //section.Body.ChildNodes[22].Remove();
|
||
// //section.Body.ChildNodes[23].Remove();
|
||
|
||
// break;
|
||
// case "6":
|
||
// builder.MoveToBookmark("text6");
|
||
// Paragraph paragraph6 = builder.CurrentParagraph;
|
||
// paragraph6.NextSibling.Remove();
|
||
// paragraph6.NextSibling.Remove();
|
||
// paragraph6.NextSibling.Remove();
|
||
// paragraph6.NextSibling.Remove();
|
||
// paragraph6.Remove();
|
||
|
||
// //section.Body.ChildNodes[23].Remove();
|
||
// //section.Body.ChildNodes[24].Remove();
|
||
// //section.Body.ChildNodes[25].Remove();
|
||
// //section.Body.ChildNodes[26].Remove();
|
||
// //section.Body.ChildNodes[27].Remove();
|
||
|
||
// break;
|
||
// }
|
||
// }
|
||
|
||
// string strSql = @" SELECT
|
||
// OrderNumber = row_number() over(order by AttachUrlDetaild)
|
||
// , AttachUrlDetaild
|
||
// , AttachUrlItemId
|
||
// , DetailType
|
||
// , Specifications
|
||
// , MachineTeamPrice
|
||
// , Remark "
|
||
// + @" from PHTGL_AttachUrl2Detail "
|
||
// + @" where 1=1 and AttachUrlItemId=@AttachUrlItemId and DetailType=@DetailType order by OrderNumber";
|
||
// List<SqlParameter> listStr = new List<SqlParameter>();
|
||
// listStr.Add(new SqlParameter("@AttachUrlItemId", att.AttachUrlItemId));
|
||
// listStr.Add(new SqlParameter("@DetailType", "1"));
|
||
|
||
// SqlParameter[] parameter = listStr.ToArray();
|
||
// DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
// if (tb.Rows.Count ==0)
|
||
// {
|
||
// DataRow dataRow = tb.NewRow();
|
||
// tb.Rows.Add(dataRow);
|
||
// }
|
||
// tb.TableName = "Table";
|
||
// doc.MailMerge.ExecuteWithRegions(tb);
|
||
// string aaa2 = "";
|
||
// for (int i = 0; i < section.Body.ChildNodes.Count; i++)
|
||
// {
|
||
// aaa2 = aaa2 + "@" + i + "@" + section.Body.ChildNodes[i].Range.Text + "/r";
|
||
// }
|
||
// string b2 = aaa2;
|
||
|
||
// string strSql2 = @" SELECT
|
||
// OrderNumber = row_number() over(order by AttachUrlDetaild)
|
||
// , AttachUrlDetaild
|
||
// , AttachUrlItemId
|
||
// , DetailType
|
||
// , Specifications
|
||
// , MachineTeamPrice
|
||
// , Remark "
|
||
// + @" from PHTGL_AttachUrl2Detail "
|
||
// + @" where 1=1 and AttachUrlItemId=@AttachUrlItemId and DetailType=@DetailType order by OrderNumber";
|
||
|
||
// List<SqlParameter> listStr2 = new List<SqlParameter>();
|
||
// listStr2.Add(new SqlParameter("@AttachUrlItemId", att.AttachUrlItemId));
|
||
// listStr2.Add(new SqlParameter("@DetailType", "2"));
|
||
// SqlParameter[] parameter2 = listStr2.ToArray();
|
||
// DataTable tb2 = SQLHelper.GetDataTableRunText(strSql2, parameter2);
|
||
// if (tb2.Rows.Count == 0)
|
||
// {
|
||
// DataRow dataRow = tb2.NewRow();
|
||
// tb2.Rows.Add(dataRow);
|
||
// }
|
||
// tb2.TableName = "Table2";
|
||
// doc.MailMerge.ExecuteWithRegions(tb2);
|
||
|
||
// Dic_File.Add("txtContractPrice", att.ContractPrice);
|
||
// Dic_File.Add("txtComprehensiveUnitPrice", att.ComprehensiveUnitPrice);
|
||
// Dic_File.Add("txtComprehensiveRate1", att.ComprehensiveRate1);
|
||
// Dic_File.Add("txtComprehensiveRate2", att.ComprehensiveRate2);
|
||
// Dic_File.Add("txtComprehensiveRate3", att.ComprehensiveRate3);
|
||
// Dic_File.Add("txtComprehensiveRate4", att.ComprehensiveRate4);
|
||
// Dic_File.Add("txtComprehensiveRate5", att.ComprehensiveRate5);
|
||
// Dic_File.Add("txtTotalPriceDown1", att.TotalPriceDown1);
|
||
// Dic_File.Add("txtTotalPriceDown2", att.TotalPriceDown2);
|
||
// Dic_File.Add("txtTotalPriceDown3", att.TotalPriceDown3);
|
||
// Dic_File.Add("txtTotalPriceDown4", att.TotalPriceDown4);
|
||
// Dic_File.Add("txtTotalPriceDown5", att.TotalPriceDown5);
|
||
// Dic_File.Add("txtTechnicalWork", att.TechnicalWork.HasValue ? att.TechnicalWork.ToString() : "");
|
||
// Dic_File.Add("txtPhysicalLaborer", att.PhysicalLaborer.HasValue ? att.PhysicalLaborer.ToString() : "");
|
||
// Dic_File.Add("txtTestCar1", att.TestCar1.HasValue ? att.TestCar1.ToString() : "");
|
||
// Dic_File.Add("txtTestCar2", att.TestCar2.HasValue ? att.TestCar2.ToString() : "");
|
||
// Dic_File.Add("txtPayWay", "");
|
||
// var Path = newUrl.Replace(".docx", "编辑栏.docx"); //word文件保存路径
|
||
// AsposeWordHelper.HtmlIntoWord(att.PayWay, Path);
|
||
// Document doc2 = new Document(Path);
|
||
|
||
// doc2.FirstSection.PageSetup.SectionStart = SectionStart.OddPage;
|
||
|
||
// doc.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
|
||
// File.Delete(Path);
|
||
|
||
//}
|
||
|
||
//foreach (var item in Dic_File)
|
||
//{
|
||
// string[] key = { item.Key };
|
||
// object[] value = { item.Value };
|
||
// doc.MailMerge.Execute(key, value);
|
||
//}
|
||
//doc.Save(newUrl);
|
||
#endregion
|
||
|
||
#region 复制表格版
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
var att = BLL.AttachUrl2Service.GetAttachUrlByAttachUrlId(AttachUrlId);
|
||
if (att != null)
|
||
{
|
||
var Path = newUrl.Replace(".docx", "编辑栏.docx"); //word文件保存路径
|
||
AsposeWordHelper.HtmlIntoWord(att.AttachUrlContent, Path);
|
||
Document doc2 = new Document(Path);
|
||
|
||
doc2.FirstSection.PageSetup.SectionStart = SectionStart.OddPage;
|
||
|
||
doc.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
|
||
File.Delete(Path);
|
||
}
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
doc.Save(newUrl);
|
||
#endregion
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
|
||
}
|
||
|
||
public static Document sch3(string AttachUrlId, int schnumber)
|
||
{
|
||
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件3 工程价格清单.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
var model = AttachUrl3Service.GetAttachUrl3ByAttachUrlId(AttachUrlId);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
|
||
if (model == null)
|
||
{
|
||
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", "");
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc;
|
||
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
// Dic_File.Add("AttachUrlContent", model.AttachUrlContent);
|
||
Dic_File.Add("AttachUrlContent", "");
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
var Path = newUrl.Replace(".docx", "编辑栏.docx"); //word文件保存路径
|
||
AsposeWordHelper.HtmlIntoWord(model.AttachUrlContent, Path);
|
||
Document doc2 = new Document(Path);
|
||
doc2.FirstSection.PageSetup.SectionStart = SectionStart.OddPage;
|
||
doc.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
|
||
File.Delete(Path);
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
Document doc = new Aspose.Words.Document();
|
||
return doc;
|
||
|
||
}
|
||
}
|
||
|
||
public static Document sch4(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件4 工程设备及材料分交.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
// string strSql = @" select
|
||
// url4.AttachUrlItemId
|
||
// ,url4.AttachUrlId
|
||
// ,url4.OrderNumber
|
||
// ,url4.Describe
|
||
// ,(Case url4.Duty_Gen
|
||
// when '0' Then ''
|
||
// when '1' Then '√' end) as Duty_Gen
|
||
// ,(Case url4.Duty_Sub
|
||
// when '0' Then ''
|
||
// when '1' Then '√' end ) Duty_Sub
|
||
// ,url4.Remarks"
|
||
// + @" from PHTGL_AttachUrl4 as url4"
|
||
// + @" where 1=1 and url4.AttachUrlId =@AttachUrlId order by url4.OrderNumber";
|
||
// List<SqlParameter> listStr = new List<SqlParameter>();
|
||
// listStr.Add(new SqlParameter("@AttachUrlId", AttachUrlId));
|
||
// SqlParameter[] parameter = listStr.ToArray();
|
||
// DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
//if (tb.Rows.Count == 0)
|
||
//{
|
||
// DataRow dataRow = tb.NewRow();
|
||
// tb.Rows.Add(dataRow);
|
||
//}
|
||
// tb.TableName = "Table";
|
||
// doc.MailMerge.ExecuteWithRegions(tb);
|
||
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
var model = AttachUrl4Service.GetAttachurl4ById(AttachUrlId);
|
||
if (model != null)
|
||
{
|
||
var Path = newUrl.Replace(".docx", "编辑栏.docx"); //word文件保存路径
|
||
AsposeWordHelper.HtmlIntoWord(model.AttachUrlContent, Path);
|
||
Document doc2 = new Document(Path);
|
||
|
||
doc2.FirstSection.PageSetup.SectionStart = SectionStart.OddPage;
|
||
|
||
doc.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
|
||
File.Delete(Path);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch5(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件5 暂估价材料.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");
|
||
try
|
||
{
|
||
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
|
||
// string strSql = @" select mat.AttachUrlItemId,
|
||
// mat.AttachUrlId,
|
||
// mat.OrderNumber,
|
||
// mat.Name,
|
||
// mat.Spec,
|
||
// mat.Material,
|
||
// mat.Company,
|
||
// mat.UnitPrice,
|
||
// mat.Remarks "
|
||
// + @" from PHTGL_AttachUrl5_MaterialsPrice as mat"
|
||
// + @" where 1=1 and mat.AttachUrlId=@AttachUrlId order by mat.OrderNumber";
|
||
//List<SqlParameter> listStr = new List<SqlParameter>();
|
||
//listStr.Add(new SqlParameter("@AttachUrlId", AttachUrlId));
|
||
//SqlParameter[] parameter = listStr.ToArray();
|
||
//DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
//if (tb.Rows.Count == 0)
|
||
//{
|
||
// DataRow dataRow = tb.NewRow();
|
||
// tb.Rows.Add(dataRow);
|
||
//}
|
||
//tb.TableName = "Table";
|
||
//doc.MailMerge.ExecuteWithRegions(tb);
|
||
|
||
|
||
//string strSql2 = @" SELECT dev.AttachUrlItemId
|
||
// ,dev.AttachUrlId
|
||
// ,dev.OrderNumber
|
||
// ,dev.Name
|
||
// ,dev.Company
|
||
// ,dev.amount
|
||
// ,dev.UnitPrice
|
||
// ,dev.Totalprice
|
||
// ,dev.Remarks "
|
||
// + @" FROM PHTGL_AttachUrl5_DevicePrice as dev"
|
||
// + @" where 1=1 and dev.AttachUrlId=@AttachUrlId order by dev.OrderNumber ";
|
||
|
||
//List<SqlParameter> listStr2 = new List<SqlParameter>();
|
||
//listStr2.Add(new SqlParameter("@AttachUrlId", AttachUrlId));
|
||
//SqlParameter[] parameter2 = listStr2.ToArray();
|
||
//DataTable tb2 = SQLHelper.GetDataTableRunText(strSql2, parameter2);
|
||
//if (tb2.Rows.Count == 0)
|
||
//{
|
||
// DataRow dataRow = tb2.NewRow();
|
||
// tb2.Rows.Add(dataRow);
|
||
//}
|
||
//tb2.TableName = "Table2";
|
||
//doc.MailMerge.ExecuteWithRegions(tb2);
|
||
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
var model = AttachUrl5Service.GetAttachUrl5ByAttachUrlId(AttachUrlId);
|
||
if (model != null)
|
||
{
|
||
var Path = newUrl.Replace(".docx", "编辑栏.docx"); //word文件保存路径
|
||
AsposeWordHelper.HtmlIntoWord(model.AttachUrlContent, Path);
|
||
Document doc2 = new Document(Path);
|
||
|
||
doc2.FirstSection.PageSetup.SectionStart = SectionStart.OddPage;
|
||
|
||
doc.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
|
||
File.Delete(Path);
|
||
}
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch6(string AttachUrlId, int schnumber)
|
||
{
|
||
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件6 关键材料框架协议.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
var model = AttachUrl6Service.GetAttachUrl6ById(AttachUrlId);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
|
||
if (model == null)
|
||
{
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", "");
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc;
|
||
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", model.AttachUrlContent);
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
Document doc = new Aspose.Words.Document();
|
||
return doc;
|
||
|
||
}
|
||
}
|
||
|
||
public static Document sch7(string AttachUrlId, int schnumber)
|
||
{
|
||
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件7 合同工期关键里程碑时间节点.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
var model = AttachUrl7Service.GetAttachUrl7ById(AttachUrlId);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
|
||
if (model == null)
|
||
{
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", "");
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc;
|
||
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", model.AttachUrlContent);
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
Document doc = new Aspose.Words.Document();
|
||
return doc;
|
||
|
||
}
|
||
}
|
||
|
||
public static Document sch8(string AttachUrlId, int schnumber)
|
||
{
|
||
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件8 总承包商关键人员一览表.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
|
||
var model = AttachUrl8Service.GetAttachurl8ById(AttachUrlId);
|
||
if (model == null)
|
||
{
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("txtProjectManager", "");
|
||
Dic_File.Add("txtProjectManager_deputy", "");
|
||
Dic_File.Add("txtSafetyDirector", "");
|
||
Dic_File.Add("txtControlManager", "");
|
||
Dic_File.Add("txtDesignManager", "");
|
||
Dic_File.Add("txtPurchasingManager", "");
|
||
Dic_File.Add("txtConstructionManager", "");
|
||
Dic_File.Add("txtConstructionManager_deputy", "");
|
||
Dic_File.Add("txtQualityManager", "");
|
||
Dic_File.Add("txtHSEManager", "");
|
||
Dic_File.Add("txtDrivingManager", "");
|
||
Dic_File.Add("txtFinancialManager", "");
|
||
Dic_File.Add("txtOfficeManager", "");
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc;
|
||
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("txtProjectManager", model.ProjectManager);
|
||
Dic_File.Add("txtProjectManager_deputy", model.ProjectManager_deputy);
|
||
Dic_File.Add("txtSafetyDirector", model.SafetyDirector);
|
||
Dic_File.Add("txtControlManager", model.ControlManager);
|
||
Dic_File.Add("txtDesignManager", model.DesignManager);
|
||
Dic_File.Add("txtPurchasingManager", model.PurchasingManager);
|
||
Dic_File.Add("txtConstructionManager", model.ConstructionManager);
|
||
Dic_File.Add("txtConstructionManager_deputy", model.ConstructionManager_deputy);
|
||
Dic_File.Add("txtQualityManager", model.QualityManager);
|
||
Dic_File.Add("txtHSEManager", model.HSEManager);
|
||
Dic_File.Add("txtDrivingManager", model.DrivingManager);
|
||
Dic_File.Add("txtFinancialManager", model.FinancialManager);
|
||
Dic_File.Add("txtOfficeManager", model.OfficeManager);
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (model != null)
|
||
{
|
||
var Path = newUrl.Replace(".docx", "编辑栏.docx"); //word文件保存路径
|
||
AsposeWordHelper.HtmlIntoWord(model.AttachUrlContent, Path);
|
||
Document doc2 = new Document(Path);
|
||
|
||
doc2.FirstSection.PageSetup.SectionStart = SectionStart.OddPage;
|
||
|
||
doc.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
|
||
File.Delete(Path);
|
||
}
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
Document doc = new Aspose.Words.Document();
|
||
return doc;
|
||
|
||
}
|
||
}
|
||
|
||
public static Document sch9(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件9 施工分包商组织机构人员配置表及关键人员名单.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
string strSql = @" SELECT OrderNumber = row_number() over(order by AttachUrlItemId),
|
||
AttachUrlItemId
|
||
, AttachUrlId
|
||
, WorkPostName
|
||
, Number
|
||
, Arrivaltime
|
||
, Remarks "
|
||
+ @" from PHTGL_AttachUrl9_SubStaffing "
|
||
+ @" where 1=1 and AttachUrlId =@AttachUrlId order by OrderNumber";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@AttachUrlId", AttachUrlId));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
if (tb.Rows.Count == 0)
|
||
{
|
||
DataRow dataRow = tb.NewRow();
|
||
tb.Rows.Add(dataRow);
|
||
}
|
||
tb.TableName = "Table";
|
||
doc.MailMerge.ExecuteWithRegions(tb);
|
||
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
var model = AttachUrl9_SubPersonService.GetSubPersonByAttachId(AttachUrlId);
|
||
if (model != null)
|
||
{
|
||
Dic_File.Add("txtProjectManager", Convert.ToString(model.ProjectManager));
|
||
Dic_File.Add("txtProjectEngineer", Convert.ToString(model.ProjectEngineer));
|
||
Dic_File.Add("txtConstructionManager", Convert.ToString(model.ConstructionManager));
|
||
Dic_File.Add("txtQualityManager", Convert.ToString(model.QualityManager));
|
||
Dic_File.Add("txtHSEManager", Convert.ToString(model.HSEManager));
|
||
Dic_File.Add("txtPersonnel_Technician", Convert.ToString(model.Personnel_Technician));
|
||
Dic_File.Add("txtPersonnel_Civil_engineering", Convert.ToString(model.Personnel_Civil_engineering));
|
||
Dic_File.Add("txtPersonnel_Installation", Convert.ToString(model.Personnel_Installation));
|
||
Dic_File.Add("txtPersonnel_Electrical", Convert.ToString(model.Personnel_Electrical));
|
||
Dic_File.Add("txtPersonnel_meter", Convert.ToString(model.Personnel_meter));
|
||
}
|
||
else
|
||
{
|
||
Dic_File.Add("txtProjectManager", "");
|
||
Dic_File.Add("txtProjectEngineer", "");
|
||
Dic_File.Add("txtConstructionManager", "");
|
||
Dic_File.Add("txtQualityManager", "");
|
||
Dic_File.Add("txtHSEManager", "");
|
||
Dic_File.Add("txtPersonnel_Technician", "");
|
||
Dic_File.Add("txtPersonnel_Civil_engineering", "");
|
||
Dic_File.Add("txtPersonnel_Installation", "");
|
||
Dic_File.Add("txtPersonnel_Electrical", "");
|
||
Dic_File.Add("txtPersonnel_meter", "");
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch10(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件10 施工分包商人员机械投入计划一览表.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");
|
||
try
|
||
{
|
||
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
|
||
//string strSql = @" SELECT AttachUrlItemId
|
||
// , AttachUrlId
|
||
// , Subject
|
||
// , WorkType
|
||
// , PersonNumber
|
||
// , LifeTime
|
||
// , Remarks "
|
||
// + @" from PHTGL_AttachUrl10_HumanInput "
|
||
// + @" where 1=1 and AttachUrlId=@AttachUrlId order by Subject";
|
||
//List<SqlParameter> listStr = new List<SqlParameter>();
|
||
//listStr.Add(new SqlParameter("@AttachUrlId", AttachUrlId));
|
||
//SqlParameter[] parameter = listStr.ToArray();
|
||
//DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
//if (tb.Rows.Count == 0)
|
||
//{
|
||
// DataRow dataRow = tb.NewRow();
|
||
// tb.Rows.Add(dataRow);
|
||
//}
|
||
//tb.TableName = "Table";
|
||
//doc.MailMerge.ExecuteWithRegions(tb);
|
||
|
||
|
||
//string strSql2 = @" SELECT
|
||
// OrderNumber = row_number() over(order by AttachUrlItemId)
|
||
// , AttachUrlItemId
|
||
// , AttachUrlId
|
||
// , MachineName
|
||
// , MachineSpec
|
||
// , number
|
||
// , LeasedOrOwned
|
||
// , Remarks "
|
||
// + @" FROM PHTGL_AttachUrl10_MachineInput "
|
||
// + @" where 1=1 and AttachUrlId=@AttachUrlId order by OrderNumber ";
|
||
|
||
//List<SqlParameter> listStr2 = new List<SqlParameter>();
|
||
//listStr2.Add(new SqlParameter("@AttachUrlId", AttachUrlId));
|
||
//SqlParameter[] parameter2 = listStr2.ToArray();
|
||
//DataTable tb2 = SQLHelper.GetDataTableRunText(strSql2, parameter2);
|
||
//if (tb2.Rows.Count == 0)
|
||
//{
|
||
// DataRow dataRow = tb2.NewRow();
|
||
// tb2.Rows.Add(dataRow);
|
||
//}
|
||
//tb2.TableName = "Table2";
|
||
//doc.MailMerge.ExecuteWithRegions(tb2);
|
||
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
var model = AttachUrl10Service.GetAttachUrl10ByAttachUrlId(AttachUrlId);
|
||
if (model != null)
|
||
{
|
||
var Path = newUrl.Replace(".docx", "编辑栏.docx"); //word文件保存路径
|
||
AsposeWordHelper.HtmlIntoWord(model.AttachUrlContent, Path);
|
||
Document doc2 = new Document(Path);
|
||
|
||
doc2.FirstSection.PageSetup.SectionStart = SectionStart.OddPage;
|
||
|
||
doc.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
|
||
File.Delete(Path);
|
||
}
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch11(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件11 履约担保格式.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
|
||
var model = AttachUrl11Service.GetPHTGL_AttachUrl11ById(AttachUrlId);
|
||
if (model == null)
|
||
{
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", "");
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc;
|
||
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", model.AttachUrlContent);
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch12(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件12 预付款担保格式.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
|
||
var model = AttachUrl12Service.GetPHTGL_AttachUrl12ById(AttachUrlId);
|
||
if (model == null)
|
||
{
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", "");
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc;
|
||
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", model.AttachUrlContent);
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch13(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件13 工程质量保修书.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
var SpecialTermsConditionsId = BLL.AttachUrlService.GetAttachUrlById(AttachUrlId).SpecialTermsConditionsId;
|
||
var ContractId = BLL.PHTGL_SpecialTermsConditionsService.GetSpecialTermsConditionsById(SpecialTermsConditionsId).ContractId;
|
||
var sub = BLL.SubcontractAgreementService.GetSubcontractAgreementByContractId(ContractId);
|
||
if (sub != null)
|
||
{
|
||
Dic_File.Add("GeneralContractor", sub.GeneralContractor);
|
||
Dic_File.Add("SubConstruction", sub.SubConstruction);
|
||
|
||
|
||
}
|
||
var model = BLL.AttachUrl13Service.GetPHTGL_AttachUrl13ById(AttachUrlId);
|
||
if (model == null)
|
||
{
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("txtGeneralContractorName", "");
|
||
Dic_File.Add("txtSubcontractorsName", "");
|
||
Dic_File.Add("txtProjectName", "");
|
||
Dic_File.Add("txtWarrantyContent", "");
|
||
Dic_File.Add("txtOtherWarrantyPeriod", "");
|
||
Dic_File.Add("txtWarrantyPeriodDate", "");
|
||
Dic_File.Add("txtDefectLiabilityDate", "");
|
||
Dic_File.Add("txtDefectLiabilityPeriod", "");
|
||
Dic_File.Add("txtOtherqualityWarranty", "");
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc;
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("txtGeneralContractorName", Convert.ToString(model.GeneralContractorName));
|
||
Dic_File.Add("txtSubcontractorsName", Convert.ToString(model.SubcontractorsName));
|
||
Dic_File.Add("txtProjectName", Convert.ToString(model.ProjectName));
|
||
Dic_File.Add("txtWarrantyContent", Convert.ToString(model.WarrantyContent));
|
||
Dic_File.Add("txtOtherWarrantyPeriod", Convert.ToString(model.OtherWarrantyPeriod));
|
||
Dic_File.Add("txtWarrantyPeriodDate", Convert.ToString(model.WarrantyPeriodDate));
|
||
Dic_File.Add("txtDefectLiabilityDate", Convert.ToString(model.DefectLiabilityDate));
|
||
Dic_File.Add("txtDefectLiabilityPeriod", Convert.ToString(model.DefectLiabilityPeriod));
|
||
Dic_File.Add("txtOtherqualityWarranty", Convert.ToString(model.OtherqualityWarranty));
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch14(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件14 施工安全管理协议书.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
var SpecialTermsConditionsId = BLL.AttachUrlService.GetAttachUrlById(AttachUrlId).SpecialTermsConditionsId;
|
||
var ContractId = BLL.PHTGL_SpecialTermsConditionsService.GetSpecialTermsConditionsById(SpecialTermsConditionsId).ContractId;
|
||
var sub = BLL.SubcontractAgreementService.GetSubcontractAgreementByContractId(ContractId);
|
||
if (sub != null)
|
||
{
|
||
Dic_File.Add("GeneralContractor", sub.GeneralContractor);
|
||
Dic_File.Add("SubConstruction", sub.SubConstruction);
|
||
|
||
|
||
}
|
||
var model = AttachUrl14Service.GetPHTGL_AttachUrl14ById(AttachUrlId);
|
||
if (model == null)
|
||
{
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("txtProjectName", "");
|
||
Dic_File.Add("txtPersonAmount", "");
|
||
Dic_File.Add("txtSafetyManagerNumber", "");
|
||
Dic_File.Add("txtSystemManagerNumber", "");
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc;
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("txtProjectName", Convert.ToString(model.ProjectName));
|
||
Dic_File.Add("txtPersonAmount", Convert.ToString(model.PersonAmount));
|
||
Dic_File.Add("txtSafetyManagerNumber", Convert.ToString(model.SafetyManagerNumber));
|
||
Dic_File.Add("txtSystemManagerNumber", Convert.ToString(model.SystemManagerNumber));
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch15(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件15 施工现场总图管理规定.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");
|
||
try
|
||
{
|
||
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
#region 附表1
|
||
string strSql = @" SELECT Number = row_number() over(order by AttachUrlItemId)
|
||
,AttachUrlItemId
|
||
, AttachUrlId
|
||
, AttachUrlContent
|
||
, ProjectName
|
||
, ContractId
|
||
, OrderNumber
|
||
, Type
|
||
, MainPoints
|
||
, Opinion "
|
||
+ @" from PHTGL_AttachUrl15_Sch1 "
|
||
+ @" where 1=1 and AttachUrlId=@AttachUrlId order by Number";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@AttachUrlId", AttachUrlId));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
if (tb.Rows.Count == 0)
|
||
{
|
||
DataRow dataRow = tb.NewRow();
|
||
tb.Rows.Add(dataRow);
|
||
}
|
||
tb.TableName = "Table";
|
||
doc.MailMerge.ExecuteWithRegions(tb);
|
||
if (tb.Rows.Count > 0)
|
||
{
|
||
Dic_File.Add("Sch1_ProjectName", Convert.ToString(tb.Rows[0]["ProjectName"]));
|
||
Dic_File.Add("Sch1_ContractId", Convert.ToString(tb.Rows[0]["ContractId"]));
|
||
Dic_File.Add("txtAttachUrlContent", Convert.ToString(tb.Rows[0]["AttachUrlContent"]));
|
||
Dic_File.Add("Sch1_Opinion", Convert.ToString(tb.Rows[0]["Opinion"]));
|
||
|
||
}
|
||
else
|
||
{
|
||
Dic_File.Add("Sch1_ProjectName", "");
|
||
Dic_File.Add("Sch1_ContractId", "");
|
||
Dic_File.Add("txtAttachUrlContent", "");
|
||
Dic_File.Add("Sch1_Opinion", "");
|
||
}
|
||
#endregion
|
||
#region 附表2
|
||
var Sch2 = BLL.PHTGL_AttachUrl15_Sch2Service.GetPHTGL_AttachUrl15_Sch2ById(AttachUrlId);
|
||
if (Sch2 != null)
|
||
{
|
||
|
||
Dic_File.Add("Sch2_ProjectName", Sch2.ProjectName.ToString());
|
||
Dic_File.Add("Sch2_ContractId", Sch2.ContractId.ToString());
|
||
Dic_File.Add("Sch2_Company", Sch2.Company.ToString());
|
||
Dic_File.Add("Sch2_ConstructionTask", Sch2.ConstructionTask.ToString());
|
||
Dic_File.Add("Sch2_Maxcapacitance", Sch2.Maxcapacitance.ToString());
|
||
Dic_File.Add("Sch2_MaxuseWtater", Sch2.MaxuseWtater.ToString());
|
||
Dic_File.Add("Sch2_elemeterPosition", Sch2.ElemeterPosition.ToString());
|
||
Dic_File.Add("Sch2_WatermeterPosition", Sch2.WatermeterPosition.ToString());
|
||
Dic_File.Add("Sch2_elemeterRead", Sch2.ElemeterRead.ToString());
|
||
Dic_File.Add("Sch2_WatermeterRead", Sch2.WatermeterRead.ToString());
|
||
if (Sch2.IsApproval.ToString() == "0")
|
||
{
|
||
Dic_File.Add("Sch2_IsApproval", "□");
|
||
Dic_File.Add("Sch2_IsApprovalNo", "√");
|
||
}
|
||
else
|
||
{
|
||
Dic_File.Add("Sch2_IsApprovalNo", "□");
|
||
Dic_File.Add("Sch2_IsApproval", "√ ");
|
||
|
||
}
|
||
if (Sch2.IsLineLayout.ToString() == "0")
|
||
{
|
||
Dic_File.Add("Sch2_IsLineLayout", "□");
|
||
Dic_File.Add("Sch2_IsLineLayoutNo", "√");
|
||
}
|
||
else
|
||
{
|
||
Dic_File.Add("Sch2_IsLineLayoutNo", "□");
|
||
Dic_File.Add("Sch2_IsLineLayout", "√ ");
|
||
}
|
||
if (Sch2.IsPowerBox.ToString() == "0")
|
||
{
|
||
Dic_File.Add("Sch2_IsPowerBox", "□");
|
||
Dic_File.Add("Sch2_IsPowerBoxNo", "√");
|
||
}
|
||
else
|
||
{
|
||
Dic_File.Add("Sch2_IsPowerBoxNo", "□");
|
||
Dic_File.Add("Sch2_IsPowerBox", "√");
|
||
}
|
||
|
||
if (Sch2.IsProfessional_ele.ToString() == "0")
|
||
{
|
||
Dic_File.Add("Sch2_IsProfessional_ele", "□");
|
||
Dic_File.Add("Sch2_IsProfessional_eleNo", "√");
|
||
}
|
||
else
|
||
{
|
||
Dic_File.Add("Sch2_IsProfessional_eleNo", "□");
|
||
Dic_File.Add("Sch2_IsProfessional_ele", "√");
|
||
}
|
||
|
||
if (Sch2.IsLineInstall.ToString() == "0")
|
||
{
|
||
Dic_File.Add("Sch2_IsLineInstall", "□");
|
||
Dic_File.Add("Sch2_IsLineInstallNo", "√");
|
||
}
|
||
else
|
||
{
|
||
Dic_File.Add("Sch2_IsLineInstallNo", "□");
|
||
Dic_File.Add("Sch2_IsLineInstall", "√");
|
||
}
|
||
if (Sch2.IsValve.ToString() == "0")
|
||
{
|
||
Dic_File.Add("Sch2_IsValve", "□");
|
||
Dic_File.Add("Sch2_IsValveNo", "√");
|
||
}
|
||
else
|
||
{
|
||
Dic_File.Add("Sch2_IsValveNo", "□");
|
||
Dic_File.Add("Sch2_IsValve", "√");
|
||
}
|
||
Dic_File.Add("Sch2_Terminalnumber", Sch2.Terminalnumber.ToString());
|
||
Dic_File.Add("Sch2_LineCabinetNumber", Sch2.LineCabinetNumber.ToString());
|
||
Dic_File.Add("Sch2_electricPrice", Sch2.ElectricPrice.ToString());
|
||
Dic_File.Add("Sch2_WaterPrice", Sch2.WaterPrice.ToString());
|
||
}
|
||
else
|
||
{
|
||
Dic_File.Add("Sch2_ProjectName", "");
|
||
Dic_File.Add("Sch2_ContractId", "");
|
||
Dic_File.Add("Sch2_Company", "");
|
||
Dic_File.Add("Sch2_ConstructionTask", "");
|
||
Dic_File.Add("Sch2_Maxcapacitance", "");
|
||
Dic_File.Add("Sch2_MaxuseWtater", "");
|
||
Dic_File.Add("Sch2_elemeterPosition", "");
|
||
Dic_File.Add("Sch2_WatermeterPosition", "");
|
||
Dic_File.Add("Sch2_elemeterRead", "");
|
||
Dic_File.Add("Sch2_WatermeterRead", "");
|
||
Dic_File.Add("Sch2_IsApproval", "□");
|
||
Dic_File.Add("Sch2_IsApprovalNo", "□");
|
||
Dic_File.Add("Sch2_IsLineLayout", "□");
|
||
Dic_File.Add("Sch2_IsLineLayoutNo", "□");
|
||
Dic_File.Add("Sch2_IsPowerBox", "□");
|
||
Dic_File.Add("Sch2_IsPowerBoxNo", "□");
|
||
Dic_File.Add("Sch2_IsProfessional_ele", "□");
|
||
Dic_File.Add("Sch2_IsProfessional_eleNo", "□");
|
||
Dic_File.Add("Sch2_IsLineInstall", "□");
|
||
Dic_File.Add("Sch2_IsLineInstallNo", "□");
|
||
Dic_File.Add("Sch2_IsValve", "□");
|
||
Dic_File.Add("Sch2_IsValveNo", "□");
|
||
Dic_File.Add("Sch2_Terminalnumber", "");
|
||
Dic_File.Add("Sch2_LineCabinetNumber", "");
|
||
Dic_File.Add("Sch2_electricPrice", "");
|
||
Dic_File.Add("Sch2_WaterPrice", "");
|
||
}
|
||
#endregion
|
||
#region 附表3
|
||
List<Model.PHTGL_AttachUrl15_Sch3> lists = BLL.PHTGL_AttachUrl15_Sch3Service.GetPHTGL_AttachUrl15ByAttachUrlId(AttachUrlId);
|
||
if (lists.Count == 0)
|
||
{
|
||
lists.Add(new Model.PHTGL_AttachUrl15_Sch3());
|
||
|
||
}
|
||
DataTable tb2 = LINQToDataTable(lists);
|
||
if (tb2.Rows.Count == 0)
|
||
{
|
||
DataRow dataRow = tb2.NewRow();
|
||
tb2.Rows.Add(dataRow);
|
||
}
|
||
tb2.TableName = "Table2";
|
||
doc.MailMerge.ExecuteWithRegions(tb2);
|
||
#endregion
|
||
#region 附表4
|
||
|
||
var Sch4 = BLL.PHTGL_AttachUrl15_Sch4Service.GetPHTGL_AttachUrl15_Sch4ById(AttachUrlId);
|
||
if (Sch4 != null)
|
||
{
|
||
Dic_File.Add("Sch4_ProjectName", Sch4.ProjectName.ToString());
|
||
Dic_File.Add("Sch4_ContractId", Sch4.ContractId.ToString());
|
||
Dic_File.Add("Sch4_SubcontractorsName", Sch4.SubcontractorsName.ToString());
|
||
Dic_File.Add("Sch4_Type", Sch4.Type.ToString());
|
||
Dic_File.Add("Sch4_Time", string.Format("{0:D}", Sch4.Time));
|
||
Dic_File.Add("Sch4_Reason", Sch4.Reason.ToString());
|
||
Dic_File.Add("Sch4_Position", Sch4.Position.ToString());
|
||
Dic_File.Add("Sch4_ImpPlan", Sch4.ImpPlan.ToString());
|
||
Dic_File.Add("Sch4_Recoverymeasures", Sch4.Recoverymeasures.ToString());
|
||
Dic_File.Add("Sch4_Caption", Sch4.Caption.ToString());
|
||
}
|
||
else
|
||
{
|
||
Dic_File.Add("Sch4_ProjectName", "");
|
||
Dic_File.Add("Sch4_ContractId", "");
|
||
Dic_File.Add("Sch4_SubcontractorsName", "");
|
||
Dic_File.Add("Sch4_Type", "");
|
||
Dic_File.Add("Sch4_Time", "");
|
||
Dic_File.Add("Sch4_Reason", "");
|
||
Dic_File.Add("Sch4_Position", "");
|
||
Dic_File.Add("Sch4_ImpPlan", "");
|
||
Dic_File.Add("Sch4_Recoverymeasures", "");
|
||
Dic_File.Add("Sch4_Caption", "");
|
||
|
||
}
|
||
#endregion
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch16(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件16施工质量奖惩管理规定.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch17(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件17保密协议书.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
var SpecialTermsConditionsId = BLL.AttachUrlService.GetAttachUrlById(AttachUrlId).SpecialTermsConditionsId;
|
||
var ContractId = BLL.PHTGL_SpecialTermsConditionsService.GetSpecialTermsConditionsById(SpecialTermsConditionsId).ContractId;
|
||
var sub = BLL.SubcontractAgreementService.GetSubcontractAgreementByContractId(ContractId);
|
||
if (sub != null)
|
||
{
|
||
Dic_File.Add("GeneralContractor", sub.GeneralContractor);
|
||
Dic_File.Add("SubConstruction", sub.SubConstruction);
|
||
|
||
}
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch18(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件18落实施工作业人员待遇承诺书.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");
|
||
try
|
||
{
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
var SpecialTermsConditionsId = BLL.AttachUrlService.GetAttachUrlById(AttachUrlId).SpecialTermsConditionsId;
|
||
var ContractId = BLL.PHTGL_SpecialTermsConditionsService.GetSpecialTermsConditionsById(SpecialTermsConditionsId).ContractId;
|
||
var sub = BLL.SubcontractAgreementService.GetSubcontractAgreementByContractId(ContractId);
|
||
if (sub != null)
|
||
{
|
||
Dic_File.Add("GeneralContractor", sub.GeneralContractor);
|
||
Dic_File.Add("SubConstruction", sub.SubConstruction);
|
||
|
||
|
||
}
|
||
var att = BLL.AttachUrl18Service.GetPHTGL_AttachUrl18ById(AttachUrlId);
|
||
if (att == null)
|
||
{
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("txtGeneralContractorName", "");
|
||
Dic_File.Add("txtSubcontractorsName", "");
|
||
Dic_File.Add("txtProjectName", "");
|
||
Dic_File.Add("txtContractId", "");
|
||
Dic_File.Add("txtStartDate", "");
|
||
Dic_File.Add("txtEndDate", "");
|
||
Dic_File.Add("txtPersonSum", "");
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc;
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("txtGeneralContractorName", att.GeneralContractorName);
|
||
Dic_File.Add("txtSubcontractorsName", att.SubcontractorsName);
|
||
Dic_File.Add("txtProjectName", att.ProjectName);
|
||
Dic_File.Add("txtContractId", att.ContractId);
|
||
Dic_File.Add("txtStartDate", att.StartDate.ToString());
|
||
Dic_File.Add("txtEndDate", att.EndDate.ToString());
|
||
Dic_File.Add("txtPersonSum", att.PersonSum.ToString());
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch19(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件19 联合体协议.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");
|
||
try
|
||
{
|
||
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
|
||
var model = AttachUrl19Service.GetPHTGL_AttachUrl19ById(AttachUrlId);
|
||
|
||
if (model == null)
|
||
{
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", "");
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc;
|
||
}
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
Dic_File.Add("AttachUrlContent", model.AttachUrlContent);
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
|
||
public static Document sch20(string AttachUrlId, int schnumber)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
initTemplatePath = "File\\Word\\PHTGL\\施工分包合同\\附件20 其他.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");
|
||
try
|
||
{
|
||
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
Dic_File.Add("schNumber", schnumber.ToString());
|
||
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
var model = AttachUrl20Service.GetAttachUrl20ByAttachUrlId(AttachUrlId);
|
||
if (model != null)
|
||
{
|
||
var Path = newUrl.Replace(".docx", "编辑栏.docx"); //word文件保存路径
|
||
AsposeWordHelper.HtmlIntoWord(model.AttachUrlContent, Path);
|
||
Document doc2 = new Document(Path);
|
||
|
||
doc2.FirstSection.PageSetup.SectionStart = SectionStart.OddPage;
|
||
|
||
doc.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
|
||
File.Delete(Path);
|
||
}
|
||
doc.Save(newUrl);
|
||
//生成PDF文件
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(string.Empty, ex);
|
||
|
||
Document doc1 = new Aspose.Words.Document();
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
return doc1;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 将IEnumerable<T>类型的集合转换为DataTable类型
|
||
/// <summary>
|
||
/// 将IEnumerable<T>类型的集合转换为DataTable类型
|
||
/// </summary>
|
||
/// <typeparam name="T"></typeparam>
|
||
/// <param name="varlist"></param>
|
||
/// <returns></returns>
|
||
public static DataTable LINQToDataTable<T>(IEnumerable<T> varlist)
|
||
{ //定义要返回的DataTable对象
|
||
DataTable dtReturn = new DataTable();
|
||
// 保存列集合的属性信息数组
|
||
PropertyInfo[] oProps = null;
|
||
if (varlist == null) return dtReturn;//安全性检查
|
||
//循环遍历集合,使用反射获取类型的属性信息
|
||
foreach (T rec in varlist)
|
||
{
|
||
//使用反射获取T类型的属性信息,返回一个PropertyInfo类型的集合
|
||
if (oProps == null)
|
||
{
|
||
oProps = ((Type)rec.GetType()).GetProperties();
|
||
//循环PropertyInfo数组
|
||
foreach (PropertyInfo pi in oProps)
|
||
{
|
||
Type colType = pi.PropertyType;//得到属性的类型
|
||
//如果属性为泛型类型
|
||
if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition()
|
||
== typeof(Nullable<>)))
|
||
{ //获取泛型类型的参数
|
||
colType = colType.GetGenericArguments()[0];
|
||
}
|
||
//将类型的属性名称与属性类型作为DataTable的列数据
|
||
dtReturn.Columns.Add(new DataColumn(pi.Name, colType));
|
||
}
|
||
}
|
||
//新建一个用于添加到DataTable中的DataRow对象
|
||
DataRow dr = dtReturn.NewRow();
|
||
//循环遍历属性集合
|
||
foreach (PropertyInfo pi in oProps)
|
||
{ //为DataRow中的指定列赋值
|
||
dr[pi.Name] = pi.GetValue(rec, null) == null ?
|
||
DBNull.Value : pi.GetValue(rec, null);
|
||
}
|
||
//将具有结果值的DataRow添加到DataTable集合中
|
||
dtReturn.Rows.Add(dr);
|
||
}
|
||
return dtReturn;//返回DataTable对象
|
||
}
|
||
#endregion
|
||
|
||
}
|
||
}
|