425 lines
17 KiB
C#
425 lines
17 KiB
C#
|
using Apache.NMS.ActiveMQ.Threads;
|
|||
|
using Aspose.Words;
|
|||
|
using BLL;
|
|||
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Web;
|
|||
|
using System.Web.UI;
|
|||
|
using System.Web.UI.WebControls;
|
|||
|
|
|||
|
namespace FineUIPro.Web.CQMS.Check
|
|||
|
{
|
|||
|
public partial class CheckFineListView : PageBase
|
|||
|
{
|
|||
|
#region 公共字段
|
|||
|
/// <summary>
|
|||
|
/// 主键
|
|||
|
/// </summary>
|
|||
|
public string CheckFineId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["CheckFineId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["CheckFineId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public string CheckControlCode
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["CheckControlCode"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["CheckControlCode"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 办理类型
|
|||
|
/// </summary>
|
|||
|
public string State
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["State"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["State"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, false);
|
|||
|
|
|||
|
CheckFineId = Request.Params["CheckFineId"];
|
|||
|
if (!string.IsNullOrEmpty(CheckFineId))
|
|||
|
{
|
|||
|
this.hdCheckControlCode.Text = CheckFineId;
|
|||
|
|
|||
|
Model.Check_CheckFine checkControl = CheckFineService.CheckFine(CheckFineId);
|
|||
|
txtDocCode.Text = checkControl.DocCode;
|
|||
|
if (!string.IsNullOrEmpty(checkControl.UnitId))
|
|||
|
{
|
|||
|
this.drpUnit.SelectedValue = checkControl.UnitId;
|
|||
|
}
|
|||
|
|
|||
|
this.txtCheckMan.Text = BLL.UserService.GetUserNameByUserId(checkControl.CheckMan);
|
|||
|
if (checkControl.CheckDate != null)
|
|||
|
{
|
|||
|
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", checkControl.CheckDate);
|
|||
|
}
|
|||
|
this.txtQuestionDef.Text = checkControl.QuestionDef;
|
|||
|
var dt = CheckFineApproveService.getListData(CheckFineId);
|
|||
|
gvApprove.DataSource = dt;
|
|||
|
gvApprove.DataBind();
|
|||
|
}
|
|||
|
|
|||
|
txtProjectName.Text = ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId).ProjectName;
|
|||
|
//是否同意触发
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 把状态转换代号为文字形式
|
|||
|
/// </summary>
|
|||
|
/// <param name="state"></param>
|
|||
|
/// <returns></returns>
|
|||
|
protected string ConvertState(object state)
|
|||
|
{
|
|||
|
if (state != null)
|
|||
|
{
|
|||
|
if (state.ToString() == BLL.Const.CheckFine_ReCompile)
|
|||
|
{
|
|||
|
return "重新编制";
|
|||
|
}
|
|||
|
else if (state.ToString() == BLL.Const.CheckFine_Compile)
|
|||
|
{
|
|||
|
return "编制";
|
|||
|
}
|
|||
|
else if (state.ToString() == BLL.Const.CheckFine_Audit1)
|
|||
|
{
|
|||
|
return "现场质量经理审核";
|
|||
|
}
|
|||
|
else if (state.ToString() == BLL.Const.CheckFine_Audit2)
|
|||
|
{
|
|||
|
return "现场经理/施工经理审批";
|
|||
|
}
|
|||
|
else if (state.ToString() == BLL.Const.CheckFine_Complete)
|
|||
|
{
|
|||
|
return "审批完成";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return "";
|
|||
|
}
|
|||
|
}
|
|||
|
return "";
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 保存并下载通知单
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnDown_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CheckFineListMenuId, BLL.Const.BtnSave))
|
|||
|
{
|
|||
|
Model.Check_CheckFine checkControl = CheckFineService.CheckFine(this.hdCheckControlCode.Text);
|
|||
|
|
|||
|
|
|||
|
string rootPath = Server.MapPath("~/");
|
|||
|
string initTemplatePath = string.Empty;
|
|||
|
string uploadfilepath = string.Empty;
|
|||
|
string newUrl = string.Empty;
|
|||
|
|
|||
|
initTemplatePath = Const.CheckFineTemplateUrl;
|
|||
|
uploadfilepath = rootPath + initTemplatePath;
|
|||
|
newUrl = uploadfilepath.Replace(".doc", checkControl.DocCode + ".doc");
|
|||
|
if (File.Exists(newUrl))
|
|||
|
{
|
|||
|
File.Delete(newUrl);
|
|||
|
}
|
|||
|
File.Copy(uploadfilepath, newUrl);
|
|||
|
Document doc = new Aspose.Words.Document(newUrl);
|
|||
|
Bookmark bookmarkProjectName = doc.Range.Bookmarks["ProjectName"];
|
|||
|
Bookmark bookmarkProjectCode = doc.Range.Bookmarks["ProjectCode"];
|
|||
|
var project = ProjectService.GetProjectByProjectId(checkControl.ProjectId);
|
|||
|
if (bookmarkProjectName != null)
|
|||
|
{
|
|||
|
|
|||
|
if (project != null)
|
|||
|
{
|
|||
|
bookmarkProjectName.Text = string.IsNullOrEmpty(project.ShortName) ? project.ProjectName : project.ShortName;
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
if (bookmarkProjectCode != null)
|
|||
|
{
|
|||
|
if (project != null)
|
|||
|
{
|
|||
|
bookmarkProjectCode.Text = project.ProjectCode;
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
Bookmark bookmarkFileNum2 = doc.Range.Bookmarks["FileNum2"];
|
|||
|
if (bookmarkFileNum2 != null)
|
|||
|
{
|
|||
|
bookmarkFileNum2.Text = checkControl.DocCode;
|
|||
|
}
|
|||
|
Bookmark bookmarkFileNum = doc.Range.Bookmarks["FileNum"];
|
|||
|
if (bookmarkFileNum != null)
|
|||
|
{
|
|||
|
bookmarkFileNum.Text = checkControl.DocCode;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
Bookmark bookmarkUnit = doc.Range.Bookmarks["Unit"];
|
|||
|
if (bookmarkUnit != null)
|
|||
|
{
|
|||
|
var unit = UnitService.GetUnitByUnitId(checkControl.UnitId);
|
|||
|
if (unit != null)
|
|||
|
{
|
|||
|
bookmarkUnit.Text = unit.UnitName;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
Bookmark bookmarkWorkArea = doc.Range.Bookmarks["WorkArea"];
|
|||
|
if (bookmarkWorkArea != null)
|
|||
|
{
|
|||
|
string option = "";
|
|||
|
var unitWork = UnitWorkService.GetUnitWorkByUnitWorkId(checkControl.UnitWorkId);
|
|||
|
if (unitWork != null)
|
|||
|
{
|
|||
|
bookmarkWorkArea.Text = unitWork.UnitWorkCode + "-" + unitWork.UnitWorkName;
|
|||
|
}
|
|||
|
}
|
|||
|
Bookmark bookmarkCheckDate = doc.Range.Bookmarks["CheckDate"];
|
|||
|
if (bookmarkCheckDate != null)
|
|||
|
{
|
|||
|
if (checkControl.CheckDate.HasValue)
|
|||
|
{
|
|||
|
bookmarkCheckDate.Text = checkControl.CheckDate.Value.ToString("yyyy年MM月dd日");
|
|||
|
}
|
|||
|
}
|
|||
|
Bookmark bookmarkFine = doc.Range.Bookmarks["Fine"];
|
|||
|
if (bookmarkFine != null)
|
|||
|
{
|
|||
|
if (checkControl.Fee.HasValue)
|
|||
|
{
|
|||
|
bookmarkFine.Text = checkControl.Fee.Value.ToString("##.##");
|
|||
|
}
|
|||
|
}
|
|||
|
Bookmark bookmarkFine2 = doc.Range.Bookmarks["Fine2"];
|
|||
|
if (bookmarkFine2 != null)
|
|||
|
{
|
|||
|
if (checkControl.Fee.HasValue)
|
|||
|
{
|
|||
|
bookmarkFine2.Text = checkControl.Fee.Value.ToString("##");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
Bookmark bookmarkQuestionDef = doc.Range.Bookmarks["QuestionDef"];
|
|||
|
if (bookmarkQuestionDef != null)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(checkControl.QuestionDef))
|
|||
|
{
|
|||
|
bookmarkQuestionDef.Text = checkControl.QuestionDef;
|
|||
|
}
|
|||
|
}
|
|||
|
Bookmark bookmarkFine3 = doc.Range.Bookmarks["Fine3"];
|
|||
|
if (bookmarkFine3 != null)
|
|||
|
{
|
|||
|
if (checkControl.Fee.HasValue)
|
|||
|
{
|
|||
|
bookmarkFine3.Text = checkControl.Fee.Value.ToString("##.##");
|
|||
|
}
|
|||
|
}
|
|||
|
Bookmark bookmarkFine4 = doc.Range.Bookmarks["Fine4"];
|
|||
|
if (bookmarkFine4 != null)
|
|||
|
{
|
|||
|
if (checkControl.Fee.HasValue)
|
|||
|
{
|
|||
|
bookmarkFine4.Text = checkControl.Fee.Value.ToString("##");
|
|||
|
}
|
|||
|
}
|
|||
|
Bookmark bookmarkCheckMan = doc.Range.Bookmarks["CheckMan"];
|
|||
|
if (bookmarkCheckMan != null)
|
|||
|
{
|
|||
|
var user = UserService.GetUserByUserId(checkControl.CheckMan);
|
|||
|
if (user != null)
|
|||
|
{
|
|||
|
bookmarkCheckMan.Text = user.UserName;
|
|||
|
}
|
|||
|
}
|
|||
|
IList<Model.AttachFile> sourlist = AttachFileService.GetBeforeFileList(checkControl.CheckFineId, BLL.Const.CheckFineListMenuId);
|
|||
|
|
|||
|
if (sourlist != null && sourlist.Count > 0)
|
|||
|
{
|
|||
|
int indexPic = 1;
|
|||
|
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(',') + ",";
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
string[] pics = AttachUrl.Split(',');
|
|||
|
foreach (string item in pics)
|
|||
|
{
|
|||
|
switch (indexPic)
|
|||
|
{
|
|||
|
case 1:
|
|||
|
{
|
|||
|
string url = rootPath + item.TrimEnd(',');
|
|||
|
//查找书签
|
|||
|
DocumentBuilder builder = new DocumentBuilder(doc);
|
|||
|
builder.MoveToBookmark("Pic1");
|
|||
|
if (!string.IsNullOrEmpty(url))
|
|||
|
{
|
|||
|
System.Drawing.Size JpgSize;
|
|||
|
float Wpx;
|
|||
|
float Hpx;
|
|||
|
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
|||
|
double i = 1;
|
|||
|
i = JpgSize.Width / 180.0;
|
|||
|
if (File.Exists(url))
|
|||
|
{
|
|||
|
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
indexPic++;
|
|||
|
}
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
{
|
|||
|
string url = rootPath + item.TrimEnd(',');
|
|||
|
//查找书签
|
|||
|
DocumentBuilder builder = new DocumentBuilder(doc);
|
|||
|
builder.MoveToBookmark("Pic2");
|
|||
|
if (!string.IsNullOrEmpty(url))
|
|||
|
{
|
|||
|
System.Drawing.Size JpgSize;
|
|||
|
float Wpx;
|
|||
|
float Hpx;
|
|||
|
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
|||
|
double i = 1;
|
|||
|
i = JpgSize.Width / 180.0;
|
|||
|
if (File.Exists(url))
|
|||
|
{
|
|||
|
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
indexPic++;
|
|||
|
}
|
|||
|
break;
|
|||
|
case 3:
|
|||
|
{
|
|||
|
string url = rootPath + item.TrimEnd(',');
|
|||
|
//查找书签
|
|||
|
DocumentBuilder builder = new DocumentBuilder(doc);
|
|||
|
builder.MoveToBookmark("Pic3");
|
|||
|
if (!string.IsNullOrEmpty(url))
|
|||
|
{
|
|||
|
System.Drawing.Size JpgSize;
|
|||
|
float Wpx;
|
|||
|
float Hpx;
|
|||
|
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
|||
|
double i = 1;
|
|||
|
i = JpgSize.Width / 180.0;
|
|||
|
if (File.Exists(url))
|
|||
|
{
|
|||
|
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
indexPic++;
|
|||
|
}
|
|||
|
break;
|
|||
|
case 4:
|
|||
|
{
|
|||
|
string url = rootPath + item.TrimEnd(',');
|
|||
|
//查找书签
|
|||
|
DocumentBuilder builder = new DocumentBuilder(doc);
|
|||
|
builder.MoveToBookmark("Pic4");
|
|||
|
if (!string.IsNullOrEmpty(url))
|
|||
|
{
|
|||
|
System.Drawing.Size JpgSize;
|
|||
|
float Wpx;
|
|||
|
float Hpx;
|
|||
|
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
|||
|
double i = 1;
|
|||
|
i = JpgSize.Width / 180.0;
|
|||
|
if (File.Exists(url))
|
|||
|
{
|
|||
|
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
indexPic++;
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
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
|
|||
|
{
|
|||
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|