831 lines
34 KiB
C#
831 lines
34 KiB
C#
using Aspose.Words;
|
|
using BLL;
|
|
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 AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.Customization.CNCCG.HSSE.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)
|
|
{
|
|
////权限按钮方法
|
|
GetButtonPower();
|
|
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"];
|
|
}
|
|
|
|
//var thisUnit = BLL.CommonService.GetIsThisUnit();
|
|
//if (!string.IsNullOrEmpty(this.CurrUser.UnitId) && thisUnit.UnitId != this.CurrUser.UnitId)
|
|
//{
|
|
// ProjectService.InitUnitProjectDropDownList(this.drpProject, this.CurrUser.UnitId, false);
|
|
//}
|
|
//else
|
|
//{
|
|
// BLL.ProjectService.InitAllProjectDropDownList(this.drpProject, true);
|
|
//}
|
|
|
|
//this.btnNew.OnClientClick = Window1.GetShowReference("ProblemNoticeManagerEdit.aspx?Type=0") + "return false;";
|
|
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, "D106708E-725C-4E4F-B1A1-371283F471B9");
|
|
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;
|
|
//项目经理或者管理员
|
|
if (CurrUser.ProjectWorkPostId== "4a72bd32-46ed-4aa1-b8a0-4f51444a3a91"||
|
|
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 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 1=1 and proType='1' ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
|
|
if (userId == Const.sysglyId || userId == Const.hfnbdId || userId == "a68bc9cc-efaa-4309-ac06-ec6ac85ea353")
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
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();
|
|
}
|
|
}
|
|
#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 "归档";
|
|
}
|
|
}
|
|
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 || ProblemNoticeItem.State!="1") ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
|
|
{
|
|
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)
|
|
{
|
|
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;
|
|
}
|
|
|
|
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);
|
|
Bmark.Text = CheckTime.Year.ToString() + "." + CheckTime.Month.ToString() + "." + CheckTime.Day.ToString()
|
|
+ "-" + Convert.ToDateTime(model.CheckEndTime).Month.ToString();
|
|
}
|
|
|
|
Bmark = doc.Range.Bookmarks["Resume"];
|
|
if (Bmark != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(model.Resume))
|
|
{
|
|
Bmark.Text = model.Resume;
|
|
}
|
|
|
|
}
|
|
|
|
//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));
|
|
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.QueDescribe, item.Requirements });
|
|
}
|
|
}
|
|
|
|
builder.RowFormat.Height = 20;
|
|
builder.Bold = false;
|
|
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 = 100;
|
|
}
|
|
else if (column.ColumnName == "整改要求")
|
|
{
|
|
builder.CellFormat.Width = 100;
|
|
}
|
|
|
|
|
|
builder.Write(row[column.ColumnName].ToString());
|
|
}
|
|
builder.EndRow();
|
|
}
|
|
//其他工作要求
|
|
builder.InsertCell();
|
|
builder.CellFormat.Width = 200;
|
|
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(model.CheckUnitSignature))
|
|
{
|
|
string url = rootPath + model.CheckUnitSignature;
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
if (File.Exists(url))
|
|
{
|
|
builder.InsertImage(url, 150, 50);
|
|
}
|
|
}
|
|
}
|
|
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(model.CheckMansSignature))
|
|
{
|
|
string url = rootPath + model.CheckMansSignature;
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
if (File.Exists(url))
|
|
{
|
|
builder.InsertImage(url, 150, 50);
|
|
}
|
|
}
|
|
}
|
|
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();
|
|
|
|
//Bmark = doc.Range.Bookmarks["OtherJob"];
|
|
//if (Bmark != null)
|
|
//{
|
|
// if (!string.IsNullOrEmpty(model.OtherJob))
|
|
// {
|
|
// Bmark.Text = model.OtherJob;
|
|
// }
|
|
|
|
//}
|
|
|
|
//Bmark = doc.Range.Bookmarks["CheckUnitSignature"];
|
|
//if (Bmark != null)
|
|
//{
|
|
// if (!string.IsNullOrEmpty(model.CheckUnitSignature))
|
|
// {
|
|
// string url = rootPath + model.CheckUnitSignature;
|
|
// DocumentBuilder builders = new DocumentBuilder(doc);
|
|
// builders.MoveToBookmark("CheckUnitSignature");
|
|
// if (!string.IsNullOrEmpty(url))
|
|
// {
|
|
// if (File.Exists(url))
|
|
// {
|
|
// builders.InsertImage(url, 150, 50);
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
//Bmark = doc.Range.Bookmarks["CheckUnitDatetime"];
|
|
//if (Bmark != null)
|
|
//{
|
|
// if (model.CheckUnitDatetime != null)
|
|
// {
|
|
// var CheckUnitDatetime = Convert.ToDateTime(model.CheckUnitDatetime);
|
|
// Bmark.Text = CheckUnitDatetime.Year.ToString() + "年" + CheckUnitDatetime.Month.ToString()
|
|
// + "月" + CheckUnitDatetime.Day.ToString() + "日";
|
|
// }
|
|
|
|
//}
|
|
|
|
//Bmark = doc.Range.Bookmarks["CheckMansSignature"];
|
|
//if (Bmark != null)
|
|
//{
|
|
// if (!string.IsNullOrEmpty(model.CheckMansSignature))
|
|
// {
|
|
// string url = rootPath + model.CheckMansSignature;
|
|
// DocumentBuilder builders = new DocumentBuilder(doc);
|
|
// builders.MoveToBookmark("CheckMansSignature");
|
|
// if (!string.IsNullOrEmpty(url))
|
|
// {
|
|
// if (File.Exists(url))
|
|
// {
|
|
// builders.InsertImage(url, 150, 50);
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
//Bmark = doc.Range.Bookmarks["CheckMansDatetime"];
|
|
//if (Bmark != null)
|
|
//{
|
|
// if (model.CheckMansDatetime != null)
|
|
// {
|
|
// var CheckMansDatetime = Convert.ToDateTime(model.CheckMansDatetime);
|
|
// Bmark.Text = CheckMansDatetime.Year.ToString() + "年" + CheckMansDatetime.Month.ToString()
|
|
// + "月" + CheckMansDatetime.Day.ToString() + "日";
|
|
// }
|
|
|
|
//}
|
|
|
|
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 = 200;
|
|
}
|
|
else
|
|
{
|
|
if (XcjcImgIndex % 2 != 0 && XcjcImgIndex != 1)
|
|
{
|
|
builder.CellFormat.Width = 200;
|
|
}
|
|
else
|
|
{
|
|
builder.CellFormat.Width = 100;
|
|
}
|
|
}
|
|
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.EndRow();
|
|
builder.EndTable();
|
|
}
|
|
//检查问题照片
|
|
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 = 200;
|
|
builder.Write("检查问题照片");
|
|
builder.EndRow();
|
|
//整改前照片
|
|
dt = new DataTable();
|
|
dt.Columns.Add("存在问题", typeof(string));
|
|
dt.Columns.Add("照片", typeof(string));
|
|
if (detailList.Count > 0)
|
|
{
|
|
foreach (var item in detailList)
|
|
{
|
|
dt.Rows.Add(new string[] { item.QueDescribe, item.ProNoticeCId });
|
|
}
|
|
}
|
|
builder.RowFormat.Height = 50;
|
|
builder.Bold = false;
|
|
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 = 100;
|
|
builder.Write(row[column.ColumnName].ToString());
|
|
}
|
|
else if (column.ColumnName == "照片")
|
|
{
|
|
builder.CellFormat.Width = 100;
|
|
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();
|
|
|
|
|
|
|
|
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
|
|
}
|
|
} |