Exemplo n.º 1
0
        private void ParseAgeGroups(Parser parser)
        {
            parser.lineno++;
            if (parser.curr.indent == 0)
            {
                return;
            }
            var startindent = parser.curr.indent;

            while (parser.curr.indent == startindent)
            {
                var agegroup = new AgeGroup();
                if (parser.curr.kw != Parser.RegKeywords.None)
                {
                    throw parser.GetException("unexpected line");
                }
                agegroup.SmallGroup = parser.GetLine();
                var m = parser.agerange.Match(agegroup.SmallGroup);
                if (!m.Success)
                {
                    parser.lineno--;
                    throw parser.GetException("expected age range like 0-12");
                }
                agegroup.StartAge = m.Groups["start"].Value.ToInt();
                agegroup.EndAge   = m.Groups["end"].Value.ToInt();
                if (parser.curr.indent <= startindent)
                {
                    throw parser.GetException("expected either indented SmallGroup or Fee");
                }
                var ind = parser.curr.indent;
                while (parser.curr.indent == ind)
                {
                    switch (parser.curr.kw)
                    {
                    case Parser.RegKeywords.SmallGroup:
                        agegroup.SmallGroup = parser.GetString(agegroup.SmallGroup);
                        break;

                    case Parser.RegKeywords.Fee:
                        agegroup.Fee = parser.GetDecimal();
                        break;

                    default:
                        throw parser.GetException("unexpected line");
                    }
                }
                AgeGroups.Add(agegroup);
            }
        }
