namespace BLL { using System.Collections.Generic; using System.Linq; using System.Text; /// /// 人员上岗证打印服务。 /// public static class PrinterDocService { /// /// 输出人员上岗证打印内容。 /// public static void PrinterDocMethod(string menuId, string id, string name) { System.Web.HttpContext.Current.Response.ClearContent(); string htmlStr = menuId == Const.SendCardMenuId ? GetSendCardHtml(id) : string.Empty; if (!string.IsNullOrEmpty(htmlStr)) { string filename = name + Funs.GetNewFileName(); System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(filename, Encoding.UTF8) + ".doc"); System.Web.HttpContext.Current.Response.ContentType = "application/word"; System.Web.HttpContext.Current.Response.ContentEncoding = Encoding.UTF8; System.Web.HttpContext.Current.Response.Write(htmlStr); System.Web.HttpContext.Current.Response.End(); } } /// /// 生成人员上岗证打印表格。 /// public static string GetSendCardHtml(string personIds) { Model.SGGLDB db = Funs.DB; StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append(""); List personIdList = Funs.GetStrListByStr(personIds, ','); foreach (string personId in personIdList) { Model.SitePerson_Person sitePerson = SitePerson_PersonService.GetSitePersonById(personId); if (sitePerson == null) { continue; } Model.Person_Persons person = Person_PersonsService.GetPerson_PersonsByIdCard(sitePerson.IdentityCard); if (person == null) { continue; } string qrUrl = person.QRCodeAttachUrl; if (string.IsNullOrEmpty(qrUrl) || !CreateQRCodeService.isHaveImage(qrUrl)) { qrUrl = CreateQRCodeService.CreateCode_Simple(sitePerson.IdentityCard); person.QRCodeAttachUrl = qrUrl; db.SubmitChanges(); } sb.Append(""); sb.Append(""); sb.Append(""); sb.AppendFormat("", (Funs.SGGLUrl + qrUrl).Replace('\\', '/')); sb.Append(""); } sb.Append("
"); sb.AppendFormat("", (Funs.SGGLUrl + person.PhotoUrl).Replace('\\', '/')); sb.Append(""); sb.AppendFormat("公司:{0}
", "赛鼎工程有限公司"); sb.AppendFormat("项目:{0}
", ProjectService.GetShortNameByProjectId(sitePerson.ProjectId)); sb.AppendFormat("单位:{0}
", UnitService.GetUnitNameByUnitId(sitePerson.UnitId)); sb.AppendFormat("岗位:{0}
", WorkPostService.getWorkPostNameById(sitePerson.WorkPostId)); sb.AppendFormat("姓名:{0}
编号:{1}", sitePerson.PersonName, sitePerson.CardNo); sb.Append("
"); return sb.ToString(); } } }