Exemple #1
0
        protected void btnImportIQTestStandardParametersSet_Click(object sender, EventArgs e)
        {
            List <IQTestStandardParametersSet> parametersSetList = new List <IQTestStandardParametersSet>();

            string dataDirectoryPath = MapPath("~/App_Data/IQTest");

            string[] dataFilePaths = Directory.GetFiles(dataDirectoryPath, "IQTestStandardParametersSet*.xml");

            foreach (string dataFilePath in dataFilePaths)
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(dataFilePath);

                XmlElement xeElementStandardParametersSet = (XmlElement)xd.SelectSingleNode("StandardParametersSet");
                int        ageMin = int.Parse(xeElementStandardParametersSet.GetAttribute("AgeMin"));
                int        ageMax = int.Parse(xeElementStandardParametersSet.GetAttribute("AgeMax"));

                IQTestStandardParametersSet parametersSet = new IQTestStandardParametersSet(ageMin, ageMax);

                foreach (XmlNode xnParameter in xeElementStandardParametersSet.SelectNodes("Parameter"))
                {
                    XmlElement xeParameter = (XmlElement)xnParameter;

                    int originalScore = int.Parse(xeParameter.GetAttribute("OriginalScore"));
                    int IQ            = int.Parse(xeParameter.GetAttribute("IQ"));

                    IQTestStandardParameter standardParameter = new IQTestStandardParameter(originalScore, IQ);
                    parametersSet.Parameters.Add(standardParameter);
                }

                parametersSetList.Add(parametersSet);
            }

            if (parametersSetList.Count > 0)
            {
                using (var context = new ComputingServicesContext())
                {
                    foreach (var parametersSet in parametersSetList)
                    {
                        var oldStandardParametersSet = context.IQTestStandardParametersSets.Where(item => item.AgeMin == parametersSet.AgeMin && item.AgeMax == parametersSet.AgeMax).SingleOrDefault();
                        if (oldStandardParametersSet != null)
                        {
                            context.IQTestStandardParametersSets.Remove(oldStandardParametersSet);
                        }
                        context.IQTestStandardParametersSets.Add(parametersSet);
                    }
                    context.SaveChanges();
                }

                ltlLog.Text = "成功完成。";
            }
            else
            {
                ltlLog.Text = "没有数据。";
            }
        }
