示例#1
0
        internal DatabaseQueries GenerateSubSectionsTable(DataProviders provider)
        {
            SubSection subsection = null;
            bool       found      = false;

            foreach (Questionaire qn in _questionaires.Where(c => c is Questionaire).Cast <Questionaire>())
            {
                foreach (Section section in qn.Sections)
                {
                    var hasSubSections = section.SubSections.Count > 0;
                    if (!hasSubSections)
                    {
                        continue;
                    }

                    subsection = section.SubSections[0];
                    found      = true;
                    break;
                }
                if (found)
                {
                    break;
                }
            }

            if (subsection == null)
            {
                return(null);
            }

            DatabaseQueries databaseQueries = subsection.GenerateTableScript("dsto_subsections", provider);

            return(databaseQueries);
        }
示例#2
0
        public override void ReadJson(JObject obj)
        {
            base.ReadJson(obj);
            if (obj["Name"] != null && ((JValue)obj["Name"]).Value != null)
            {
                Name = ((JValue)obj["Name"]).Value.ToString();
            }
            if (obj["Description"] != null && ((JValue)obj["Description"]).Value != null)
            {
                Description = ((JValue)obj["Description"]).Value.ToString();
            }
            if (obj["QuestionaireKey"] != null && ((JValue)obj["QuestionaireKey"]).Value != null)
            {
                QuestionaireKey = ((JValue)obj["QuestionaireKey"]).Value.ToString();
            }
            if (obj["Deleted"] != null && ((JValue)obj["Deleted"]).Value != null)
            {
                Deleted = bool.Parse(((JValue)obj["Deleted"]).Value.ToString());
            }

            if (obj["SubSections"] != null)
            {
                JArray subSectionsObjs = JArray.FromObject(obj["SubSections"]);
                if (subSectionsObjs != null)
                {
                    this.SubSections.Clear();
                    foreach (JObject cobj in subSectionsObjs)
                    {
                        SubSection subSection = SubSections.Add();
                        subSection.ReadJson(cobj);
                    }
                }
            }

            if (obj["Questions"] != null)
            {
                JArray questionsObjs = JArray.FromObject(obj["Questions"]);
                if (questionsObjs != null)
                {
                    this.Questions.Clear();
                    foreach (JObject cobj in questionsObjs)
                    {
                        QuestionTypes questionType = QuestionTypes.None;
                        if (cobj["QuestionType"] != null && ((JValue)cobj["QuestionType"]).Value != null)
                        {
                            questionType = (QuestionTypes)Enum.Parse(typeof(QuestionTypes), ((JValue)cobj["QuestionType"]).Value.ToString());
                        }
                        Question question = Questions.Add(questionType);
                        if (question != null)
                        {
                            question.ReadJson(cobj);
                        }
                    }
                }
            }

            ObjectState = ObjectStates.None;
            SetOriginal();
        }
示例#3
0
 internal override void SetOriginal()
 {
     _original = Copy() as SubSection;
 }