Exemplo n.º 1
0
        //---------------------------------------------------------------------------------------------

        private async Task PopulateWithGoalCompletionStats(int goalId, GoalPeriodStatsData stats)
        {
            // All periods.
            var results = await _dbQuery.ExecuteSql <int>($"EXEC dbo.sp_CalculateGoalAverageCompletionAcrossAllPeriods {goalId}");

            if (results.Count > 0)
            {
                stats.AverageCompletionAcrossAllPeriods = results[0];
            }
            else
            {
                _log.LogError($"Failed to retrieve goal average completion across all periods stats for goal {goalId}.");
            }

            // Last 3 periods.
            results = await _dbQuery.ExecuteSql <int>($"EXEC dbo.sp_CalculateGoalAverageCompletionAcrossLast3Periods {goalId}");

            if (results.Count > 0)
            {
                stats.AverageCompletionAcrossLast3Periods = results[0];
            }
            else
            {
                _log.LogError($"Failed to retrieve goal average completion across last 3 periods stats for goal {goalId}.");
            }
        }
        /// <summary>
        ///  新建问卷
        /// </summary>
        /// <param name="surveyDirectory"></param>
        /// <returns></returns>
        public long Insert(SurveyDirectory surveyDirectory)
        {
            var dirid = _repository.Add(surveyDirectory);

            if (dirid > 0)
            {
                var detailId = _surveyDetailServices.Add(new SurveyDetail()
                {
                    DirId      = (int)dirid,
                    SurveyNote = surveyDirectory.DirType == 2 ? "非常感谢您的参与!如有涉及个人信息,我们将严格保密。" : string.Empty,
                    EndTime    = DateTime.Now.AddMonths(1)
                });
                _dbQuery.ExecuteSql("UPDATE dbo.SurveyDirectory SET SurveyDetailId = @surveydetailid WHERE id=@id", new { surveydetailid = detailId, id = dirid });
            }
            return(dirid);
        }
Exemplo n.º 3
0
        public long SaveAnswer(SurveyAnswer model)
        {
            var answerId = _repository.Add(model);

            if (answerId > 0)
            {
                model.AnswerRadio.ForEach(p => p.BelongAnswerId = answerId);
                _repositoryAnswerRadio.AddBatch(model.AnswerRadio);

                model.AnswerCheckbox.ForEach(p => p.BelongAnswerId = answerId);
                _repositoryAnswerCheckbox.AddBatch(model.AnswerCheckbox);

                model.AnswerFillblank.ForEach(p => p.BelongAnswerId = answerId);
                _repositoryAnswerFillblank.AddBatch(model.AnswerFillblank);

                model.AnswerScore.ForEach(p => p.BelongAnswerId = answerId);
                _repositoryAnswerScore.AddBatch(model.AnswerScore);

                model.AnswerOrder.ForEach(p => p.BelongAnswerId = answerId);
                _repositoryAnswerOrder.AddBatch(model.AnswerOrder);


                model.AnswerMultiFillblank.ForEach(p => p.BelongAnswerId = answerId);
                _repositoryAnswerMultiFillblank.AddBatch(model.AnswerMultiFillblank);

                model.AnswerChenRadio.ForEach(p => p.BelongAnswerId = answerId);
                _repositoryAnswerChenRadio.AddBatch(model.AnswerChenRadio);

                model.AnswerChenCheckbox.ForEach(p => p.BelongAnswerId = answerId);
                _repositoryAnswerChenCheckbox.AddBatch(model.AnswerChenCheckbox);

                model.AnswerChenScore.ForEach(p => p.BelongAnswerId = answerId);
                _repositoryAnswerChenScore.AddBatch(model.AnswerChenScore);

                model.AnswerChenFillblank.ForEach(p => p.BelongAnswerId = answerId);
                _repositoryAnswerChenFillblank.AddBatch(model.AnswerChenFillblank);

                _dbQuery.ExecuteSql("UPDATE dbo.SurveyDirectory SET AnswerNum =AnswerNum + 1 WHERE IsValid=1 AND id=@dirid;", new { dirid = model.DirId });

                return(answerId);
            }
            return(0);
        }
 public int UpdateQuestionNum(long dirid)
 {
     return(_dbQuery.ExecuteSql("UPDATE dbo.SurveyDirectory SET SurveyQuNum =SurveyQuNum + 1 WHERE IsValid=1 AND id=@dirid;",
                                new { dirid = dirid }));
 }