コード例 #1
0
        public Amount_InfoEntity GetAEntity(string Amount_Code)
        {
            Amount_InfoEntity modle = new Amount_InfoEntity();
            Amount_InfoEntity ds    = MgrServices.DistributeRecordService.GetAEntity(Amount_Code);

            modle._amount_guidance = ds._amount_guidance;
            modle._amount_name     = ds._amount_name;
            return(modle);
        }
コード例 #2
0
        /// <summary>
        /// 创建日期:2016/11/08
        /// 根据序号加载题干信息
        /// </summary>
        /// <param name="code">量表编码</param>
        /// <param name="index">题干序号</param>
        /// <param name="context"></param>
        private void InitStemS(string code, int index, int ARadom, int DID, HttpContext context)
        {
            try
            {
                int Indexs = 0;

                DataTable sourceTemp = new DataTable();
                if (code.Equals("LB_14811899636250"))
                {
                    // sourceTemp = MgrServices.AnswerAddService.GetMMPI_Subject_Temp();
                    string MMPI_Json = MgrServices.AnswerAddService.GetMMPI_Question();
                    context.Response.Write(MMPI_Json);
                    return;
                }
                else
                {
                    sourceTemp = MgrServices.AnswerAddService.GetSubEntityTemp(code, 0);
                }

                //GetOperationCodeTemp


                List <QModel> listT = new List <QModel>();
                if (sourceTemp != null && sourceTemp.Rows.Count > 0)
                {
                    if (ARadom == 1)
                    {
                        //重新处理sourceTemp
                        //取  DID (分配记录) 对应的作答记录
                        //如果作答记录不为空
                        //重新编排sourceTemp
                        AnswerAddEntity aae       = MgrServices.DistributeRecordService.GetAnswerAddEntity_ByDID(DID);
                        DataTable       tempTable = sourceTemp.Clone();

                        if (aae != null && aae._answeradd_record.Length > 0)
                        {
                            Dictionary <string, string> answerRecordDic = JsonConvert.DeserializeObject <Dictionary <string, string> >(aae._answeradd_record);//将用户答题记录json字符串反序列为字典项键值对                        }
                            foreach (var item in answerRecordDic.Keys)
                            {
                                DataRow tempRow = sourceTemp.AsEnumerable().Where(x => x["SubjectCode"].ToString() == item).First();
                                tempTable.ImportRow(tempRow);
                                sourceTemp.Rows.Remove(tempRow);
                            }
                        }
                        int    tableLength = sourceTemp.Rows.Count;
                        Random rd          = new Random();
                        for (int j = tableLength; j > 0; j--)
                        {
                            DataRow tempRow = sourceTemp.Rows[rd.Next(0, j)];
                            tempTable.ImportRow(tempRow);
                            sourceTemp.Rows.Remove(tempRow);
                        }
                        sourceTemp = tempTable;
                    }

                    Amount_InfoEntity ds         = MgrServices.DistributeRecordService.GetAEntity(code);
                    string            SubCodeStr = "";
                    foreach (DataRow SunDtr in sourceTemp.Rows)
                    {
                        if (!SubCodeStr.Equals(""))
                        {
                            SubCodeStr += ",'" + SunDtr["SubjectCode"] + "'";
                        }
                        else
                        {
                            SubCodeStr += "'" + SunDtr["SubjectCode"] + "'";
                        }
                    }
                    DataTable OperationTemp         = new DataTable();
                    DataTable OperationRelarionTemp = new DataTable();

                    if (!SubCodeStr.Equals(""))
                    {
                        OperationRelarionTemp = MgrServices.DistributeRecordService.GetOperationCodeTemp(SubCodeStr); //查询的是题干和题支的关系集合
                        OperationTemp         = MgrServices.DistributeRecordService.GetOperationTemp(SubCodeStr);     // 查询的是题支的实体信息集合
                    }


                    StringBuilder sb = new StringBuilder("{'questions':[");
                    foreach (DataRow DTR in sourceTemp.Rows)
                    {
                        Indexs++;
                        QModel model = new QModel();
                        sb.Append("{'question':");
                        string SubjectContent = DTR["SubjectContent"].ToString();
                        if (SubjectContent.Contains("/SubjectImages"))
                        {
                            model.question = DTR["SubjectContent"].ToString();
                        }
                        else
                        {
                            model.question = Indexs + "." + DTR["SubjectContent"].ToString();
                        }
                        string StemCode    = DTR["SubjectCode"].ToString();
                        string SubjectCode = "";
                        string IndexNum    = "";
                        sb.Append("'" + model.question + "'");
                        DataRow[] OperCodeRW = OperationRelarionTemp.Select(" SubjectCode='" + StemCode + "'");
                        string    OPC_Str    = "";
                        if (OperCodeRW != null && OperCodeRW.Length > 0)
                        {
                            foreach (DataRow OCDTR in OperCodeRW)
                            {
                                if (!OPC_Str.Equals(""))
                                {
                                    OPC_Str += ",'" + OCDTR["OperationCode"] + "'";
                                }
                                else
                                {
                                    OPC_Str += "'" + OCDTR["OperationCode"] + "'";
                                }
                            }
                        }

                        DataRow[] SourceTemps = OperationTemp.Select(" OperationCode in (" + OPC_Str + ")  ");
                        if (SourceTemps != null && SourceTemps.Length > 0)
                        {
                            sb.Append(",");
                            sb.Append("'answers':[");
                            string OpCode   = "";
                            string Factions = "";
                            foreach (DataRow DTRs in SourceTemps)
                            {
                                model.OptionCode = DTRs["OperationCode"].ToString();
                                model.IndexNum   = DTRs["OperationNum"].ToString();
                                model.Faction    = DTRs["OperationFraction"].ToString();
                                model.answers    = DTRs["OperationContent"].ToString();
                                sb.Append("'" + model.answers + "',");//model.answers
                                OpCode      += "'" + model.OptionCode + "',";
                                Factions    += "'" + model.Faction + "',";
                                SubjectCode += "'" + StemCode + "',";
                                IndexNum    += "'" + model.IndexNum + "',";
                            }
                            sb.Append("]" + ",");
                            sb.Append("'OpCode':[" + SubjectCode + "]" + ",");
                            sb.Append("'IndexNum':[" + IndexNum + "]" + ",");
                            sb.Append("'Factions':[" + Factions + "]" + ",");
                            sb.Append("'OptionCode':[" + OpCode + "]}" + ",");
                        }
                    }
                    sb.Append("],");

                    ds._amount_guidance    = ds._amount_guidance.Replace("'", "&apos;");
                    ds._amount_guidance    = ds._amount_guidance.Replace("\"", "&quot;");
                    ds._amount_displayname = ds._amount_displayname.Replace("'", "&apos;");
                    ds._amount_displayname = ds._amount_displayname.Replace("\"", "&quot;");

                    sb.Append("'Amount_Guidance': [{'AGuidance':" + "'" + ds._amount_guidance + "'},{'AName':" + "'" + ds._amount_displayname + "'}]");
                    sb.Append("}");

                    string json = sb.ToString().Replace("'", "\"");

                    context.Response.Write(json);

                    //context.Response.Write("000000");
                }
            }
            catch
            { }
        }