// // 评审 - 个人全部评审信息导出至pdf // GET:/Eval/ExportAll // public ActionResult ExportAll() { var user = ResSettings.SettingsInSession.User; var expertId = user.UserId; var models = GetExpertScoreViewModels(expertId); var indicaitons = db.IndicationDal.ConditionQuery(idi.ActiveId == ThisApp.CurrentActiveId, null, null, null); var htmlText = _pdfRender.RenderViewToString(this, "ExportAll", new ExportAllViewModel { ScoreModels = models, IndicationModels = indicaitons, GroupName = models.Count() <= 0 ? string.Empty : models.First().GroupName }); byte[] pdfFile = FormatConverter.ConvertHtmlTextToPDF(htmlText); return(new BinaryContentResult($"专家:{user.UserName} 的评审结果.pdf", "application/pdf", pdfFile)); }
// // 评审 - 评审导出至pdf // GET: /Eval/Export // public ActionResult Export(long id, long resId, long groupId, long?expertId) { var expert = expertId == null ? ResSettings.SettingsInSession.User : APBplDef.ResUserBpl.PrimaryGet(expertId.Value); if (expert == null) { throw new ArgumentException("expert can not be null"); } var i = APDBDef.Indication; var a = APDBDef.Active; var er = APDBDef.EvalResult; var u = APDBDef.ResUser; var ege = APDBDef.EvalGroupExpert; var egr = APDBDef.EvalGroupResource; var model = APBplDef.CroResourceBpl.GetResource(db, resId); var query = APQuery.select(i.IndicationId, i.Description, i.LevelPKID, i.Score, i.IndicationName, i.TypePKID, i.ActiveId, a.ActiveName, a.ActiveId, eri.ResultId, eri.Score.As("evalScore"), er.Comment, er.ExpertId) .from(i, a.JoinInner(a.ActiveId == i.ActiveId), eri.JoinLeft(eri.IndicationId == i.IndicationId & eri.ResultId == id), er.JoinLeft(er.ResultId == eri.ResultId & er.ResultId == id) ); string comment = string.Empty, expId = string.Empty; // indication list var list = query.query(db, r => { comment = er.Comment.GetValue(r); expId = er.ExpertId.GetValue(r).ToString(); var indication = new Indication(); indication.IndicationName = i.IndicationName.GetValue(r); indication.ActiveId = a.ActiveId.GetValue(r); indication.ActiveName = a.ActiveName.GetValue(r); indication.IndicationId = i.IndicationId.GetValue(r); indication.Description = i.Description.GetValue(r); indication.EvalScore = eri.Score.GetValue(r, "evalScore"); indication.Score = (int)eri.Score.GetValue(r); indication.LevelPKID = i.LevelPKID.GetValue(r); indication.TypePKID = i.TypePKID.GetValue(r); return(indication); }).ToList(); var subquery = APQuery.select(egr.GroupId).from(egr).where (egr.ResourceId == resId); var experts = APQuery.select(u.UserId, u.RealName) .from( u, ege.JoinLeft(ege.ExpertId == u.UserId) ) .where (ege.GroupId.In(subquery)) .group_by(u.UserId, u.RealName) .query(db, r => u.RealName.GetValue(r)) .ToArray(); // Expert html to pdf var htmlText = _pdfRender.RenderViewToString(this, "Export", new EvalExportViewModel { Experts = experts, Resource = model, Indications = list, EvalComment = comment }); byte[] pdfFile = FormatConverter.ConvertHtmlTextToPDF(htmlText); return(new BinaryContentResult($"【{model.Title}】评审结果.pdf", "application/pdf", pdfFile)); //return View(new EvalExportViewModel { Experts = experts, Resource = model, Indications = list, EvalComment = comment }); }