private bool checkValid() { user = Page.User.Identity.Name; if (Request.QueryString["row"] != null) { row = Int32.Parse(Request.QueryString["row"]); } if (Request.QueryString["score"] != null) { score = Int32.Parse(Request.QueryString["score"]); } score = score < 1 ? 1 : score; score = score > 5 ? 5 : score; BrainTrain.Model.bt_gantong_user uM = uBll.GetModel(user); if (uM != null) { string trainList = uM.trainList; string[] trainListArr = trainList.Split(';'); if (trainListArr.Length > row) { string[] trainListArr2 = trainListArr[row].Split(','); if (trainListArr2.Length >= 2) { groupName = trainListArr2[0]; level = trainListArr2[1]; } ; } age = uM.age; } //if (Request.QueryString["groupName"] != null) //{ // groupName = Request.QueryString["groupName"]; //} //if (Request.QueryString["level"] != null) //{ // level = Request.QueryString["level"]; //} DataTable dt = gBll.GetDataTable("name=\"" + groupName + "\""); if (dt.Rows.Count > 0) { modId = Int32.Parse(dt.Rows[0]["modId"].ToString()); } if (user == "" || row < 0 || groupName == "" || level == "" || modId < 0 || age <= 0) { return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) { Response.Redirect("./vueUnLogin.aspx"); } string user = Page.User.Identity.Name; BrainTrain.Model.bt_gantong_curriculum c_m = cBll.GetModel(user); int ui_count = uBll.GetDataTable("name=\"" + user + "\" order by ui desc").Rows.Count; if (c_m == null || c_m.times - ui_count <= 0) { // 量表创建次数已经使用完 Response.Write("{" + String.Format("\"msg\":\"你的量表创建次数已经用完,如需继续创建,请联系管理员。\",\"u_i\":{0}", -1) + "}"); return; } if (Request.QueryString["name"] != null) { name = Request.QueryString["name"]; } if (Request.QueryString["sex"] != null) { sex = Request.QueryString["sex"]; } if (Request.QueryString["age"] != null) { age = Request.QueryString["age"]; } if (Request.QueryString["remark"] != null) { remark = Request.QueryString["remark"]; } name = removeSQLString(name); sex = removeSQLString(sex); age = removeSQLString(age); remark = removeSQLString(remark); if (name == "" || sex == "" || age == "") { json_ret = "{" + String.Format("\"msg\":\"个人信息不能为空!\",\"u_i\":-1") + "}"; Response.Write(json_ret); return; } if (Request.QueryString["score"] != null) { scoreStr = Cgl.Common.TextHelper.RemoveSQLString(Request.QueryString["score"]); } scoreArr = scoreStr.Split('b'); if (scoreArr.Length < 7) { json_ret = "{" + String.Format("\"msg\":\"请提交完整的量表!\",\"u_i\":-1") + "}"; Response.Write(json_ret); return; } int[] bili = new int[] { 1, 1, 1, 1, 1, 1, 1 }; bili[0] = getBiLi(new int[] { 17, 22, 28 }, Int32.Parse(scoreArr[0])); // 前庭 bili[1] = getBiLi(new int[] { 19, 25, 30 }, Int32.Parse(scoreArr[1])); // 执行。。 bili[2] = getBiLi(new int[] { 24, 31, 38 }, Int32.Parse(scoreArr[2])); // 触觉 bili[3] = getBiLi(new int[] { 17, 24, 30 }, Int32.Parse(scoreArr[3])); // 发展 bili[4] = getBiLi(new int[] { 8, 11, 15 }, Int32.Parse(scoreArr[4])); // 视觉空间。。 bili[5] = getBiLi(new int[] { 16, 23, 31 }, Int32.Parse(scoreArr[5])); // 重力 bili[6] = getBiLi(new int[] { 24, 31, 38 }, Int32.Parse(scoreArr[6])); // 情绪。。 //getComment(bili); int[] bili2 = new int[] { bili[0], bili[5], bili[2], bili[3] }; int[] nArr = new int[] { 0, 0, 0, 0 }; nArr[0] = getN(bili2, 0); // 前庭 nArr[1] = getN(bili2, 1); // 重力 nArr[2] = getN(bili2, 2); // 触觉 nArr[3] = getN(bili2, 3); // 发展 //Response.Write(bili[0]); Response.Write(bili[2]); Response.Write(bili[3]); //Response.Write(nArr[0]); Response.Write(nArr[2]); Response.Write(nArr[3]); List <string> grpList = new List <string>(); //List<string> goalList = new List<string>(); .........goalList......... List <string> groupChoose = new List <string>(); // 当前年龄段包含的训练组 /// 3,4,5岁 /// FKGGHHLRJSFFCCTY HEQPPMWHHH GPUCCCVDXVV GGGB BBC /// 6-12岁 /// LFKGGHHRJSCCFFY HEQPPMWHHH DXGPV、VVUCCC GGGB BBC if (Int32.Parse(age) < 6) { groupChoose.Add("F"); groupChoose.Add("K"); groupChoose.Add("GG"); groupChoose.Add("HH"); groupChoose.Add("L"); groupChoose.Add("R"); groupChoose.Add("J"); groupChoose.Add("S"); groupChoose.Add("FF"); groupChoose.Add("CC"); groupChoose.Add("T"); groupChoose.Add("Y"); groupChoose.Add("H"); groupChoose.Add("E"); groupChoose.Add("Q"); groupChoose.Add("PP"); groupChoose.Add("M"); groupChoose.Add("W"); groupChoose.Add("HHH"); groupChoose.Add("G"); groupChoose.Add("P"); groupChoose.Add("U"); groupChoose.Add("CCC"); groupChoose.Add("V"); groupChoose.Add("D"); groupChoose.Add("X"); groupChoose.Add("VV"); groupChoose.Add("GGG"); groupChoose.Add("B"); groupChoose.Add("BB"); groupChoose.Add("C"); } else { groupChoose.Add("L"); groupChoose.Add("F"); groupChoose.Add("K"); groupChoose.Add("GG"); groupChoose.Add("HH"); groupChoose.Add("R"); groupChoose.Add("J"); groupChoose.Add("S"); groupChoose.Add("CC"); groupChoose.Add("FF"); groupChoose.Add("Y"); groupChoose.Add("H"); groupChoose.Add("E"); groupChoose.Add("Q"); groupChoose.Add("PP"); groupChoose.Add("M"); groupChoose.Add("W"); groupChoose.Add("HHH"); groupChoose.Add("D"); groupChoose.Add("X"); groupChoose.Add("G"); groupChoose.Add("P"); groupChoose.Add("V"); groupChoose.Add("VV"); groupChoose.Add("U"); groupChoose.Add("CCC"); groupChoose.Add("GGG"); groupChoose.Add("B"); groupChoose.Add("BB"); groupChoose.Add("C"); } int added = 0; DataTable dt = groupBll.GetDataTable("modId = 5"); for (int i = 0; i < groupChoose.Count; i++) { string grp = groupChoose[i]; if (added >= 1) { break; } if (findGroup(dt, grp)) { grpList.Add(grp); //goalList.Add("综合训练"); added++; } } added = 0; dt = groupBll.GetDataTable("modId = 1"); for (int i = 0; i < groupChoose.Count; i++) { string grp = groupChoose[i]; if (added >= nArr[0]) { break; } if (findGroup(dt, grp)) { grpList.Add(grp); //goalList.Add("前庭平衡和大脑双侧分化"); added++; } } added = 0; dt = groupBll.GetDataTable("modId = 2"); for (int i = 0; i < groupChoose.Count; i++) { string grp = groupChoose[i]; if (added >= nArr[1]) { break; } if (findGroup(dt, grp)) { grpList.Add(grp); //goalList.Add("重力不安"); added++; } } added = 0; dt = groupBll.GetDataTable("modId = 3"); for (int i = 0; i < groupChoose.Count; i++) { string grp = groupChoose[i]; if (added >= nArr[2]) { break; } if (findGroup(dt, grp)) { grpList.Add(grp); //goalList.Add("触觉敏感"); added++; } } added = 0; dt = groupBll.GetDataTable("modId = 4"); for (int i = 0; i < groupChoose.Count; i++) { string grp = groupChoose[i]; if (added >= nArr[3]) { break; } if (findGroup(dt, grp)) { grpList.Add(grp); //goalList.Add("发展性协调运动功能"); added++; } } string trainList = ""; //json = "["; added = 0; for (int i = 0; i < grpList.Count; i++) { string grp = grpList[i]; DataTable dt2 = courseBll.GetDataTable("groupName=\"" + grp + "\" order by level asc"); //DataTable dt3 = Cgl.Data.MysqlHelper.GetDataTable("select name from bt_gantong_module where modId=(select modId from bt_gantong_group where name=\"" + grp + "\" limit 1);"); if (dt2.Rows.Count > 0) { DataRow dr = dt2.Rows[0]; string level = dr["level"].ToString(); level = level.Length > 1 ? level : "0" + level; string group = dr["groupName"].ToString(); //json += added == 0 ? "" : ","; //json += String.Format("[\"{0}{1} {2}\",\"{5}\",\"{3}\",\"{4}\",\"{6}\"]", group, level, dr["name"], dr["aid"], dr["duration"], dt3.Rows[0]["name"], dr["tip"]); trainList += added == 0 ? "" : ";"; trainList += group + "," + dr["level"].ToString(); added++; } } //json += "]"; int u_i = 0; dt = uBll.GetDataTable("name=\"" + user + "\" order by ui desc"); if (dt.Rows.Count > 0) { u_i = Int32.Parse(dt.Rows[0]["ui"].ToString()); u_i++; } BrainTrain.Model.bt_gantong_user uModel = new BrainTrain.Model.bt_gantong_user(); uModel.name = user; uModel.ui = u_i; uModel.scores = scoreStr; uModel.trainListOri = trainList; uModel.trainList = trainList; uModel.time = DateTime.Now; uModel.nameCn = name; uModel.sex = sex; uModel.age = Int32.Parse(age); uModel.remark = remark; uBll.Add(uModel); json_ret = "{" + String.Format("\"msg\":\"训练方案生成成功!\",\"u_i\":{0}", u_i) + "}"; Response.Write(json_ret); }
private void updateTrainList() { List <string> groupChoose = new List <string>(); // 当前年龄段包含的训练组 // 这里的顺序决定了训练的顺序 if (age < 6) { groupChoose.Add("F"); groupChoose.Add("K"); groupChoose.Add("GG"); groupChoose.Add("HH"); groupChoose.Add("L"); groupChoose.Add("R"); groupChoose.Add("J"); groupChoose.Add("S"); groupChoose.Add("FF"); groupChoose.Add("CC"); groupChoose.Add("T"); groupChoose.Add("Y"); groupChoose.Add("H"); groupChoose.Add("E"); groupChoose.Add("Q"); groupChoose.Add("PP"); groupChoose.Add("M"); groupChoose.Add("W"); groupChoose.Add("HHH"); groupChoose.Add("G"); groupChoose.Add("P"); groupChoose.Add("U"); groupChoose.Add("CCC"); groupChoose.Add("V"); groupChoose.Add("D"); groupChoose.Add("X"); groupChoose.Add("VV"); groupChoose.Add("GGG"); groupChoose.Add("B"); groupChoose.Add("BB"); groupChoose.Add("C"); } else { groupChoose.Add("L"); groupChoose.Add("F"); groupChoose.Add("K"); groupChoose.Add("GG"); groupChoose.Add("HH"); groupChoose.Add("R"); groupChoose.Add("J"); groupChoose.Add("S"); groupChoose.Add("CC"); groupChoose.Add("FF"); groupChoose.Add("Y"); groupChoose.Add("H"); groupChoose.Add("E"); groupChoose.Add("Q"); groupChoose.Add("PP"); groupChoose.Add("M"); groupChoose.Add("W"); groupChoose.Add("HHH"); groupChoose.Add("D"); groupChoose.Add("X"); groupChoose.Add("G"); groupChoose.Add("P"); groupChoose.Add("V"); groupChoose.Add("VV"); groupChoose.Add("U"); groupChoose.Add("CCC"); groupChoose.Add("GGG"); groupChoose.Add("B"); groupChoose.Add("BB"); groupChoose.Add("C"); } // 获取已经训练的分组 List <string> groupChooseNo = new List <string>(); DataTable dt = rBll.GetDataTable("name=\"" + user + "\" group by groupName"); for (int i = 0; i < dt.Rows.Count; i++) { groupChooseNo.Add(dt.Rows[i]["groupName"].ToString()); } BrainTrain.Model.bt_gantong_user uM = uBll.GetModel(user); string trainList = uM.trainList; string[] trainListArr = trainList.Split(';'); for (int i = 0; i < trainListArr.Length; i++) { string[] trainListArr2 = trainListArr[i].Split(','); if (trainListArr2.Length >= 2) { groupChooseNo.Add(trainListArr2[0]); } } // 获取新的训练的组号与难度 string groupNameNew = ""; int levelNew = -1; dt = cBll.GetDataTable("groupName=\"" + groupName + "\" AND level>" + level + " order by level asc"); if (dt.Rows.Count > 0 && score >= 5) { // 只需要更新难度 groupNameNew = dt.Rows[0]["groupName"].ToString(); levelNew = Int32.Parse(dt.Rows[0]["level"].ToString()); } else { // 需要更新组号与难度 List <string> groupChoose2 = new List <string>(); // 当前可以分配的训练组 dt = gBll.GetDataTable("modId=" + modId + ""); for (int i = 0; i < groupChoose.Count; i++) { string grp = groupChoose[i]; if (findGroup(dt, grp) && groupChooseNo.IndexOf(grp) < 0) { groupChoose2.Add(grp); } } //for (int i = 0; i < dt.Rows.Count; i++) //{ // string grp = dt.Rows[i]["name"].ToString(); // if (groupChoose.IndexOf(grp) >= 0 && groupChooseNo.IndexOf(grp) < 0) // { // groupChoose2.Add(grp); // } //} if (groupChoose2.Count > 0) { groupNameNew = groupChoose2[0]; dt = cBll.GetDataTable("groupName=\"" + groupNameNew + "\" order by level asc"); if (dt.Rows.Count > 0) { levelNew = Int32.Parse(dt.Rows[0]["level"].ToString()); } } } // 更新trainList trainList = ""; for (int i = 0; i < trainListArr.Length; i++) { if (i != row || levelNew <= 0) { // 当没有搜索到课程时,继续保持原来的课程表 trainList += trainListArr[i]; } else { trainList += groupNameNew + "," + levelNew; } if (i < trainListArr.Length - 1) { trainList += ";"; } } uM.trainList = trainList; uBll.Update(uM); }