Example #1
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);
        }
        /// <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);
        }
Example #3
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);
        }
Example #4
0
        protected override SetQuestionnaireRD ProcessRequest(APIRequest <SetQuestionnaireRP> pRequest)
        {
            var rd   = new SetQuestionnaireRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            T_QN_QuestionnaireEntity model_QuestionnaireEntity = null;


            var QuestionBLL = new T_QN_QuestionBLL(loggingSessionInfo);
            var QuestionNaireQuestionMappingBLL = new T_QN_QuestionNaireQuestionMappingBLL(loggingSessionInfo);
            var OptionBLL = new T_QN_OptionBLL(loggingSessionInfo);

            var QuestionPicBLL = new T_QN_QuestionPicBLL(loggingSessionInfo);

            if (para != null)
            {
                #region 问卷编辑

                Guid?tempguid = null;
                if (para.QuestionnaireID != "")
                {
                    tempguid = new System.Guid(para.QuestionnaireID);
                }
                model_QuestionnaireEntity = new T_QN_QuestionnaireEntity
                {
                    BGImageSrc            = para.BGImageSrc,
                    QuestionnaireID       = tempguid,
                    ButtonName            = para.ButtonName,
                    CustomerID            = loggingSessionInfo.ClientID,
                    IsShowQRegular        = para.IsShowQRegular,
                    ModelType             = para.ModelType,
                    QRegular              = para.QRegular,
                    QResultBGColor        = para.QResultBGColor,
                    QResultBGImg          = para.QResultBGImg,
                    QResultBtnTextColor   = para.QResultBtnTextColor,
                    QResultImg            = para.QResultImg,
                    QResultTitle          = para.QResultTitle,
                    QuestionnaireName     = para.QuestionnaireName,
                    QuestionnaireType     = para.QuestionnaireType,
                    StartPageBtnBGColor   = para.StartPageBtnBGColor,
                    StartPageBtnTextColor = para.StartPageBtnTextColor,
                    Sort   = 999,
                    Status = 1
                };

                var QuestionnaireBLL = new T_QN_QuestionnaireBLL(loggingSessionInfo);

                if (para.QuestionnaireID != null && para.QuestionnaireID != "")
                {
                    QuestionnaireBLL.Update(model_QuestionnaireEntity);
                }
                else
                {
                    QuestionnaireBLL.Create(model_QuestionnaireEntity);
                }

                #endregion

                rd.QuestionnaireID = model_QuestionnaireEntity.QuestionnaireID;


                if (para.step == 3 || para.step == 4)
                {
                    #region 问卷题目删除
                    if (para.step == 3 && para.QuestionDelDatalist != null)
                    {
                        object[] dels = new object[para.QuestionDelDatalist.Count];
                        for (int j = 0; j < para.QuestionDelDatalist.Count; j++)
                        {
                            dels[j] = para.QuestionDelDatalist[j].Questionid;
                        }

                        QuestionBLL.Delete(dels);
                    }
                    #endregion

                    #region 问卷题目编辑
                    if (para.Questiondatalist != null)
                    {
                        for (int i = 0; i < para.Questiondatalist.Count; i++)
                        {
                            Question            ques           = para.Questiondatalist[i];
                            T_QN_QuestionEntity QuestionEntity = new T_QN_QuestionEntity();

                            T_QN_QuestionPicEntity QuestionPicEntity = new T_QN_QuestionPicEntity();


                            if (para.step == 3)
                            {
                                QuestionEntity.CustomerID          = loggingSessionInfo.ClientID;
                                QuestionEntity.DefaultValue        = getValue(ques.DefaultValue);
                                QuestionEntity.Isphone             = getValue(ques.Isphone);
                                QuestionEntity.IsRequired          = getValue(ques.IsRequired);
                                QuestionEntity.IsShowAddress       = getValue(ques.IsShowAddress);
                                QuestionEntity.IsShowCity          = getValue(ques.IsShowCity);
                                QuestionEntity.IsShowCounty        = getValue(ques.IsShowCounty);
                                QuestionEntity.IsShowProvince      = getValue(ques.IsShowProvince);
                                QuestionEntity.IsValidateEndDate   = getValue(ques.IsValidateEndDate);
                                QuestionEntity.IsValidateMaxChar   = getValue(ques.IsValidateMaxChar);
                                QuestionEntity.IsValidateMinChar   = getValue(ques.IsValidateMinChar);
                                QuestionEntity.IsValidateStartDate = getValue(ques.IsValidateStartDate);
                                QuestionEntity.MaxChar             = getValue(ques.MaxChar);
                                QuestionEntity.MinChar             = getValue(ques.MinChar);
                                QuestionEntity.Name           = getValue(ques.Name);
                                QuestionEntity.NoRepeat       = getValue(ques.NoRepeat);
                                QuestionEntity.Questionid     = getValue(ques.Questionid);
                                QuestionEntity.QuestionidType = getValue(ques.QuestionidType);
                                QuestionEntity.StartDate      = getValue(ques.StartDate);
                                QuestionEntity.EndDate        = getValue(ques.EndDate);
                                QuestionEntity.Sort           = i + 1;
                                QuestionEntity.Status         = getValue(ques.Status);
                            }

                            if (para.step == 4)
                            {
                                QuestionEntity.Questionid = getValue(ques.Questionid);
                                QuestionEntity.ScoreStyle = getValue(ques.ScoreStyle);

                                if (QuestionEntity.ScoreStyle == 3)
                                {
                                    QuestionEntity.MaxScore = getValue(ques.MaxScore);
                                    QuestionEntity.MinScore = getValue(ques.MinScore);
                                }
                            }

                            if (QuestionEntity.Questionid == null || QuestionEntity.Questionid.Value.ToString() == "")
                            {
                                QuestionEntity.ScoreStyle = 1;
                                QuestionBLL.Create(QuestionEntity);
                            }
                            else
                            {
                                QuestionBLL.Update(QuestionEntity, false);
                            }

                            #region 题目图片编辑

                            if (para.step == 3)
                            {
                                QuestionPicEntity.Src        = getValue(ques.Src);
                                QuestionPicEntity.QuestionID = QuestionEntity.Questionid.Value.ToString();
                                QuestionPicEntity.CustomerID = QuestionEntity.CustomerID;
                                Guid?tempguid1 = null;
                                if (ques.QuestionPicID != "")
                                {
                                    tempguid1 = new System.Guid(ques.QuestionPicID);
                                }
                                QuestionPicEntity.QuestionPicID = tempguid1;
                                if (ques.QuestionPicID != null && ques.QuestionPicID != "")
                                {
                                    QuestionPicBLL.Update(QuestionPicEntity);
                                }
                                else
                                {
                                    QuestionPicBLL.Create(QuestionPicEntity);
                                }
                            }
                            #endregion


                            if (ques.Optionlist != null)
                            {
                                #region  项编辑
                                for (int j = 0; j < ques.Optionlist.Count; j++)
                                {
                                    Option            opt          = ques.Optionlist[j];
                                    T_QN_OptionEntity OptionEntity = new T_QN_OptionEntity();


                                    if (para.step == 3)
                                    {
                                        OptionEntity.CustomerID     = loggingSessionInfo.ClientID;
                                        OptionEntity.OptionContent  = getValue(opt.OptionContent);
                                        OptionEntity.OptionPicSrc   = getValue(opt.OptionPicSrc);
                                        OptionEntity.QuestionID     = getValue(QuestionEntity.Questionid.ToString());
                                        OptionEntity.QuestionidType = getValue(QuestionEntity.QuestionidType);
                                        OptionEntity.Sort           = j + 1;
                                        OptionEntity.OptionID       = getValue(opt.OptionID);
                                        OptionEntity.Status         = getValue(opt.Status);
                                    }

                                    if (para.step == 4)
                                    {
                                        OptionEntity.IsRightValue   = getValue(opt.IsRightValue);
                                        OptionEntity.NoOptionScore  = getValue(opt.NoOptionScore);
                                        OptionEntity.OptionID       = getValue(opt.OptionID);
                                        OptionEntity.YesOptionScore = getValue(opt.YesOptionScore);
                                    }

                                    if (OptionEntity.OptionID == null || OptionEntity.OptionID.Value.ToString() == "")
                                    {
                                        OptionEntity.IsRightValue   = 0;
                                        OptionEntity.NoOptionScore  = 0;
                                        OptionEntity.YesOptionScore = 0;
                                        OptionBLL.Create(OptionEntity);
                                    }
                                    else
                                    {
                                        OptionBLL.Update(OptionEntity, false);
                                    }
                                }

                                #endregion

                                #region  项删除
                                if (para.step == 3 && ques.OptionDelDatalist != null)
                                {
                                    object[] dels = new object[ques.OptionDelDatalist.Count];
                                    for (int j = 0; j < ques.OptionDelDatalist.Count; j++)
                                    {
                                        dels[j] = ques.OptionDelDatalist[j].OptionID;
                                    }

                                    OptionBLL.Delete(dels);
                                }

                                #endregion
                            }


                            #region 问卷关联题目添加
                            T_QN_QuestionNaireQuestionMappingEntity QuestionNaireQuestionMappingEntity = new T_QN_QuestionNaireQuestionMappingEntity()
                            {
                                CustomerID      = loggingSessionInfo.ClientID,
                                QuestionID      = QuestionEntity.Questionid.ToString(),
                                QuestionnaireID = model_QuestionnaireEntity.QuestionnaireID.ToString(),
                                Sort            = 999,
                                Status          = 0
                            };

                            QuestionNaireQuestionMappingBLL.Create(QuestionNaireQuestionMappingEntity);
                            #endregion
                        }
                    }
                    #endregion
                }
            }



            return(rd);
        }