protected override ActionResult DoTask(string data) { QuestionLinkTypeEnum linkType = (QuestionLinkTypeEnum)int.Parse(Request.QueryString["style"]); int linkId = 0; string[] blocks = StringUtility.Split(data, "%22"); for (int i = 0; i < blocks.Length; i++) { string block = blocks[i]; string[] param = StringUtility.Split(block, "%27"); if (i == 0) { string shortDesc = Escape.JsUnEscape(param[0]); int diff = int.Parse(Escape.JsUnEscape(param[2])); string content = Escape.JsUnEscape(param[3]); string attached = Escape.JsUnEscape(param[4]); QuestionEntity linkEntity = new QuestionEntity(); linkEntity.QuestionLinkType = linkType; linkEntity.QuestionLinkContent = content; linkEntity.QuestionLinkDifficulty = diff; linkEntity.QuestionLinkShortDescription = shortDesc; linkEntity.QuestionLinkAttachedInfo = attached; linkEntity.Save(); linkId = linkEntity.QuestionLinkId; } else { string shortDesc = Escape.JsUnEscape(param[0]); int score = int.Parse(Escape.JsUnEscape(param[1])); int diff = int.Parse(Escape.JsUnEscape(param[2])); string content = Escape.JsUnEscape(param[3]); string item = Escape.JsUnEscape(param[4]); string answer = Escape.JsUnEscape(param[5]); DefaultTypeEnum defaultType = (DefaultTypeEnum)int.Parse(Escape.JsUnEscape(param[6])); if (score == 0) { DefaultEntity defaultEntity = new DefaultEntity(); defaultEntity.DefaultType = defaultType; defaultEntity.Fill(); score = defaultEntity.DefaultScore; if (score == 0) { switch (defaultType) { case DefaultTypeEnum.SingleSelect: score = 2; break; case DefaultTypeEnum.MultiSelect: score = 4; break; case DefaultTypeEnum.JudgeSelect: score = 1; break; } } } QuestionEntity entity = new QuestionEntity(); entity.QuestionType = QuestionEntity.ConvertDefaultTypeToQuestionType(defaultType); entity.QuestionLinkId = linkId; entity.QuestionContent = content; entity.QuestionDifficulty = diff; entity.QuestionAnswer = answer; entity.QuestionScore = score; entity.QuestionShortDescription = shortDesc; entity.QuestionItem = item; entity.QuestionLinkType = QuestionLinkTypeEnum.Nothing; entity.Save(); } } QuestionCollection collection = new QuestionCollection(); collection.PageSize = 8; collection.AbsolutePage = 1; collection.IsReturnDataTable = true; collection.Fill(); ActionResult result = new ActionResult(); result.IsSuccess = true; StringBuilder response = new StringBuilder(); response.Append(ActionTaskUtility.ReturnClientDataArray(collection.GetFillDataTable())); response.Append(string.Format("TmpStr={0};", collection.PageCount)); result.ResponseData = response.ToString(); return result; }
protected void Page_Load(object sender, EventArgs e) { collection = new QuestionCollection(); collection.PageSize = 8; collection.AbsolutePage = 1; collection.Fill(); this.repQuestionList.DataSource = QuestionViewModelList; this.repQuestionList.DataBind(); }