protected override EmptyResponseData ProcessRequest(APIRequest <DelQuestionnaireAnswerRecordRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            List <string> AnswerOptionIDs = new List <string>();


            var QuestionnaireAnswerRecordBLL = new T_QN_QuestionnaireAnswerRecordBLL(loggingSessionInfo);

            var QuestionnaireOptionCountBLL = new T_QN_QuestionnaireOptionCountBLL(this.CurrentUserInfo);

            for (int i = 0; i < para.VipIDs.Length; i++)
            {
                string[] tempAnswerOptionID = QuestionnaireAnswerRecordBLL.GetVipIDModelList(para.VipIDs[0]);

                ArrangeValue(tempAnswerOptionID, ref AnswerOptionIDs);
            }

            #region 修改记录数
            var pTran = QuestionnaireAnswerRecordBLL.GetTran();

            using (pTran.Connection)
            {
                try
                {
                    QuestionnaireOptionCountBLL.UpdateSelectedCount(AnswerOptionIDs, para.ActivityID, pTran);
                    if (para.VipIDs != null)
                    {
                        QuestionnaireAnswerRecordBLL.DeletevipIDs(para.VipIDs);
                    }
                    pTran.Commit();//提交事物
                }
                catch (Exception ex)
                {
                    pTran.Rollback();

                    throw new APIException(ex.Message);
                }
            }

            #endregion

            return(rd);
        }
Ejemplo n.º 2
0
        protected override GetScoreRecoveryOptionInforRD ProcessRequest(APIRequest <GetActivityIDAndQuestionnaireIDRP> pRequest)
        {
            var rd   = new GetScoreRecoveryOptionInforRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var QOCMBLL            = new T_QN_QuestionnaireOptionCountBLL(loggingSessionInfo);
            var QuestionBLL        = new T_QN_QuestionBLL(loggingSessionInfo);
            var OptionBLL          = new T_QN_OptionBLL(loggingSessionInfo);

            //查询活动下的问卷信息
            var AQMmodel = new T_QN_ActivityQuestionnaireMappingBLL(loggingSessionInfo).GetByAID(para.ActivityID);

            if (AQMmodel != null)
            {
                //获取答题选项统计列表
                var QOCList = QOCMBLL.GetList(AQMmodel.QuestionnaireID, para.ActivityID);

                //获取选择类型题目数据集合
                var QuestionEntitys = QuestionBLL.getOptionQuestionList(AQMmodel.QuestionnaireID);

                if (rd.Questionlist == null)
                {
                    rd.Questionlist = new List <Question>();
                }

                //向返回列表增加题目集合
                for (int i = 0; i < QuestionEntitys.Length; i++)
                {
                    var      QuestionEntity = QuestionEntitys[i];
                    Question q = new Question();
                    q.Name           = QuestionEntity.Name;
                    q.Questionid     = QuestionEntity.Questionid;
                    q.QuestionidType = QuestionEntity.QuestionidType.Value;

                    var QuestionOptionlist = OptionBLL.GetListByQuestionID(q.Questionid.ToString());

                    if (q.Optionlist == null)
                    {
                        q.Optionlist = new List <Option>();
                    }

                    int sum = 0;
                    //向返回列表增加题目的选项集合
                    foreach (var _QuestionOption in QuestionOptionlist)
                    {
                        var OptionList = (from list in QOCList
                                          where list.ActivityID == para.ActivityID
                                          where list.OptionID == _QuestionOption.OptionID.ToString()
                                          select new
                        {
                            ActivityName = list.ActivityName,
                            OptionID = list.OptionID,
                            OptionName = list.OptionName,
                            QuestionnaireName = list.QuestionnaireName,
                            QuestionName = list.QuestionName,
                            SelectedCount = list.SelectedCount
                        }).ToList();
                        if (OptionList.Count > 0)
                        {
                            Option _Option = new Option();
                            _Option.OptionID      = OptionList[0].OptionID;
                            _Option.OptionName    = OptionList[0].OptionName;
                            _Option.SelectedCount = OptionList[0].SelectedCount.Value;
                            sum += OptionList[0].SelectedCount.Value;
                            q.Optionlist.Add(_Option);
                        }
                        else
                        {
                            Option _Option = new Option();
                            _Option.OptionID        = _QuestionOption.OptionID.ToString();
                            _Option.OptionName      = _QuestionOption.OptionContent;
                            _Option.SelectedCount   = 0;
                            _Option.SelectedPercent = "0";
                            q.Optionlist.Add(_Option);
                        }
                    }

                    for (int k = 0; k < q.Optionlist.Count; k++)
                    {
                        if (sum > 0)
                        {
                            q.Optionlist[k].SelectedPercent = string.Format("{0:0}", Convert.ToDouble(q.Optionlist[k].SelectedCount) * 100 / Convert.ToDouble(sum));
                        }
                    }



                    rd.Questionlist.Add(q);
                }
            }
            return(rd);
        }