Exemple #2
0
        protected void btnImportIQTestQuestionsSet_Click(object sender, EventArgs e)
        {
            List <IQTestQuestionsSet> questionsSetList = new List <IQTestQuestionsSet>();

            string dataDirectoryPath = MapPath("~/App_Data/IQTest");

            string[] dataFilePaths = Directory.GetFiles(dataDirectoryPath, "IQTestQuestionsSet*.xml");

            foreach (string dataFilePath in dataFilePaths)
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(dataFilePath);

                XmlElement xeQuestionsSet   = (XmlElement)xd.SelectSingleNode("QuestionsSet");
                string     questionsSetCode = xeQuestionsSet.GetAttribute("Code");

                IQTestQuestionsSet questionsSet = new IQTestQuestionsSet(questionsSetCode);

                foreach (XmlNode xnQuestion in xeQuestionsSet.SelectNodes("Question"))
                {
                    XmlElement xeQuestion = (XmlElement)xnQuestion;

                    string group         = xeQuestion.GetAttribute("Group");
                    int    code          = int.Parse(xeQuestion.GetAttribute("Code"));
                    string correctChoice = xeQuestion.GetAttribute("CorrectChoice");

                    IQTestQuestion question = new IQTestQuestion(group, code, correctChoice);
                    questionsSet.Questions.Add(question);
                }

                questionsSetList.Add(questionsSet);
            }

            if (questionsSetList.Count > 0)
            {
                using (var context = new ComputingServicesContext())
                {
                    foreach (var questionsSet in questionsSetList)
                    {
                        var oldQuestionsSet = context.IQTestQuestionsSets.Where(item => item.Code == questionsSet.Code).SingleOrDefault();
                        if (oldQuestionsSet != null)
                        {
                            context.IQTestQuestionsSets.Remove(oldQuestionsSet);
                        }
                        context.IQTestQuestionsSets.Add(questionsSet);
                    }
                    context.SaveChanges();
                }

                ltlLog.Text = "成功完成。";
            }
            else
            {
                ltlLog.Text = "没有数据。";
            }
        }
        // DELETE api/certainsportabilitytestevaluationcriteriasport/5
        public HttpResponseMessage Delete(int id)
        {
            using (var context = new ComputingServicesContext())
            {
                CertainSportAbilityTestEvaluationCriteriaSport sport = context.CertainSportAbilityTestEvaluationCriteriaSports.SingleOrDefault(item => item.Id == id);
                if (sport == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
                context.CertainSportAbilityTestEvaluationCriteriaSports.Remove(sport);

                context.SaveChanges();
            }

            var response = Request.CreateResponse(HttpStatusCode.NoContent);

            return(response);
        }
        // PUT api/certainsportabilitytestevaluationcriteriasport/5
        public HttpResponseMessage Put(int id, [FromBody] CertainSportAbilityTestEvaluationCriteriaSportDTO sportDTO)
        {
            using (var context = new ComputingServicesContext())
            {
                CertainSportAbilityTestEvaluationCriteriaSport sport = context.CertainSportAbilityTestEvaluationCriteriaSports.SingleOrDefault(item => item.Id == id);
                if (sport == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
                sport.UpdateBasicInfo(sportDTO.Code, sportDTO.Name);

                context.SaveChanges();
            }

            var response = Request.CreateResponse(HttpStatusCode.NoContent);

            return(response);
        }
        // POST api/certainsportabilitytestevaluationcriteriasport
        public HttpResponseMessage Post([FromBody] CertainSportAbilityTestEvaluationCriteriaSportDTO sportDTO)
        {
            CertainSportAbilityTestEvaluationCriteriaSport sport = new CertainSportAbilityTestEvaluationCriteriaSport(sportDTO.Code, sportDTO.Name);

            using (var context = new ComputingServicesContext())
            {
                context.CertainSportAbilityTestEvaluationCriteriaSports.Add(sport);

                context.SaveChanges();
            }

            sportDTO.Id = sport.Id;

            var    response = Request.CreateResponse(HttpStatusCode.Created, sportDTO);
            string url      = Url.Link("DefaultApi", new { sportDTO.Id });

            response.Headers.Location = new Uri(url);

            return(response);
        }
Exemple #6
0
        public void TestAddCertainSportAbilityTestEvaluationCriteriaSport()
        {
            string sportCode = "sport_for_test";

            CertainSportAbilityTestEvaluationCriteriaSport sport = new CertainSportAbilityTestEvaluationCriteriaSport(sportCode, "花样游泳");

            sport.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSportParameter("优秀", 90, null, null, null));
            sport.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSportParameter("合格", 60, null, null, null));

            List <CertainSportAbilityTestEvaluationCriteriaSubSport> subSportList = new List <CertainSportAbilityTestEvaluationCriteriaSubSport>();
            List <CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet> subSportParametersSetList = new List <CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet>();

            {
                CertainSportAbilityTestEvaluationCriteriaSubSport subSport = new CertainSportAbilityTestEvaluationCriteriaSubSport("800m", "800米跑", "秒", CertainSportAbilityTestDataType.TimeSpan, CertainSportAbilityTestComparePattern.LessThanOrEqual, sport);

                subSportList.Add(subSport);

                {
                    CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet subSportParametersSet = new CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet(1, 100, Gender.Female, subSport);

                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("4:20", 3, "及格"));
                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("4:10", 4, "良好"));
                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("4:00", 5, "优秀"));

                    subSportParametersSetList.Add(subSportParametersSet);
                }
            }

            {
                CertainSportAbilityTestEvaluationCriteriaSubSport subSport = new CertainSportAbilityTestEvaluationCriteriaSubSport("NeckLength", "颈长", "厘米", CertainSportAbilityTestDataType.Integer, CertainSportAbilityTestComparePattern.GreaterThanOrEqual, sport);

                subSportList.Add(subSport);

                {
                    CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet subSportParametersSet = new CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet(8, 8, null, subSport);

                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("11", 3, "及格"));
                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("13", 5, "优秀"));

                    subSportParametersSetList.Add(subSportParametersSet);
                }
                {
                    CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet subSportParametersSet = new CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet(9, 9, null, subSport);

                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("12", 3, "及格"));
                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("15", 5, "优秀"));

                    subSportParametersSetList.Add(subSportParametersSet);
                }
                {
                    CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet subSportParametersSet = new CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet(10, 10, null, subSport);

                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("14", 3, "及格"));
                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("17", 5, "优秀"));

                    subSportParametersSetList.Add(subSportParametersSet);
                }
                {
                    CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet subSportParametersSet = new CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet(11, 12, null, subSport);

                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("16", 3, "及格"));
                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("19", 5, "优秀"));

                    subSportParametersSetList.Add(subSportParametersSet);
                }
            }

            {
                CertainSportAbilityTestEvaluationCriteriaSubSport subSport = new CertainSportAbilityTestEvaluationCriteriaSubSport("Expressiveness", "表现力", null, CertainSportAbilityTestDataType.Characters, CertainSportAbilityTestComparePattern.Equal, sport);

                subSportList.Add(subSport);

                {
                    CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet subSportParametersSet = new CertainSportAbilityTestEvaluationCriteriaSubSportParametersSet(8, 12, null, subSport);

                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("仅能表达出主题", 3, "及格"));
                    subSportParametersSet.Parameters.Add(new CertainSportAbilityTestEvaluationCriteriaSubSportParameter("具有较强的感染力", 5, "优秀"));

                    subSportParametersSetList.Add(subSportParametersSet);
                }
            }

            using (var context = new ComputingServicesContext())
            {
                var existsSport = context.CertainSportAbilityTestEvaluationCriteriaSports.SingleOrDefault(item => item.Code == sportCode);
                if (existsSport != null)
                {
                    context.CertainSportAbilityTestEvaluationCriteriaSports.Remove(existsSport);
                }

                context.CertainSportAbilityTestEvaluationCriteriaSports.Add(sport);
                context.CertainSportAbilityTestEvaluationCriteriaSubSports.AddRange(subSportList);
                context.CertainSportAbilityTestEvaluationCriteriaSubSportParametersSets.AddRange(subSportParametersSetList);
                context.SaveChanges();
            }
        }
