/// <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 evaluation score kpi or kpi group.
        /// </summary>
        /// <param name="evaLogs">The evaluation log collection.</param>
        /// <param name="kpiGroupId">The kpi group identity.</param>
        /// <param name="kpiId">The kpi identity.</param>
        /// <returns></returns>
        private string GetScore(UserEvaluationDetailViewModel evaLogs,
                                int kpiGroupId, int kpiId)
        {
            string score = "";

            if (evaLogs != null)
            {
                var evaLog = evaLogs.EvaluationLogs.FirstOrDefault(x => x.KpiGroupId == kpiGroupId && x.KpiId == kpiId);
                if (evaLog != null)
                {
                    score = evaLog.Score.Value.ToString();
                }
            }
            return(score);
        }
        /// <summary>
        /// Get evaluation all log result.
        /// </summary>
        /// <param name="adUser">The owner result evaluation.</param>
        /// <param name="evaluationId">The evaluation identity.</param>
        /// <returns></returns>
        private IEnumerable <UserEvaluationDetailViewModel> GetEvaluationLogs(string adUser, int evaluationId, int criteriaId)
        {
            var result         = new List <UserEvaluationDetailViewModel>();
            var evaluationLogs = _unitOfWork.GetRepository <EvaluationLog>().Get(x => x.AdUser == adUser && x.EvaluationId == evaluationId);

            foreach (var item in evaluationLogs)
            {
                var evaLog = new UserEvaluationDetailViewModel();
                var log    = _unitOfWork.GetRepository <EvaluationLogItem>().Get(x => x.EvaluationLogId == item.Id);
                evaLog.Id         = item.Id;
                evaLog.ActionDate = item.ActionDate;
                foreach (var logItem in log)
                {
                    bool isHaveKpi = false;
                    if (logItem.KpiId == 0 || logItem.KpiId == null)
                    {
                        isHaveKpi = log.Any(x => x.KpiGroupId == logItem.KpiGroupId && (x.KpiId != 0 && x.KpiId != null));
                    }

                    evaLog.EvaluationLogs.Add(new UserEvaluationLogItemViewModel
                    {
                        Id         = logItem.Id,
                        KpiGroupId = logItem.KpiGroupId,
                        KpiId      = logItem.KpiId,
                        LevelPoint = logItem.LevelPoint,
                        Reason     = logItem.Reason,
                        Score      = logItem.Score,
                        Sequence   = this.GetSequence(logItem.KpiGroupId.Value, logItem.KpiId, criteriaId),
                        RawScore   = isHaveKpi ? 0 : Convert.ToDouble(logItem.RawScore.Value),
                        MaxScore   = this.GetMaxScore(logItem.KpiGroupId.Value, logItem.KpiId, criteriaId)
                    });
                }
                result.Add(evaLog);
            }
            return(result);
        }