Exemplo n.º 2
0
        public void ReadXml(XmlReader reader)
        {
            var xd = XDocument.Load(reader);

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

            foreach (var e in xd.Root.Elements())
            {
                var name = e.Name.ToString();
                switch (name)
                {
                case "Confirmation":
                    Subject = e.Element("Subject")?.Value;
                    Body    = e.Element("Body")?.Value;
                    break;

                case "Reminder":
                    ReminderSubject = e.Element("Subject")?.Value;
                    ReminderBody    = e.Element("Body")?.Value;
                    break;

                case "SupportEmail":
                    SupportSubject = e.Element("Subject")?.Value;
                    SupportBody    = e.Element("Body")?.Value;
                    break;

                case "SenderEmail":
                    SenderSubject = e.Element("Subject")?.Value;
                    SenderBody    = e.Element("Body")?.Value;
                    break;

                case "Instructions":
                    InstructionLogin   = e.Element("Login")?.Value;
                    InstructionSelect  = e.Element("Select")?.Value;
                    InstructionFind    = e.Element("Find")?.Value;
                    InstructionOptions = e.Element("Options")?.Value;
                    InstructionSpecial = e.Element("Special")?.Value;
                    InstructionSubmit  = e.Element("Submit")?.Value;
                    InstructionSorry   = e.Element("Sorry")?.Value;
                    ThankYouMessage    = e.Element("Thanks")?.Value;
                    Terms = e.Element("Terms")?.Value;
                    break;

                case "Fees":
                    Fee                         = e.Element("Fee").ToDecimal();
                    Deposit                     = e.Element("Deposit").ToDecimal();
                    ExtraFee                    = e.Element("ExtraFee").ToDecimal();
                    MaximumFee                  = e.Element("MaximumFee").ToDecimal();
                    ApplyMaxToOtherFees         = e.Element("ApplyMaxToOtherFees").ToBool();
                    ExtraValueFeeName           = e.Element("ExtraValueFeeName")?.Value;
                    AccountingCode              = e.Element("AccountingCode")?.Value;
                    PushpayFundName             = e.Element("PushpayFundName")?.Value;
                    IncludeOtherFeesWithDeposit = e.Element("IncludeOtherFeesWithDeposit").ToBool();
                    OtherFeesAddedToOrgFee      = e.Element("OtherFeesAddedToOrgFee").ToBool();
                    AskDonation                 = e.Element("AskDonation").ToBool();
                    DonationLabel               = e.Element("DonationLabel")?.Value;
                    DonationFundId              = e.Element("DonationFundId").ToInt2();
                    break;

                case "AgeGroups":
                    if (AgeGroups == null)
                    {
                        AgeGroups = new List <AgeGroup>();
                    }
                    foreach (var ee in e.Elements("Group"))
                    {
                        AgeGroups.Add(new AgeGroup
                        {
                            StartAge   = ee.Attribute("StartAge").ToInt2() ?? 0,
                            EndAge     = ee.Attribute("EndAge").ToInt2() ?? 0,
                            Fee        = ee.Attribute("Fee").ToDecimal(),
                            SmallGroup = ee.Value
                        });
                    }
                    break;

                case "OrgFees":
                    if (OrgFees == null)
                    {
                        OrgFees = new List <OrgFee>();
                    }
                    foreach (var ee in e.Elements("Fee"))
                    {
                        OrgFees.Add(new OrgFee
                        {
                            OrgId = ee.Attribute("OrgId").ToInt2(),
                            Fee   = ee.Attribute("Fee").ToDecimal()
                        });
                    }
                    break;

                case "Options":
                    ConfirmationTrackingCode = e.Element("ConfirmationTrackingCode")?.Value;
                    ValidateOrgs             = e.Element("ValidateOrgs")?.Value;
                    Shell   = e.Element("Shell")?.Value;
                    ShellBs = e.Element("ShellBs")?.Value;
                    FinishRegistrationButton = e.Element("FinishRegistrationButton")?.Value;
                    SpecialScript            = e.Element("SpecialScript")?.Value;
                    OnEnrollScript           = e.Element("OnEnrollScript")?.Value;
                    GroupToJoin       = e.Element("GroupToJoin")?.Value;
                    TimeOut           = e.Element("TimeOut").ToInt2();
                    AllowOnlyOne      = e.Element("AllowOnlyOne").ToBool();
                    TargetExtraValues = e.Element("TargetExtraValues").ToBool();
                    AllowReRegister   = e.Element("AllowReRegister").ToBool();
                    AllowSaveProgress = e.Element("AllowSaveProgress").ToBool();
                    MemberOnly        = e.Element("MemberOnly").ToBool();
                    AddAsProspect     = e.Element("AddAsProspect").ToBool();
                    DisallowAnonymous = e.Element("DisallowAnonymous").ToBool();
                    break;

                case "NotRequired":
                    NoReqBirthYear  = e.Element("NoReqBirthYear").ToBool();
                    NotReqDOB       = e.Element("NotReqDOB").ToBool();
                    NotReqAddr      = e.Element("NotReqAddr").ToBool();
                    NotReqZip       = e.Element("NotReqZip").ToBool();
                    NotReqPhone     = e.Element("NotReqPhone").ToBool();
                    NotReqGender    = e.Element("NotReqGender").ToBool();
                    NotReqMarital   = e.Element("NotReqMarital").ToBool();
                    NotReqCampus    = e.Element("NotReqCampus").ToBool();
                    ShowDOBOnFind   = e.Element("ShowDOBOnFind").ToBool();
                    ShowPhoneOnFind = e.Element("ShowPhoneOnFind").ToBool();
                    break;

                case "TimeSlots":
                    TimeSlots = TimeSlots.ReadXml(e);
                    if (TimeSlots.TimeSlotLockDays.HasValue)
                    {
                        TimeSlotLockDays = TimeSlots.TimeSlotLockDays;
                    }
                    break;

                case "AskItems":
                    foreach (var ele in e.Elements())
                    {
                        AskItems.Add(Ask.ReadXml(ele));
                    }
                    break;
                }
            }
            SetUniqueIds("AskDropdown");
            SetUniqueIds("AskExtraQuestions");
            SetUniqueIds("AskCheckboxes");
            SetUniqueIds("AskText");
            SetUniqueIds("AskMenu");
        }