Exemplo n.º 1
0
        public Examination Convert()
        {
            Examination examination = new Examination();

            if (ExaminationQuestion != null)
            {
                examination.ExaminationQuestions = ExaminationQuestion;
            }
            if (VoterScene != null)
            {
                foreach (var v in VoterScene)
                {
                    if (!examination.Voters.Any(k => k.VoterId == v.VoterId))
                    {
                        examination.Voters.Add(v.convert());
                    }
                }
                foreach (var v in VoterScene)
                {
                    examination.Add(v.VoterId, v.QuestionNumber, v.Select);
                }
            }

            return(examination);
        }
Exemplo n.º 2
0
        private void init()
        {
            MessageSubscribeRelations.AddSubscribe(MessageType.WSDEDataEvent, new Relation()
            {
                CanUninstall     = true,
                IsActive         = true,
                IsKeep           = false,
                RelationDescribe = Title,
                RelationGuid     = this.StrGuid,
                RelationAction   = messageData =>
                {
                    base.BindingPropInOtherTask(() =>
                    {
                        JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                        var response = javaScriptSerializer.Deserialize <WSDESubVoterSelectRequest>(messageData.MessageData);
                        if (!Start)
                        {
                            StudentLogin(response);
                            return;
                        }
                        StudentLogin(response);
                        if (String.IsNullOrWhiteSpace(response.SubVoterResult) || response.SubVoterResult.Equals("login"))
                        {
                            return;
                        }
                        if (!StudentList.Any(k => k.StudentNumber == response.SubVoterNumber) && RefuseOutOfStudentList)
                        {
                            return;
                        }
                        response.SubVoterResult = response.SubVoterResult.Replace(".", "");
                        response.SubVoterResult = StringUtils.RemoveDuplicateCharacters(response.SubVoterResult);
                        var number = System.Convert.ToInt32(response.SubVoterSelectNumber);
                        examination.Add(response.SubVoterNumber, number, response.SubVoterResult);
                        if (QuestionList.Any(k => k.QuestionNumber == response.SubVoterSelectNumber))
                        {
                            QuestionList.First(k => k.QuestionNumber == response.SubVoterSelectNumber).Set(examination.ExaminationQuestions.First(k => k.QuestionNumber == number));
                        }
                        if (!StudentList.Any(k => k.StudentNumber == response.SubVoterNumber) && examination.Voters != null && examination.Voters.Count() > 0)
                        {
                            StudentVM studentNM = new StudentVM();
                            studentNM.Set(examination.Voters.First(k => k.VoterId == response.SubVoterNumber));
                            StudentList.Add(studentNM);
                        }
                        if (examination.Voters != null && examination.Voters.Count() > 0)
                        {
                            StudentList.First(k => k.StudentNumber == response.SubVoterNumber).Set(examination.Voters.First(k => k.VoterId == response.SubVoterNumber));
                        }

                        base.ViewChange();
                    });
                },
            });
        }