Exemple #7
0
        protected void btnImportPersonalityTestElementStandardParametersSet_Click(object sender, EventArgs e)
        {
            List <PersonalityTestElementStandardParametersSet> parametersSetList = new List <PersonalityTestElementStandardParametersSet>();

            string dataDirectoryPath = MapPath("~/App_Data/PersonalityTest");

            string[] dataFilePaths = Directory.GetFiles(dataDirectoryPath, "ElementStandardParametersSet*.xml");

            foreach (string dataFilePath in dataFilePaths)
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(dataFilePath);

                XmlElement xeElementStandardParametersSet = (XmlElement)xd.SelectSingleNode("ElementStandardParametersSet");
                string     name   = xeElementStandardParametersSet.GetAttribute("Name");
                int        ageMin = int.Parse(xeElementStandardParametersSet.GetAttribute("AgeMin"));
                int        ageMax = int.Parse(xeElementStandardParametersSet.GetAttribute("AgeMax"));
                Core.Domain.Models.Shared.Gender gender = (Core.Domain.Models.Shared.Gender)Enum.Parse(typeof(Core.Domain.Models.Shared.Gender), xeElementStandardParametersSet.GetAttribute("Gender"));

                PersonalityTestElementStandardParametersSet parametersSet = new PersonalityTestElementStandardParametersSet(name, ageMin, ageMax, gender);

                foreach (XmlNode xnParameter in xeElementStandardParametersSet.SelectNodes("Parameter"))
                {
                    XmlElement xeParameter = (XmlElement)xnParameter;

                    string             parameterElement = xeParameter.GetAttribute("Element");
                    PersonalityElement element          = (PersonalityElement)Enum.Parse(typeof(PersonalityElement), parameterElement);
                    decimal            parameterX       = decimal.Parse(xeParameter.GetAttribute("X"));
                    decimal            parameterS       = decimal.Parse(xeParameter.GetAttribute("S"));

                    PersonalityTestElementStandardParameter elementStandardParameter = new PersonalityTestElementStandardParameter(element, parameterX, parameterS);

                    foreach (XmlNode xnSegment in xeParameter.SelectNodes("Segment"))
                    {
                        XmlElement xeSegment = (XmlElement)xnSegment;

                        int originalScoreMin = int.Parse(xeSegment.GetAttribute("OriginalScoreMin"));
                        int originalScoreMax = int.Parse(xeSegment.GetAttribute("OriginalScoreMax"));
                        int standardScore    = int.Parse(xeSegment.GetAttribute("StandardScore"));

                        PersonalityTestElementStandardParameterSegment parameterSegment = new PersonalityTestElementStandardParameterSegment(originalScoreMin, originalScoreMax, standardScore);

                        elementStandardParameter.Segments.Add(parameterSegment);
                    }

                    parametersSet.Parameters.Add(elementStandardParameter);
                }

                parametersSetList.Add(parametersSet);
            }

            if (parametersSetList.Count > 0)
            {
                using (var context = new ComputingServicesContext())
                {
                    foreach (var parametersSet in parametersSetList)
                    {
                        var oldPersonalityTestElementStandardParametersSet = context.PersonalityTestElementStandardParametersSets.Where(item => item.AgeMin == parametersSet.AgeMin && item.AgeMax == parametersSet.AgeMax).ToList().SingleOrDefault(item => item.Gender == parametersSet.Gender);
                        if (oldPersonalityTestElementStandardParametersSet != null)
                        {
                            context.PersonalityTestElementStandardParametersSets.Remove(oldPersonalityTestElementStandardParametersSet);
                        }
                        context.PersonalityTestElementStandardParametersSets.Add(parametersSet);
                    }
                    context.SaveChanges();
                }

                ltlLog.Text = "成功完成。";
            }
            else
            {
                ltlLog.Text = "没有数据。";
            }
        }
