/// <summary> /// Generate header table score. /// </summary> /// <param name="workbook">The npoi workbook interface.</param> /// <param name="sheet1">The npoi sheet interface.</param> /// <param name="rowIndex">The row target index.</param> /// <param name="summary">The evaluation summary.</param> private void GenerateScoreHeader(IWorkbook workbook, ISheet sheet1, ref int rowIndex, SummaryEvaluationViewModel summary) { this.GenerateSubHeaderTable(workbook, sheet1, ref rowIndex); IRow subContentRow = sheet1.CreateRow(rowIndex); int cellSubContentIndex = 3; string[] subContent = new string[] { "คะแนนรวม", summary.Total.ToString(), "100", summary.GradeName, "" }; sheet1.AddMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 6, 7)); foreach (var content in subContent) { ExcelService.CreateContentCell(workbook, sheet1, subContentRow, cellSubContentIndex, content); cellSubContentIndex++; } rowIndex += 1; IRow topicUserContent = sheet1.CreateRow(rowIndex); ExcelService.CreateContentCellNoBorder(workbook, sheet1, topicUserContent, 1, "คะแนนผู้ประเมิน"); sheet1.AddMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 1, 2)); rowIndex += 1; }
/// <summary> /// Generate evaluation template and user score evaluation. /// </summary> /// <param name="workbook">The npoi workbook interface.</param> /// <param name="sheet1">The npoi sheet interface.</param> /// <param name="rowIndex">The row target index.</param> /// <param name="weigthingKey">The weighting key condition max score.</param> /// <param name="summary">The evaluation summary.</param> /// <param name="evaTemplate">The evaluation template.</param> /// <param name="evaLogs">The user evaluation log collection.</param> private void GenerateCriteriaContent(IWorkbook workbook, ISheet sheet1, ref int rowIndex, string weigthingKey, SummaryEvaluationViewModel summary, EvaluationTemplateDisplayViewModel evaTemplate, UserEvaluationDetailViewModel evaLogs) { foreach (var item in evaTemplate.Criteria.CriteriaGroups) { rowIndex++; string criteriaGroup = $" {item.Sequence}. {item.KpiGroupNameTh}"; string score = this.GetScore(evaLogs, item.KpiGroupId, 0); IRow kpiGroupContent = sheet1.CreateRow(rowIndex); ExcelService.CreateContentCell(workbook, sheet1, kpiGroupContent, 2, criteriaGroup, horizontalAlignment: HorizontalAlignment.Left); ExcelService.SetCellContentStyle(workbook, kpiGroupContent, 3, 3); ExcelService.CreateContentCell(workbook, sheet1, kpiGroupContent, 4, score); ExcelService.CreateContentCell(workbook, sheet1, kpiGroupContent, 5, this.GetMaxScore(weigthingKey, item.MaxScore)); sheet1.AddMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 2, 3)); foreach (var subItem in item.CriteriaItems) { rowIndex++; string criteriaItem = $" {item.Sequence}.{subItem.Sequence}. {subItem.KpiNameTh}"; string subScore = this.GetScore(evaLogs, item.KpiGroupId, subItem.KpiId.Value); IRow kpiContent = sheet1.CreateRow(rowIndex); ExcelService.CreateContentCell(workbook, sheet1, kpiContent, 2, criteriaItem, horizontalAlignment: HorizontalAlignment.Left); ExcelService.SetCellContentStyle(workbook, kpiContent, 3, 3); ExcelService.CreateContentCell(workbook, sheet1, kpiContent, 4, score); ExcelService.CreateContentCell(workbook, sheet1, kpiContent, 5, this.GetMaxScore(weigthingKey, subItem.MaxScore)); sheet1.AddMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 2, 3)); } } }
/// <summary> /// Get kpi group collection for genarate report. /// </summary> /// <param name="templateId">The evaluation template identity.</param> /// <param name="weigthingKey">The weigthing key for maximun max score.</param> /// <param name="summary">The summary detail evaluation.</param> /// <returns></returns> private IEnumerable <VendorEvaluationRequestItemModel> GetKpiGroupCollection(EvaluationTemplate templateInfo, string weigthingKey, SummaryEvaluationViewModel summary) { var criteriaInfo = _unitOfWork.GetRepository <Criteria>().GetCache(x => x.Id == templateInfo.CriteriaId).FirstOrDefault(); var criteriaGroups = _unitOfWork.GetRepository <CriteriaGroup>().GetCache(x => x.CriteriaId == criteriaInfo.Id); var kpiGroups = _unitOfWork.GetRepository <KpiGroup>().GetCache(); return(this.InitialVendorEvaluationRequestItemModel(kpiGroups, criteriaGroups, weigthingKey, summary)); }
/// <summary> /// Generate main content table. /// </summary> /// <param name="workbook">The npoi workbook interface.</param> /// <param name="sheet1">The npoi sheet interface.</param> /// <param name="summaryList">The evaluation summary result. </param> /// <param name="evaluationList">The evaluation data collection.</param> /// <param name="rowIndex">The row data index.</param> /// <param name="cellHeaderIndex">The max cell table generate.</param> private void GenerateContentTable(IWorkbook workbook, ISheet sheet1, SummaryEvaluationViewModel summary, Data.Pocos.Evaluation evaluation, ref int rowIndex, PeriodItem periodItem, IEnumerable <Hremployee> empList) { rowIndex++; IRow contentRow = sheet1.CreateRow(rowIndex); int cellContentIndex = 0; string[] mainContent = new string[] { evaluation.DocNo, evaluation.ComCode, UtilityService.DateTimeToString(periodItem.StartEvaDate.Value, "dd.MM.yyyy"), UtilityService.DateTimeToString(periodItem.EndEvaDate.Value, "dd.MM.yyyy"), periodItem.PeriodName, evaluation.VendorNo, summary.VendorName, summary.WeightingKey, summary.PurchasingOrgName, }; foreach (var content in mainContent) { ExcelService.CreateContentCell(workbook, sheet1, contentRow, cellContentIndex, content); cellContentIndex++; } rowIndex += 2; var evaTemplate = _evaluationTemplateBll.LoadTemplate(evaluation.EvaluationTemplateId.Value); this.GenerateScoreHeader(workbook, sheet1, ref rowIndex, summary); foreach (var user in summary.UserLists) { var emp = empList.FirstOrDefault(x => x.Aduser == user.AdUser); string evaluatorName = $" คุณ{emp?.FirstnameTh} {emp?.LastnameTh}"; IRow userContent = sheet1.CreateRow(rowIndex); ExcelService.CreateContentCell(workbook, sheet1, userContent, 1, evaluatorName, horizontalAlignment: HorizontalAlignment.Left); ExcelService.SetCellContentStyle(workbook, userContent, 2, 2); sheet1.AddMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 1, 2)); var evaLogs = user.EvaluationLogs.FirstOrDefault(); this.GenerateCriteriaContent(workbook, sheet1, ref rowIndex, evaluation.WeightingKey, summary, evaTemplate, evaLogs); rowIndex += 2; } }
/// <summary> /// Generate user cell content data. /// </summary> /// <param name="summary">The evaluation summary result.</param> /// <param name="cellContentIndex">The target cell content index.</param> /// <param name="workbook">The npoi workbook interface.</param> /// <param name="sheet1">The npoi sheet interface.</param> /// <param name="contentRow">The npoi content row interface.</param> private void GenerateUserCellContent(SummaryEvaluationViewModel summary, ref int cellContentIndex, IWorkbook workbook, ISheet sheet1, IRow contentRow) { foreach (var user in summary.UserLists) { string[] content = new string[] { user.FullName, this.GetEvaStatus(user.IsAction, user.IsReject), user.ReasonReject }; foreach (var userContent in content) { ExcelService.CreateContentCell(workbook, sheet1, contentRow, cellContentIndex, userContent); cellContentIndex++; } } }
/// <summary> /// Initial data for vendor evaluaiton request item model. /// </summary> /// <param name="kpiGroups">The kpi group collection.</param> /// <param name="criteriaGroups">The criteria group collection.</param> /// <param name="weigthingKey">The weithing key for maximun max score.</param> /// <param name="summary">The summary detail evaluation.</param> /// <returns></returns> private IEnumerable <VendorEvaluationRequestItemModel> InitialVendorEvaluationRequestItemModel(IEnumerable <KpiGroup> kpiGroups, IEnumerable <CriteriaGroup> criteriaGroups, string weigthingKey, SummaryEvaluationViewModel summary) { var result = new List <VendorEvaluationRequestItemModel>(); foreach (var item in criteriaGroups) { int score = 0; var scoreSummary = summary.Summarys.FirstOrDefault(x => x.KpiGroupId == item.KpiGroupId && x.KpiId == 0); if (scoreSummary != null) { score = Convert.ToInt32(scoreSummary.Score); } result.Add(new VendorEvaluationRequestItemModel { KpiGroupName = $"{item.Sequence}. {kpiGroups.FirstOrDefault(x => x.Id == item.KpiGroupId.Value)?.KpiGroupNameTh}", MaxScore = string.Equals(weigthingKey, "A2", StringComparison.OrdinalIgnoreCase) ? 100 : item.MaxScore.Value, Score = score, }); } return(result); }