804 lines
35 KiB
C#
804 lines
35 KiB
C#
using Aspose.Words;
|
||
using Aspose.Words.Tables;
|
||
using BLL;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.IO;
|
||
using System.Linq;
|
||
|
||
namespace FineUIPro.Web.Customization.CNCCG.HSSE.Problem
|
||
{
|
||
public partial class ProblemReplyManager : PageBase
|
||
{
|
||
/// <summary>
|
||
/// 项目主键
|
||
/// </summary>
|
||
public string ProjectId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ProjectId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ProjectId"] = value;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 页面加载
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
||
{
|
||
this.ProjectId = Request.Params["projectId"];
|
||
}
|
||
|
||
////权限按钮方法
|
||
GetButtonPower();
|
||
Funs.DropDownPageSize(this.ddlPageSize);
|
||
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
||
{
|
||
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
||
}
|
||
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||
// 绑定表格
|
||
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.CurrUser.LoginProjectId, this.CurrUser.UserId, "E11F9246-0448-461D-BAF4-0DF2EA7CE636");
|
||
if (buttonList.Count() > 0)
|
||
{
|
||
if (buttonList.Contains(BLL.Const.BtnAdd))
|
||
{
|
||
//this.btnNew.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()
|
||
{
|
||
var userId = CurrUser.UserId;
|
||
var roleId = CurrUser.RoleId;
|
||
|
||
//2-项目经理、3-子分公司安全质量部部长、4-子分公司副总经理 5、检查组
|
||
var workPostid = CurrUser.ProjectWorkPostId;
|
||
if (workPostid == "4a72bd32-46ed-4aa1-b8a0-4f51444a3a91" ||//项目经理
|
||
//workPostid == "3F322FF1-85AA-49E8-9F8E-CFB4F9302C71" ||//子分公司安全质量部部长
|
||
//workPostid == "986876f8-5b47-465f-9840-6bc55e073618" ||//子分公司副总经理
|
||
roleId == "b8eae262-05e2-4d05-a673-9fb16691649b" //检查组
|
||
/*workPostid == "2E86E0EB-0246-48DE-8104-CD8E2E2F96F4"*/ ||//检查组
|
||
userId == Const.sysglyId || userId == Const.hfnbdId || userId == "a68bc9cc-efaa-4309-ac06-ec6ac85ea353")
|
||
{
|
||
string strSql = @"select F.ProjectId,ProNoticeId,a.ProjectName,ProCode,CheckMans,c.UnitName,CheckStartTime
|
||
,CheckEndTime,b.UserName as CreateUserName,F.CreateDate,CreateUser,State,F.Unitid,proType 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
|
||
Where F.State<> '0' and F.State <> '1' and proType='1' ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
|
||
if (userId == Const.sysglyId || userId == Const.hfnbdId || userId == "a68bc9cc-efaa-4309-ac06-ec6ac85ea353" || roleId == "b8eae262-05e2-4d05-a673-9fb16691649b")
|
||
{
|
||
|
||
}
|
||
else
|
||
{
|
||
//不是管理员只能看到自己单位待回复的数据
|
||
//strSql += " AND F.Unitid='" + CurrUser.UnitId + "' ";
|
||
|
||
//不是管理员只能看到自己单位、项目 的通知单(项目经理)
|
||
strSql += " And F.ProjectId='" + ProjectId + "' ";
|
||
}
|
||
if (!string.IsNullOrEmpty(txtProCode.Text.Trim()))
|
||
{
|
||
strSql += " AND F.ProCode like @ProCode ";
|
||
listStr.Add(new SqlParameter("@ProCode", "%" + this.txtProCode.Text.Trim() + "%"));
|
||
}
|
||
|
||
//if (drpProject.SelectedValue != BLL.Const._Null)
|
||
//{
|
||
// strSql += " AND F.ProjectId=@ProjectId ";
|
||
// listStr.Add(new SqlParameter("@ProjectId", drpProject.SelectedValue));
|
||
//}
|
||
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();
|
||
}
|
||
//else {
|
||
// //检查组
|
||
// string strSql = @"select F.ProjectId,ProNoticeId,a.ProjectName,ProCode,CheckMans,c.UnitName,CheckStartTime
|
||
// ,CheckEndTime,b.UserName as CreateUserName,F.CreateDate,CreateUser,State,F.Unitid 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
|
||
// Where F.State<> '0' and F.State <> '1' ";
|
||
// List<SqlParameter> listStr = new List<SqlParameter>();
|
||
|
||
// //检查组
|
||
// strSql += " AND F.CreateUser=@CreateUser ";
|
||
// listStr.Add(new SqlParameter("@CreateUser", userId));
|
||
|
||
// if (!string.IsNullOrEmpty(txtProCode.Text.Trim()))
|
||
// {
|
||
// strSql += " AND F.ProCode like @ProCode ";
|
||
// listStr.Add(new SqlParameter("@ProCode", "%" + this.txtProCode.Text.Trim() + "%"));
|
||
// }
|
||
|
||
// 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();
|
||
//}
|
||
}
|
||
#endregion
|
||
|
||
#region 状态
|
||
protected string ConvertState(object state)
|
||
{
|
||
if (state != null)
|
||
{
|
||
if (state.ToString() == "2")
|
||
{
|
||
return "受检单位负责人审批";
|
||
}
|
||
else if (state.ToString() == "3")
|
||
{
|
||
return "复查人审批";
|
||
}
|
||
else if (state.ToString() == "4")
|
||
{
|
||
return "分管领导审批";
|
||
}
|
||
else if (state.ToString() == "5")
|
||
{
|
||
return "检查组审批";
|
||
}
|
||
else
|
||
{
|
||
return "已归档";
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
#endregion
|
||
|
||
#region 编辑
|
||
|
||
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("ProblemReplyManagerEdit.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)
|
||
{
|
||
#region 状态是2 :项目经理;3 :项目安全质量部部长;4 :子分公司副总经理 5-检查组
|
||
//1.获取当前项目的人员信息
|
||
var WorkPostManList = (from x in Funs.DB.Project_ProjectUser
|
||
join y in Funs.DB.Sys_User on x.UserId equals y.UserId
|
||
join z in Funs.DB.SitePerson_Person on y.IdentityCard equals z.IdentityCard
|
||
where x.ProjectId == ProjectId
|
||
select new {
|
||
UserId = x.UserId,
|
||
WorkPostId=z.WorkPostId
|
||
}).ToList();
|
||
|
||
var Userid = CurrUser.UserId;
|
||
if (ProblemNoticeItem.State == "2")
|
||
{
|
||
//当前用户是否和项目用户 的岗位相同
|
||
var personCount = WorkPostManList.Where(x => x.UserId == Userid && x.WorkPostId == "4a72bd32-46ed-4aa1-b8a0-4f51444a3a91").ToList().Count;
|
||
if (personCount == 0)
|
||
{
|
||
Alert.ShowInTop("当前状态只能由项目经理来进行操作,请点击右键查看。", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
else if (ProblemNoticeItem.State == "3")
|
||
{
|
||
var RoleUserList = (from x in Funs.DB.Sys_User
|
||
where x.UserId == Userid && x.RoleId != null
|
||
select new
|
||
{
|
||
UserId = x.UserId,
|
||
RoleId = x.RoleId
|
||
}).ToList();
|
||
|
||
var personCount = RoleUserList.Where(x => x.RoleId == "bd3ca210-a85c-41ea-a5af-8b2f79f31fdb").ToList().Count();
|
||
//当前项目下的单位
|
||
var unitCount = Funs.DB.Project_ProjectUnit.Where(x => x.ProjectId == ProblemNoticeItem.ProjectId
|
||
&& x.UnitId == CurrUser.UnitId).ToList().Count();
|
||
|
||
|
||
if (personCount == 0 || unitCount == 0)
|
||
{
|
||
Alert.ShowInTop("当前状态只能由当前项目下的子分公司安全质量部部长来进行操作,请点击右键查看。", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
//var personCount = WorkPostManList.Where(x => x.UserId == Userid && x.WorkPostId == "3F322FF1-85AA-49E8-9F8E-CFB4F9302C71").ToList().Count;
|
||
//if (personCount == 0)
|
||
//{
|
||
// Alert.ShowInTop("当前状态只能由子分公司安全质量部部长来进行操作,请点击右键查看。", MessageBoxIcon.Warning);
|
||
// return;
|
||
//}
|
||
}
|
||
else if (ProblemNoticeItem.State == "4")
|
||
{
|
||
//公司级的
|
||
var RoleUserList = (from x in Funs.DB.Sys_User
|
||
where x.UserId == Userid && x.RoleId != null
|
||
select new
|
||
{
|
||
UserId = x.UserId,
|
||
RoleId = x.RoleId
|
||
}).ToList();
|
||
|
||
var personCount = RoleUserList.Where(x => x.RoleId == "1e508df7-fd48-4e93-bea0-a88154c060e9").ToList().Count();
|
||
//当前项目下的单位
|
||
var unitCount = Funs.DB.Project_ProjectUnit.Where(x => x.ProjectId == ProblemNoticeItem.ProjectId
|
||
&& x.UnitId == CurrUser.UnitId).ToList().Count();
|
||
|
||
if (personCount == 0 || unitCount == 0)
|
||
{
|
||
Alert.ShowInTop("当前状态只能由当前项目下的子分公司副总经理来进行操作,请点击右键查看。", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
else if (ProblemNoticeItem.State == "5")
|
||
{
|
||
|
||
//需要本公司的
|
||
var RoleUserList = (from x in Funs.DB.Sys_User
|
||
where x.UnitId == CommonService.GetThisUnitId() && x.RoleId != null
|
||
select new
|
||
{
|
||
UserId = x.UserId,
|
||
RoleId = x.RoleId
|
||
}).ToList();
|
||
|
||
//公司安全质量部经理
|
||
var personCount = RoleUserList.Where(x => x.RoleId == "b8eae262-05e2-4d05-a673-9fb16691649b" && x.UserId == Userid).ToList().Count();
|
||
//var personCount = WorkPostManList.Where(x => x.UserId == Userid && x.WorkPostId == "2E86E0EB-0246-48DE-8104-CD8E2E2F96F4").ToList().Count ;
|
||
if (personCount==0)
|
||
{
|
||
Alert.ShowInTop("当前状态只能由公司安全质量部经理来进行操作,请点击右键查看。", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
|
||
|
||
if (this.btnMenuEdit.Hidden || ProblemNoticeItem.State == "6") ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProblemReplyManagerEdit.aspx?ProNoticeId={0}&Type=1", id, "查看 - ")));
|
||
}
|
||
else
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProblemReplyManagerEdit.aspx?ProNoticeId={0}&Type=0", id, "编辑 - ")));
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
#region 导出
|
||
protected void btnMenuOut_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
string id = Grid1.SelectedRowID;
|
||
var model = Funs.DB.Problem_Notice.FirstOrDefault(x => x.ProNoticeId == id);
|
||
if (model != null)
|
||
{
|
||
var ProjectName = BLL.ProjectService.GetProjectByProjectId(model.ProjectId).ShortName; ;
|
||
var Cdate = Convert.ToDateTime(model.CreateDate);
|
||
var NowFileName = Cdate.Month.ToString() + "." + Cdate.Day.ToString() + ProjectName + "安全质量检查回复单";
|
||
|
||
string rootPath = Server.MapPath("~/");
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
|
||
initTemplatePath = "File\\Word\\安全质量检查回复单.doc";
|
||
uploadfilepath = rootPath + initTemplatePath;
|
||
//newUrl = uploadfilepath.Replace(".doc", string.Format("{0}-{1:D4}", code, Grid1.RecordCount - Grid1.PageIndex * Grid1.PageSize - Grid1.SelectedRowIndex) + ".doc");
|
||
newUrl = uploadfilepath.Replace("安全质量检查回复单.doc", NowFileName + ".doc");
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
|
||
Bookmark Bmark = doc.Range.Bookmarks["ProjectName"];
|
||
if (Bmark != null)
|
||
{
|
||
Bmark.Text = ProjectName;
|
||
}
|
||
//存在问题整改情况
|
||
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.Bold = false;
|
||
}
|
||
DataTable dt = new DataTable();
|
||
dt.Columns.Add("序号", typeof(string));
|
||
dt.Columns.Add("存在问题", typeof(string));
|
||
dt.Columns.Add("整改情况", typeof(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)
|
||
{
|
||
dt.Rows.Add(new string[] { (item.SortIndex + 1).ToString(), item.QueDescribe, item.ReSituation });
|
||
}
|
||
}
|
||
|
||
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;//水平居中对齐
|
||
builder.CellFormat.Width = 40;
|
||
builder.Write("序号");
|
||
builder.InsertCell();
|
||
builder.CellFormat.Width = 100;
|
||
builder.Write("存在问题");
|
||
builder.InsertCell();
|
||
builder.CellFormat.Width = 60;
|
||
builder.Write("整改情况");
|
||
|
||
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.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
|
||
builder.CellFormat.Width = 40;
|
||
}
|
||
else if (column.ColumnName == "存在问题")
|
||
{
|
||
builder.CellFormat.Width = 100;
|
||
}
|
||
else if (column.ColumnName == "整改情况")
|
||
{
|
||
builder.CellFormat.Width = 60;
|
||
}
|
||
builder.Write(row[column.ColumnName].ToString());
|
||
}
|
||
builder.EndRow();
|
||
}
|
||
builder.EndTable();
|
||
|
||
|
||
|
||
|
||
//受检单位负责人签名
|
||
Bmark = doc.Range.Bookmarks["TestedUnitManSignature"];
|
||
if (Bmark != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(model.TestedUnitManSignature))
|
||
{
|
||
string url = rootPath + model.TestedUnitManSignature;
|
||
DocumentBuilder builders = new DocumentBuilder(doc);
|
||
builders.MoveToBookmark("TestedUnitManSignature");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
if (File.Exists(url))
|
||
{
|
||
builders.InsertImage(url, 150, 50);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
Bmark = doc.Range.Bookmarks["TestedUnitManDatetime"];
|
||
if (Bmark != null)
|
||
{
|
||
if (model.TestedUnitManDatetime != null)
|
||
{
|
||
var TestedUnitManDatetime = Convert.ToDateTime(model.TestedUnitManDatetime);
|
||
Bmark.Text = TestedUnitManDatetime.Year.ToString() + "年" + TestedUnitManDatetime.Month.ToString()
|
||
+ "月" + TestedUnitManDatetime.Day.ToString() + "日";
|
||
}
|
||
|
||
}
|
||
|
||
Bmark = doc.Range.Bookmarks["ReviewOpinions"];
|
||
if (Bmark != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(model.ReviewOpinions))
|
||
{
|
||
Bmark.Text = model.ReviewOpinions;
|
||
}
|
||
|
||
}
|
||
//复查人签字
|
||
Bmark = doc.Range.Bookmarks["ReviewSignature"];
|
||
if (Bmark != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(model.ReviewSignature))
|
||
{
|
||
string url = rootPath + model.ReviewSignature;
|
||
DocumentBuilder builders = new DocumentBuilder(doc);
|
||
builders.MoveToBookmark("ReviewSignature");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
if (File.Exists(url))
|
||
{
|
||
builders.InsertImage(url, 150, 50);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
Bmark = doc.Range.Bookmarks["ReviewDatetime"];
|
||
if (Bmark != null)
|
||
{
|
||
if (model.ReviewDatetime != null)
|
||
{
|
||
var ReviewDatetime = Convert.ToDateTime(model.ReviewDatetime);
|
||
Bmark.Text = ReviewDatetime.Year.ToString() + "年" + ReviewDatetime.Month.ToString()
|
||
+ "月" + ReviewDatetime.Day.ToString() + "日";
|
||
}
|
||
|
||
}
|
||
|
||
//分管领导
|
||
Bmark = doc.Range.Bookmarks["LeaderSignature"];
|
||
if (Bmark != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(model.LeaderSignature))
|
||
{
|
||
string url = rootPath + model.LeaderSignature;
|
||
DocumentBuilder builders = new DocumentBuilder(doc);
|
||
builders.MoveToBookmark("LeaderSignature");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
if (File.Exists(url))
|
||
{
|
||
builders.InsertImage(url, 150, 50);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
Bmark = doc.Range.Bookmarks["LeaderDatetime"];
|
||
if (Bmark != null)
|
||
{
|
||
if (model.LeaderDatetime != null)
|
||
{
|
||
var LeaderDatetime = Convert.ToDateTime(model.LeaderDatetime);
|
||
Bmark.Text = LeaderDatetime.Year.ToString() + "年" + LeaderDatetime.Month.ToString()
|
||
+ "月" + LeaderDatetime.Day.ToString() + "日";
|
||
}
|
||
|
||
}
|
||
//检查组
|
||
Bmark = doc.Range.Bookmarks["InspectionUnitSignature"];
|
||
if (Bmark != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(model.InspectionUnitSignature))
|
||
{
|
||
string url = rootPath + model.InspectionUnitSignature;
|
||
DocumentBuilder builders = new DocumentBuilder(doc);
|
||
builders.MoveToBookmark("InspectionUnitSignature");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
if (File.Exists(url))
|
||
{
|
||
builders.InsertImage(url, 150, 50);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
Bmark = doc.Range.Bookmarks["InspectionUnitDatetime"];
|
||
if (Bmark != null)
|
||
{
|
||
if (model.InspectionUnitDatetime != null)
|
||
{
|
||
var InspectionUnitDatetime = Convert.ToDateTime(model.InspectionUnitDatetime);
|
||
Bmark.Text = InspectionUnitDatetime.Year.ToString() + "年" + InspectionUnitDatetime.Month.ToString()
|
||
+ "月" + InspectionUnitDatetime.Day.ToString() + "日";
|
||
}
|
||
|
||
}
|
||
|
||
#region 安全质量检查回复单
|
||
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.Bold = false;
|
||
}
|
||
builder.RowFormat.Height = 50;
|
||
builder.Bold = false;
|
||
foreach (var item in detailList)
|
||
{
|
||
//1.问题描述
|
||
|
||
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 = 100;
|
||
|
||
builder.InsertCell();
|
||
builder.Write("整改前");
|
||
builder.InsertCell();
|
||
builder.Write("整改后");
|
||
//下一行
|
||
builder.EndRow();
|
||
//整改前照片
|
||
builder.InsertCell();
|
||
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Top;//顶端对齐
|
||
|
||
IList<Model.AttachFile> sourlistDetail = AttachFileService.GetBeforeFileList(item.ProNoticeCId, BLL.Const.ProblemNoticeManagerMenuId);
|
||
if (sourlistDetail != null && sourlistDetail.Count > 0)
|
||
{
|
||
string AttachUrl = "";
|
||
foreach (var items in sourlistDetail)
|
||
{
|
||
if (!string.IsNullOrEmpty(items.AttachUrl) && items.AttachUrl.ToLower().EndsWith(".jpg")
|
||
|| items.AttachUrl.ToLower().EndsWith(".jpeg") || items.AttachUrl.ToLower().EndsWith(".png"))
|
||
{
|
||
AttachUrl += items.AttachUrl.TrimEnd(',') + ",";
|
||
}
|
||
|
||
}
|
||
AttachUrl = AttachUrl.Remove(AttachUrl.LastIndexOf(","), 1);
|
||
string[] pics = AttachUrl.Split(',');
|
||
foreach (string picsitem in pics)
|
||
{
|
||
string url = rootPath + picsitem.TrimEnd(',');
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, 200, 180);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
builder.Write("");
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
builder.Write("");
|
||
}
|
||
|
||
builder.InsertCell();
|
||
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Top;//顶端对齐
|
||
//整改后照片
|
||
sourlistDetail = AttachFileService.GetBeforeFileList(item.ProNoticeCId + "ZGH", BLL.Const.ProblemNoticeManagerMenuId);
|
||
if (sourlistDetail != null && sourlistDetail.Count > 0)
|
||
{
|
||
string AttachUrl = "";
|
||
foreach (var items in sourlistDetail)
|
||
{
|
||
if (!string.IsNullOrEmpty(items.AttachUrl) && items.AttachUrl.ToLower().EndsWith(".jpg")
|
||
|| items.AttachUrl.ToLower().EndsWith(".jpeg") || items.AttachUrl.ToLower().EndsWith(".png"))
|
||
{
|
||
AttachUrl += items.AttachUrl.TrimEnd(',') + ",";
|
||
}
|
||
|
||
}
|
||
AttachUrl = AttachUrl.Remove(AttachUrl.LastIndexOf(","), 1);
|
||
string[] pics = AttachUrl.Split(',');
|
||
foreach (string picsitem in pics)
|
||
{
|
||
string url = rootPath + picsitem.TrimEnd(',');
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, 200, 180);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
builder.Write("");
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
builder.Write("");
|
||
}
|
||
//下一行
|
||
builder.EndRow();
|
||
|
||
builder.InsertCell();
|
||
builder.CellFormat.Width = 100;
|
||
builder.Write("问题:" + item.QueDescribe);
|
||
//2.整改完成情况
|
||
builder.InsertCell();
|
||
builder.CellFormat.Width = 100;
|
||
if (!string.IsNullOrEmpty(item.ReSituation))
|
||
{
|
||
builder.Write("整改完成情况:" + item.ReSituation);
|
||
}
|
||
else
|
||
{
|
||
builder.Write("");
|
||
}
|
||
builder.EndRow();
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
doc.Save(newUrl);
|
||
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
|
||
|
||
//验证参数
|
||
if (doc1 == null) { throw new Exception("Word文件无效"); }
|
||
string fileName = Path.GetFileName(newUrl);
|
||
FileInfo info = new FileInfo(newUrl);
|
||
long fileSize = info.Length;
|
||
Response.Clear();
|
||
Response.ContentType = "application/x-zip-compressed";
|
||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||
Response.AddHeader("Content-Length", fileSize.ToString());
|
||
Response.TransmitFile(newUrl, 0, fileSize);
|
||
Response.Flush();
|
||
Response.Close();
|
||
File.Delete(newUrl);
|
||
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("只能导出已回复的数据!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
} |