Ejemplo n.º 3
0
        protected override GetScoreRecoveryInformationRD ProcessRequest(APIRequest <GetQuestionnaireAnswerRecordRP> pRequest)
        {
            var rd   = new GetScoreRecoveryInformationRD();
            var para = pRequest.Parameters;
            T_QN_QuestionnaireAnswerRecordEntity model_QuestionnaireAnswerRecordEntity = null;


            var QuestionnaireAnswerRecordBLL = new T_QN_QuestionnaireAnswerRecordBLL(this.CurrentUserInfo);
            var QuestionnaireOptionCountBLL  = new T_QN_QuestionnaireOptionCountBLL(this.CurrentUserInfo);

            var ScoreRecoveryInformationBLL = new T_QN_ScoreRecoveryInformationBLL(this.CurrentUserInfo);


            if (para != null)
            {
                if (para.VipID == null || para.VipID == "")
                {
                    para.VipID = Guid.NewGuid().ToString();
                }
                var SumScore = 0;

                var createqoc = new List <T_QN_QuestionnaireOptionCountEntity>();
                var updateqoc = new List <T_QN_QuestionnaireOptionCountEntity>();
                var createqar = new List <T_QN_QuestionnaireAnswerRecordEntity>();

                for (int i = 0; i < para.QuestionnaireAnswerRecordlist.Count; i++)
                {
                    var qarl = para.QuestionnaireAnswerRecordlist[i];

                    string AnswerOptionIDs = "";

                    #region 答题选项统计
                    if (qarl.optionlist != null)
                    {
                        for (int j = 0; j < qarl.optionlist.Count; j++)
                        {
                            var option = qarl.optionlist[j];
                            if (!(option.OptionID == null || option.OptionID == "" || option.OptionName == null || option.OptionName == ""))
                            {
                                AnswerOptionIDs += option.OptionID + ",";
                                var model_qoce = QuestionnaireOptionCountBLL.isExist(option.OptionID, para.ActivityID);

                                if (model_qoce != null)
                                {
                                    model_qoce.SelectedCount += 1;
                                }
                                else
                                {
                                    model_qoce                   = new T_QN_QuestionnaireOptionCountEntity();
                                    model_qoce.CustomerID        = this.CurrentUserInfo.ClientID;
                                    model_qoce.ActivityID        = para.ActivityID;
                                    model_qoce.ActivityName      = para.ActivityName;
                                    model_qoce.QuestionID        = qarl.QuestionID;
                                    model_qoce.QuestionnaireID   = para.QuestionnaireID;
                                    model_qoce.QuestionnaireName = para.QuestionnaireName;
                                    model_qoce.QuestionName      = qarl.QuestionName;
                                    model_qoce.OptionID          = option.OptionID;
                                    model_qoce.OptionName        = option.OptionName;
                                    model_qoce.SelectedCount     = 1;
                                }


                                if (model_qoce.QuestionnaireOptionCountID == null)
                                {
                                    createqoc.Add(model_qoce);
                                }
                                else
                                {
                                    updateqoc.Add(model_qoce);
                                }
                            }
                        }
                    }

                    #endregion

                    #region 新增答题记录
                    model_QuestionnaireAnswerRecordEntity = new T_QN_QuestionnaireAnswerRecordEntity
                    {
                        CustomerID        = this.CurrentUserInfo.ClientID,
                        ActivityID        = para.ActivityID,
                        ActivityName      = para.ActivityName,
                        AnswerAddress     = qarl.AnswerAddress,
                        AnswerCity        = qarl.AnswerCity,
                        AnswerCounty      = qarl.AnswerCounty,
                        AnswerDate        = qarl.AnswerDate,
                        AnswerOption      = qarl.AnswerOption,
                        AnswerOptionId    = AnswerOptionIDs,
                        AnswerProvince    = qarl.AnswerProvince,
                        AnswerText        = qarl.AnswerText,
                        QuestionID        = qarl.QuestionID,
                        QuestionidType    = qarl.QuestionidType,
                        QuestionnaireID   = para.QuestionnaireID,
                        QuestionnaireName = para.QuestionnaireName,
                        QuestionName      = qarl.QuestionName,
                        QuestionScore     = qarl.QuestionScore,
                        VipID             = para.VipID,
                        Status            = 1
                    };
                    SumScore += qarl.SumScore;

                    createqar.Add(model_QuestionnaireAnswerRecordEntity);

                    #endregion
                }


                #region 新增答题记录和修改记录数
                var pTran = QuestionnaireAnswerRecordBLL.GetTran();

                using (pTran.Connection)
                {
                    try
                    {
                        for (int j = 0; j < createqoc.Count; j++)
                        {
                            QuestionnaireOptionCountBLL.Create(createqoc[j], pTran);
                        }

                        for (int j = 0; j < updateqoc.Count; j++)
                        {
                            QuestionnaireOptionCountBLL.Update(updateqoc[j], pTran);
                        }

                        for (int j = 0; j < createqar.Count; j++)
                        {
                            QuestionnaireAnswerRecordBLL.Create(createqar[j], pTran);
                        }

                        pTran.Commit();//提交事物
                    }
                    catch (Exception ex)
                    {
                        pTran.Rollback();

                        throw new APIException(ex.Message);
                    }

                    #endregion
                }



                var QuestionnaireAnswerRecordID = model_QuestionnaireAnswerRecordEntity.QuestionnaireAnswerRecordID;

                #region 获取结束页展示数据
                if (SumScore > 0)
                {
                    T_QN_ScoreRecoveryInformationEntity[] list_ScoreRecoveryInformation = ScoreRecoveryInformationBLL.getScoreRecoveryInformationByScore(para.QuestionnaireID, SumScore.ToString());

                    if (list_ScoreRecoveryInformation.Length > 0)
                    {
                        T_QN_ScoreRecoveryInformationEntity tempentity = list_ScoreRecoveryInformation[0];

                        rd.RecoveryContent = tempentity.RecoveryContent;
                        rd.RecoveryImg     = tempentity.RecoveryImg;
                        rd.RecoveryType    = tempentity.RecoveryType;
                    }
                }
                #endregion
            }



            return(rd);
        }