1065 lines
42 KiB
C#
1065 lines
42 KiB
C#
using Aspose.Words;
|
|
using Aspose.Words.Fonts;
|
|
using Aspose.Words.Saving;
|
|
using Aspose.Words.Tables;
|
|
using BLL;
|
|
using Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using WIA;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
using Bookmark = Aspose.Words.Bookmark;
|
|
using Document = Aspose.Words.Document;
|
|
|
|
namespace FineUIPro.Web.Customization.CNCCG.ZHGL.Problem
|
|
{
|
|
public partial class ProblemNoticeManager : PageBase
|
|
{
|
|
#region 项目主键
|
|
/// <summary>
|
|
/// 项目主键
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 页面加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
|
{
|
|
this.ProjectId = Request.Params["projectId"];
|
|
}
|
|
|
|
this.ucTree.UnitId = this.CurrUser.UnitId;
|
|
this.ucTree.ProjectId = this.ProjectId;
|
|
if (!string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
this.panelLeftRegion.Hidden = true;
|
|
////权限按钮方法
|
|
this.GetButtonPower();
|
|
}
|
|
this.btnNew.OnClientClick = Window1.GetShowReference("ProblemNoticeManagerEdit.aspx?Type=0") + "return false;";
|
|
this.btnNew_Finalize.OnClientClick = Window1.GetShowReference("ProblemNoticeManagerEdit.aspx?Type=-1") + "return false;";
|
|
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
|
{
|
|
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
|
}
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 公司级树加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void changeTree(object sender, EventArgs e)
|
|
{
|
|
this.ProjectId = this.ucTree.ProjectId;
|
|
|
|
if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
btnNew.Hidden = true;
|
|
}
|
|
this.GetButtonPower();
|
|
this.BindGrid();
|
|
}
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
return;
|
|
}
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.ProblemNoticeManagerMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
this.btnNew_Finalize.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
this.btnMenuEdit.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDelete.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 搜索
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 改变索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭弹出窗
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
#region 加载数据
|
|
protected void BindGrid()
|
|
{
|
|
if (string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
return;
|
|
}
|
|
int unitType = CommonService.GetUnitTypeByUserId(this.CurrUser.UserId);
|
|
|
|
string strSql = @"select F.ProjectId,ProNoticeId,
|
|
case when F.ProType='1' then a.ProjectName
|
|
else d.UnitName end as ProjectName
|
|
,ProCode,CheckMans,
|
|
case when F.ProType='1' then c.UnitName
|
|
else d.UnitName end as UnitName
|
|
,CheckStartTime
|
|
,CheckEndTime,b.UserName as CreateUserName,F.CreateDate,CreateUser,State,ProType,e.UnitId as CreateUnitId from Problem_Notice F
|
|
LEFT JOIN Base_Project a on F.ProjectId=a.ProjectId
|
|
LEFT JOIN Sys_User b on F.CreateUser=b.UserId
|
|
LEFT JOIN Base_Unit c on F.Unitid=c.UnitId
|
|
LEFT JOIN Base_unit d on F.ProjectId=d.UnitId
|
|
LEFT JOIN Base_unit e on b.UnitId=e.Unitid
|
|
Where 1=1 ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (unitType != 0 && string.IsNullOrEmpty(this.ProjectId)) //公司/分公司
|
|
{
|
|
strSql += " AND ( F.ProjectId='" + CurrUser.UnitId + "' and proType='2') or ( proType='1' and F.Unitid='" + CurrUser.UnitId + "' ) or a.UnitId='" + CurrUser.UnitId + "'";
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
strSql += " and proType='1' And F.ProjectId='" + this.ProjectId + "' ";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(txtProCode.Text.Trim()))
|
|
{
|
|
strSql += " AND F.ProCode like @ProCode ";
|
|
listStr.Add(new SqlParameter("@ProCode", "%" + this.txtProCode.Text.Trim() + "%"));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(txtProjectName.Text.Trim()))
|
|
{
|
|
strSql += " AND ProjectName like @ProjectName or d.unitname like @ProjectName";
|
|
listStr.Add(new SqlParameter("@ProjectName", "%" + this.txtProjectName.Text.Trim() + "%"));
|
|
}
|
|
|
|
//if (drpProject.SelectedValue != BLL.Const._Null)
|
|
//{
|
|
// strSql += " AND F.ProjectId=@ProjectId ";
|
|
// listStr.Add(new SqlParameter("@ProjectId", drpProject.SelectedValue));
|
|
//}
|
|
|
|
//除了超级管理员,其他只显示单位的数据
|
|
if (CurrUser.Account != "hfnbd")
|
|
{
|
|
strSql += " AND e.UnitId=@CreateUnitId ";
|
|
listStr.Add(new SqlParameter("@CreateUnitId", CurrUser.UnitId));
|
|
}
|
|
strSql += " order by CreateDate desc";
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
|
|
for (int i = 0; i < Grid1.Rows.Count; i++)
|
|
{
|
|
Model.Problem_Notice model = Funs.DB.Problem_Notice.FirstOrDefault(x => x.ProNoticeId == Grid1.Rows[i].DataKeys[0].ToString());
|
|
|
|
if (model.State == "-1" && string.IsNullOrEmpty(BLL.AttachFileService.getFileUrl(model.ProNoticeId + "-FinalizeRelpy")))
|
|
{
|
|
Grid1.Rows[i].RowCssClass = "red";
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 状态
|
|
protected string ConvertState(object proType, object state)
|
|
{
|
|
if (state != null && proType != null)
|
|
{
|
|
//项目级
|
|
string proTypes = proType.ToString();
|
|
if (state.ToString() == "0")
|
|
{
|
|
return "待提交";
|
|
}
|
|
else if (state.ToString() == "1")
|
|
{
|
|
// return "被检查单位负责人审批";
|
|
return "检查组审批";
|
|
}
|
|
else if (state.ToString() == "2")
|
|
{
|
|
return "回复单审批";
|
|
}
|
|
else if (state.ToString() == "3")
|
|
{
|
|
return "归档";
|
|
}
|
|
else if (state.ToString() == "-1")
|
|
{
|
|
return "定稿";
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
protected string GetThisApprove(object proNoticeId)
|
|
{
|
|
string result = "";
|
|
if (proNoticeId != null)
|
|
{
|
|
var list = ProblemNoticeApprove.GetProblem_NoticeApproveByParentId(proNoticeId.ToString());
|
|
if (list != null)
|
|
{
|
|
string userids = string.Join(",", list.Select(x => x.ApproveMan).ToList());
|
|
result = UserService.getUserNamesUserIds(userids);
|
|
}
|
|
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 查看回复单明细
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuViewReply_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
var ProblemNoticeItem = Funs.DB.Problem_Notice.FirstOrDefault(x => x.ProNoticeId == id);
|
|
if (ProblemNoticeItem != null)
|
|
{
|
|
if (Convert.ToInt32(ProblemNoticeItem.State) <= 2)
|
|
{
|
|
ShowNotify("当前通知单尚未回复。", MessageBoxIcon.Warning);
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProblemReplyManagerEdit.aspx?ProNoticeId={0}&Type=1", id, "查看 - ")));
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void btnMenuView_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProblemNoticeManagerEdit.aspx?ProNoticeId={0}&Type=1", id, "查看 - ")));
|
|
}
|
|
/// <summary>
|
|
/// 双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键编辑事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑
|
|
/// </summary>
|
|
protected void EditData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
|
|
var ProblemNoticeItem = Funs.DB.Problem_Notice.FirstOrDefault(x => x.ProNoticeId == id);
|
|
if (ProblemNoticeItem != null)
|
|
{
|
|
|
|
if ((this.btnMenuEdit.Hidden || Convert.ToInt32(ProblemNoticeItem.State) > 1) && ProblemNoticeItem.CreateUser == CurrUser.UserId) ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProblemNoticeManagerEdit.aspx?ProNoticeId={0}&Type=1", id, "查看 - ")));
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProblemNoticeManagerEdit.aspx?ProNoticeId={0}&Type=0", id, "编辑 - ")));
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var getV = Funs.DB.Problem_Notice.FirstOrDefault(x => x.ProNoticeId == rowID);
|
|
if (getV.State != "0")
|
|
{
|
|
ShowNotify("只能删除待提交的数据!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (getV != null)
|
|
{
|
|
BLL.ProblemNoticeService.Delete(rowID);
|
|
}
|
|
}
|
|
this.BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出
|
|
protected void btnMenuOut_Click(object sender, EventArgs e)
|
|
{
|
|
string id = Grid1.SelectedRowID;
|
|
var CheckUnitSignature = ""; //被检查负责人签名
|
|
var CheckMansSignature = "";//审批组签名
|
|
var ProjectName = "";//项目名称
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
var model = Funs.DB.Problem_Notice.FirstOrDefault(x => x.ProNoticeId == id);
|
|
if (model == null)
|
|
{
|
|
ShowNotify("只能导出已提交的数据。!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
BuildSignaturesAndProjectInfo(id, model, out CheckUnitSignature, out CheckMansSignature, out ProjectName);
|
|
var cdate = Convert.ToDateTime(model.CreateDate);
|
|
var nowFileName = cdate.Month.ToString() + "." + cdate.Day.ToString() + ProjectName + "问题督导整改通知单";
|
|
string rootPath = Server.MapPath("~/");
|
|
var initTemplatePath = "File\\Word\\问题督导整改通知单.docx";
|
|
var uploadfilepath = rootPath + initTemplatePath;
|
|
var newUrl = uploadfilepath.Replace("问题督导整改通知单.docx", nowFileName + ".docx");
|
|
if (File.Exists(newUrl))
|
|
{
|
|
File.Delete(newUrl);
|
|
}
|
|
|
|
File.Copy(uploadfilepath, newUrl);
|
|
Document doc = new Aspose.Words.Document(newUrl);
|
|
|
|
#region 问题督导整改通知单
|
|
|
|
|
|
Bookmark Bmark = doc.Range.Bookmarks["ProjectName"]; //项目名称
|
|
if (Bmark != null)
|
|
{
|
|
Bmark.Text = ProjectName;
|
|
}
|
|
|
|
Bmark = doc.Range.Bookmarks["ProCode"]; //项目编号
|
|
if (Bmark != null)
|
|
{
|
|
Bmark.Text = model.ProCode;
|
|
}
|
|
|
|
Bmark = doc.Range.Bookmarks["CheckMans"];//检查人
|
|
if (Bmark != null)
|
|
{
|
|
Bmark.Text = model.CheckMans;
|
|
}
|
|
|
|
Bmark = doc.Range.Bookmarks["CheckTime"]; //检查时间
|
|
if (Bmark != null)
|
|
{
|
|
var CheckTime = Convert.ToDateTime(model.CheckStartTime);
|
|
var EndTime = Convert.ToDateTime(model.CheckEndTime);
|
|
Bmark.Text = CheckTime.Year.ToString() + "." + CheckTime.Month.ToString() + "." +
|
|
CheckTime.Day.ToString()
|
|
+ "-" + EndTime.Month.ToString() + "." +
|
|
EndTime.Day.ToString();
|
|
}
|
|
|
|
Bmark = doc.Range.Bookmarks["Resume"];
|
|
if (Bmark != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(model.Resume))
|
|
{
|
|
Bmark.Text = model.Resume;
|
|
}
|
|
}
|
|
|
|
|
|
var table = doc.GetChildNodes(Aspose.Words.NodeType.Table, true)[0] as Aspose.Words.Tables.Table;
|
|
double width1 = 0; //前两列表格宽度
|
|
double width2 = 0; //后两列表格宽度
|
|
if (table != null)
|
|
{
|
|
// 计算表格宽度
|
|
width1 = table.FirstRow.Cells[0].CellFormat.Width + table.FirstRow.Cells[1].CellFormat.Width;
|
|
width2 = table.FirstRow.Cells[2].CellFormat.Width + table.FirstRow.Cells[3].CellFormat.Width;
|
|
}
|
|
|
|
//tab1
|
|
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
|
|
bool isbool = builder.MoveToBookmark("tab1");
|
|
if (isbool)
|
|
{
|
|
builder.StartTable();
|
|
builder.RowFormat.Alignment = Aspose.Words.Tables.RowAlignment.Center;
|
|
builder.CellFormat.Borders.LineStyle = LineStyle.Single;
|
|
builder.CellFormat.Borders.Color = System.Drawing.Color.Black;
|
|
//builder.RowFormat.LeftIndent = 5;
|
|
//builder.RowFormat.RightPadding = 50;
|
|
builder.Bold = false;
|
|
//builder.RowFormat.Height = 20;
|
|
//builder.CellFormat.Width = 80;
|
|
}
|
|
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add("存在问题", typeof(string));
|
|
dt.Columns.Add("整改要求", typeof(string));
|
|
dt.Columns.Add("整改责任人", typeof(string));
|
|
// dt.Rows.Add(new string[] { "存在问题", "整改要求" });
|
|
var detailList = Funs.DB.Problem_Notice_C.Where(x => x.ProNoticeId == id).OrderBy(x => x.SortIndex)
|
|
.ToList();
|
|
if (detailList.Count > 0)
|
|
{
|
|
foreach (var item in detailList)
|
|
{
|
|
var CheckManName = UserService.GetUserNameByUserId(item.CheckMan);
|
|
dt.Rows.Add(new string[] { item.SortIndex + item.QueDescribe, item.Requirements, CheckManName });
|
|
}
|
|
}
|
|
|
|
builder.RowFormat.Height = 20;
|
|
builder.Bold = false;
|
|
|
|
//增加表头,垂直水平居中
|
|
builder.InsertCell();
|
|
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
|
|
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
|
|
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center; //垂直居中对齐
|
|
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; //水平居中对齐
|
|
builder.CellFormat.Width = width1;
|
|
builder.Write("存在问题");
|
|
builder.InsertCell();
|
|
builder.CellFormat.Width = width2 / 2;
|
|
builder.Write("整改要求");
|
|
builder.InsertCell();
|
|
builder.Write("整改责任人");
|
|
builder.CellFormat.Width = width2 / 2;
|
|
builder.EndRow();
|
|
|
|
//循环插入表格内容
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
foreach (DataColumn column in dt.Columns)
|
|
{
|
|
builder.InsertCell();
|
|
|
|
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
|
|
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
|
|
builder.CellFormat.VerticalAlignment =
|
|
Aspose.Words.Tables.CellVerticalAlignment.Center; //垂直居中对齐
|
|
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left; //水平居中对齐
|
|
if (column.ColumnName == "存在问题")
|
|
{
|
|
builder.CellFormat.Width = width1;
|
|
}
|
|
else if (column.ColumnName == "整改要求")
|
|
{
|
|
builder.CellFormat.Width = width2 / 2;
|
|
}
|
|
else if (column.ColumnName == "整改责任人")
|
|
{
|
|
builder.CellFormat.Width = width2 / 2;
|
|
}
|
|
|
|
builder.Write(row[column.ColumnName].ToString());
|
|
}
|
|
|
|
builder.EndRow();
|
|
}
|
|
|
|
//其他工作要求
|
|
builder.InsertCell();
|
|
builder.CellFormat.Width = width1 + width2;
|
|
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
|
|
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
|
|
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center; //垂直居中对齐
|
|
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left; //水平居中对齐
|
|
builder.Write("其他工作要求:\n");
|
|
if (!string.IsNullOrEmpty(model.OtherJob))
|
|
{
|
|
builder.Write(model.OtherJob);
|
|
}
|
|
|
|
builder.EndRow();
|
|
//被检查单位负责人
|
|
builder.InsertCell();
|
|
builder.Write("被检查单位负责人:");
|
|
//插入被检查组负责人所有签名
|
|
if (!string.IsNullOrEmpty(CheckUnitSignature))
|
|
{
|
|
string[] checkUnitSignatures = CheckUnitSignature.Split(',');
|
|
foreach (string item in checkUnitSignatures)
|
|
{
|
|
string url = rootPath + item.TrimEnd(',');
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
if (File.Exists(url))
|
|
{
|
|
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center; //垂直居中对齐
|
|
builder.InsertImage(url, 100, 30);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
builder.Write("");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
builder.Write("");
|
|
}
|
|
|
|
builder.EndRow();
|
|
//日期
|
|
builder.InsertCell();
|
|
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right; //水平居中对齐
|
|
if (model.CheckUnitDatetime != null)
|
|
{
|
|
var CheckUnitDatetime = Convert.ToDateTime(model.CheckUnitDatetime);
|
|
builder.Write(CheckUnitDatetime.Year.ToString() + "年" + CheckUnitDatetime.Month.ToString()
|
|
+ "月" + CheckUnitDatetime.Day.ToString() + "日");
|
|
}
|
|
else
|
|
{
|
|
builder.Write("");
|
|
}
|
|
|
|
builder.EndRow();
|
|
//检查组人员
|
|
builder.InsertCell();
|
|
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left; //水平居中对齐
|
|
builder.Write("检查组人员:");
|
|
//插入审批组负责人所有签名
|
|
if (!string.IsNullOrEmpty(CheckMansSignature))
|
|
{
|
|
string[] CheckMansSignatures = CheckMansSignature.Split(',');
|
|
int CheckMansSignatureIndex = 1;
|
|
foreach (string item in CheckMansSignatures)
|
|
{
|
|
string url = rootPath + item.TrimEnd(',');
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
if (File.Exists(url))
|
|
{
|
|
builder.InsertImage(url, 100, 30);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
builder.Write("");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
builder.Write("");
|
|
}
|
|
|
|
builder.EndRow();
|
|
|
|
//日期
|
|
builder.InsertCell();
|
|
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right; //水平居中对齐
|
|
if (model.CheckMansDatetime != null)
|
|
{
|
|
var CheckMansDatetime = Convert.ToDateTime(model.CheckMansDatetime);
|
|
builder.Write(CheckMansDatetime.Year.ToString() + "年" + CheckMansDatetime.Month.ToString()
|
|
+ "月" + CheckMansDatetime.Day.ToString() + "日");
|
|
}
|
|
else
|
|
{
|
|
builder.Write("");
|
|
}
|
|
|
|
builder.EndRow();
|
|
|
|
builder.EndTable();
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region 安全质量检查照片
|
|
|
|
Run pageBreakRun = new Run(doc, ControlChar.PageBreak);
|
|
//插入分页符
|
|
builder.InsertNode(pageBreakRun);
|
|
Bmark = doc.Range.Bookmarks["ProjectName2"];
|
|
if (Bmark != null)
|
|
{
|
|
Bmark.Text = "单位/项目名称:" + ProjectName;
|
|
}
|
|
|
|
//安全质量检查照片
|
|
builder = new Aspose.Words.DocumentBuilder(doc);
|
|
isbool = builder.MoveToBookmark("tab2");
|
|
if (isbool)
|
|
{
|
|
builder.StartTable();
|
|
builder.RowFormat.Alignment = Aspose.Words.Tables.RowAlignment.Center;
|
|
builder.CellFormat.Borders.LineStyle = LineStyle.Single;
|
|
builder.CellFormat.Borders.Color = System.Drawing.Color.Black;
|
|
//builder.RowFormat.LeftIndent = 5;
|
|
//builder.RowFormat.RightPadding = 50;
|
|
builder.Bold = false;
|
|
//builder.RowFormat.Height = 20;
|
|
//builder.CellFormat.Width = 80;
|
|
}
|
|
|
|
//1.现场检查照片
|
|
IList<Model.AttachFile> sourlist =
|
|
AttachFileService.GetBeforeFileList(id, BLL.Const.ProblemNoticeManagerMenuId);
|
|
if (sourlist != null && sourlist.Count > 0)
|
|
{
|
|
string AttachUrl = "";
|
|
foreach (var item in sourlist)
|
|
{
|
|
if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg")
|
|
|| item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png"))
|
|
{
|
|
AttachUrl += item.AttachUrl.TrimEnd(',') + ",";
|
|
}
|
|
}
|
|
|
|
AttachUrl = AttachUrl.Remove(AttachUrl.LastIndexOf(","), 1);
|
|
string[] pics = AttachUrl.Split(',');
|
|
int xcjcImgIndex = 1;
|
|
foreach (string item in pics)
|
|
{
|
|
builder.RowFormat.Height = 50;
|
|
builder.Bold = false;
|
|
builder.InsertCell();
|
|
|
|
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
|
|
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
|
|
builder.CellFormat.VerticalAlignment =
|
|
Aspose.Words.Tables.CellVerticalAlignment.Center; //垂直居中对齐
|
|
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; //水平居中对齐
|
|
|
|
if (pics.Length == 1)
|
|
{
|
|
builder.CellFormat.Width = width1 + width2;
|
|
}
|
|
else
|
|
{
|
|
if (xcjcImgIndex % 2 != 0 && xcjcImgIndex != 1)
|
|
{
|
|
builder.CellFormat.Width = width1 + width2;
|
|
}
|
|
else
|
|
{
|
|
builder.CellFormat.Width = width1;
|
|
}
|
|
}
|
|
|
|
string url = rootPath + item.TrimEnd(',');
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
if (File.Exists(url))
|
|
{
|
|
builder.InsertImage(url, 200, 180);
|
|
}
|
|
}
|
|
|
|
xcjcImgIndex += 1;
|
|
if (xcjcImgIndex % 2 != 0 || (xcjcImgIndex - 1) == pics.Length)
|
|
{
|
|
builder.EndRow();
|
|
}
|
|
}
|
|
|
|
builder.EndTable();
|
|
}
|
|
|
|
//检查问题照片
|
|
dt = new DataTable();
|
|
dt.Columns.Add("存在问题", typeof(string));
|
|
dt.Columns.Add("照片", typeof(string));
|
|
dt.Columns.Add("AttachUrl", typeof(string));
|
|
if (detailList.Count > 0)
|
|
{
|
|
|
|
foreach (var item in detailList)
|
|
{
|
|
string attachUrl = "";
|
|
IList<Model.AttachFile> sourlistDetail =
|
|
AttachFileService.GetBeforeFileList(item.ProNoticeCId,
|
|
BLL.Const.ProblemNoticeManagerMenuId);
|
|
if (sourlistDetail != null && sourlistDetail.Count > 0)
|
|
{
|
|
|
|
foreach (var detailAttachFile in sourlistDetail)
|
|
{
|
|
if (!string.IsNullOrEmpty(detailAttachFile.AttachUrl) &&
|
|
detailAttachFile.AttachUrl.ToLower().EndsWith(".jpg")
|
|
|| detailAttachFile.AttachUrl.ToLower().EndsWith(".jpeg") ||
|
|
detailAttachFile.AttachUrl.ToLower().EndsWith(".png"))
|
|
{
|
|
attachUrl += detailAttachFile.AttachUrl.TrimEnd(',') + ",";
|
|
}
|
|
}
|
|
|
|
attachUrl = attachUrl.Remove(attachUrl.LastIndexOf(","), 1);
|
|
|
|
}
|
|
dt.Rows.Add(new string[] { item.QueDescribe, item.ProNoticeCId, attachUrl });
|
|
}
|
|
}
|
|
//将dt.Rows 数据两行一组拆分,最后不足两行的补齐
|
|
List<DataTable> tables = new List<DataTable>();
|
|
DataTable tempDt = dt.Clone(); //复制结构
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
tempDt.Rows.Add(dt.Rows[i].ItemArray); //复制数据
|
|
|
|
if (tempDt.Rows.Count == 2)
|
|
{
|
|
tables.Add(tempDt);
|
|
tempDt = dt.Clone(); //派生新表用于下一轮
|
|
}
|
|
}
|
|
|
|
if (tempDt.Rows.Count > 0) //不足两行的数据
|
|
{
|
|
while (tempDt.Rows.Count < 2)
|
|
{
|
|
DataRow row = tempDt.NewRow();
|
|
for (int i = 0; i < tempDt.Columns.Count; i++)
|
|
{
|
|
row[i] = ""; // 可以根据实际情况替换为你需要补齐的数据
|
|
}
|
|
tempDt.Rows.Add(row);
|
|
}
|
|
|
|
tables.Add(tempDt);
|
|
}
|
|
|
|
var table2 = builder.StartTable();
|
|
builder.RowFormat.Height = 20;
|
|
builder.Bold = false;
|
|
builder.InsertCell();
|
|
|
|
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
|
|
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
|
|
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center; //垂直居中对齐
|
|
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; //水平居中对齐
|
|
builder.CellFormat.Width = width1 + width2;
|
|
builder.Write("检查问题照片");
|
|
builder.EndRow();
|
|
|
|
|
|
builder.RowFormat.Height = 50;
|
|
builder.Bold = false;
|
|
|
|
|
|
foreach (var dataTable in tables) //循环表格
|
|
{
|
|
builder.InsertCell();
|
|
|
|
builder.CellFormat.FitText = true;
|
|
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
|
|
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
|
|
builder.CellFormat.VerticalAlignment =
|
|
Aspose.Words.Tables.CellVerticalAlignment.Center; //垂直居中对齐
|
|
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left; //水平居中对齐
|
|
builder.CellFormat.Width = width1;
|
|
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Top; //顶端对齐
|
|
string[] pics = dataTable.Rows[0]["AttachUrl"].ToString().Split(',');
|
|
foreach (string item in pics)
|
|
{
|
|
string url = rootPath + item.TrimEnd(',');
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
if (File.Exists(url))
|
|
{
|
|
builder.InsertImage(url, width1, 180);
|
|
}
|
|
else
|
|
{
|
|
builder.Write("");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
builder.Write("");
|
|
}
|
|
}
|
|
builder.InsertCell();
|
|
builder.CellFormat.Width = width2;
|
|
string[] pics2 = dataTable.Rows[1]["AttachUrl"].ToString().Split(',');
|
|
foreach (string item in pics2)
|
|
{
|
|
string url = rootPath + item.TrimEnd(',');
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
if (File.Exists(url))
|
|
{
|
|
builder.InsertImage(url, width2, 180);
|
|
}
|
|
else
|
|
{
|
|
builder.Write("");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
builder.Write("");
|
|
}
|
|
}
|
|
|
|
builder.EndRow();
|
|
|
|
builder.InsertCell();
|
|
builder.CellFormat.Width = width1;
|
|
builder.Write(dataTable.Rows[0]["存在问题"].ToString() ?? " ");
|
|
builder.InsertCell();
|
|
builder.CellFormat.Width = width2;
|
|
builder.Write(dataTable.Rows[1]["存在问题"].ToString() ?? " ");
|
|
builder.EndRow();
|
|
}
|
|
|
|
//foreach (DataRow row in dt.Rows) //循环行
|
|
//{
|
|
// foreach (DataColumn column in dt.Columns)
|
|
// {
|
|
// builder.InsertCell();
|
|
|
|
// builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
|
|
// builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
|
|
// builder.CellFormat.VerticalAlignment =
|
|
// Aspose.Words.Tables.CellVerticalAlignment.Center; //垂直居中对齐
|
|
// builder.ParagraphFormat.Alignment = ParagraphAlignment.Left; //水平居中对齐
|
|
// if (column.ColumnName == "存在问题")
|
|
// {
|
|
// builder.CellFormat.Width = width1;
|
|
// builder.Write(row[column.ColumnName].ToString());
|
|
// }
|
|
// else if (column.ColumnName == "照片")
|
|
// {
|
|
// builder.CellFormat.Width = width2;
|
|
// builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Top; //顶端对齐
|
|
// //查询照片并插入
|
|
// IList<Model.AttachFile> sourlistDetail =
|
|
// AttachFileService.GetBeforeFileList(row[column.ColumnName].ToString(),
|
|
// BLL.Const.ProblemNoticeManagerMenuId);
|
|
// if (sourlistDetail != null && sourlistDetail.Count > 0)
|
|
// {
|
|
// string AttachUrl = "";
|
|
// foreach (var item in sourlistDetail)
|
|
// {
|
|
// if (!string.IsNullOrEmpty(item.AttachUrl) &&
|
|
// item.AttachUrl.ToLower().EndsWith(".jpg")
|
|
// || item.AttachUrl.ToLower().EndsWith(".jpeg") ||
|
|
// item.AttachUrl.ToLower().EndsWith(".png"))
|
|
// {
|
|
// AttachUrl += item.AttachUrl.TrimEnd(',') + ",";
|
|
// }
|
|
// }
|
|
|
|
// AttachUrl = AttachUrl.Remove(AttachUrl.LastIndexOf(","), 1);
|
|
// string[] pics = AttachUrl.Split(',');
|
|
// foreach (string item in pics)
|
|
// {
|
|
// string url = rootPath + item.TrimEnd(',');
|
|
// if (!string.IsNullOrEmpty(url))
|
|
// {
|
|
// if (File.Exists(url))
|
|
// {
|
|
// builder.InsertImage(url, 200, 180);
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// builder.Write("");
|
|
// }
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// builder.Write("");
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// builder.EndRow();
|
|
//}
|
|
|
|
|
|
builder.EndTable();
|
|
table2.AutoFit(AutoFitBehavior.FixedColumnWidths);
|
|
|
|
#endregion
|
|
|
|
doc.Save(newUrl);
|
|
//string pdfUrl = newUrl.Replace(".docx", ".pdf");
|
|
//libreOfficeHelp.ToPdf(newUrl,Path.GetDirectoryName(newUrl));
|
|
|
|
string fileName = Path.GetFileName(newUrl);
|
|
FileInfo info = new FileInfo(newUrl);
|
|
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(newUrl, 0, fileSize);
|
|
System.Web.HttpContext.Current.Response.Flush();
|
|
System.Web.HttpContext.Current.Response.Close();
|
|
File.Delete(newUrl);
|
|
//File.Delete(pdfUrl);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取相关参数
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="model"></param>
|
|
/// <param name="CheckUnitSignature">被检查负责人签名</param>
|
|
/// <param name="CheckMansSignature">审批组签名</param>
|
|
/// <param name="ProjectName"></param>
|
|
private void BuildSignaturesAndProjectInfo(string id, Problem_Notice model, out string CheckUnitSignature, out string CheckMansSignature, out string ProjectName)
|
|
{
|
|
CheckUnitSignature = "";
|
|
CheckMansSignature = "";
|
|
ProjectName = "";
|
|
|
|
var MansApprove = BLL.UserService.getUserListUserIds(model.UnitApproveUserIds);
|
|
if (MansApprove != null)
|
|
{
|
|
CheckMansSignature = string.Join(",", MansApprove.Select(x => x.SignatureUrl).ToList());
|
|
}
|
|
if (model.ProType == "1")
|
|
{
|
|
ProjectName = BLL.ProjectService.GetProjectByProjectId(model.ProjectId).ShortName;
|
|
var ProjectApprove = BLL.UserService.getUserListUserIds(model.ProjectUnitApproveUserIds);
|
|
if (ProjectApprove != null)
|
|
{
|
|
CheckUnitSignature = string.Join(",", ProjectApprove.Select(x => x.SignatureUrl).ToList());
|
|
}
|
|
|
|
}
|
|
else if (model.ProType == "2")
|
|
{
|
|
ProjectName = BLL.UnitService.GetUnitByUnitId(model.ProjectId).ShortUnitName;
|
|
|
|
var ProjectApprove = BLL.UserService.getUserListUserIds(model.SubUnitApproveUserIds);
|
|
if (ProjectApprove != null)
|
|
{
|
|
CheckUnitSignature = string.Join(",", ProjectApprove.Select(x => x.SignatureUrl).ToList());
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |