예제 #1
0
파일: GetRecord.ashx.cs 프로젝트: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            int    pageIndex = Convert.ToInt32(context.Request["page"]);
            int    pageSize  = Convert.ToInt32(context.Request["rows"]);
            string setId     = context.Request["set_id"];
            int    total     = 0;

            try
            {
                List <QuestionnaireRecord> list = bllQuestion.GetRecord(pageSize, pageIndex, setId, CurrentUserInfo.UserID, out total, true);

                apiResp.status = true;
                apiResp.code   = (int)APIErrCode.IsSuccess;
                apiResp.result = new
                {
                    totalcount = total,
                    list       = from p in list
                                 select new {
                        id            = p.AutoId,
                        correct_count = p.CorrectCount,
                        answer_count  = p.AnswerCount,
                        date          = p.InsertDate.ToString("yyyy-MM-dd HH:mm")
                    }
                };
            }
            catch (Exception ex)
            {
                apiResp.status = false;
                apiResp.code   = (int)APIErrCode.OperateFail;
                apiResp.msg    = ex.Message;
            }
            bllQuestion.ContextResponse(context, apiResp);
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            int    pageIndex = Convert.ToInt32(context.Request["page"]);
            int    pageSize  = Convert.ToInt32(context.Request["rows"]);
            string title     = context.Request["title"];

            List <BLLJIMP.Model.QuestionnaireSet> data = bllQuestion.GetSetList(pageSize, pageIndex, bllQuestion.WebsiteOwner, title, null);
            int totalCount = bllQuestion.GetSetCount(bllQuestion.WebsiteOwner, title, null);
            var result     = from p in data
                             select new
            {
                id              = p.AutoID,
                title           = p.Title,
                img             = p.Img,
                score           = p.Score,
                score_num       = p.ScoreNum,
                ip              = p.IP,
                pv              = p.PV,
                uv              = p.UV,
                start_date      = DateTimeHelper.DateTimeToUnixTimestamp(p.StartDate),
                end_date        = DateTimeHelper.DateTimeToUnixTimestamp(p.EndDate),
                isrand_question = p.IsOptionRandom.HasValue? p.IsQuestionRandom.Value:0,
                isrand_option   = p.IsOptionRandom.HasValue? p.IsOptionRandom.Value:0,
                answer_count    = bllQuestion.GetRecordCount(null, p.AutoID, null)
            };

            apiResp.status = true;
            apiResp.result = new
            {
                totalcount = totalCount,
                list       = result
            };
            bllQuestion.ContextResponse(context, apiResp);
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            string AutoID = context.Request["AutoID"];

            BLLJIMP.Model.QuestionnaireSet QuestionnaireSetModel =
                bllQuestion.GetByKey <BLLJIMP.Model.QuestionnaireSet>("AutoID", AutoID);
            if (QuestionnaireSetModel == null)
            {
                apiResp.code = (int)APIErrCode.ContentNotFound;
                apiResp.msg  = "没有找到记录";
                bllQuestion.ContextResponse(context, apiResp);
                return;
            }

            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.status = true;
            apiResp.result = QuestionnaireSetModel;
            bllQuestion.ContextResponse(context, apiResp);
        }
예제 #4
0
파일: GetBySet.ashx.cs 프로젝트: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            List <BLLJIMP.Model.Question> questions = null;
            string msg    = "";
            bool   result = bllQuestion.GetQuestionListBySet(Convert.ToInt32(context.Request["id"]), out questions, out msg);

            if (result)
            {
                BLLJIMP.Model.QuestionnaireSet QuestionnaireSetModel = bllQuestion.GetByKey <BLLJIMP.Model.QuestionnaireSet>("AutoID", context.Request["id"]);

                bool isUserAnswer = bllQuestion.ExistsRecordCount(CurrentUserInfo.UserID, QuestionnaireSetModel.AutoID, null);
                var  resultList   = from p in questions
                                    select new
                {
                    question_id       = p.QuestionID,
                    question_name     = p.QuestionName,
                    question_type     = p.QuestionType,
                    question_required = p.IsRequired,
                    question_options  = (from s in p.Answers
                                         select new
                    {
                        option_id = s.AnswerID,
                        option_name = s.AnswerName
                    })
                };

                apiResp.result = new
                {
                    id            = QuestionnaireSetModel.AutoID,
                    title         = QuestionnaireSetModel.Title,
                    img           = QuestionnaireSetModel.Img,
                    describe      = QuestionnaireSetModel.Description,
                    bgimg_index   = QuestionnaireSetModel.BgImgIndex,
                    bgimg_answer  = QuestionnaireSetModel.BgImgAnswer,
                    bgimg_end     = QuestionnaireSetModel.BgImgEnd,
                    is_useranswer = isUserAnswer,
                    is_moreanswer = QuestionnaireSetModel.IsMoreAnswer,
                    win_count     = QuestionnaireSetModel.WinCount,
                    win_btn_text  = QuestionnaireSetModel.WinBtnText,
                    win_btn_url   = QuestionnaireSetModel.WinBtnUrl,
                    win_describe  = QuestionnaireSetModel.WinDescription,
                    questions     = resultList
                };

                apiResp.code = (int)APIErrCode.IsSuccess;
            }
            else
            {
                apiResp.code = (int)APIErrCode.OperateFail;
            }

            apiResp.status = result;
            apiResp.msg    = msg;
            bllQuestion.ContextResponse(context, apiResp);
        }
예제 #5
0
파일: SelectList.ashx.cs 프로젝트: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            List <Questionnaire> data = bllQuestion.GetSelectList(bllQuestion.WebsiteOwner, context.Request["type"]);
            var result = from p in data
                         select new
            {
                value = p.QuestionnaireID,
                name  = p.QuestionnaireName,
                count = bllQuestion.GetQuestionCount(p.QuestionnaireID)
            };

            apiResp.status = true;
            apiResp.result = result;
            bllQuestion.ContextResponse(context, apiResp);
        }
예제 #6
0
        public void ProcessRequest(HttpContext context)
        {
            string AutoIDs = context.Request["AutoIDs"];
            int    nCount  = bllQuestion.UpdateMultByKey <BLLJIMP.Model.QuestionnaireSet>("AutoID", AutoIDs, "IsDelete", "1");

            apiResp.status = nCount > 0;
            if (apiResp.status)
            {
                apiResp.code = (int)APIErrCode.IsSuccess;
                apiResp.msg  = "成功删除" + nCount + "行记录";
                bllLog.Add(BLLJIMP.Enums.EnumLogType.Marketing, BLLJIMP.Enums.EnumLogTypeAction.Delete, bllLog.GetCurrUserID(), "删除答题[id=" + AutoIDs + "]");
            }
            else
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "删除失败";
            }
            bllQuestion.ContextResponse(context, apiResp);
        }
예제 #7
0
파일: Update.ashx.cs 프로젝트: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string AutoID = context.Request["AutoID"];

            BLLJIMP.Model.QuestionnaireSet QuestionnaireSetModel = bllQuestion.GetByKey <BLLJIMP.Model.QuestionnaireSet>("AutoID", AutoID);
            QuestionnaireSetModel = bllQuestion.ConvertRequestToModel <BLLJIMP.Model.QuestionnaireSet>(QuestionnaireSetModel);
            apiResp.status        = bllQuestion.Update(QuestionnaireSetModel);
            if (apiResp.status)
            {
                apiResp.code = (int)APIErrCode.IsSuccess;
                apiResp.msg  = "更新完成";
                bllLog.Add(BLLJIMP.Enums.EnumLogType.Marketing, BLLJIMP.Enums.EnumLogTypeAction.Update, bllLog.GetCurrUserID(), "编辑答题[id=" + AutoID + "]");
            }
            else
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "更新失败";
            }
            bllQuestion.ContextResponse(context, apiResp);
        }
예제 #8
0
파일: Add.ashx.cs 프로젝트: uvbs/mmp
 public void ProcessRequest(HttpContext context)
 {
     BLLJIMP.Model.QuestionnaireSet QuestionnaireSetModel =
         bllQuestion.ConvertRequestToModel <BLLJIMP.Model.QuestionnaireSet>(new BLLJIMP.Model.QuestionnaireSet());
     QuestionnaireSetModel.CreateTime   = DateTime.Now;
     QuestionnaireSetModel.CreateUserId = currentUserInfo.UserID;
     QuestionnaireSetModel.WebsiteOwner = bllQuestion.WebsiteOwner;
     apiResp.status = bllQuestion.Add(QuestionnaireSetModel);
     if (apiResp.status)
     {
         apiResp.code = (int)APIErrCode.IsSuccess;
         apiResp.msg  = "新增完成";
         bllLog.Add(BLLJIMP.Enums.EnumLogType.Marketing, BLLJIMP.Enums.EnumLogTypeAction.Add, bllLog.GetCurrUserID(), "添加答题");
     }
     else
     {
         apiResp.code = (int)APIErrCode.OperateFail;
         apiResp.msg  = "新增失败";
     }
     bllQuestion.ContextResponse(context, apiResp);
 }
