2023-06-10 12:00:41 +08:00
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 ;
namespace FineUIPro.Web.HSSE.License
{
public partial class TempElectricity : PageBase
{
#region 项 目 主 键
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return ( string ) ViewState [ "ProjectId" ] ;
}
set
{
ViewState [ "ProjectId" ] = value ;
}
}
#endregion
#region 加 载
/// <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 . GetButtonPower ( ) ;
this . ProjectId = this . CurrUser . LoginProjectId ;
//if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
//{
// this.ProjectId = Request.Params["projectId"];
//}
UnitService . InitUnitDropDownList ( this . drpUnit , this . ProjectId , true ) ;
if ( BLL . ProjectUnitService . GetProjectUnitTypeByProjectIdUnitId ( this . ProjectId , this . CurrUser . UnitId ) )
{
this . drpUnit . SelectedValue = this . CurrUser . UnitId ;
this . drpUnit . Enabled = false ;
}
this . drpStates . DataValueField = "Value" ;
this . drpStates . DataTextField = "Text" ;
this . drpStates . DataSource = LicensePublicService . drpStatesItem ( ) ;
this . drpStates . DataBind ( ) ;
this . drpStates . SelectedValue = Const . _Null ;
if ( this . CurrUser ! = null & & this . CurrUser . PageSize . HasValue )
{
Grid1 . PageSize = this . CurrUser . PageSize . Value ;
}
this . ddlPageSize . SelectedValue = Grid1 . PageSize . ToString ( ) ;
// 绑定表格
this . BindGrid ( ) ;
}
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid ( )
{
string strSql = "SELECT license.TempElectricityId,license.ProjectId,license.LicenseCode,license.ApplyUnitId,ApplyUnit.UnitName AS ApplyUnitName,license.ApplyManId,license.ApplyDate,license.WorkPalce,license.ValidityStartTime,license.ValidityEndTime,license.WorkMeasures,license.States"
+ @" ,(CASE WHEN license.States=-2 THEN '作废' WHEN license.States=0 THEN '待提交' WHEN license.States=1 THEN '审核中' WHEN license.States=2 THEN '作业中' WHEN license.States=3 THEN '已完成' WHEN license.States=-1 THEN '已取消' ELSE '未知' END) AS StatesName "
+ @" FROM dbo.License_TempElectricity AS license "
+ @" LEFT JOIN Base_Unit AS ApplyUnit ON license.ApplyUnitId =ApplyUnit.UnitId"
+ @" WHERE license.ProjectId= '" + this . ProjectId + "'" ;
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
if ( ProjectUnitService . GetProjectUnitTypeByProjectIdUnitId ( this . ProjectId , this . CurrUser . UnitId ) )
{
strSql + = " AND license.ApplyUnitId = @UnitId" ; ///状态为已完成
listStr . Add ( new SqlParameter ( "@UnitId" , this . CurrUser . UnitId ) ) ;
}
if ( this . drpUnit . SelectedValue ! = Const . _Null )
{
strSql + = " AND license.ApplyUnitId = @UnitId2" ;
listStr . Add ( new SqlParameter ( "@UnitId2" , this . drpUnit . SelectedValue ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . drpStates . SelectedValue ) & & this . drpStates . SelectedValue ! = Const . _Null )
{
strSql + = " AND license.States = @States" ;
listStr . Add ( new SqlParameter ( "@States" , this . drpStates . SelectedValue ) ) ;
}
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 ( ) ;
}
/// <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 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_Sort ( object sender , FineUIPro . GridSortEventArgs e )
{
Grid1 . SortDirection = e . SortDirection ;
Grid1 . SortField = e . SortField ;
BindGrid ( ) ;
}
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close ( object sender , EventArgs e )
{
BindGrid ( ) ;
}
#endregion
#region 查 询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged ( object sender , EventArgs e )
{
this . BindGrid ( ) ;
}
#endregion
#region 编 辑
/// <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 btnMenuView_Click ( object sender , EventArgs e )
{
this . EditData ( ) ;
}
/// <summary>
/// 编辑数据方法
/// </summary>
private void EditData ( )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请至少选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
string id = Grid1 . SelectedRowID ;
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "TempElectricityView.aspx?TempElectricityId={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 TempElectricity = LicensePublicService . GetTempElectricityById ( rowID ) ;
if ( TempElectricity ! = null )
{
LogService . AddSys_Log ( this . CurrUser , TempElectricity . LicenseCode , TempElectricity . TempElectricityId , Const . ProjectTempElectricityMenuId , Const . BtnDelete ) ;
LicensePublicService . DeleteTempElectricityById ( rowID ) ;
}
}
this . BindGrid ( ) ;
ShowNotify ( "删除数据成功!" , MessageBoxIcon . Success ) ;
}
}
#endregion
#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 , BLL . Const . ProjectTempElectricityMenuId ) ;
if ( buttonList . Count ( ) > 0 )
{
//if (buttonList.Contains(BLL.Const.BtnAdd))
//{
// this.btnNew.Hidden = false;
//}
if ( buttonList . Contains ( BLL . Const . BtnModify ) )
{
this . btnMenuView . Hidden = false ;
}
if ( buttonList . Contains ( BLL . Const . BtnDelete ) )
{
this . btnMenuDelete . Hidden = false ;
}
}
}
#endregion
#region 导 出 按 钮
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click ( object sender , EventArgs e )
{
Response . ClearContent ( ) ;
string filename = Funs . GetNewFileName ( ) ;
Response . AddHeader ( "content-disposition" , "attachment; filename=" + System . Web . HttpUtility . UrlEncode ( "临电作业票" + filename , System . Text . Encoding . UTF8 ) + ".xls" ) ;
Response . ContentType = "application/excel" ;
Response . ContentEncoding = Encoding . UTF8 ;
this . Grid1 . PageSize = this . Grid1 . RecordCount ;
this . BindGrid ( ) ;
Response . Write ( GetGridTableHtml ( Grid1 ) ) ;
Response . End ( ) ;
}
#endregion
#region 打 印
protected void btnPrinter_Click ( object sender , EventArgs e )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请至少选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
string Id = Grid1 . SelectedRowID ;
string rootPath = Server . MapPath ( "~/" ) ;
string initTemplatePath = string . Empty ;
string uploadfilepath = string . Empty ;
string newUrl = string . Empty ;
string filePath = string . Empty ;
initTemplatePath = "File\\Word\\HSSE\\临电作业票.doc" ;
uploadfilepath = rootPath + initTemplatePath ;
string docfilename = Funs . GetNewFileName ( ) ;
newUrl = uploadfilepath . Replace ( ".doc" , docfilename + ".doc" ) ;
filePath = initTemplatePath . Replace ( ".doc" , docfilename + ".pdf" ) ;
File . Copy ( uploadfilepath , newUrl ) ;
///更新书签
var getTempElectricity = LicensePublicService . GetTempElectricityById ( Id ) ;
2024-02-27 18:13:26 +08:00
var projectName = ProjectService . GetProjectNameByProjectId ( getTempElectricity . ProjectId ) ;
2023-06-10 12:00:41 +08:00
Document doc = new Aspose . Words . Document ( newUrl ) ;
2024-02-27 18:13:26 +08:00
Bookmark bookmarkProjectName = doc . Range . Bookmarks [ "ProjectName" ] ; //编号
if ( bookmarkProjectName ! = null )
{
if ( ! string . IsNullOrEmpty ( projectName ) )
{
bookmarkProjectName . Text = projectName ;
}
}
2023-06-10 12:00:41 +08:00
Bookmark bookmarkLicenseCode = doc . Range . Bookmarks [ "LicenseCode" ] ; //编号
if ( bookmarkLicenseCode ! = null )
{
if ( getTempElectricity ! = null )
{
bookmarkLicenseCode . Text = getTempElectricity . LicenseCode ;
}
}
2024-02-27 18:13:26 +08:00
Bookmark bookmarkWorkLeader = doc . Range . Bookmarks [ "WorkLeader" ] ; //现场负责人
if ( bookmarkWorkLeader ! = null )
2023-06-10 12:00:41 +08:00
{
if ( getTempElectricity ! = null )
{
2024-02-27 18:13:26 +08:00
var getUser = UserService . GetUserByUserId ( getTempElectricity . WorkLeaderId ) ;
2023-06-10 12:00:41 +08:00
if ( getUser ! = null )
{
2024-02-27 18:13:26 +08:00
bookmarkWorkLeader . Text = getUser . UserName ;
2023-06-10 12:00:41 +08:00
}
}
}
2024-02-27 18:13:26 +08:00
2023-06-10 12:00:41 +08:00
Bookmark bookmarkUnitName = doc . Range . Bookmarks [ "UnitName" ] ; //申请单位
if ( bookmarkUnitName ! = null )
{
if ( getTempElectricity ! = null )
{
if ( ! string . IsNullOrEmpty ( getTempElectricity . ApplyUnitId ) )
{
bookmarkUnitName . Text = BLL . UnitService . GetUnitNameByUnitId ( getTempElectricity . ApplyUnitId ) ;
}
}
}
2024-02-27 18:13:26 +08:00
Bookmark bookmarkUseTo = doc . Range . Bookmarks [ "UseTo" ] ; //用电用途
if ( bookmarkUseTo ! = null )
{
if ( getTempElectricity ! = null & & ! string . IsNullOrEmpty ( getTempElectricity . UseTo ) )
{
bookmarkUseTo . Text = getTempElectricity . UseTo ;
}
}
Bookmark bookmarkWorkPalce = doc . Range . Bookmarks [ "WorkPalce" ] ; //用电地点
2023-06-10 12:00:41 +08:00
if ( bookmarkWorkPalce ! = null )
{
2024-02-27 18:13:26 +08:00
if ( getTempElectricity ! = null & & ! string . IsNullOrEmpty ( getTempElectricity . WorkPalce ) )
2023-06-10 12:00:41 +08:00
{
bookmarkWorkPalce . Text = getTempElectricity . WorkPalce ;
}
}
2024-02-27 18:13:26 +08:00
Bookmark bookmarkAccessPoint = doc . Range . Bookmarks [ "AccessPoint" ] ; //接入点名称
if ( bookmarkAccessPoint ! = null )
{
if ( getTempElectricity ! = null & & ! string . IsNullOrEmpty ( getTempElectricity . AccessPoint ) )
{
bookmarkAccessPoint . Text = getTempElectricity . AccessPoint ;
}
}
Bookmark bookmarkAccessPointNo = doc . Range . Bookmarks [ "AccessPointNo" ] ; //接入点编号
if ( bookmarkAccessPointNo ! = null )
{
if ( getTempElectricity ! = null & & ! string . IsNullOrEmpty ( getTempElectricity . AccessPointNo ) )
{
bookmarkAccessPointNo . Text = getTempElectricity . AccessPointNo ;
}
}
Bookmark bookmarkAccessPointAddress = doc . Range . Bookmarks [ "AccessPointAddress" ] ; //接入点位置
if ( bookmarkAccessPointAddress ! = null )
{
if ( getTempElectricity ! = null & & ! string . IsNullOrEmpty ( getTempElectricity . AccessPointAddress ) )
{
bookmarkAccessPointAddress . Text = getTempElectricity . AccessPointAddress ;
}
}
Bookmark bookmarkWorkingVoltage = doc . Range . Bookmarks [ "WorkingVoltage" ] ; //接入点位置
if ( bookmarkWorkingVoltage ! = null )
{
if ( getTempElectricity ! = null & & ! string . IsNullOrEmpty ( getTempElectricity . WorkingVoltage ) )
{
bookmarkWorkingVoltage . Text = getTempElectricity . WorkingVoltage ;
}
}
Bookmark bookmarkElectrician = doc . Range . Bookmarks [ "Electrician" ] ; // 电气专业人员 姓名及手机号
2023-06-10 12:00:41 +08:00
if ( bookmarkElectrician ! = null )
{
if ( getTempElectricity ! = null )
{
2024-02-27 18:13:26 +08:00
bookmarkElectrician . Text = getTempElectricity . Electrician + "\n" + getTempElectricity . ElectricianPhone ;
2023-06-10 12:00:41 +08:00
}
}
2024-02-27 18:13:26 +08:00
2023-06-10 12:00:41 +08:00
Bookmark bookmarkWatchManName = doc . Range . Bookmarks [ "WatchManName" ] ; //监火人员
if ( bookmarkWatchManName ! = null )
{
if ( getTempElectricity ! = null )
{
var getUser = UserService . GetUserByUserId ( getTempElectricity . WatchManId ) ;
if ( getUser ! = null )
{
bookmarkWatchManName . Text = getUser . UserName ;
}
else
{
bookmarkWatchManName . Text = getTempElectricity . WatchManName ;
}
}
}
Bookmark bookmarkValidityDate = doc . Range . Bookmarks [ "ValidityDate" ] ; //有效期限
if ( bookmarkValidityDate ! = null )
{
if ( getTempElectricity ! = null )
{
if ( getTempElectricity . ValidityStartTime . HasValue )
{
2024-02-27 18:13:26 +08:00
bookmarkValidityDate . Text = getTempElectricity . ValidityStartTime . Value . Year + "年" + getTempElectricity . ValidityStartTime . Value . Month + "月" + getTempElectricity . ValidityStartTime . Value . Day + "日" + getTempElectricity . ValidityStartTime . Value . Hour + "时" + getTempElectricity . ValidityStartTime . Value . Minute + "分至" ;
2023-06-10 12:00:41 +08:00
if ( getTempElectricity . ValidityEndTime . HasValue )
{
2024-02-27 18:13:26 +08:00
bookmarkValidityDate . Text + = getTempElectricity . ValidityEndTime . Value . Year + "年" + getTempElectricity . ValidityEndTime . Value . Month + "月" + getTempElectricity . ValidityEndTime . Value . Day + "日" + getTempElectricity . ValidityEndTime . Value . Hour + "时" + getTempElectricity . ValidityEndTime . Value . Minute + "分" ;
2023-06-10 12:00:41 +08:00
}
}
}
}
2024-02-27 18:13:26 +08:00
Bookmark bookmarkOtherAttach = doc . Range . Bookmarks [ "OtherAttach" ] ; //
if ( bookmarkOtherAttach ! = null & & ! string . IsNullOrEmpty ( getTempElectricity . OtherAttach ) )
{
bookmarkOtherAttach . Text = getTempElectricity . OtherAttach ;
}
Bookmark bookmarkTools = doc . Range . Bookmarks [ "Tools" ] ; //
2023-06-10 12:00:41 +08:00
if ( bookmarkTools ! = null )
{
if ( getTempElectricity ! = null & & ! string . IsNullOrEmpty ( getTempElectricity . Tools ) )
{
bookmarkTools . Text = getTempElectricity . Tools ;
}
}
Bookmark bookmarkWorkMeasures = doc . Range . Bookmarks [ "WorkMeasures" ] ; //作业内容
if ( bookmarkWorkMeasures ! = null )
{
2024-02-27 18:13:26 +08:00
if ( getTempElectricity ! = null & & ! string . IsNullOrEmpty ( getTempElectricity . WorkMeasures ) )
2023-06-10 12:00:41 +08:00
{
bookmarkWorkMeasures . Text = getTempElectricity . WorkMeasures ;
}
}
2024-02-27 18:13:26 +08:00
Bookmark bookmarkEquipmentLoadDes = doc . Range . Bookmarks [ "EquipmentLoadDes" ] ; //作业内容
if ( bookmarkEquipmentLoadDes ! = null )
2023-06-10 12:00:41 +08:00
{
2024-02-27 18:13:26 +08:00
if ( getTempElectricity ! = null & & ! string . IsNullOrEmpty ( getTempElectricity . EquipmentLoadDes ) )
2023-06-10 12:00:41 +08:00
{
2024-02-27 18:13:26 +08:00
bookmarkEquipmentLoadDes . Text = getTempElectricity . EquipmentLoadDes ;
2023-06-10 12:00:41 +08:00
}
2024-02-27 18:13:26 +08:00
}
Bookmark bookmarkHasSpecial1 = doc . Range . Bookmarks [ "HasSpecial1" ] ; //
Bookmark bookmarkHasSpecial2 = doc . Range . Bookmarks [ "HasSpecial2" ] ; //
if ( ! string . IsNullOrEmpty ( getTempElectricity . HasSpecialProgramme ) )
{
if ( getTempElectricity . HasSpecialProgramme = = "是" )
2023-06-10 12:00:41 +08:00
{
2024-02-27 18:13:26 +08:00
bookmarkHasSpecial1 . Text = "■" ;
bookmarkHasSpecial2 . Text = "□" ;
2023-06-10 12:00:41 +08:00
}
2024-02-27 18:13:26 +08:00
else
2023-06-10 12:00:41 +08:00
{
2024-02-27 18:13:26 +08:00
bookmarkHasSpecial1 . Text = "□" ;
bookmarkHasSpecial2 . Text = "■" ;
2023-06-10 12:00:41 +08:00
}
2024-02-27 18:13:26 +08:00
}
else
{
bookmarkHasSpecial2 . Text = "□" ;
bookmarkHasSpecial1 . Text = "□" ;
}
Bookmark bookmarkEquipmentLoadList1 = doc . Range . Bookmarks [ "EquipmentLoadList1" ] ; //
Bookmark bookmarkEquipmentLoadList2 = doc . Range . Bookmarks [ "EquipmentLoadList2" ] ; //
if ( ! string . IsNullOrEmpty ( getTempElectricity . EquipmentLoadList ) )
{
if ( getTempElectricity . EquipmentLoadList = = "是" )
2023-06-10 12:00:41 +08:00
{
2024-02-27 18:13:26 +08:00
bookmarkEquipmentLoadList1 . Text = "■" ;
bookmarkEquipmentLoadList2 . Text = "□" ;
2023-06-10 12:00:41 +08:00
}
2024-02-27 18:13:26 +08:00
else
2023-06-10 12:00:41 +08:00
{
2024-02-27 18:13:26 +08:00
bookmarkEquipmentLoadList1 . Text = "□" ;
bookmarkEquipmentLoadList2 . Text = "■" ;
2023-06-10 12:00:41 +08:00
}
2024-02-27 18:13:26 +08:00
}
else
{
bookmarkEquipmentLoadList1 . Text = "□" ;
bookmarkEquipmentLoadList2 . Text = "□" ;
}
2023-06-10 12:00:41 +08:00
2024-02-27 18:13:26 +08:00
var GetLicenseItemList = LicensePublicService . GetLicenseItemListByDataId ( Id ) ;
if ( GetLicenseItemList . Count > 0 )
{
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 1 , "LicenseItemList1" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 2 , "LicenseItemList2" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 3 , "LicenseItemList3" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 4 , "LicenseItemList4" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 5 , "LicenseItemList5" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 6 , "LicenseItemList6" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 7 , "LicenseItemList7" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 8 , "LicenseItemList8" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 9 , "LicenseItemList9" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 10 , "LicenseItemList10" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 11 , "LicenseItemList11" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 12 , "LicenseItemList12" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 13 , "LicenseItemList13" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 14 , "LicenseItemList14" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 15 , "LicenseItemList15" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 16 , "LicenseItemList16" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 17 , "LicenseItemList17" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 18 , "LicenseItemList18" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 19 , "LicenseItemList19" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 20 , "LicenseItemList20" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 21 , "LicenseItemList21" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 22 , "LicenseItemList22" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 23 , "LicenseItemList23" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 24 , "LicenseItemList24" ) ;
bookmarLicense_LicenseItem ( doc , GetLicenseItemList , 25 , "LicenseItemList25" ) ;
2023-06-10 12:00:41 +08:00
}
//审核记录
var getFlows = LicensePublicService . GetFlowOperateListByDataId ( Id ) ;
if ( getFlows . Count ( ) > 0 )
{
var getF1 = getFlows . FirstOrDefault ( x = > x . SortIndex = = 1 ) ;
if ( getF1 ! = null )
{
Bookmark bookmarkOpinion1 = doc . Range . Bookmarks [ "Opinion1" ] ;
if ( bookmarkOpinion1 ! = null )
{
if ( getF1 . IsAgree = = true )
{
if ( string . IsNullOrEmpty ( getF1 . Opinion ) )
{
bookmarkOpinion1 . Text = "同意。" ;
}
else
{
bookmarkOpinion1 . Text = getF1 . Opinion ;
}
}
else
{
bookmarkOpinion1 . Text = "不同意: " + getF1 . Opinion ;
}
}
if ( ! string . IsNullOrEmpty ( getF1 . SignatureUrl ) & & File . Exists ( rootPath + getF1 . SignatureUrl ) )
{
DocumentBuilder builders = new DocumentBuilder ( doc ) ;
var file = rootPath + getF1 . SignatureUrl ;
builders . MoveToBookmark ( "OperaterMan1" ) ;
builders . InsertImage ( file , 80 , 20 ) ;
}
else
{
var getUser = UserService . GetUserByUserId ( getF1 . OperaterId ) ;
if ( getUser ! = null )
{
Bookmark bookmarkOperaterMan1 = doc . Range . Bookmarks [ "OperaterMan1" ] ;
if ( bookmarkOperaterMan1 ! = null & & getF1 . OperaterTime . HasValue )
{
bookmarkOperaterMan1 . Text = getUser . UserName ;
}
}
}
Bookmark bookmarkOperaterTime1 = doc . Range . Bookmarks [ "OperaterTime1" ] ;
if ( bookmarkOperaterTime1 ! = null )
{
if ( getF1 . OperaterTime . HasValue )
{
bookmarkOperaterTime1 . Text = string . Format ( "{0:yyyy年MM月dd日 HH:mm}" , getF1 . OperaterTime ) ;
}
}
}
var getF2 = getFlows . FirstOrDefault ( x = > x . SortIndex = = 2 ) ;
if ( getF2 ! = null )
{
Bookmark bookmarkOpinion2 = doc . Range . Bookmarks [ "Opinion2" ] ;
if ( bookmarkOpinion2 ! = null )
{
if ( getF2 . IsAgree = = true )
{
if ( string . IsNullOrEmpty ( getF2 . Opinion ) )
{
bookmarkOpinion2 . Text = "同意。" ;
}
else
{
bookmarkOpinion2 . Text = getF2 . Opinion ;
}
}
else
{
bookmarkOpinion2 . Text = "不同意: " + getF2 . Opinion ;
}
}
if ( ! string . IsNullOrEmpty ( getF2 . SignatureUrl ) & & File . Exists ( rootPath + getF2 . SignatureUrl ) )
{
DocumentBuilder builders = new DocumentBuilder ( doc ) ;
var file = rootPath + getF2 . SignatureUrl ;
builders . MoveToBookmark ( "OperaterMan2" ) ;
builders . InsertImage ( file , 80 , 20 ) ;
}
else
{
var getUser = UserService . GetUserByUserId ( getF2 . OperaterId ) ;
if ( getUser ! = null )
{
Bookmark bookmarkOperaterMan2 = doc . Range . Bookmarks [ "OperaterMan2" ] ;
if ( bookmarkOperaterMan2 ! = null & & getF2 . OperaterTime . HasValue )
{
bookmarkOperaterMan2 . Text = getUser . UserName ;
}
}
}
Bookmark bookmarkOperaterTime2 = doc . Range . Bookmarks [ "OperaterTime2" ] ;
if ( bookmarkOperaterTime2 ! = null )
{
if ( getF2 . OperaterTime . HasValue )
{
bookmarkOperaterTime2 . Text = string . Format ( "{0:yyyy年MM月dd日 HH:mm}" , getF2 . OperaterTime ) ;
}
}
}
var getF3 = getFlows . FirstOrDefault ( x = > x . SortIndex = = 3 ) ;
if ( getF3 ! = null )
{
Bookmark bookmarkOpinion3 = doc . Range . Bookmarks [ "Opinion3" ] ;
if ( bookmarkOpinion3 ! = null )
{
if ( getF3 . IsAgree = = true )
{
if ( string . IsNullOrEmpty ( getF3 . Opinion ) )
{
bookmarkOpinion3 . Text = "同意。" ;
}
else
{
bookmarkOpinion3 . Text = getF1 . Opinion ;
}
}
else
{
bookmarkOpinion3 . Text = "不同意: " + getF3 . Opinion ;
}
}
if ( ! string . IsNullOrEmpty ( getF3 . SignatureUrl ) & & File . Exists ( rootPath + getF3 . SignatureUrl ) )
{
DocumentBuilder builders = new DocumentBuilder ( doc ) ;
var file = rootPath + getF3 . SignatureUrl ;
builders . MoveToBookmark ( "OperaterMan3" ) ;
builders . InsertImage ( file , 80 , 20 ) ;
}
else
{
var getUser = UserService . GetUserByUserId ( getF3 . OperaterId ) ;
if ( getUser ! = null )
{
Bookmark bookmarkOperaterMan3 = doc . Range . Bookmarks [ "OperaterMan3" ] ;
if ( bookmarkOperaterMan3 ! = null & & getF3 . OperaterTime . HasValue )
{
bookmarkOperaterMan3 . Text = getUser . UserName ;
}
}
}
Bookmark bookmarkOperaterTime3 = doc . Range . Bookmarks [ "OperaterTime3" ] ;
if ( bookmarkOperaterTime3 ! = null )
{
if ( getF3 . OperaterTime . HasValue )
{
bookmarkOperaterTime3 . Text = string . Format ( "{0:yyyy年MM月dd日 HH:mm}" , getF3 . OperaterTime ) ;
}
}
}
}
Bookmark bookmarkCance = doc . Range . Bookmarks [ "Cancel" ] ; //取消
if ( bookmarkCance ! = null )
{
if ( getTempElectricity ! = null )
{
if ( ! string . IsNullOrEmpty ( getTempElectricity . CancelManId ) )
{
var getUser = UserService . GetUserByUserId ( getTempElectricity . CancelManId ) ;
if ( getUser ! = null )
{
if ( ! string . IsNullOrEmpty ( getUser . SignatureUrl ) & & File . Exists ( rootPath + getUser . SignatureUrl ) )
{
var file = rootPath + getUser . SignatureUrl ;
DocumentBuilder builders = new DocumentBuilder ( doc ) ;
builders . MoveToBookmark ( "Cancel" ) ;
// builders.InsertImage(file, 80, 20);
builders . Write ( "取消原因:" + getTempElectricity . CancelReasons + " 取消时间:" + string . Format ( "{0:yyyy-MM-dd HH:mm}" , getTempElectricity . CancelTime ) ) ;
}
else
{
bookmarkCance . Text = getUser . UserName + " 取消原因:" + getTempElectricity . CancelReasons + " 取消时间:" + string . Format ( "{0:yyyy-MM-dd HH:mm}" , getTempElectricity . CancelTime ) ;
}
}
}
}
}
Bookmark bookmarkClose = doc . Range . Bookmarks [ "Close" ] ; //关闭
if ( bookmarkClose ! = null )
{
if ( getTempElectricity ! = null )
{
if ( ! string . IsNullOrEmpty ( getTempElectricity . CloseManId ) )
{
var getUser = UserService . GetUserByUserId ( getTempElectricity . CloseManId ) ;
if ( getUser ! = null )
{
if ( ! string . IsNullOrEmpty ( getTempElectricity . CloseReasons ) )
{
bookmarkClose . Text = getTempElectricity . CloseReasons + " 关闭时间:"
+ string . Format ( "{0:yyyy-MM-dd HH:mm}" , getTempElectricity . CloseTime ) + "。" ;
}
else if ( ! string . IsNullOrEmpty ( getUser . SignatureUrl ) & & File . Exists ( rootPath + getUser . SignatureUrl ) )
{
var file = rootPath + getUser . SignatureUrl ;
DocumentBuilder builders = new DocumentBuilder ( doc ) ;
builders . MoveToBookmark ( "Close" ) ;
// builders.InsertImage(file, 80, 20);
builders . Write ( "关闭时间:" + string . Format ( "{0:yyyy-MM-dd HH:mm}" , getTempElectricity . CloseTime ) ) ;
}
else
{
bookmarkClose . Text = getUser . UserName + " 关闭时间:" + string . Format ( "{0:yyyy-MM-dd HH:mm}" , getTempElectricity . CloseTime ) ;
}
}
}
}
}
doc . Save ( newUrl ) ;
//生成PDF文件
string pdfUrl = newUrl . Replace ( ".doc" , ".pdf" ) ;
Document doc1 = new Aspose . Words . Document ( newUrl ) ;
//验证参数
if ( doc1 = = null ) { throw new Exception ( "Word文件无效" ) ; }
doc1 . Save ( pdfUrl , Aspose . Words . SaveFormat . Pdf ) ; //还可以改成其它格式
string fileName = Path . GetFileName ( filePath ) ;
FileInfo info = new FileInfo ( pdfUrl ) ;
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 ( pdfUrl , 0 , fileSize ) ;
Response . Flush ( ) ;
Response . Close ( ) ;
File . Delete ( newUrl ) ;
File . Delete ( pdfUrl ) ;
}
2024-02-27 18:13:26 +08:00
private void bookmarLicense_LicenseItem ( Document doc , List < Model . License_LicenseItem > list , int index , string LicenseItem )
{
var item1 = list . FirstOrDefault ( x = > x . SortIndex = = index ) ;
if ( item1 ! = null )
{
Bookmark bookmarkUser1 = doc . Range . Bookmarks [ LicenseItem ] ; //确认执行
if ( item1 . IsUsed = = true )
{
if ( bookmarkUser1 ! = null )
{
bookmarkUser1 . Text = "■" + item1 . SafetyMeasures ;
}
}
else
{
if ( bookmarkUser1 ! = null )
{
bookmarkUser1 . Text = "□" + item1 . SafetyMeasures ;
}
}
}
}
2023-06-10 12:00:41 +08:00
#endregion
}
}