Пример #1
0
        private void ReadExtraQuestion(XElement e)
        {
            var cnt = setting.AskItems.Count(vv => vv.IsAskExtraQuestions);

            if (ExtraQuestion == null)
            {
                ExtraQuestion = new List <Dictionary <string, string> >();
                for (var n = 0; n < cnt; n++)
                {
                    ExtraQuestion.Add(new Dictionary <string, string>());
                }
            }
            var eqsetattr = e.Attribute("set");

            if (eqsetattr != null)
            {
                eqset = eqsetattr.Value.ToInt();
            }

            if (ExtraQuestion.Count <= eqset)
            {
                ExtraQuestion.Add(new Dictionary <string, string>());
            }

            var eq = e.Attribute("question");

            if (eq != null)
            {
                ExtraQuestion[eqset].Add(eq.Value, e.Value);
            }
        }
Пример #2
0
        private void PopulateExtraAnswers(OrganizationMember om, Ask ask)
        {
            FetchQuestionsAnswersList(om);

            if (ExtraQuestion == null)
            {
                ExtraQuestion = new List <Dictionary <string, string> >();
            }

            var eq = new Dictionary <string, string>();

            ExtraQuestion.Add(eq);

            foreach (var q in ((AskExtraQuestions)ask).list)
            {
                if (setting.TargetExtraValues)
                {
                    var v = person.GetExtra(q.Question);
                    if (v.HasValue())
                    {
                        eq[q.Question] = v;
                    }
                }
                else if (qlist != null)
                {
                    var v = qlist.SingleOrDefault(qq => qq.Question == q.Question && qq.Type == "question");
                    if (v != null)
                    {
                        eq[q.Question] = v.Answer;
                    }
                }
            }
        }
Пример #3
0
        public new static AskExtraQuestions ReadXml(XElement e)
        {
            var eq = new AskExtraQuestions();

            foreach (var ee in e.Elements("Question"))
            {
                eq.list.Add(ExtraQuestion.ReadXml(ee));
            }
            return(eq);
        }
Пример #4
0
        public new static AskExtraQuestions ReadXml(XElement e)
        {
            var eq = new AskExtraQuestions {
                TargetExtraValue = e.Attribute("TargetExtraValue").ToBool(),
            };

            foreach (var ee in e.Elements("Question"))
            {
                eq.list.Add(ExtraQuestion.ReadXml(ee));
            }
            return(eq);
        }
Пример #5
0
        public static AskExtraQuestions Parse(Parser parser)
        {
            var eq = new AskExtraQuestions();

            parser.lineno++;
            if (parser.curr.indent == 0)
            {
                return(eq);
            }
            var startindent = parser.curr.indent;

            while (parser.curr.indent == startindent)
            {
                var q = ExtraQuestion.Parse(parser, startindent);
                eq.list.Add(q);
            }
            return(eq);
        }
Пример #6
0
        private void ReadExtraQuestion(XElement e)
        {
            if (ExtraQuestion == null)
            {
                ExtraQuestion = new List <Dictionary <string, string> >();
            }
            var eqsetattr = e.Attribute("set");

            if (eqsetattr != null)
            {
                eqset = eqsetattr.Value.ToInt();
            }
            if (ExtraQuestion.Count == eqset)
            {
                ExtraQuestion.Add(new Dictionary <string, string>());
            }
            var eq = e.Attribute("question");

            if (eq != null)
            {
                ExtraQuestion[eqset].Add(eq.Value, e.Value);
            }
        }