예제 #9
0
        public void ProcessRequest(HttpContext context)
        {
            List <BLLJIMP.Model.Question> questions = null;
            string msg = "";

            bool result = bllQuestion.GetQuestionList(context.Request["question_collection"], context.Request["full_return"]
                                                      , context.Request["question_random"], context.Request["option_random"], context.Request["used_questions"]
                                                      , null, out questions, out msg);

            if (result)
            {
                var resultList = from p in questions
                                 select new
                {
                    question_id       = p.QuestionID,
                    question_name     = p.QuestionName,
                    question_type     = p.QuestionType,
                    question_required = p.IsRequired,
                    question_options  = (from s in p.Answers
                                         select new
                    {
                        option_id = s.AnswerID,
                        option_name = s.AnswerName
                    })
                };

                apiResp.result = resultList;
                apiResp.code   = (int)APIErrCode.IsSuccess;
            }
            else
            {
                apiResp.code = (int)APIErrCode.OperateFail;
            }

            apiResp.status = result;
            apiResp.msg    = msg;
            bllQuestion.ContextResponse(context, apiResp);
        }
예제 #10
0
파일: Delete.ashx.cs 프로젝트: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string id          = context.Request["id"];
            string forceDelete = context.Request["force_delete"];

            //force_delete等于1时,则不管是否存在答题记录,进行强制删除
            if (forceDelete != "1")
            {
                if (bllQuestion.GetCountByKey <QuestionnaireRecord>("QuestionnaireID", id) > 0)
                {
                    resp.errcode = (int)APIErrCode.LotteryHaveRecord;
                    resp.errmsg  = string.Format("已经有人答题,不能删除");
                    bllQuestion.ContextResponse(context, resp);
                    return;
                }
            }
            BLLTransaction tran = new BLLTransaction();

            try
            {
                if (bllQuestion.UpdateByKey <Questionnaire>("QuestionnaireID", id, "IsDelete", "1", tran) == -1)
                {
                    tran.Rollback();
                    resp.errcode = (int)APIErrCode.OperateFail;
                    resp.errmsg  = "删除问卷失败";
                    bllQuestion.ContextResponse(context, resp);
                    return;
                }

                //if (bllQuestion.DeleteByKey<Questionnaire>("QuestionnaireID", id, tran) == -1)
                //{
                //    tran.Rollback();
                //    resp.errcode = (int)APIErrCode.OperateFail;
                //    resp.errmsg = "删除问卷失败";
                //    bllQuestion.ContextResponse(context, resp);
                //    return;
                //}

                //if (bllQuestion.DeleteByKey<BLLJIMP.Model.Question>("QuestionnaireID", id, tran) == -1)
                //{
                //    tran.Rollback();
                //    resp.errcode = (int)APIErrCode.OperateFail;
                //    resp.errmsg = "删除问题失败";
                //    bllQuestion.ContextResponse(context, resp);
                //    return;
                //}
                //if (bllQuestion.DeleteByKey<Answer>("QuestionnaireID", id, tran) == -1)
                //{
                //    tran.Rollback();
                //    resp.errcode = (int)APIErrCode.OperateFail;
                //    resp.errmsg = "删除选项失败";
                //    bllQuestion.ContextResponse(context, resp);
                //    return;
                //}
                //if (bllQuestion.DeleteByKey<QuestionnaireRecord>("QuestionnaireID", id, tran) == -1)
                //{
                //    tran.Rollback();
                //    resp.errcode = (int)APIErrCode.OperateFail;
                //    resp.errmsg = "删除答题失败";
                //    bllQuestion.ContextResponse(context, resp);
                //    return;
                //}
                //if (bllQuestion.DeleteByKey<QuestionnaireRecordDetail>("QuestionnaireID", id, tran) == -1)
                //{
                //    tran.Rollback();
                //    resp.errcode = (int)APIErrCode.OperateFail;
                //    resp.errmsg = "删除答题详情失败";
                //    bllQuestion.ContextResponse(context, resp);
                //    return;
                //}
                tran.Commit();
                resp.errcode   = (int)APIErrCode.IsSuccess;
                resp.isSuccess = true;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = ex.Message;
            }
            bllQuestion.ContextResponse(context, resp);
        }