Exemple #8
0
        protected void btnImportPersonalityTestQuestionsSet_Click(object sender, EventArgs e)
        {
            var questionsSetList = new List <PersonalityTestQuestionsSet>();

            string dataDirectoryPath = MapPath("~/App_Data/PersonalityTest");

            string[] dataFilePaths = Directory.GetFiles(dataDirectoryPath, "QuestionsSet*.xml");
            foreach (string dataFilePath in dataFilePaths)
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(dataFilePath);

                XmlElement xeQuestionsSet   = (XmlElement)xd.SelectSingleNode("QuestionsSet");
                string     questionsSetCode = xeQuestionsSet.GetAttribute("Code");

                PersonalityTestQuestionsSet questionsSet = new PersonalityTestQuestionsSet(questionsSetCode);

                foreach (XmlNode xnQuestion in xeQuestionsSet.SelectNodes("Question"))
                {
                    XmlElement xeQuestion = (XmlElement)xnQuestion;

                    int                questionCode    = int.Parse(xeQuestion.GetAttribute("Code"));
                    string             questionElement = xeQuestion.GetAttribute("Element");
                    PersonalityElement element         = (PersonalityElement)Enum.Parse(typeof(PersonalityElement), questionElement);

                    PersonalityTestQuestion question = new PersonalityTestQuestion(questionCode, element);

                    foreach (XmlNode xnChoiceScore in xeQuestion.SelectNodes("ChoiceScore"))
                    {
                        XmlElement xeChoiceScore = (XmlElement)xnChoiceScore;

                        string choice = xeChoiceScore.GetAttribute("Choice");
                        int    score  = int.Parse(xeChoiceScore.GetAttribute("Score"));

                        PersonalityTestQuestionChoiceScore choiceScore = new PersonalityTestQuestionChoiceScore(choice, score);
                        question.ChoiceScores.Add(choiceScore);
                    }

                    questionsSet.Questions.Add(question);
                }

                questionsSetList.Add(questionsSet);
            }

            if (questionsSetList.Count > 0)
            {
                using (var context = new ComputingServicesContext())
                {
                    foreach (var questionsSet in questionsSetList)
                    {
                        PersonalityTestQuestionsSet oldQuestionsSet = context.PersonalityTestQuestionsSets.SingleOrDefault(item => item.Code == questionsSet.Code);
                        if (oldQuestionsSet != null)
                        {
                            context.PersonalityTestQuestionsSets.Remove(oldQuestionsSet);
                        }
                        context.PersonalityTestQuestionsSets.Add(questionsSet);
                    }
                    context.SaveChanges();
                }

                ltlLog.Text = "成功完成。";
            }
            else
            {
                ltlLog.Text = "没有数据。";
            }
        }