1、html部分:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="rs_FilePrint.aspx.cs" Inherits="Web.rs_Manage.rs_PrintDownload.rs_FilePrint" %> <!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10" /> <title></title> <link href="../../css/base.css" type="text/css" rel="stylesheet"> <link href="../../css/upload.css" type="text/css" rel="stylesheet"> <link href="../../css/lvse/Outer_color.css" type="text/css" rel="stylesheet"> <link href="../../css/mend.css" type="text/css" rel="stylesheet"> <link href="../../css/color.css" type="text/css" rel="stylesheet"> <script type="text/javascript" src="../../js/jquery-1.8.3.min.js"></script> <script type="text/javascript" src="../../js/UploadBar2.js"></script> </head> <body> <div id="maskUpload"></div> <div class="uploadContent clear"> <%-- <div class="clear" id="sidebar-collapse"> <div class="Statistics" style="height: 34px; position: relative; right: 76px;"> <div style="position: absolute; right: 0; top: 0;" class="minWidth"> <span class="stnumber" id="spanRoleName">00120125-李丽-投资公司会计</span> <span></span> </div> </div> </div>--%> <input id="idDel" type="button" title="关闭" /> <div class="sidebar ml5" id="sidebar" style="border: 1px solid #ccc;"> <div class="bd" id="scroll_bd"> <div class="top" id="bd"> <ul class="nav nav-list" id="nav-list"> <li class="parent_li" mark="1"> <a href="javascript:void(0);" class="parent_a" title=""> <i class="icon-fifth"></i> <span class="menu-text">入职资料</span> <span class="icon-angle-down"></span> </a> <ul class="submenu"> <li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="22" filedes="入职资料->面试简历表"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>面试简历表 <span class="arrow2"></span> </a> </li> <li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="9" filedes="入职资料->入职登记表"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>入职登记表 <span class="arrow2"></span> </a> </li> <li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="30" filedes="入职资料->入职面谈表"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>入职面谈表 <span class="arrow2"></span> </a> </li> <li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="n" filetype="23" filedes="入职资料->岗位职责"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>岗位职责 <span class="arrow2"></span> </a> </li> <li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="10-max" filetype="13" filedes="入职资料->劳动合同"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>劳动合同 <span class="arrow2"></span> </a> </li> <li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="3" filetype="14" filedes="入职资料->保密协议"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>保密协议 <span class="arrow2"></span> </a> </li> <!-- -------------------------------------------------------------------------------------------------------------------- --> <li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="15" filedes="入职资料->员工背景调查表"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>员工背景调查表 <span class="arrow2"></span> </a> </li> <li class="last"> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="34" filedes="入职资料->放弃社保证明"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>放弃社保证明 <span class="arrow2"></span> </a> </li> </ul> <div class="line"></div> </li> <li class="parent_li" mark="2"> <a href="javascript:void(0);" class="parent_a" title=""> <i class="icon-fifth"></i> <span class="menu-text">转正资料</span> <span class="icon-angle-down"></span> </a> <ul class="submenu"> <li class="last"> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="2" filetype="24" filedes="转正资料->转正申请表"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>转正申请表 <span class="arrow2"></span> </a> </li> <li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="26" filedes="转正资料->转正面谈表"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>转正面谈表 <span class="arrow2"></span> </a> </li> <%--<li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="31" filedes="转正资料->延期通知单"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>延期通知单 <span class="arrow2"></span> </a> </li>--%> </ul> <div class="line"></div> </li> <li class="parent_li" mark="3"> <a href="javascript:void(0);" class="parent_a" title=""> <i class="icon-fifth"></i> <span class="menu-text">调职办理</span> <span class="icon-angle-down"></span> </a> <ul class="submenu"> <li class="last"> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="n" filetype="29" filedes="调职办理->调职申请表"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>调职申请表 <span class="arrow2"></span> </a> </li> <%--<li class="last"> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="n" filetype="36" filedes="调职办理->调职岗位职责"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>调职岗位职责 <span class="arrow2"></span> </a> </li>--%> </ul> <div class="line"></div> </li> <li class="parent_li" mark="4"> <a href="javascript:void(0);" class="parent_a" title=""> <i class="icon-fifth"></i> <span class="menu-text">调薪办理</span> <span class="icon-angle-down"></span> </a> <ul class="submenu"> <li class="last"> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="n" filetype="25" filedes="调薪办理->调薪申请表"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>调薪申请表 <span class="arrow2"></span> </a> </li> </ul> <div class="line"></div> </li> <li class="parent_li" mark="5"> <a href="javascript:void(0);" class="parent_a" title=""> <i class="icon-fifth"></i> <span class="menu-text">离职办理</span> <span class="icon-angle-down"></span> </a> <ul class="submenu"> <li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="27" filedes="离职办理->离职申请表"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>离职申请表 <span class="arrow2"></span> </a> </li> <li class="last"> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="20" filedes="离职办理->工作交接"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>工作交接 <span class="arrow2"></span> </a> </li> <li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="32" filedes="离职办理->离职面谈表"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>离职面谈表 <span class="arrow2"></span> </a> </li> <%--<li> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="38" filedes="离职办理->离职声明"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>离职声明 <span class="arrow2"></span> </a> </li> <li class="last"> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="1" filetype="33" filedes="离职办理->特殊离职资料"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>特殊离职资料 <span class="arrow2"></span> </a> </li>--%> </ul> <div class="line"></div> </li> <li class="parent_li" mark="6"> <a href="javascript:void(0);" class="parent_a" title=""> <i class="icon-fifth"></i> <span class="menu-text">合同续签</span> <span class="icon-angle-down"></span> </a> <ul class="submenu"> <li class="last"> <a href="javascript:void(0);" title="" data-msg=‘‘ filecount="n" filetype="37" filedes="合同续签->劳动合同续签"> <small class="icon-left"> <img src="../../img/icon1.jpg"></small>劳动合同续签 <span class="arrow2"></span> </a> </li> </ul> <div class="line"></div> </li> </ul> </div> <div class="scroll" id="scroll"> <p id="p"></p> </div> </div> </div> <div class="main-content2 clear" style="position: relative;"> <%-- <div class="printRemark" style="position: absolute; left: 0px; top: 60px;"> <p class="darkB">备注:打印页面根据实际打印预览设计</p> </div>--%> <div class="printImg" style="width: 945px;"> <object classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" width="945" height="99%"> <param name="SRC" value=""> <param name="movie" value="TestPZ.swf" /> <param name="quality" value="high" /> <param name="wmode" value="opaque"> <embed id="pdfUrl" width="945" height="99%" fullscreen="yes"></embed><%-- src="../../rs_Model/劳动合同-修.pdf"--%> </object> </div> </div> <input type="hidden" id="hidPicWebserviceRetValue" /> <input type="hidden" id="hidPdfUrl" /> <input type="hidden" id="hidFiletypeValue" /> </div> </body> <script src="../../js/rxued.js"></script> <script src="../../js/scrollimgplus.js"></script> <script src="~/js/index.js"></script> <script> window.onload = function() { //rxued.iframe.autoHeight2(‘ifmUpload‘,0); //alert($(window).height()); $(".printImg").css(‘height‘, $(window).height() + ‘px‘); $("#ifmUpload", parent.document).css(‘height‘, ‘100%‘); }; parent.$(window).resize(function() { $(".printImg").css(‘height‘, $(window).height() + ‘px‘); $("#ifmUpload", parent.document).css(‘height‘, ‘100%‘); }); $(function () { //点击左侧菜单导航事件 $("a[filetype]").click(function () { //资料类型 var filetp = $(this).attr("filetype"); //if (filetp == "23") { // alert("暂无此文档,等待升级..."); // return; //} $("#hidFiletypeValue").val(filetp); $("#spanFileDes").html($(this).attr("fileDes")); GetFilesByFileType(filetp); //更换资料的标准图 //$("#imgBiaoZhun").attr("src","../../img/FileBiaoZhun/File_" + filetp); }); //定位到资料的大项 $("li.parent_li").each(function () { if ($(this).attr(‘mark‘) == ‘<%=FileCate%>‘) { $(this).addClass(‘active‘); } else { $(this).removeClass(‘active‘); } }); //$(window).resize(function() { // ReCtorPdfFiles(); //}); //定位到具体的资料细项且触发细项的click事件;注:trigger(‘click‘)的监听事件必须定义在trigger触发器之前 $(".submenu li").each(function () { if ($(this).find(‘a[filetype]‘).attr(‘filetype‘) == ‘<%=FileType%>‘) { $(this).addClass(‘active2‘); $(this).find(‘a[filetype]‘).trigger(‘click‘); } else { $(this).removeClass(‘active2‘); } }); $("#spanRoleName").html(‘<%=UserInfo%>‘); $("#idDel").click(function () { if (‘<%= IsClose%>‘ == "true") { window.close(); } else $("#uploadContent,#mask0", parent.document).hide(); }); }); </script> <script> //获取资料图片数据 function GetFilesByFileType(fileType) { var _url = ""; //面试试岗时打印 if (‘<%= Phone%>‘ != "-") { if (fileType == "22") { _url = "rs_FilePrintHandler.ashx?type=getFilesUrl&phone=" + ‘<%= Phone %>‘ + "&fileType=" + fileType; } else { alert("只能打印面试简历表"); return; } } else { _url = "rs_FilePrintHandler.ashx?type=getFilesUrl&u_KaHao=" + ‘<%= UKaHao %>‘ + "&fileType=" + fileType + "&CheckboxValues=" + ‘<%= CheckboxValues %>‘; } $(‘#maskUpload‘).show(); $.ajax({ type: "POST", url: _url, success: function (msg) { if (msg.split(‘|‘)[0] == "0") alert("转换失败,未找到相应的word文档"); var html = "<object classid=‘clsid:CA8A9780-280D-11CF-A24D-444553540000‘ width=‘945‘ height=‘99%‘>" + "<param name=‘SRC‘ value=‘" + msg + "‘>" + "<param name=‘movie‘ value=‘TestPZ.swf‘ />" + "<param name=‘quality‘ value=‘high‘ />" + "<param name=‘wmode‘ value=‘opaque‘>" + "<embed id=‘pdfUrl‘ width=‘945‘ height=‘99%‘ src=‘" + msg + "‘ fullscreen=‘yes‘></embed></object>"; $(".printImg").html(html); $("#hidPdfUrl").val(msg); $(‘#maskUpload‘).hide(); }, error: function (msg) { //alert(msg); $(‘#maskUpload‘).hide(); } }); } //窗口发生变化时,重新构造pdf文件并计算高度 //function ReCtorPdfFiles() { // var msg = $("#hidPdfUrl").val(); // var html = "<object classid=‘clsid:CA8A9780-280D-11CF-A24D-444553540000‘ width=‘945‘ height=‘90%‘>" + // "<param name=‘SRC‘ value=‘" + msg + "‘>" + // "<embed id=‘pdfUrl‘ width=‘945‘ height=‘90%‘ src=‘" + msg + "‘ fullscreen=‘yes‘></embed></object>"; // $(".printImg").html(html); //} </script> </html>
2、一般处理程序
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.UI; using Microsoft.Office.Interop.Word; using Print2Flash3; namespace Web.rs_Manage.rs_PrintDownload { /// <summary> /// rs_FilePrintHandler 的摘要说明 /// </summary> public class rs_FilePrintHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain;charset=utf-8"; context.Response.Charset = "utf-8"; context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); var strReturn = DataSource(context, context.Request.QueryString["type"]); context.Response.Write(strReturn); } private static string DataSource(HttpContext context, string type) { try { string retStr; switch (type) { case "getFilesUrl": retStr = GetFilesUrl(context); break; case "getFilesUrlProgress": retStr = GetFilesUrlProgress(context); break; default: retStr = string.Empty; break; } return retStr; } catch (Exception e) { return ""; } } private static string GetFilesUrl(HttpContext context) { try { var uKaHao = context.Request["u_KaHao"]; var fileType = context.Request["fileType"]; var url = string.Empty; var current = AppDomain.CurrentDomain.BaseDirectory; var fileName = ""; WCFRsglServiceClientHelper rs = new WCFRsglServiceClientHelper(); DataSet ds = Wps.Common.Util.CDataSet(rs.ExecuteSQLTwo(@" select u_xingming,u_shouji,u_xingbie,u_xueli,u_shigongzi,u_zhenggongzi,u_ruzhitime,u_zhuanzhengtime,u_diqu,u_bumen,u_zhiwu,u_qiritime,u_kahao,u_jibie,u_zhuangtai from rsgl_UserList where u_kahao=‘" + uKaHao + "‘", "dsUser")); BiaoZhun biaozhun = new BiaoZhun(); WordClass word = new WordClass(); switch (fileType) { case "25": case "29": { fileName = string.Format("员工调职、调薪审批表({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { string diqu = biaozhun.GetOne("select dq_name from rsgl_diqu where dq_id=" + ds.Tables[0].Rows[0]["u_diqu"].ToString()); string bumen = biaozhun.GetOne("select bm_name from rsgl_bumen where bm_id=" + ds.Tables[0].Rows[0]["u_bumen"].ToString()); string zhiwu = biaozhun.GetOne("select zw_name from rsgl_zhiwu where zw_id=" + ds.Tables[0].Rows[0]["u_zhiwu"].ToString()); var dic = new Dictionary<string, string> { {"name",ds.Tables[0].Rows[0]["u_xingming"].ToString()}, {"kahao",ds.Tables[0].Rows[0]["u_kahao"].ToString()}, //{"ruzhi",Convert.ToDateTime(ds.Tables[0].Rows[0]["u_ruzhitime"]).ToString("yyyy-MM-dd")}, {"olddq",diqu}, {"oldbm",bumen}, {"oldzw",zhiwu}, {"newgz2",Convert.ToDouble(ds.Tables[0].Rows[0]["u_zhenggongzi"]) > 0 ? ds.Tables[0].Rows[0]["u_zhenggongzi"].ToString() : ds.Tables[0].Rows[0]["u_shigongzi"].ToString()}, {"oldgz",Convert.ToDouble(ds.Tables[0].Rows[0]["u_zhenggongzi"]) > 0 ? ds.Tables[0].Rows[0]["u_zhenggongzi"].ToString() : ds.Tables[0].Rows[0]["u_shigongzi"].ToString()} }; url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\员工调职、调薪审批表.doc", current + "wordfile\\员工调职、调薪审批表" + Guid.NewGuid() + ".doc", url, dic); } break; } case "24": { fileName = string.Format("员工转正审批表({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { string diqu = biaozhun.GetOne("select dq_name from rsgl_diqu where dq_id=" + ds.Tables[0].Rows[0]["u_diqu"].ToString()); string bumen = biaozhun.GetOne("select bm_name from rsgl_bumen where bm_id=" + ds.Tables[0].Rows[0]["u_bumen"].ToString()); string zhiwu = biaozhun.GetOne("select zw_name from rsgl_zhiwu where zw_id=" + ds.Tables[0].Rows[0]["u_zhiwu"].ToString()); var dic = new Dictionary<string, string> { {"name",ds.Tables[0].Rows[0]["u_xingming"].ToString()}, //{"kahao",ds.Tables[0].Rows[0]["u_kahao"].ToString()}, {"lianxifangshi",ds.Tables[0].Rows[0]["u_shouji"].ToString()}, {"xingbie",ds.Tables[0].Rows[0]["u_xingbie"].ToString()}, {"xueli",ds.Tables[0].Rows[0]["u_xueli"].ToString()}, {"shiyongxinzi",ds.Tables[0].Rows[0]["u_shigongzi"].ToString()}, {"ruzhiriqi",Convert.ToDateTime(ds.Tables[0].Rows[0]["u_qiritime"]).ToString("yyyy-MM-dd")}, {"shigangriqi",Convert.ToDateTime(ds.Tables[0].Rows[0]["u_ruzhitime"]).ToString("yyyy-MM-dd")}, //{"diqu1",diqu}, {"diqu",diqu}, {"bumen",bumen}, {"zhiwu",zhiwu}, //{"sj","0"}, //{"bj","0"}, //{"zt","0"}, //{"kg","0"} }; url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\员工转正审批表.doc", current + "wordfile\\员工转正审批表" + Guid.NewGuid() + ".doc", url, dic); } break; } case "9": { fileName = string.Format("员工入职登记表({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); ds = Wps.Common.Util.CDataSet(rs.ExecuteSQLTwo(@"select u_xingming,u_xingbie,u_jiguan,u_mingzu,u_shouji,u_birthDay,u_hukouleixing,u_hunyin,u_diqu,u_bumen,u_zhiwu ,u_xueli,‘毕业时间‘,‘毕业院校‘,u_xianzhuzhi,u_xianyoubian,u_shenfenzhengdizhi,u_shenfenzheng,u_jjlianxiren,u_jjlxrguanxi,u_jjlxrdianhua,u_ruZhitime,u_shigongzi,u_youxiang, u_zhenggongzi from rsgl_userlist where u_kahao=‘" + uKaHao + "‘", "dsUser_201408151500")); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { string diqu = biaozhun.GetOne("select dq_name from rsgl_diqu where dq_id=" + ds.Tables[0].Rows[0]["u_diqu"].ToString()); string bumen = biaozhun.GetOne("select bm_name from rsgl_bumen where bm_id=" + ds.Tables[0].Rows[0]["u_bumen"].ToString()); string zhiwu = biaozhun.GetOne("select zw_name from rsgl_zhiwu where zw_id=" + ds.Tables[0].Rows[0]["u_zhiwu"].ToString()); var dic = new Dictionary<string, string>(); dic.Add("diqu", diqu); dic.Add("bumen", bumen); dic.Add("zhiwu", zhiwu); dic.Add("kahao", uKaHao); dic.Add("name", ds.Tables[0].Rows[0]["u_xingming"].ToString()); dic.Add("xingbie", ds.Tables[0].Rows[0]["u_xingbie"].ToString()); dic.Add("jiguan", ds.Tables[0].Rows[0]["u_jiguan"].ToString()); dic.Add("minzu", ds.Tables[0].Rows[0]["u_mingzu"].ToString()); dic.Add("lianxifangshi", ds.Tables[0].Rows[0]["u_shouji"].ToString()); //还没有完善基本信息,此信息为空 //dic.Add("chushengnianyue", Convert.ToDateTime(ds.Tables[0].Rows[0]["u_birthDay"]).ToString("yyyy-MM-dd")); dic.Add("hukouleixing", ds.Tables[0].Rows[0]["u_hukouleixing"].ToString()); dic.Add("hunfou", ds.Tables[0].Rows[0]["u_hunyin"].ToString()); dic.Add("xueli", ds.Tables[0].Rows[0]["u_xueli"].ToString()); dic.Add("xianzhuzhi", ds.Tables[0].Rows[0]["u_xianzhuzhi"].ToString()); dic.Add("shenfenzhengdizhi", ds.Tables[0].Rows[0]["u_shenfenzhengdizhi"].ToString()); dic.Add("shenfenzhenghao", ds.Tables[0].Rows[0]["u_shenfenzheng"].ToString()); dic.Add("dangdilianxiren", ds.Tables[0].Rows[0]["u_jjlianxiren"].ToString()); dic.Add("lianxirenguanxi", ds.Tables[0].Rows[0]["u_jjlxrguanxi"].ToString()); dic.Add("lianxirendianhuan", ds.Tables[0].Rows[0]["u_jjlxrdianhua"].ToString()); dic.Add("shigangriqi", Convert.ToDateTime(ds.Tables[0].Rows[0]["u_ruZhitime"]).ToString("yyyy-MM-dd")); dic.Add("shiyongxinzi", ds.Tables[0].Rows[0]["u_shigongzi"].ToString()); dic.Add("zhuanzhengxinzi", ds.Tables[0].Rows[0]["u_zhenggongzi"].ToString()); dic.Add("email", ds.Tables[0].Rows[0]["u_youxiang"].ToString()); url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\员工入职登记表.doc", current + "wordfile\\员工入职登记表" + Guid.NewGuid() + ".doc", url, dic); } break; } case "22": { fileName = string.Format("面试简历表修({0}).pdf", ""); var dic = new Dictionary<string, string>(); var phone = context.Request["phone"]; if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { phone = ds.Tables[0].Rows[0]["u_shouji"].ToString(); } #region 拾取面试信息 string sql = string.Format(@"select [id], msname,mssex,mszhiwei,msipone,msemail,msyytime,mssgtime,msDepart,msKahao,msResult,msPingYu,msScore,msRsUpLoadWord,msXinliScore ,dq_name ,ISNULL(b.bm_name,a.bm_name) bm_name from rsgl_MianShiUser left join rsgl_diqu on dq_id=rsgl_MianShiUser.tb_diqu left join rsgl_bumen a on a.bm_id=msDepart left join rsgl_buMen b on a.bm_liShu=b.bm_id and b.bm_jiBie=2 where [msipone]=‘{0}‘", phone); DataTable dt = WCFRsglServiceClientHelper.Instance.GetDataByExecuteSql(sql);//【Y】 if (dt != null && dt.Rows.Count > 0) { string dqName = Convert.ToString(dt.Rows[0]["dq_name"]); string msZhiwu = Convert.ToString(dt.Rows[0]["mszhiwei"]); string msBumen = Convert.ToString(dt.Rows[0]["bm_name"]); string msName = Convert.ToString(dt.Rows[0]["msname"]); string msPhone = Convert.ToString(dt.Rows[0]["msipone"]); string msTime = DateTime.Parse(dt.Rows[0]["msyytime"].ToString()).ToString("yyyy/MM/dd"); #region 简历填写信息 登记表 DataTable dtJL = null; WCFRsglServiceClientHelper rsWCF = new WCFRsglServiceClientHelper(); string strSQL = string.Format("select * from rsgl_Jianli where jl_shouji=‘{0}‘ and jl_jincheng=0", phone); DataSet ds1 = Wps.Common.Util.CDataSet(rsWCF.ExecuteSQLTwo(strSQL, "H_jianli_Look_002")); if (ds1 != null && ds1.Tables.Count > 0) { dtJL = ds1.Tables[0]; } if (dtJL != null && dtJL.Rows.Count > 0) { string[] testcontent = new string[74]; string[] testTableremarks = { "cell_5", "cell_6", "cell_7", "cell_8", "cell_9", "cell_10", "cell_11", "cell_12", "cell_13", "cell_14", "cell_15", "cell_16", "cell_17", "cell_18", "cell_19", "cell_20", "cell_21", "cell_74", "cell_23", "cell_24", "cell_25", "cell_26", "cell_27", "cell_28", "cell_29", "cell_30", "cell_31", "cell_32", "cell_33", "cell_34", "cell_35", "cell_36", "cell_37", "cell_38", "cell_39", "cell_40", "cell_41", "cell_42", "cell_43", "cell_44", "cell_45", "cell_46", "cell_47", "cell_48", "cell_49", "cell_50", "cell_51", "cell_52", "cell_53", "cell_54", "cell_55", "cell_56", "cell_57", "cell_58", "cell_59", "cell_60", "cell_61", "cell_62", "cell_63", "cell_64", "cell_65", "cell_66", "cell_67", "cell_68", "cell_69", "cell_1", "cell_2", "cell_3", "cell_4", "cell_70", "cell_71", "cell_72", "cell_73", "cell_75" }; string xingBie = string.Empty; DataRow row = dtJL.Rows[0]; fileName = string.Format("面试简历表(含面试考评表)({0}).pdf", row["jl_xingming"]); string jlID = Convert.ToString(row["jl_ID"]); //GUID xingBie = Convert.ToString(row["jl_xingbie"]).Equals("0") ? "男" : "女"; string hunyin = Convert.ToString(row["jl_hunyin"]).Equals("0") ? "已婚" : "否"; #region 基本信息 0 ~ 18 testcontent[0] = Convert.ToString(row["jl_xingming"]); testcontent[1] = xingBie; testcontent[2] = Convert.ToString(row["jl_birthDay"]); //3 testcontent[3] = Convert.ToString(row["jl_jiguan"]); testcontent[4] = hunyin; testcontent[5] = Convert.ToString(row["jl_shouji"]); //6 testcontent[6] = Convert.ToString(row["jl_qiwangGongzi"]); testcontent[7] = Convert.ToString(row["jl_xueli"]); testcontent[8] = Convert.ToString(row["jl_Email"]); //9 testcontent[9] = Convert.ToString(row["jl_workTime"]); testcontent[10] = Convert.ToString(row["jl_zhuanye"]); testcontent[11] = Convert.ToString(row["jl_IDCode"]); //12 testcontent[12] = Convert.ToString(row["jl_daogangTime"]); testcontent[13] = Convert.ToString(row["jl_jjlianxiren"]); testcontent[14] = Convert.ToString(row["jl_jjlxrdianhua"]); testcontent[15] = Convert.ToString(row["jl_IDAddr"]); testcontent[16] = Convert.ToString(row["jl_xianzhuzhi"]); testcontent[17] = Convert.ToString(row["jl_ziwopingjia"]); testcontent[18] = Convert.ToString(row["jl_jinengAihao"]); #endregion #region 家庭成员 19 ~ 26 strSQL = string.Format("select * from rsgl_JianliHome where jl_id=‘{0}‘", jlID); ds1 = Wps.Common.Util.CDataSet(rsWCF.ExecuteSQLTwo(strSQL, "H_jianli_Look_003")); DataTable dtHome = null; if (ds1 != null && ds1.Tables.Count > 0) { dtHome = ds1.Tables[0]; } if (dtHome != null && dtHome.Rows.Count > 0) { DataRow rowHome = dtHome.Rows[0]; testcontent[19] = Convert.ToString(rowHome["lxr_xingming"]); //姓名 testcontent[20] = Convert.ToString(rowHome["lxr_guanxi"]); //关系 testcontent[21] = Convert.ToString(rowHome["lxr_workMore"]); //工作单位及职务 testcontent[22] = Convert.ToString(rowHome["lxr_phone"]); //联系电话 if (dtHome.Rows.Count >= 2) { DataRow rowHome2 = dtHome.Rows[1]; testcontent[23] = Convert.ToString(rowHome2["lxr_xingming"]); //姓名2 testcontent[24] = Convert.ToString(rowHome2["lxr_guanxi"]); //关系2 testcontent[25] = Convert.ToString(rowHome2["lxr_workMore"]); //工作单位及职务2 testcontent[26] = Convert.ToString(rowHome2["lxr_phone"]); //联系电话2 } else { testcontent[23] = string.Empty; testcontent[24] = string.Empty; testcontent[25] = string.Empty; testcontent[26] = string.Empty; } } else { testcontent[19] = string.Empty; testcontent[20] = string.Empty; testcontent[21] = string.Empty; testcontent[22] = string.Empty; testcontent[23] = string.Empty; testcontent[24] = string.Empty; testcontent[25] = string.Empty; testcontent[26] = string.Empty; } #endregion #region 工作经历 27 ~ 42 strSQL = string.Format("select * from rsgl_JianliWork where jl_id=‘{0}‘", jlID); ds1 = Wps.Common.Util.CDataSet(rsWCF.ExecuteSQLTwo(strSQL, "H_jianli_Look_003")); DataTable dtWork = null; if (ds1 != null && ds1.Tables.Count > 0) { dtWork = ds1.Tables[0]; } if (dtWork != null && dtWork.Rows.Count > 0) { //第一份工作经历 DataRow rowWork = dtWork.Rows[0]; testcontent[27] = Convert.ToString(rowWork["work_gongzuoTime"]); //起止时间 testcontent[28] = Convert.ToString(rowWork["work_GSName"]); //公司名称 testcontent[29] = Convert.ToString(rowWork["work_guimo"]); //规模(人) testcontent[30] = Convert.ToString(rowWork["work_gangwei"]); //工作岗位 testcontent[31] = Convert.ToString(rowWork["work_xinzi"]); //薪资待遇 testcontent[32] = Convert.ToString(rowWork["work_zhengmingren"]); //证明人及电话 testcontent[33] = Convert.ToString(rowWork["work_lizhiYuanyin"]); //离职原因 #region //work_HavDiaocha 0是,1否 //checkRBTN = Convert.ToString(rowWork["work_HavDiaocha"]).Equals("0") ? true : false; #endregion testcontent[34] = Convert.ToString(rowWork["work_Neirong"]); //工作内容 -------------------------------------第一份工作经历end if (dtWork.Rows.Count >= 2) { //第二份工作经历 DataRow rowWork2 = dtWork.Rows[1]; testcontent[35] = Convert.ToString(rowWork2["work_gongzuoTime"]); //起止时间 testcontent[36] = Convert.ToString(rowWork2["work_GSName"]); //公司名称 testcontent[37] = Convert.ToString(rowWork2["work_guimo"]); //规模(人) testcontent[38] = Convert.ToString(rowWork2["work_gangwei"]); //工作岗位 testcontent[39] = Convert.ToString(rowWork2["work_xinzi"]); //薪资待遇 testcontent[40] = Convert.ToString(rowWork2["work_zhengmingren"]); //证明人及电话 testcontent[41] = Convert.ToString(rowWork2["work_lizhiYuanyin"]); //离职原因 #region //work_HavDiaocha 0是,1否 //checkRBTN = Convert.ToString(rowWork2["work_HavDiaocha"]).Equals("0") ? true : false; #endregion testcontent[42] = Convert.ToString(rowWork2["work_Neirong"]); //工作内容-------------------------------------第二份工作经历end } else { testcontent[35] = string.Empty; testcontent[36] = string.Empty; testcontent[37] = string.Empty; testcontent[38] = string.Empty; testcontent[39] = string.Empty; testcontent[40] = string.Empty; testcontent[41] = string.Empty; testcontent[42] = string.Empty; } } else { testcontent[27] = string.Empty; testcontent[28] = string.Empty; testcontent[29] = string.Empty; testcontent[30] = string.Empty; testcontent[31] = string.Empty; testcontent[32] = string.Empty; testcontent[33] = string.Empty; testcontent[34] = string.Empty; testcontent[35] = string.Empty; testcontent[36] = string.Empty; testcontent[37] = string.Empty; testcontent[38] = string.Empty; testcontent[39] = string.Empty; testcontent[40] = string.Empty; testcontent[41] = string.Empty; testcontent[42] = string.Empty; } #endregion #region 教育经历 & 培训记录 43 ~ 62 strSQL = string.Format("select * from rsgl_JianliSchool where jl_id=‘{0}‘", jlID); ds1 = Wps.Common.Util.CDataSet(rsWCF.ExecuteSQLTwo(strSQL, "H_jianli_Look_004")); DataTable dtSchool = null; if (ds1 != null && ds1.Tables.Count > 0) { dtSchool = ds1.Tables[0]; } if (dtSchool != null && dtSchool.Rows.Count > 0) { #region 教育经历 DataRow[] rowsJY = dtSchool.Select("school_Type=0"); if (rowsJY != null && rowsJY.Length > 0) { testcontent[43] = Convert.ToString(rowsJY[0]["school_stratTime"]); //起止时间 起 testcontent[44] = Convert.ToString(rowsJY[0]["school_endTime"]); //起止时间 止 testcontent[45] = Convert.ToString(rowsJY[0]["school_Name"]); //学校名称 testcontent[46] = Convert.ToString(rowsJY[0]["school_zhengshu"]); //所获证书 testcontent[47] = Convert.ToString(rowsJY[0]["school_zhengmingren"]); //证明人及电话 if (rowsJY.Length >= 2) { testcontent[48] = Convert.ToString(rowsJY[1]["school_stratTime"]); //起止时间2 起 testcontent[49] = Convert.ToString(rowsJY[1]["school_endTime"]); //起止时间2 止 testcontent[50] = Convert.ToString(rowsJY[1]["school_Name"]); //学校名称2 testcontent[51] = Convert.ToString(rowsJY[1]["school_zhengshu"]); //所获证书2 testcontent[52] = Convert.ToString(rowsJY[1]["school_zhengmingren"]); //证明人及电话2 } else { testcontent[48] = string.Empty; testcontent[49] = string.Empty; testcontent[50] = string.Empty; testcontent[51] = string.Empty; testcontent[52] = string.Empty; } } else { testcontent[43] = string.Empty; testcontent[44] = string.Empty; testcontent[45] = string.Empty; testcontent[46] = string.Empty; testcontent[47] = string.Empty; testcontent[48] = string.Empty; testcontent[49] = string.Empty; testcontent[50] = string.Empty; testcontent[51] = string.Empty; testcontent[52] = string.Empty; } #endregion #region 培训记录 DataRow[] rowsPX = dtSchool.Select("school_Type=1"); if (rowsPX != null && rowsPX.Length > 0) { testcontent[53] = Convert.ToString(rowsPX[0]["school_stratTime"]); //起止时间 起 testcontent[54] = Convert.ToString(rowsPX[0]["school_endTime"]); //起止时间 止 testcontent[55] = Convert.ToString(rowsPX[0]["school_Name"]); //学校名称 testcontent[56] = Convert.ToString(rowsPX[0]["school_zhengshu"]); //所获证书 testcontent[57] = Convert.ToString(rowsPX[0]["school_zhengmingren"]); //证明人及电话 if (rowsPX.Length >= 2) { testcontent[58] = Convert.ToString(rowsPX[1]["school_stratTime"]); //起止时间2 起 testcontent[59] = Convert.ToString(rowsPX[1]["school_endTime"]); //起止时间2 止 testcontent[60] = Convert.ToString(rowsPX[1]["school_Name"]); //学校名称2 testcontent[61] = Convert.ToString(rowsPX[1]["school_zhengshu"]); //所获证书2 testcontent[62] = Convert.ToString(rowsPX[1]["school_zhengmingren"]); //证明人及电话2 } else { testcontent[58] = string.Empty; testcontent[59] = string.Empty; testcontent[60] = string.Empty; testcontent[61] = string.Empty; testcontent[62] = string.Empty; } } else { testcontent[53] = string.Empty; testcontent[54] = string.Empty; testcontent[55] = string.Empty; testcontent[56] = string.Empty; testcontent[57] = string.Empty; testcontent[58] = string.Empty; testcontent[59] = string.Empty; testcontent[60] = string.Empty; testcontent[61] = string.Empty; testcontent[62] = string.Empty; } #endregion } else { testcontent[43] = string.Empty; testcontent[44] = string.Empty; testcontent[45] = string.Empty; testcontent[46] = string.Empty; testcontent[47] = string.Empty; testcontent[48] = string.Empty; testcontent[49] = string.Empty; testcontent[50] = string.Empty; testcontent[51] = string.Empty; testcontent[52] = string.Empty; testcontent[53] = string.Empty; testcontent[54] = string.Empty; testcontent[55] = string.Empty; testcontent[56] = string.Empty; testcontent[57] = string.Empty; testcontent[58] = string.Empty; testcontent[59] = string.Empty; testcontent[60] = string.Empty; testcontent[61] = string.Empty; testcontent[62] = string.Empty; } #endregion testcontent[63] = Convert.ToString(row["jl_ljgstj"]); //从何途径了解到公司 testcontent[64] = Convert.ToString(row["jl_diyiYinxiang"]); //您对公司的第一印象 testcontent[65] = dqName; testcontent[66] = msZhiwu; testcontent[67] = msBumen; testcontent[68] = msTime; testcontent[69] = msName; testcontent[70] = msZhiwu; testcontent[71] = msPhone; testcontent[72] = msTime; #region 获取心理测试,专业测试分数 17 & 73 testcontent[17] = H_xinliCS(dt.Rows[0]["msXinliScore"]); string msScore = Convert.ToString(dt.Rows[0]["msScore"]); testcontent[73] = string.IsNullOrEmpty(msScore) ? "未参加上机答题" : string.Format("{0}分", dt.Rows[0]["msScore"]); #endregion //将信息填充至键值对中 for (var i = 0; i < testTableremarks.Length; i++) { dic.Add(testTableremarks[i], testcontent[i]); } } #endregion } #endregion url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\面试简历表修.doc", current + "wordfile\\面试简历表修" + Guid.NewGuid() + ".doc", url, dic); break; } case "13": case "37": { fileName = string.Format("劳动合同({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { string bumen = biaozhun.GetOne("select bm_name from rsgl_bumen where bm_id=" + ds.Tables[0].Rows[0]["u_bumen"].ToString()); string zhiwu = biaozhun.GetOne("select zw_name from rsgl_zhiwu where zw_id=" + ds.Tables[0].Rows[0]["u_zhiwu"].ToString()); var dic = new Dictionary<string, string>(); dic.Add("myName", ds.Tables[0].Rows[0]["u_xingming"].ToString()); dic.Add("myDepartment", bumen); dic.Add("myPostName", zhiwu); url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\劳动合同-修.docx", current + "wordfile\\劳动合同-修" + Guid.NewGuid() + ".docx", url, dic); } break; } case "20": { fileName = string.Format("工作交接表({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { string juese = biaozhun.GetOne("select js_name from rsgl_juese where js_id =" + ds.Tables[0].Rows[0]["u_jibie"].ToString()); string bumen = biaozhun.GetOne("select bm_name from rsgl_bumen where bm_id=" + ds.Tables[0].Rows[0]["u_bumen"].ToString()); string diqu = biaozhun.GetOne("select dq_name from rsgl_diqu where dq_id=" + ds.Tables[0].Rows[0]["u_diqu"].ToString()); var dic = new Dictionary<string, string>(); dic.Add("xingming", ds.Tables[0].Rows[0]["u_xingming"].ToString()); dic.Add("diqu", diqu); dic.Add("bumen", bumen); dic.Add("juese", juese); dic.Add("kahao", uKaHao); url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\工作交接表.doc", current + "wordfile\\工作交接表" + Guid.NewGuid() + ".doc", url, dic); } break; } case "34": { //不需向word中插入数据 fileName = string.Format("放弃社保证明({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { word.CreateNewDocument(current + "rs_Model\\放弃社保证明.doc"); url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\放弃社保证明.doc", current + "wordfile\\放弃社保证明" + Guid.NewGuid() + ".doc", url, null); } break; } case "14": { fileName = string.Format("保守商业秘密协议({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { string bumen = biaozhun.GetOne("select bm_name from rsgl_bumen where bm_id=" + ds.Tables[0].Rows[0]["u_bumen"].ToString()); string zhiwu = biaozhun.GetOne("select zw_name from rsgl_zhiwu where zw_id=" + ds.Tables[0].Rows[0]["u_zhiwu"].ToString()); var dic = new Dictionary<string, string>(); dic.Add("myName", ds.Tables[0].Rows[0]["u_xingming"].ToString()); dic.Add("myDepartment", bumen); dic.Add("myPostName", zhiwu); url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\保守商业秘密协议.doc", current + "wordfile\\保守商业秘密协议" + Guid.NewGuid() + ".doc", url, dic); } break; } case "21": case "27": { fileName = string.Format("员工离职申请表(含解除劳动合同协议书及工作交接表)({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); string diqu = biaozhun.GetOne("select dq_name from rsgl_diqu where dq_id=" + ds.Tables[0].Rows[0]["u_diqu"].ToString()); string bumen = biaozhun.GetOne("select bm_name from rsgl_bumen where bm_id=" + ds.Tables[0].Rows[0]["u_bumen"].ToString()); string zhiwu = biaozhun.GetOne("select zw_name from rsgl_zhiwu where zw_id=" + ds.Tables[0].Rows[0]["u_zhiwu"].ToString()); var dic = new Dictionary<string, string>(); dic.Add("name", ds.Tables[0].Rows[0]["u_xingming"].ToString()); dic.Add("bumen", bumen); dic.Add("zhiwu", zhiwu); dic.Add("ruzhi", Convert.ToDateTime(ds.Tables[0].Rows[0]["u_ruzhitime"]).ToString("yyyy-MM-dd")); dic.Add("shouji", ds.Tables[0].Rows[0]["u_shouji"].ToString()); dic.Add("zhuangtai", ds.Tables[0].Rows[0]["u_zhuangtai"].ToString() == "3" ? "是" : "否"); dic.Add("kahao", ds.Tables[0].Rows[0]["u_kahao"].ToString()); dic.Add("rs_kahao", ds.Tables[0].Rows[0]["u_kahao"].ToString()); dic.Add("rs_diqu", diqu); dic.Add("rs_bumen", bumen); dic.Add("rs_zhiwu", zhiwu); dic.Add("rs_xingming", ds.Tables[0].Rows[0]["u_xingming"].ToString()); url = current + "wordfile\\" + fileName; if (Convert.ToString(ds.Tables[0].Rows[0]["u_jibie"]) == "54" || Convert.ToString(ds.Tables[0].Rows[0]["u_jibie"]) == "55") { word.WordCopyToWpf(current + "rs_Model\\员工离职申请表(含解除劳动合同协议书及工作交接表(财务)).doc", current + "wordfile\\员工离职申请表(含解除劳动合同协议书及工作交接表(财务))" + Guid.NewGuid() + ".doc", url, dic); } else { word.WordCopyToWpf(current + "rs_Model\\员工离职申请表(含解除劳动合同协议书及工作交接表(非财务)).doc", current + "wordfile\\员工离职申请表(含解除劳动合同协议书及工作交接表(非财务))" + Guid.NewGuid() + ".doc", url, dic); } break; } case "30": { fileName = string.Format("员工入职面谈记录表({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { string diqu = biaozhun.GetOne("select dq_name from rsgl_diqu where dq_id=" + ds.Tables[0].Rows[0]["u_diqu"].ToString()); string bumen = biaozhun.GetOne("select bm_name from rsgl_bumen where bm_id=" + ds.Tables[0].Rows[0]["u_bumen"].ToString()); string zhiwu = biaozhun.GetOne("select zw_name from rsgl_zhiwu where zw_id=" + ds.Tables[0].Rows[0]["u_zhiwu"].ToString()); var dic = new Dictionary<string, string>(); dic.Add("name", ds.Tables[0].Rows[0]["u_xingming"].ToString()); dic.Add("diqu", diqu); dic.Add("bumen", bumen); dic.Add("zhiwu", zhiwu); dic.Add("ruzhi", Convert.ToDateTime(ds.Tables[0].Rows[0]["u_ruzhitime"].ToString()).ToString("yyyy-MM-dd")); dic.Add("zhuanheng", Convert.ToDateTime(ds.Tables[0].Rows[0]["u_zhuanzhengtime"]).ToString("yyyy-MM-dd")); dic.Add("shigongzi", ds.Tables[0].Rows[0]["u_shigongzi"].ToString()); dic.Add("zhenggongzi", ds.Tables[0].Rows[0]["u_zhenggongzi"].ToString()); dic.Add("kahao", uKaHao); url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\员工入职面谈记录表.doc", current + "wordfile\\员工入职面谈记录表" + Guid.NewGuid() + ".doc", url, dic); } break; } case "26": { fileName = string.Format("员工转正面谈记录表({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { string diqu = biaozhun.GetOne("select dq_name from rsgl_diqu where dq_id=" + ds.Tables[0].Rows[0]["u_diqu"].ToString()); string bumen = biaozhun.GetOne("select bm_name from rsgl_bumen where bm_id=" + ds.Tables[0].Rows[0]["u_bumen"].ToString()); string zhiwu = biaozhun.GetOne("select zw_name from rsgl_zhiwu where zw_id=" + ds.Tables[0].Rows[0]["u_zhiwu"].ToString()); var dic = new Dictionary<string, string>(); dic.Add("name", ds.Tables[0].Rows[0]["u_xingming"].ToString()); dic.Add("diqu", diqu); dic.Add("bumen", bumen); dic.Add("zhiwu", zhiwu); dic.Add("ruzhi", Convert.ToDateTime(ds.Tables[0].Rows[0]["u_ruzhitime"].ToString()).ToString("yyyy-MM-dd")); dic.Add("zhuanheng", Convert.ToDateTime(ds.Tables[0].Rows[0]["u_zhuanzhengtime"]).ToString("yyyy-MM-dd")); //dic.Add("shigongzi", ds.Tables[0].Rows[0]["u_shigongzi"].ToString()); dic.Add("zhenggongzi", ds.Tables[0].Rows[0]["u_zhenggongzi"].ToString()); dic.Add("kahao", uKaHao); url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\员工转正面谈记录表.doc", current + "wordfile\\员工转正面谈记录表" + Guid.NewGuid() + ".doc", url, dic); } break; } case "32": { var checkboxValues = context.Request["CheckboxValues"]; fileName = string.Format("离职面谈记录表({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { //string diqu = biaozhun.GetOne("select dq_name from rsgl_diqu where dq_id=" + ds.Tables[0].Rows[0]["u_diqu"].ToString()); string bumen = biaozhun.GetOne("select bm_name from rsgl_bumen where bm_id=" + ds.Tables[0].Rows[0]["u_bumen"].ToString()); string zhiwu = biaozhun.GetOne("select zw_name from rsgl_zhiwu where zw_id=" + ds.Tables[0].Rows[0]["u_zhiwu"].ToString()); var dic = new Dictionary<string, string>(); dic.Add("S_EmployeeName", ds.Tables[0].Rows[0]["u_xingming"].ToString()); dic.Add("S_Department", bumen); dic.Add("S_Duty", zhiwu); dic.Add("S_CardNum", uKaHao); dic.Add("S_EntryDate", ds.Tables[0].Rows[0]["u_ruzhitime"].ToString().Split(‘T‘)[0]); if (checkboxValues.Trim() != "") { string[] check = checkboxValues.Split(‘,‘); for (int i = 0; i < check.Length; i++) { dic.Add("checkbox" + check[i], "?");//? } } url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\离职面谈记录表.doc", current + "wordfile\\离职面谈记录表" + Guid.NewGuid() + ".doc", url, dic); } break; } case "15": { //是否十大岗位 var i = new SpecialRole().GetJueSeByJibie(ds.Tables[0].Rows[0]["u_jibie"].ToString()); var checkboxValues = context.Request["CheckboxValues"]; fileName = string.Format("员工背景调查表({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { string bumen = biaozhun.GetOne("select bm_name from rsgl_bumen where bm_id=" + ds.Tables[0].Rows[0]["u_bumen"].ToString()); string zhiwu = biaozhun.GetOne("select zw_name from rsgl_zhiwu where zw_id=" + ds.Tables[0].Rows[0]["u_zhiwu"].ToString()); var dic = new Dictionary<string, string>(); dic.Add("name", ds.Tables[0].Rows[0]["u_xingming"].ToString()); dic.Add("sex", ds.Tables[0].Rows[0]["u_xingbie"].ToString()); dic.Add("bumen", bumen); dic.Add("zhiwu", zhiwu); dic.Add("ruzhi", Convert.ToDateTime(ds.Tables[0].Rows[0]["u_ruzhitime"].ToString()).ToString("yyyy-MM-dd")); dic.Add(i > 0 ? "zhongyao" : "yiban", "?"); var bj = WCFRsglServiceClientHelper.Instance.GetDataByExecuteSql(@" Select b_Checkjibie, b_id, b_Method, b_Reason, b_Time, bs_id, bs_Name, u_Kahao from rsgl_Background WHERE u_Kahao=" + uKaHao); if (bj != null && bj.Rows.Count > 0) { var shenfen = bj.Select("bs_id=2"); var xueli = bj.Select("bs_id=1"); var jingli = bj.Select("bs_id=3"); var lizhi = bj.Select("bs_id=4"); #region 身份信息 if (shenfen != null && shenfen.Length > 0) { if (shenfen[0]["b_Method"].ToString() == "1") { dic.Add("shenfenWay", "网站调查"); } else if (shenfen[0]["b_Method"].ToString() == "2") { dic.Add("shenfenWay", "电话调查"); } else if (shenfen[0]["b_Method"].ToString() == "3") { dic.Add("shenfenWay", "其他方式"); } dic.Add("shenfenRemarks", shenfen[0]["b_Reason"].ToString()); } #endregion #region 学历调查 if (xueli != null && xueli.Length > 0) { if (xueli[0]["b_Method"].ToString() == "1") { dic.Add("xueliWay", "网站调查"); } else if (xueli[0]["b_Method"].ToString() == "2") { dic.Add("xueliWay", "电话调查"); } else if (xueli[0]["b_Method"].ToString() == "3") { dic.Add("xueliWay", "其他方式"); } dic.Add("xueliRemarks", xueli[0]["b_Reason"].ToString()); } #endregion #region 工作经历 if (jingli != null && jingli.Length > 0) { if (jingli[0]["b_Method"].ToString() == "1") { dic.Add("jingliWay", "网站调查"); } else if (jingli[0]["b_Method"].ToString() == "2") { dic.Add("jingliWay", "电话调查"); } else if (jingli[0]["b_Method"].ToString() == "3") { dic.Add("jingliWay", "其他方式"); } dic.Add("jingliRemarks", jingli[0]["b_Reason"].ToString()); } #endregion #region 离职原因 if (lizhi != null && lizhi.Length > 0) { if (lizhi[0]["b_Method"].ToString() == "1") { dic.Add("lizhiWay", "网站调查"); } else if (lizhi[0]["b_Method"].ToString() == "2") { dic.Add("lizhiWay", "电话调查"); } else if (lizhi[0]["b_Method"].ToString() == "3") { dic.Add("lizhiWay", "其他方式"); } dic.Add("lizhiRemarks", lizhi[0]["b_Reason"].ToString()); } #endregion } if (checkboxValues.Trim() != "") { string[] check = checkboxValues.Split(‘,‘); for (int j = 0; j < check.Length; j++) { dic.Add(check[j], "?");//? } } url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\员工背景调查表.doc", current + "wordfile\\员工背景调查表" + Guid.NewGuid() + ".doc", url, dic); } break; } case "23": { //不需向word中插入数据 if (ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { string juese = biaozhun.GetOne("select js_name from rsgl_juese where js_id =" + ds.Tables[0].Rows[0]["u_jibie"].ToString()); //命名形如:55_出纳岗位职责 var jueSeWordName = ds.Tables[0].Rows[0]["u_jibie"] + "_" + juese + "岗位职责"; fileName = string.Format(jueSeWordName + "({0}).pdf", ds.Tables[0].Rows[0]["u_xingming"]); word.CreateNewDocument(current + "rs_Model\\岗位职责\\" + jueSeWordName + ".docx"); url = current + "wordfile\\" + fileName; word.WordCopyToWpf(current + "rs_Model\\岗位职责\\" + jueSeWordName + ".docx", current + "wordfile\\" + jueSeWordName + "" + Guid.NewGuid() + ".docx", url, null); } break; } } if (string.IsNullOrEmpty(fileName)) return ""; return "../../wordfile/" + fileName; } catch (Exception e) { return "0|" + e.Message; } } #region 获取心理测试分数 private static string H_xinliCS(object obj) { string result = string.Empty; double score = 0; if (double.TryParse(Convert.ToString(obj), out score)) { if (score <= 50) { result = "你很重视原则,多数时候都能够和别人合作,非常随和。可是你仍然有自己的底线,是所有人都无法逾越的。假使对方的要求超过你能接受的程度,又一点都没有讨论的弹性,那你可会受不了,以任何想得到的方法来抵制。或许双方兜个圈子来谈事情,就不会弄得那么僵。"; } else if (score <= 70) { result = "你有点讨厌麻烦的事,所以遇到一些突如其来的意外,会显得格外不耐烦,也有一点点担心不能处理得当。若是给你很有规律固定的工作,你通常都可以做得很好。 可是一碰上别人对你临危受命,你就开始慌张起来。所以一定要有人陪在身边,你才会有安全感,有信心把事情完成。"; } else if (score <= 115) { result = "遇到压力时,你会找其他管道来舒缓紧绷的情绪,让自己不会那么沉重。然后等到心情平静下来,慢慢思考解决方法,顺利渡过逆境。所以人家多半会误以为你一 直过得很平顺 ,无风无雨,却不知你已经面对过不少困境,运用经验闯过了每一次关卡。"; } else { result = "你是个外柔内刚的人,平日总是不会经常表达自己的意见。因为你知道应该要让事情发展到某种程度,你再发言,才不会被当作乱放炮。所以你的容忍度颇高,即使到不能忍耐的时候,你还是会让自己去适应环境。可是,你很可能日益习惯压力的逼迫,无形中延展你的耐力,逐渐麻痹,也不知道真正的界限在哪儿。"; } } else { result = "未回答心理测试题目。"; } return result; } #endregion private static string GetFilesUrlProgress(HttpContext context) { var u_kaHao = context.Request["u_KaHao"]; var u_jueSe = context.Request["u_JueSe"]; return ""; } public bool IsReusable { get { return false; } } } }
向word标签中插入值之前,word文档一定要先有相应名称的标签名;
3、word帮助类
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Text; using Microsoft.Office.Interop.Word; using Web.Code; using System.Management; using System.IO; public class WordClass { public WordClass() { killWinWordProcess(); } ~WordClass() { killWinWordProcess(); } private _Application wordApp = null; private _Document wordDoc = null; public _Application Application { get { return wordApp; } set { wordApp = value; } } public _Document Document { get { return wordDoc; } set { wordDoc = value; } } /// <summary> /// 通过模板创建新文档 /// </summary> /// <param name="filePath">模板文档</param> public void CreateNewDocument(string filePath) { wordApp = new ApplicationClass(); wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone; wordApp.Visible = false; try { object missing = System.Reflection.Missing.Value; object templateName = filePath; object temp = filePath; //建立一个基于摸版的文档 // doc = app.Documents.Add(ref temp, ref nothing, ref nothing, ref nothing); //第一种 Add wordDoc = wordApp.Documents.Add(ref temp, ref missing, ref missing, ref missing); //第二种 Open //wordDoc = wordApp.Documents.Open(ref templateName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, // ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); } catch (Exception e) { LogRecord.Write(null, "创建模板失败!" + filePath); //Add异常 关闭wordDoc,wordApp对象 object SaveChanges = WdSaveOptions.wdSaveChanges; object OriginalFormat = WdOriginalFormat.wdOriginalDocumentFormat; object RouteDocument = false; wordDoc.Close(ref SaveChanges, ref OriginalFormat, ref RouteDocument); wordApp.Quit(ref SaveChanges, ref OriginalFormat, ref RouteDocument); throw e; } } /// <summary> /// 保存新文件 /// </summary> /// <param name="filePath">保存路径</param> /// <param name="saveFormat">保存格式(Word: WdSaveFormat.wdFormatDocument; PDF: WdSaveFormat.wdFormatPDF; Other: ...)</param> public void SaveDocument(string filePath, WdSaveFormat saveFormat) { object fileName = WdSaveFormat.wdFormatPDF == saveFormat ? filePath.Substring(0, filePath.Length - 4) + ".pdf" : filePath; object format = saveFormat; object missing = System.Reflection.Missing.Value; try { wordDoc.SaveAs(ref fileName, ref format, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); LogRecord.Write(null, string.Format("\"{0}\" 文件已保存到服务器.", filePath)); } catch (Exception e) { LogRecord.Write(null, string.Format("\"{0}\" 文件已保存到服务器失败!", filePath)); throw e; } finally { //保存完毕 关闭wordDoc,wordApp对象 if (wordDoc != null) { if (WdSaveFormat.wdFormatPDF != saveFormat) wordDoc.Close(ref missing, ref missing, ref missing); wordDoc = null; } if (wordApp != null) { wordApp.Quit(ref missing, ref missing, ref missing); wordApp = null; } } } //保存新文件 public void SaveDocument(string filePath) { object fileName = filePath; object format = WdSaveFormat.wdFormatDocument;//保存格式 object miss = System.Reflection.Missing.Value; try { wordDoc.SaveAs(ref fileName, ref format, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss); LogRecord.Write(null, string.Format("\"{0}\" 文件已保存到服务器.", filePath)); } catch (Exception e) { LogRecord.Write(null, string.Format("\"{0}\" 文件已保存到服务器失败!", filePath)); throw e; } finally { //保存完毕 关闭wordDoc,wordApp对象 object SaveChanges = WdSaveOptions.wdSaveChanges; object OriginalFormat = WdOriginalFormat.wdOriginalDocumentFormat; object RouteDocument = false; wordDoc.Close(ref SaveChanges, ref OriginalFormat, ref RouteDocument); wordApp.Quit(ref SaveChanges, ref OriginalFormat, ref RouteDocument); } } //在书签处插入值 public bool InsertValue(string bookmark, string value) { object bkObj = bookmark; try { if (wordApp.ActiveDocument.Bookmarks.Exists(bookmark)) { //对应第一种 //wordApp.ActiveDocument.Bookmarks.get_Item(ref bkObj).Select(); //wordApp.Selection.TypeText(value); //对应第二种 wordApp.ActiveDocument.Bookmarks.get_Item(ref bkObj).Range.Text = value; return true; } } catch (Exception e) { LogRecord.Write(null, string.Format("\"{0}\" 标签插入失败!", bookmark)); //插入标签异常完毕 关闭wordDoc,wordApp对象 object SaveChanges = WdSaveOptions.wdSaveChanges; object OriginalFormat = WdOriginalFormat.wdOriginalDocumentFormat; object RouteDocument = false; wordDoc.Close(ref SaveChanges, ref OriginalFormat, ref RouteDocument); wordApp.Quit(ref SaveChanges, ref OriginalFormat, ref RouteDocument); throw e; } return false; } //插入表格,bookmark书签 public Table InsertTable(string bookmark, int rows, int columns, float width) { object miss = System.Reflection.Missing.Value; object oStart = bookmark; Range range = wordDoc.Bookmarks.get_Item(ref oStart).Range;//表格插入位置 Table newTable = wordDoc.Tables.Add(range, rows, columns, ref miss, ref miss); //设置表的格式 newTable.Borders.Enable = 1; //允许有边框,默认没有边框(为0时报错,1为实线边框,2、3为虚线边框,以后的数字没试过) newTable.Borders.OutsideLineWidth = WdLineWidth.wdLineWidth050pt;//边框宽度 if (width != 0) { newTable.PreferredWidth = width;//表格宽度 } newTable.AllowPageBreaks = false; return newTable; } //合并单元格 表名,开始行号,开始列号,结束行号,结束列号 public void MergeCell(Microsoft.Office.Interop.Word.Table table, int row1, int column1, int row2, int column2) { table.Cell(row1, column1).Merge(table.Cell(row2, column2)); } //设置表格内容对齐方式 Align水平方向,Vertical垂直方向(左对齐,居中对齐,右对齐分别对应Align和Vertical的值为-1,0,1) public void SetParagraph_Table(Microsoft.Office.Interop.Word.Table table, int Align, int Vertical) { switch (Align) { case -1: table.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft; break;//左对齐 case 0: table.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; break;//水平居中 case 1: table.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight; break;//右对齐 } switch (Vertical) { case -1: table.Range.Cells.VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalTop; break;//顶端对齐 case 0: table.Range.Cells.VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalCenter; break;//垂直居中 case 1: table.Range.Cells.VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalBottom; break;//底端对齐 } } //设置表格字体 public void SetFont_Table(Microsoft.Office.Interop.Word.Table table, string fontName, double size) { if (size != 0) { table.Range.Font.Size = Convert.ToSingle(size); } if (fontName != "") { table.Range.Font.Name = fontName; } } //是否使用边框,n表格的序号,use是或否 public void UseBorder(int n, bool use) { if (use) { wordDoc.Content.Tables[n].Borders.Enable = 1; //允许有边框,默认没有边框(为0时报错,1为实线边框,2、3为虚线边框,以后的数字没试过) } else { wordDoc.Content.Tables[n].Borders.Enable = 2; //允许有边框,默认没有边框(为0时报错,1为实线边框,2、3为虚线边框,以后的数字没试过) } } //给表格插入一行,n表格的序号从1开始记 public void AddRow(int n) { object miss = System.Reflection.Missing.Value; wordDoc.Content.Tables[n].Rows.Add(ref miss); } //给表格添加一行 public void AddRow(Microsoft.Office.Interop.Word.Table table) { object miss = System.Reflection.Missing.Value; table.Rows.Add(ref miss); } //给表格插入rows行,n为表格的序号 public void AddRow(int n, int rows) { object miss = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Table table = wordDoc.Content.Tables[n]; for (int i = 0; i < rows; i++) { table.Rows.Add(ref miss); } } //给表格中单元格插入元素,table所在表格,row行号,column列号,value插入的元素 public void InsertCell(Microsoft.Office.Interop.Word.Table table, int row, int column, string value) { table.Cell(row, column).Range.Text = value; } //给表格中单元格插入元素,n表格的序号从1开始记,row行号,column列号,value插入的元素 public void InsertCell(int n, int row, int column, string value) { wordDoc.Content.Tables[n].Cell(row, column).Range.Text = value; } //给表格插入一行数据,n为表格的序号,row行号,columns列数,values插入的值 public void InsertCell(int n, int row, int columns, string[] values) { Microsoft.Office.Interop.Word.Table table = wordDoc.Content.Tables[n]; for (int i = 0; i < columns; i++) { table.Cell(row, i + 1).Range.Text = values[i]; } } //插入图片 public void InsertPicture(string bookmark, string picturePath, float width, float hight) { object miss = System.Reflection.Missing.Value; object oStart = bookmark; Object linkToFile = false; //图片是否为外部链接 Object saveWithDocument = true; //图片是否随文档一起保存 object range = wordDoc.Bookmarks.get_Item(ref oStart).Range;//图片插入位置 wordDoc.InlineShapes.AddPicture(picturePath, ref linkToFile, ref saveWithDocument, ref range); wordDoc.Application.ActiveDocument.InlineShapes[1].Width = width; //设置图片宽度 wordDoc.Application.ActiveDocument.InlineShapes[1].Height = hight; //设置图片高度 } //插入一段文字,text为文字内容 public void InsertText(string bookmark, string text) { object oStart = bookmark; object range = wordDoc.Bookmarks.get_Item(ref oStart).Range; Paragraph wp = wordDoc.Content.Paragraphs.Add(ref range); wp.Format.SpaceBefore = 6; wp.Range.Text = text; wp.Format.SpaceAfter = 24; wp.Range.InsertParagraphAfter(); wordDoc.Paragraphs.Last.Range.Text = "\n"; } // 杀掉winword.exe进程 public void killWinWordProcess() { try { System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("WINWORD"); foreach (System.Diagnostics.Process process in processes) { if (process.HasExited) { continue; } //获取进程用户名 // LogRecord.Write(null, "进程用户名" + GetProcessUserName(process.Id)); if (process.MainWindowTitle == "") { DateTime startTime = process.StartTime; TimeSpan ts = DateTime.Now - startTime; //停止启动大于15秒的进程&&进程未终止 if (ts.Seconds > 15) { process.Kill(); } } } } catch (Exception e) { LogRecord.Write(e, "进程停止失败!"); throw e; } } private static string GetProcessUserName(int pID) { string text1 = null; SelectQuery query1 = new SelectQuery("Select * from Win32_Process WHERE processID=" + pID); ManagementObjectSearcher searcher1 = new ManagementObjectSearcher(query1); try { foreach (ManagementObject disk in searcher1.Get()) { ManagementBaseObject inPar = null; ManagementBaseObject outPar = null; inPar = disk.GetMethodParameters("GetOwner"); outPar = disk.InvokeMethod("GetOwner", inPar, null); text1 = outPar["User"].ToString(); break; } } catch { text1 = "SYSTEM"; } return text1; } public void WordCopyToWpf(string sourceFileName,string sourceCopyFileName,string destWpfFileName,Dictionary<string,string> dic) { //复制源文件的一个副本 File.Copy(sourceFileName, sourceCopyFileName, true); //将源文件副本进行插入标签值后生成Wpf WordToPdf(sourceCopyFileName, destWpfFileName, dic); //删除源文件的副本 if(System.IO.Directory.Exists(sourceCopyFileName)) File.Delete(sourceCopyFileName); } /// <summary> /// 把Word文件转换成pdf文件 /// </summary> /// <param name="sourcePath">需要转换的文件路径和文件名称</param> /// <param name="targetPath">转换完成后的文件的路径和文件名名称</param> /// <returns>成功返回true,失败返回false</returns> public bool WordToPdf(object sourcePath, string targetPath, Dictionary<string, string> dic) { bool result = false; WdExportFormat wdExportFormatPDF = WdExportFormat.wdExportFormatPDF; object missing = Type.Missing; ApplicationClass applicationClass = null; Document document = null; try { applicationClass = new ApplicationClass(); document = applicationClass.Documents.Open(ref sourcePath, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); if (document != null) { InsertWordMarks(applicationClass, dic); document.ExportAsFixedFormat(targetPath, wdExportFormatPDF, false, WdExportOptimizeFor.wdExportOptimizeForPrint, WdExportRange.wdExportAllDocument, 0, 0, WdExportItem.wdExportDocumentContent, true, true, WdExportCreateBookmarks.wdExportCreateWordBookmarks, true, true, false, ref missing); } result = true; } catch(Exception e) { LogRecord.Write(e,e.Message); result = false; } finally { if (document != null) { document.Close(ref missing, ref missing, ref missing); document = null; } if (applicationClass != null) { applicationClass.Quit(ref missing, ref missing, ref missing); applicationClass = null; } } return result; } public void InsertWordMarks(ApplicationClass appClass, Dictionary<string, string> dic) { if(dic != null) foreach (var aDic in dic) { object bkObj = aDic.Key; if (appClass.ActiveDocument.Bookmarks.Exists(bkObj.ToString())) appClass.ActiveDocument.Bookmarks.get_Item(ref bkObj).Range.Text = aDic.Value; } } }
4、需要注意的地方:本机安装office2007及以上版本;即可引用Microsoft.Office.Interop.Word dll文件;
5、代码部署至服务器上后,给服务器安装SaveAsPDFandXPS(office2007不支持Word转PDF时安装_服务器端);然后再进行DOM组件的设置(如下图);本地要运行的话也要安装SaveAsPDFandXPS(office2007不支持Word转PDF时安装_服务器端)
完毕;
时间: 2024-11-07 19:02:37