Пример #7
0
        public void ReadXml(XmlReader reader)
        {
            var s = reader.ReadOuterXml();
            var x = XDocument.Parse(s);

            if (x.Root == null)
            {
                return;
            }

            var eqset   = 0;
            var menuset = 0;

            foreach (var e in x.Root.Elements())
            {
                var name = e.Name.ToString();
                switch (name)
                {
                case "FundItem":
                    if (FundItem == null)
                    {
                        FundItem = new Dictionary <int, decimal?>();
                    }
                    var fu = e.Attribute("fund");
                    if (fu != null)
                    {
                        FundItem.Add(fu.Value.ToInt(), e.Value.ToDecimal());
                    }
                    break;

                case "FamilyAttend":
                    var fa = new FamilyAttendInfo();
                    fa.PeopleId  = GetAttr(e, "PeopleId").ToInt2();
                    fa.Attend    = GetAttr(e, "Attend").ToBool();
                    fa.Name      = GetAttr(e, "Name");
                    fa.Birthday  = GetAttr(e, "Birthday");
                    fa.Email     = GetAttr(e, "Email");
                    fa.MaritalId = GetAttr(e, "MaritalId").ToInt2();
                    fa.GenderId  = GetAttr(e, "GenderId").ToInt2();
                    if (FamilyAttend == null)
                    {
                        FamilyAttend = new List <FamilyAttendInfo>();
                    }
                    FamilyAttend.Add(fa);
                    break;

                case "ExtraQuestion":
                    if (ExtraQuestion == null)
                    {
                        ExtraQuestion = new List <Dictionary <string, string> >();
                    }
                    var eqsetattr = e.Attribute("set");
                    if (eqsetattr != null)
                    {
                        eqset = eqsetattr.Value.ToInt();
                    }
                    if (ExtraQuestion.Count == eqset)
                    {
                        ExtraQuestion.Add(new Dictionary <string, string>());
                    }
                    var eq = e.Attribute("question");
                    if (eq != null)
                    {
                        ExtraQuestion[eqset].Add(eq.Value, e.Value);
                    }
                    break;

                case "YesNoQuestion":
                    if (YesNoQuestion == null)
                    {
                        YesNoQuestion = new Dictionary <string, bool?>();
                    }
                    var ynq = e.Attribute("question");
                    if (ynq != null)
                    {
                        YesNoQuestion.Add(ynq.Value, e.Value.ToBool());
                    }
                    break;

                case "option":
                    if (option == null)
                    {
                        option = new List <string>();
                    }
                    option.Add(e.Value);
                    break;

                case "Checkbox":
                    if (Checkbox == null)
                    {
                        Checkbox = new List <string>();
                    }
                    Checkbox.Add(e.Value);
                    break;

                case "MenuItem":
                    if (MenuItem == null)
                    {
                        MenuItem = new List <Dictionary <string, int?> >();
                    }
                    var menusetattr = e.Attribute("set");
                    if (menusetattr != null)
                    {
                        menuset = menusetattr.Value.ToInt();
                    }
                    if (MenuItem.Count == menuset)
                    {
                        MenuItem.Add(new Dictionary <string, int?>());
                    }
                    var aname  = e.Attribute("name");
                    var number = e.Attribute("number");
                    if (aname != null && number != null)
                    {
                        MenuItem[menuset].Add(aname.Value, number.Value.ToInt());
                    }
                    break;

                case "MissionTripPray":
                    MissionTripPray = e.Value.ToBool();
                    break;

                case "MissionTripGoerId":
                    MissionTripGoerId = e.Value.ToInt();
                    break;

                case "CreatingAccount":
                    CreatingAccount = e.Value.ToBool();
                    break;

                default:
                    Util.SetPropertyFromText(this, TranslateName(name), e.Value);
                    break;
                }
            }
        }
