예제 #1
0
        protected override GetQuestionListRD ProcessRequest(APIRequest <GetQuestionnaireIDRP> pRequest)
        {
            var rd   = new GetQuestionListRD();
            var para = pRequest.Parameters;

            var QuestionBLL = new T_QN_QuestionBLL(this.CurrentUserInfo);


            var OptionBLL = new T_QN_OptionBLL(this.CurrentUserInfo);



            #region 获取数据集


            T_QN_QuestionEntity[] list_QuestionEntity = QuestionBLL.getList(para.QuestionnaireID);

            rd.QuestionnaireList = new List <Question>();
            for (int i = 0; i < list_QuestionEntity.Length; i++)
            {
                var      ques      = list_QuestionEntity[i];
                Question _question = new Question();

                _question.CustomerID          = ques.CustomerID;
                _question.DefaultValue        = ques.DefaultValue;
                _question.Isphone             = ques.Isphone.Value;
                _question.IsRequired          = ques.IsRequired.Value;
                _question.IsShowAddress       = ques.IsShowAddress.Value;
                _question.IsShowCity          = ques.IsShowCity.Value;
                _question.IsShowCounty        = ques.IsShowCounty.Value;
                _question.IsShowProvince      = ques.IsShowProvince.Value;
                _question.IsValidateEndDate   = ques.IsValidateEndDate.Value;
                _question.IsValidateMaxChar   = ques.IsValidateMaxChar.Value;
                _question.IsValidateMinChar   = ques.IsValidateMinChar.Value;
                _question.IsValidateStartDate = ques.IsValidateStartDate.Value;
                _question.MaxChar             = ques.MaxChar.Value;
                _question.MaxScore            = ques.MaxScore;
                _question.MinChar             = ques.MinChar.Value;
                _question.MinScore            = ques.MinScore;
                _question.Name           = ques.Name;
                _question.NoRepeat       = ques.NoRepeat.Value;
                _question.Questionid     = ques.Questionid.Value;
                _question.QuestionidType = ques.QuestionidType.Value;
                _question.ScoreStyle     = ques.ScoreStyle.Value;
                _question.StartDate      = ques.StartDate;
                _question.EndDate        = ques.EndDate;
                _question.Sort           = ques.Sort.Value;
                _question.Status         = ques.Status.Value;



                #region 获取题目选项

                #region 条件参数

                List <IWhereCondition> complexCondition1 = new List <IWhereCondition>();
                complexCondition1.Add(new EqualsCondition()
                {
                    FieldName = "CustomerID", Value = this.CurrentUserInfo.ClientID
                });
                if (_question.Questionid != null)
                {
                    complexCondition1.Add(new EqualsCondition()
                    {
                        FieldName = "QuestionID", Value = _question.Questionid
                    });
                }

                #endregion

                #region 排序参数

                List <OrderBy> lstOrder1 = new List <OrderBy> {
                };
                lstOrder1.Add(new OrderBy()
                {
                    FieldName = "Sort", Direction = OrderByDirections.Asc
                });

                #endregion
                T_QN_OptionEntity[] list_OptionEntity = OptionBLL.Query(complexCondition1.ToArray(), lstOrder1.ToArray());

                _question.Optionlist = new List <Option>();

                for (int j = 0; j < list_OptionEntity.Length; j++)
                {
                    var    opt     = list_OptionEntity[j];
                    Option _Option = new Option();

                    _Option.CustomerID     = this.CurrentUserInfo.ClientID;
                    _Option.IsRightValue   = opt.IsRightValue.Value;
                    _Option.NoOptionScore  = opt.NoOptionScore.Value;
                    _Option.OptionContent  = opt.OptionContent;
                    _Option.OptionID       = opt.OptionID;
                    _Option.OptionPicSrc   = opt.OptionPicSrc;
                    _Option.QuestionID     = opt.QuestionID;
                    _Option.QuestionidType = opt.QuestionidType.Value;
                    _Option.Sort           = opt.Sort.Value;
                    _Option.Status         = opt.Status.Value;
                    _Option.YesOptionScore = opt.YesOptionScore.Value;
                    _question.Optionlist.Add(_Option);
                }

                #endregion

                #region 获取题目标题图片

                var QuestionPicBLL = new T_QN_QuestionPicBLL(this.CurrentUserInfo);

                #region 条件参数

                List <IWhereCondition> complexCondition2 = new List <IWhereCondition>();
                complexCondition2.Add(new EqualsCondition()
                {
                    FieldName = "CustomerID", Value = this.CurrentUserInfo.ClientID
                });
                if (_question.Questionid != null)
                {
                    complexCondition2.Add(new EqualsCondition()
                    {
                        FieldName = "QuestionID", Value = _question.Questionid
                    });
                }

                #endregion

                T_QN_QuestionPicEntity[] list_QuestionPicEntity = QuestionPicBLL.Query(complexCondition2.ToArray(), null);

                if (list_QuestionPicEntity.Length > 0)
                {
                    _question.Src           = list_QuestionPicEntity[0].Src;
                    _question.QuestionPicID = list_QuestionPicEntity[0].QuestionPicID.Value.ToString();
                }
                else
                {
                    _question.Src           = "";
                    _question.QuestionPicID = "";
                }

                #endregion

                rd.QuestionnaireList.Add(_question);
            }
            #endregion

            return(rd);
        }
        /// <summary>
        /// 获取答题记录详细信息
        /// </summary>
        /// <param name="ActivityID">活动id</param>
        /// <param name="QuestionnaireID">问卷id</param>
        /// <returns></returns>
        public static DataTable GetQuestionnaireInfor(string ActivityID, string QuestionnaireID, out TitleName[] TitleData)
        {
            DataTable dt = new DataTable();

            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var QARMBLL            = new T_QN_QuestionnaireAnswerRecordBLL(loggingSessionInfo);
            var QuestionBLL        = new T_QN_QuestionBLL(loggingSessionInfo);

            var tempList = QARMBLL.GetModelList(ActivityID, QuestionnaireID);

            var questionlist = QuestionBLL.getList(QuestionnaireID);

            TitleData = new TitleName[questionlist.Length + 2];
            for (int j = 0; j < questionlist.Length; j++)
            {
                DataColumn dc = new DataColumn(questionlist[j].Questionid.ToString());
                if (TitleData[j] == null)
                {
                    TitleData[j] = new TitleName();
                }
                TitleData[j].Name   = questionlist[j].Name;
                TitleData[j].NameID = questionlist[j].Questionid.ToString();
                dt.Columns.Add(dc);
            }

            if (TitleData[questionlist.Length] == null)
            {
                TitleData[questionlist.Length] = new TitleName();
            }
            TitleData[questionlist.Length].Name   = "提交时间";
            TitleData[questionlist.Length].NameID = "submitdate";
            DataColumn dcsubmitdate = new DataColumn("submitdate");

            dt.Columns.Add(dcsubmitdate);

            if (TitleData[questionlist.Length + 1] == null)
            {
                TitleData[questionlist.Length + 1] = new TitleName();
            }
            TitleData[questionlist.Length + 1].Name   = "标识";
            TitleData[questionlist.Length + 1].NameID = "ID";
            DataColumn dcID = new DataColumn("ID");

            dt.Columns.Add(dcID);

            var vipdata = QARMBLL.GetUserModelList(ActivityID, QuestionnaireID);



            for (int k = 0; k < vipdata.Length; k++)
            {
                DataRow dr       = dt.NewRow();
                var     _vipdata = vipdata[k];
                var     datetime = new DateTime();
                for (int j = 0; j < questionlist.Length; j++)
                {
                    var _questindata = questionlist[j];
                    for (int i = 0; i < tempList.Length; i++)
                    {
                        var _data = tempList[i];
                        if (_vipdata.ToString() == _data.VipID.ToString())
                        {
                            if (_questindata.Questionid.ToString() == _data.QuestionID)
                            {
                                dr[_questindata.Questionid.ToString()] = (_data.AnswerText + _data.AnswerOption + _data.AnswerDate + _data.AnswerProvince + _data.AnswerCity + _data.AnswerCounty + _data.AnswerAddress).TrimEnd(',');
                                datetime = _data.CreateTime.Value;
                            }
                        }
                    }
                }
                dr["submitdate"] = datetime;
                dr["ID"]         = _vipdata;
                dt.Rows.Add(dr);
            }

            return(dt);
        }