public Settings(string s, CMSDataContext Db, int OrgId) : this() { this.Db = Db; this.OrgId = OrgId; org = Db.LoadOrganizationById(OrgId); var parser = new Parser(s); while (parser.NextSection()) { ParseSection(parser); } SetUniqueIds("AskDropdown"); SetUniqueIds("AskExtraQuestions"); SetUniqueIds("AskCheckboxes"); SetUniqueIds("AskText"); SetUniqueIds("AskMenu"); var sglist = new List <string>(); AskItems.ForEach(a => sglist.AddRange(a.SmallGroups())); var q = sglist.GroupBy(mi => mi).Where(g => g.Count() > 1).Select(g => g.Key).ToList(); if (q.Any()) { throw parser.GetException("Duplicate SmallGroup: " + string.Join(",", q)); } parser.data = null; }
private void SetUniqueIds(string t) { var n = 0; foreach (var dd in AskItems.Where(aa => aa.Type == t)) { dd.UniqueId = n++; } }
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"); }
private AskSize asksize; // To support old Registration Documents void ParseSection(Parser parser) { switch (parser.curr.kw) { case Parser.RegKeywords.AskParents: case Parser.RegKeywords.AnswersNotRequired: case Parser.RegKeywords.AskSMS: case Parser.RegKeywords.AskDoctor: case Parser.RegKeywords.AskInsurance: case Parser.RegKeywords.AskEmContact: case Parser.RegKeywords.AskAllergies: case Parser.RegKeywords.AskChurch: case Parser.RegKeywords.AskTylenolEtc: case Parser.RegKeywords.AskCoaching: AskItems.Add(Ask.ParseAsk(parser)); break; case Parser.RegKeywords.SpecialScript: SpecialScript = parser.GetString(); break; case Parser.RegKeywords.AskSuggestedFee: AskItems.Add(AskSuggestedFee.Parse(parser)); break; case Parser.RegKeywords.AskTickets: AskItems.Add(AskTickets.Parse(parser)); break; case Parser.RegKeywords.AskRequest: AskItems.Add(AskRequest.Parse(parser)); break; case Parser.RegKeywords.AskHeader: AskItems.Add(AskHeader.Parse(parser)); break; case Parser.RegKeywords.AskInstruction: AskItems.Add(AskInstruction.Parse(parser)); break; case Parser.RegKeywords.Dropdown: case Parser.RegKeywords.AskOptions: case Parser.RegKeywords.ExtraOptions: case Parser.RegKeywords.Dropdown1: case Parser.RegKeywords.Dropdown2: case Parser.RegKeywords.Dropdown3: AskItems.Add(AskDropdown.Parse(parser)); break; case Parser.RegKeywords.MenuItems: AskItems.Add(AskMenu.Parse(parser)); break; case Parser.RegKeywords.ExtraQuestions: AskItems.Add(AskExtraQuestions.Parse(parser)); break; case Parser.RegKeywords.Text: AskItems.Add(AskText.Parse(parser)); break; case Parser.RegKeywords.Checkboxes: case Parser.RegKeywords.Checkboxes2: AskItems.Add(AskCheckboxes.Parse(parser)); break; case Parser.RegKeywords.YesNoQuestions: AskItems.Add(AskYesNoQuestions.Parse(parser)); break; case Parser.RegKeywords.AskGradeOptions: case Parser.RegKeywords.GradeOptions: AskItems.Add(AskGradeOptions.Parse(parser)); break; case Parser.RegKeywords.AskSize: AskItems.Add(AskSize.Parse(parser)); break; case Parser.RegKeywords.MemberOnly: MemberOnly = parser.GetBool(); break; case Parser.RegKeywords.AskMedical: parser.GetBool(); break; case Parser.RegKeywords.AskDonation: AskDonation = parser.GetBool(); break; case Parser.RegKeywords.NoReqBirthYear: NoReqBirthYear = parser.GetBool(); break; case Parser.RegKeywords.NotReqDOB: NotReqDOB = parser.GetBool(); break; case Parser.RegKeywords.NotReqAddr: NotReqAddr = parser.GetBool(); break; case Parser.RegKeywords.NotReqPhone: NotReqPhone = parser.GetBool(); break; case Parser.RegKeywords.NotReqGender: NotReqGender = parser.GetBool(); break; case Parser.RegKeywords.NotReqMarital: NotReqMarital = parser.GetBool(); break; case Parser.RegKeywords.NotReqZip: NotReqZip = parser.GetBool(); break; case Parser.RegKeywords.DonationFundId: DonationFundId = parser.GetNullInt(); break; case Parser.RegKeywords.AccountingCode: AccountingCode = parser.GetString(); break; case Parser.RegKeywords.DonationLabel: DonationLabel = parser.GetString(); break; case Parser.RegKeywords.ExtraValueFeeName: ExtraValueFeeName = parser.GetString(); break; case Parser.RegKeywords.GroupToJoin: GroupToJoin = parser.GetString(); break; case Parser.RegKeywords.AddAsProspect: AddAsProspect = parser.GetBool(); break; case Parser.RegKeywords.LinkGroupsFromOrgs: LinkGroupsFromOrgs = (from i in parser.curr.value.Split(',') where i.ToInt() > 0 select i.ToInt()).ToList(); parser.lineno++; break; case Parser.RegKeywords.ValidateOrgs: ValidateOrgs = parser.curr.value; parser.lineno++; break; case Parser.RegKeywords.Terms: ParseTerms(parser); break; case Parser.RegKeywords.Instructions: ParseInstructions(parser); break; case Parser.RegKeywords.Confirmation: ParseConfirmation(parser); break; case Parser.RegKeywords.ConfirmationTrackingCode: ParseTrackingCode(parser); break; case Parser.RegKeywords.Reminder: ParseReminder(parser); break; case Parser.RegKeywords.SupportEmail: ParseSupport(parser); break; case Parser.RegKeywords.SenderEmail: ParseSender(parser); break; case Parser.RegKeywords.AgeGroups: ParseAgeGroups(parser); break; case Parser.RegKeywords.OrgMemberFees: case Parser.RegKeywords.OrgFees: OrgFees = OrgFees.Parse(parser); break; case Parser.RegKeywords.VoteTags: ParseVoteTags(parser); break; case Parser.RegKeywords.Title: Title = parser.GetString(); break; case Parser.RegKeywords.Shell: Shell = parser.GetString(); break; case Parser.RegKeywords.ShellBs: ShellBs = parser.GetString(); break; case Parser.RegKeywords.Fee: Fee = parser.GetDecimal(); break; // BEGIN support for old Registration Documents case Parser.RegKeywords.GiveOrgMembAccess: parser.GetBool(); break; case Parser.RegKeywords.UseBootstrap: parser.GetBool(); break; case Parser.RegKeywords.AskGrade: parser.GetBool(); parser.GetLabel("Grade"); break; case Parser.RegKeywords.AskShirtSize: parser.GetBool(); asksize = new AskSize(); AskItems.Add(asksize); break; case Parser.RegKeywords.ShirtSizes: asksize.list = AskSize.ParseShirtSizes(parser); break; case Parser.RegKeywords.AllowLastYearShirt: asksize.AllowLastYear = parser.GetBool(); break; case Parser.RegKeywords.ShirtFee: if (asksize == null) { asksize = new AskSize(); AskItems.Add(asksize); } asksize.Fee = parser.GetDecimal(); break; // END support for old Registration Documents case Parser.RegKeywords.Deposit: Deposit = parser.GetDecimal(); break; case Parser.RegKeywords.ExtraFee: ExtraFee = parser.GetDecimal(); break; case Parser.RegKeywords.MaximumFee: MaximumFee = parser.GetDecimal(); break; case Parser.RegKeywords.AllowOnlyOne: AllowOnlyOne = parser.GetBool(); break; case Parser.RegKeywords.OtherFeesAdded: case Parser.RegKeywords.OtherFeesAddedToOrgFee: OtherFeesAddedToOrgFee = parser.GetBool(); break; case Parser.RegKeywords.IncludeOtherFeesWithDeposit: IncludeOtherFeesWithDeposit = parser.GetBool(); break; case Parser.RegKeywords.ApplyMaxToOtherFees: ApplyMaxToOtherFees = parser.GetBool(); break; case Parser.RegKeywords.AllowReRegister: AllowReRegister = parser.GetBool(); break; case Parser.RegKeywords.AllowSaveProgress: AllowSaveProgress = parser.GetBool(); break; case Parser.RegKeywords.TargetExtraValues: TargetExtraValues = parser.GetBool(); break; case Parser.RegKeywords.TimeSlotLockDays: TimeSlotLockDays = parser.GetNullInt(); break; case Parser.RegKeywords.TimeSlots: TimeSlots = TimeSlots.Parse(parser); if (TimeSlotLockDays.HasValue) { TimeSlots.TimeSlotLockDays = TimeSlotLockDays; } break; } }