Пример #8
0
        public void PopulateRegistrationFromDb(OrganizationMember om)
        {
            var reg = person.RecRegs.SingleOrDefault();

            if (reg == null)
            {
                reg = new RecReg();
                person.RecRegs.Add(reg);
            }
            foreach (var ask in setting.AskItems)
            {
                switch (ask.Type)
                {
                case "AskSize":
                    shirtsize = om.ShirtSize;
                    break;

                case "AskChurch":
                    otherchurch = reg.ActiveInAnotherChurch ?? false;
                    memberus    = reg.Member ?? false;
                    break;

                case "AskAllergies":
                    medical = reg.MedicalDescription;
                    break;

                case "AskParents":
                    mname = reg.Mname;
                    fname = reg.Fname;
                    break;

                case "AskEmContact":
                    emcontact = reg.Emcontact;
                    emphone   = reg.Emphone;
                    break;

                case "AskTylenolEtc":
                    tylenol    = reg.Tylenol;
                    advil      = reg.Advil;
                    robitussin = reg.Robitussin;
                    maalox     = reg.Maalox;
                    break;

                case "AskDoctor":
                    docphone = reg.Docphone;
                    doctor   = reg.Doctor;
                    break;

                case "AskCoaching":
                    coaching = reg.Coaching;
                    break;

                //                    case "AskSMS":
                //                        sms = person.ReceiveSMS;
                //                        break;
                case "AskInsurance":
                    insurance = reg.Insurance;
                    policy    = reg.Policy;
                    break;

                case "AskTickets":
                    ntickets = om.Tickets;
                    break;

                case "AskYesNoQuestions":
                    if (setting.TargetExtraValues == false)
                    {
                        foreach (var yn in ((AskYesNoQuestions)ask).list)
                        {
                            {
                                if (om.IsInGroup("Yes:" + yn.SmallGroup))
                                {
                                    YesNoQuestion[yn.SmallGroup] = true;
                                }
                                if (om.IsInGroup("No:" + yn.SmallGroup))
                                {
                                    YesNoQuestion[yn.SmallGroup] = false;
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (var yn in ((AskYesNoQuestions)ask).list)
                        {
                            if (person.GetExtra(yn.SmallGroup) == "Yes")
                            {
                                YesNoQuestion[yn.SmallGroup] = true;
                            }
                            if (person.GetExtra(yn.SmallGroup) == "No")
                            {
                                YesNoQuestion[yn.SmallGroup] = false;
                            }
                        }
                    }
                    break;

                case "AskCheckboxes":
                    if (setting.TargetExtraValues)
                    {
                        foreach (var ck in ((AskCheckboxes)ask).list)
                        {
                            if (person.GetExtra(ck.SmallGroup).ToBool())
                            {
                                Checkbox.Add(ck.SmallGroup);
                            }
                        }
                    }
                    else
                    {
                        foreach (var ck in ((AskCheckboxes)ask).list)
                        {
                            if (om.IsInGroup(ck.SmallGroup))
                            {
                                Checkbox.Add(ck.SmallGroup);
                            }
                        }
                    }
                    break;

                case "AskExtraQuestions":
                    if (ExtraQuestion == null)
                    {
                        ExtraQuestion = new List <Dictionary <string, string> >();
                    }
                    var eq = new Dictionary <string, string>();
                    ExtraQuestion.Add(eq);
                    var lines = (om.UserData ?? "").Split('\n');
                    foreach (var q in ((AskExtraQuestions)ask).list)
                    {
                        if (setting.TargetExtraValues)
                        {
                            var v = person.GetExtra(q.Question);
                            if (v.HasValue())
                            {
                                eq[q.Question] = v;
                            }
                        }
                        else
                        {
                            var v = (from li in lines
                                     where li.StartsWith(q.Question + ": ")
                                     select li.Substring(q.Question.Length + 2)).FirstOrDefault();
                            if (v.HasValue())
                            {
                                eq[q.Question] = v;
                            }
                        }
                    }
                    break;

                case "AskText":
                    if (Text == null)
                    {
                        Text = new List <Dictionary <string, string> >();
                    }
                    var tx = new Dictionary <string, string>();
                    Text.Add(tx);
                    lines = (om.UserData ?? "").Split('\n');
                    foreach (var q in ((AskText)ask).list)
                    {
                        if (setting.TargetExtraValues)
                        {
                            var v = person.GetExtra(q.Question);
                            if (v.HasValue())
                            {
                                tx[q.Question] = v;
                            }
                        }
                        else
                        {
                            var sb = new StringBuilder();
                            var i  = 0;
                            for (; i < lines.Length; i++)
                            {
                                if (lines[i] == q.Question + ":")
                                {
                                    break;
                                }
                            }
                            for (i++; i < lines.Length; i++)
                            {
                                if (lines[i].Length == 0 || lines[i][0] != '\t')
                                {
                                    break;
                                }
                                sb.AppendLine(lines[i].Substring(1));
                            }
                            if (sb.Length > 0)
                            {
                                tx[q.Question] = sb.ToString();
                            }
                        }
                    }
                    break;

                case "AskMenu":
                    //                        foreach (var i in MenuItem)
                    //                            om.AddToGroup(DbUtil.Db, i.Key, i.Value);
                    //                        {
                    //                            var menulabel = "Menu Items";
                    //                            foreach (var i in ((AskMenu)ask).MenuItemsChosen(MenuItem))
                    //                            {
                    //                                om.AddToMemberData(menulabel);
                    //                                string desc;
                    //                                if (i.amt > 0)
                    //                                    desc = "{0} {1} (at {2:N2})".Fmt(i.number, i.desc, i.amt);
                    //                                else
                    //                                    desc = "{0} {1}".Fmt(i.number, i.desc);
                    //                                om.AddToMemberData(desc);
                    //                                menulabel = string.Empty;
                    //                            }
                    //                        }
                    break;

                case "AskDropdown":
                    if (option == null)
                    {
                        option = new List <string>();
                    }
                    if (setting.TargetExtraValues)
                    {
                        foreach (var dd in ((AskDropdown)ask).list)
                        {
                            if (person.GetExtra(dd.SmallGroup) == "true")
                            {
                                option.Add(dd.SmallGroup);
                            }
                        }
                    }
                    else
                    {
                        foreach (var dd in ((AskDropdown)ask).list)
                        {
                            if (om.IsInGroup(dd.SmallGroup))
                            {
                                option.Add(dd.SmallGroup);
                            }
                        }
                    }
                    break;

                case "AskGradeOptions":
                    gradeoption = person.Grade.ToString();
                    if (!setting.TargetExtraValues)
                    {
                        gradeoption = om.Grade.ToString();
                    }
                    break;
                }
            }
            //            if (setting.TargetExtraValues)
            //            {
            //                foreach (var ag in setting.AgeGroups)
            //                    person.RemoveExtraValue(DbUtil.Db, ag.SmallGroup);
            //                if (setting.AgeGroups.Count > 0)
            //                    person.AddEditExtraValue(AgeGroup(), "true");
            //            }
            //            else
            //            {
            //                foreach (var ag in setting.AgeGroups)
            //                    om.RemoveFromGroup(DbUtil.Db, ag.SmallGroup);
            //                if (setting.AgeGroups.Count > 0)
            //                    om.AddToGroup(DbUtil.Db, AgeGroup());
            //            }
        }
Пример #9
0
        public void ReadXml(XmlReader reader)
        {
            var s = reader.ReadOuterXml();
            var x = XDocument.Parse(s);

            if (x.Root == null)
            {
                return;
            }

            var eqset = 0;

            foreach (var e in x.Root.Elements())
            {
                var name = e.Name.ToString();
                switch (name)
                {
                case "FundItem":
                    if (FundItem == null)
                    {
                        FundItem = new Dictionary <int, decimal?>();
                    }
                    var fu = e.Attribute("fund");
                    if (fu != null)
                    {
                        FundItem.Add(fu.Value.ToInt(), e.Value.ToDecimal());
                    }
                    break;

                case "ExtraQuestion":
                    if (ExtraQuestion == null)
                    {
                        ExtraQuestion = new List <Dictionary <string, string> >();
                    }
                    var eqsetattr = e.Attribute("set");
                    if (eqsetattr != null)
                    {
                        eqset = eqsetattr.Value.ToInt();
                    }
                    if (ExtraQuestion.Count == eqset)
                    {
                        ExtraQuestion.Add(new Dictionary <string, string>());
                    }
                    var eq = e.Attribute("question");
                    if (eq != null)
                    {
                        ExtraQuestion[eqset].Add(eq.Value, e.Value);
                    }
                    break;

                case "YesNoQuestion":
                    if (YesNoQuestion == null)
                    {
                        YesNoQuestion = new Dictionary <string, bool?>();
                    }
                    var ynq = e.Attribute("question");
                    if (ynq != null)
                    {
                        YesNoQuestion.Add(ynq.Value, e.Value.ToBool());
                    }
                    break;

                case "option":
                    if (option == null)
                    {
                        option = new List <string>();
                    }
                    option.Add(e.Value);
                    break;

                case "Checkbox":
                    if (Checkbox == null)
                    {
                        Checkbox = new List <string>();
                    }
                    Checkbox.Add(e.Value);
                    break;

                case "MenuItem":
                    if (MenuItem == null)
                    {
                        MenuItem = new Dictionary <string, int?>();
                    }
                    var aname  = e.Attribute("name");
                    var number = e.Attribute("number");
                    if (aname != null && number != null)
                    {
                        MenuItem.Add(aname.Value, number.Value.ToInt());
                    }
                    break;

                default:
                    Util.SetPropertyFromText(this, name, e.Value);
                    break;
                }
            }
        }