public ActionResult Lookups(string id) { var ret = AuthenticateDeveloper(); if (ret.StartsWith("!")) { return(Content($"<Lookups error=\"{ret.Substring(1)}\" />")); } if (!id.HasValue()) { return(Content("Lookups error=\"not found\">")); } var q = DbUtil.Db.ExecuteQuery <LookupController.Row>("select * from lookup." + id); var w = new APIWriter(); w.Start("Lookups"); w.Attr("name", id); foreach (var i in q) { w.Start("Lookup"); w.Attr("Id", i.Id); w.AddText(i.Description); w.End(); } w.End(); DbUtil.LogActivity("APIMeta Lookups"); return(Content(w.ToString(), "text/xml")); }
public void WriteXml(XmlWriter writer) { var w = new APIWriter(writer); writer.WriteComment(DateTime.Now.ToString()); foreach (var pi in typeof(OnlineRegModel).GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(vv => vv.CanRead && vv.CanWrite)) { switch (pi.Name) { case "List": w.Start("List"); foreach (var i in list) { Util.Serialize(i, writer); } w.End(); break; case "History": w.Start("History"); foreach (var i in History) { w.Add("item", i); } w.End(); break; case "password": break; case "testing": if (testing == true) { w.Add(pi.Name, testing); } break; case "prospect": if (prospect) { w.Add(pi.Name, prospect); } break; default: w.Add(pi.Name, pi.GetValue(this, null)); break; } } }
public void WriteXml(XmlWriter writer) { var w = new APIWriter(writer); writer.WriteComment(DateTime.Now.ToString()); foreach (PropertyInfo pi in typeof(OnlineRegModel).GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(vv => vv.CanRead && vv.CanWrite)) { Debug.WriteLine(pi.Name); switch (pi.Name) { case "List": w.Start("List"); foreach (var i in list) { Util.Serialize(i, writer); } w.End(); break; case "password": break; default: w.Add(pi.Name, pi.GetValue(this, null)); break; } } }
public ActionResult SQLView(string id) { var ret = AuthenticateDeveloper(); if (ret.StartsWith("!")) { return(Content($"<SQLView error=\"{ret.Substring(1)}\" />")); } if (!id.HasValue()) { return(Content("<SQLView error\"no view name\" />")); } try { var cmd = new SqlCommand("select * from guest." + id.Replace(" ", "")); cmd.Connection = new SqlConnection(Util.ConnectionString); cmd.Connection.Open(); var rdr = cmd.ExecuteReader(); DbUtil.LogActivity("APIMeta SQLView " + id); var w = new APIWriter(); w.Start("SQLView"); w.Attr("name", id); var read = rdr.Read(); while (read) { w.Start("row"); for (var i = 0; i < rdr.FieldCount; i++) { w.Attr(rdr.GetName(i), rdr[i].ToString()); } w.End(); read = rdr.Read(); } w.End(); return(Content(w.ToString(), "text/xml")); } catch (Exception) { return(Content($"<SQLView error=\"cannot find view guest.{id}\" />")); } }
private void WriteSpecialTest(APIWriter w) { if (SpecialTest != null) { foreach (var d in SpecialTest) { w.Start("SpecialTest"); w.Attr("key", d.Key); w.AddText(d.Value); w.End(); } } }
private void WriteYesNoChoices(APIWriter w) { if (YesNoQuestion != null && YesNoQuestion.Count > 0) { foreach (var q in YesNoQuestion) { w.Start("YesNoQuestion"); w.Attr("question", q.Key); w.AddText(q.Value.ToString()); w.End(); } } }
public override void WriteXml(APIWriter w) { if (list.Count == 0) { return; } w.Start(Type); foreach (var q in list) { w.Add("Question", q.Question); } w.End(); }
public override void WriteXml(APIWriter w) { if (list.Count == 0) { return; } w.Start(Type); foreach (var q in list) { q.WriteXml(w); } w.End(); }
private void WriteFundItems(APIWriter w) { if (FundItem != null && FundItem.Count > 0) { foreach (var f in FundItem.Where(ff => ff.Value > 0)) { w.Start("FundItem"); w.Attr("fund", f.Key); w.AddText(f.Value.Value.ToString()); w.End(); } } }
private void WriteDocumentsUpload(APIWriter w) { if (OrganizationDocument != null && OrganizationDocument.Count > 0) { foreach (var q in OrganizationDocument) { w.Start("Documents"); w.Attr("documentName", q.Key); w.AddText(q.Value.ToString()); w.End(); } } }
public override void WriteXml(APIWriter w) { if (list.Count == 0) { return; } w.Start(Type); w.Add("Label", Label); foreach (var g in list) { g.WriteXml(w); } w.End(); }
public override void WriteXml(APIWriter w) { if (list.Count == 0) { return; } w.Start(Type) .AttrIfTrue("TargetExtraValue", TargetExtraValue); foreach (var q in list) { q.WriteXml(w); } w.End(); }
public override void WriteXml(APIWriter w) { if (list.Count == 0) { return; } w.Start(Type) .Attr("Fee", Fee) .Attr("AllowLastYear", AllowLastYear) .Add("Label", Label ?? "Size"); foreach (var g in list) { g.WriteXml(w); } w.End(); }
private void WriteFamilyAttend(APIWriter w) { if (FamilyAttend != null && FamilyAttend.Count > 0) { foreach (var f in FamilyAttend) { w.Start("FamilyAttend"); w.Attr("PeopleId", f.PeopleId); w.Attr("Name", f.Name); w.Attr("Attend", f.Attend); w.Attr("Birthday", f.Birthday); w.Attr("GenderId", f.GenderId); w.Attr("MaritalId", f.MaritalId); w.End(); } } }
public string WriteXml() { var optionsAdded = false; var checkoxesAdded = false; var w = new APIWriter(); w.Start("OnlineRegPersonModel"); foreach (PropertyInfo pi in typeof(OnlineRegPersonModel0).GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(vv => vv.CanRead && vv.CanWrite)) { switch (pi.Name) { case "ExtraQuestion": WriteExtraAnswers(w); break; case "Text": WriteText(w); break; case "YesNoQuestion": WriteYesNoChoices(w); break; case "option": optionsAdded = WriteDropdownOptions(optionsAdded, w); break; case "Checkbox": checkoxesAdded = WriteCheckboxChoices(checkoxesAdded, w); break; case "MenuItem": WriteMenuChoices(w); break; default: w.Add(pi.Name, pi.GetValue(this, null)); break; } } w.End(); return(w.ToString()); }
public override void WriteXml(APIWriter w) { if (list.Count == 0) { return; } w.Start(Type) .Attr("Minimum", Minimum) .Attr("Maximum", Maximum) .Attr("Columns", Columns == 1 ? null : Columns) .AddCdata("Label", Label); foreach (var i in list) { i.WriteXml(w); } // todo: prevent duplicates w.End(); }
private void WriteExtraAnswers(APIWriter w) { if (ExtraQuestion != null) { for (var i = 0; i < ExtraQuestion.Count; i++) { if (ExtraQuestion[i] != null && ExtraQuestion[i].Count > 0) { foreach (var q in ExtraQuestion[i]) { w.Start("ExtraQuestion"); w.Attr("set", i); w.Attr("question", q.Key); w.AddText(q.Value); w.End(); } } } } }
private void WriteText(APIWriter w) { if (Text != null) { for (var i = 0; i < Text.Count; i++) { if (Text[i] != null && Text[i].Count > 0) { foreach (var q in Text[i]) { w.Start("Text"); w.Attr("set", i); w.Attr("question", q.Key); w.AddText(q.Value); w.End(); } } } } }
private void WriteMenuChoices(APIWriter w) { if (MenuItem != null) { for (var i = 0; i < MenuItem.Count; i++) { if (MenuItem[i] != null && MenuItem[i].Count > 0) { foreach (var q in MenuItem[i]) { w.Start("MenuItem"); w.Attr("set", i); w.Attr("name", q.Key); w.Attr("number", q.Value); w.End(); } } } } }
public XDocument StandardColumns(bool includeRoot = true) { var doc = new XDocument(); using (var writer = doc.CreateWriter()) { var w = new APIWriter(writer); if (includeRoot) { w.Start("CustomReports"); } w.Start("Report").Attr("name", "YourReportNameGoesHere"); if (orgid.HasValue) { w.Attr("showOnOrgId", orgid); } foreach (var c in mc.Columns.Values) { w.Start("Column").Attr("name", c.Column).End(); } var protectedevs = from value in Views.GetStandardExtraValues(db, "People") where value.VisibilityRoles.HasValue() select value.Name; var standards = (from value in Views.GetStandardExtraValues(db, "People") select value.Name).ToList(); var extravalues = from ev in db.PeopleExtras where !protectedevs.Contains(ev.Field) where (ev.UseAllValues ?? false) == false group ev by new { ev.Field, ev.Type } into g orderby g.Key.Field select g.Key; var familyextravalues = from fe in db.FamilyExtras where (fe.UseAllValues ?? false) == false group fe by new { fe.Field, fe.Type } into fv orderby fv.Key.Field select fv.Key; foreach (var ev in extravalues) { if (!Regex.IsMatch(ev.Type, @"Code|Date|Text|Int|Bit")) { continue; } w.Start("Column"); w.Attr("field", ev.Field).Attr("name", "ExtraValue" + ev.Type); if (!standards.Contains(ev.Field)) { w.Attr("disabled", "true"); } w.End(); } foreach (var fe in familyextravalues) { if (!Regex.IsMatch(fe.Type, @"Code|Date|Text|Int|Bit")) { continue; } w.Start("Column"); w.Attr("field", fe.Field).Attr("name", "FamilyExtraValue" + fe.Type); w.End(); } var statusflags = from f in db.ViewStatusFlagLists where f.RoleName == null orderby f.Name select f; foreach (var f in statusflags) { w.Start("Column") .Attr("description", f.Name) .Attr("flag", f.Flag) .Attr("name", "StatusFlag") .End(); } if (orgid.HasValue) { var specialcols = from c in mc.SpecialColumns.Values where c.Context == "org" where c.Column != "SmallGroup" select c; foreach (var c in specialcols) { w.Start("Column") .Attr("name", c.Column) .Attr("orgid", orgid) .End(); } var smallgroups = from sg in db.MemberTags where sg.OrgId == orgid orderby sg.Name select sg; foreach (var sg in smallgroups) { w.Start("Column") .Attr("smallgroup", sg.Name) .Attr("orgid", orgid) .Attr("name", "SmallGroup") .End(); } } w.End(); if (includeRoot) { w.End(); } } return(doc); }
public void WriteXml(XmlWriter writer) { var optionsAdded = false; var checkoxesAdded = false; var menuitemsAdded = false; var w = new APIWriter(writer); foreach (PropertyInfo pi in typeof(OnlineRegPersonModel).GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(vv => vv.CanRead && vv.CanWrite)) { switch (pi.Name) { case "FundItem": if (FundItem != null && FundItem.Count > 0) { foreach (var f in FundItem.Where(ff => ff.Value > 0)) { w.Start("FundItem"); w.Attr("fund", f.Key); w.AddText(f.Value.Value.ToString()); w.End(); } } break; case "ExtraQuestion": if (ExtraQuestion != null) { for (var i = 0; i < ExtraQuestion.Count; i++) { if (ExtraQuestion[i] != null && ExtraQuestion[i].Count > 0) { foreach (var q in ExtraQuestion[i]) { w.Start("ExtraQuestion"); w.Attr("set", i); w.Attr("question", q.Key); w.AddText(q.Value); w.End(); } } } } break; case "YesNoQuestion": if (YesNoQuestion != null && YesNoQuestion.Count > 0) { foreach (var q in YesNoQuestion) { w.Start("YesNoQuestion"); w.Attr("question", q.Key); w.AddText(q.Value.ToString()); w.End(); } } break; case "option": if (option != null && option.Count > 0 && !optionsAdded) { foreach (var o in option) { w.Add("option", o); } } optionsAdded = true; break; case "Checkbox": if (Checkbox != null && Checkbox.Count > 0 && !checkoxesAdded) { foreach (var c in Checkbox) { w.Add("Checkbox", c); } } checkoxesAdded = true; break; case "MenuItem": if (MenuItem != null && !menuitemsAdded) { foreach (var kv in MenuItem) { w.Start("MenuItem"); w.Attr("name", kv.Key); w.Attr("number", kv.Value); w.End(); } } menuitemsAdded = true; break; default: w.Add(pi.Name, pi.GetValue(this, null)); break; } } }
public override void WriteXml(APIWriter w) { w.Start(Type); w.AddText(Label ?? "Suggested Amount"); w.End(); }
public override void ExecuteResult(ControllerContext context) { context.HttpContext.Response.ContentType = "text/xml"; var settings = new XmlWriterSettings() { Encoding = new System.Text.UTF8Encoding(false), Indent = true }; using (var w = XmlWriter.Create(context.HttpContext.Response.OutputStream, settings)) { var x = new APIWriter(w); x.NoDefaults = true; x.Start("Attendees"); var m = new CheckInModel(); List <CheckinFamilyMember> q; if (CheckInModel.UseOldCheckin()) { q = m.FamilyMembersOld(fid, campus, thisday); } else { q = m.FamilyMembers(fid, campus, thisday); } x.Attr("familyid", fid); x.Attr("waslocked", waslocked); var count = q.Count(); if (page > 0) { const int INT_PageSize = 10; var startrow = (page - 1) * INT_PageSize; if (count > startrow + INT_PageSize) { x.Attr("next", (page + 1)); } else { x.Attr("next", ""); } if (page > 1) { x.Attr("prev", (page - 1)); } else { x.Attr("prev", ""); } q = q.Skip(startrow).Take(INT_PageSize).ToList(); } x.Attr("maxlabels", DbUtil.Db.Setting("MaxLabels", "6")); // TODO: Consider the option to numbers only. Per Braden Kok @ Granite Springs var code = DbUtil.Db.NextSecurityCode().Select(c => c.Code).Single(); x.Attr("securitycode", code); var accommodateCheckInBug = DbUtil.Db.Setting("AccommodateCheckinBug", "false").ToBool(); foreach (var c in q) { var parents = ""; if (c.Position == 30) { var child = (from e in DbUtil.Db.People where e.PeopleId == c.Id select e).SingleOrDefault(); if (child.Family.HeadOfHouseholdId != null) { parents = child.Family.HeadOfHousehold.FirstName; if (child.Family.HeadOfHouseholdSpouseId != null) { parents += " & " + child.Family.HeadOfHouseholdSpouse.FirstName; } } else if (child.Family.HeadOfHouseholdSpouseId != null) { parents = child.Family.HeadOfHouseholdSpouse.FirstName; } } double hoursBeforeClassStarts = 0; if (c.Hour.HasValue) { var midnight = c.Hour.Value.Date; var now = midnight.Add(Util.Now.TimeOfDay); hoursBeforeClassStarts = c.Hour.Value.Subtract(now).TotalHours; // TZOffset will be positive to the east, negative to the west // but we are trying to get to central time so we subtract // if tzoffset is +1 then we need to -1 to go to CentralTime. hoursBeforeClassStarts -= DbUtil.Db.Setting("TZOffset", "0").ToInt(); // now we need to make sure we are within 24 hours (ignore the date change) hoursBeforeClassStarts %= 24; } x.Start("attendee"); x.Attr("id", c.Id.ToString()); x.Attr("mv", c.MemberVisitor); x.Attr("name", c.DisplayName); x.Attr("preferredname", c.PreferredName); x.Attr("first", accommodateCheckInBug ? c.PreferredName : c.First); x.Attr("last", c.Last); x.Attr("org", c.DisplayClass); x.Attr("orgname", c.OrgName); x.Attr("leader", c.Leader); x.Attr("orgid", c.OrgId.ToString()); x.Attr("loc", c.Location); x.Attr("gender", c.Genderid); x.Attr("leadtime", hoursBeforeClassStarts.ToString()); x.Attr("age", Person.AgeDisplay(c.Age, c.Id).ToString()); x.Attr("numlabels", c.NumLabels.ToString()); x.Attr("checkedin", c.CheckedIn.ToString()); x.Attr("custody", c.Custody.ToString()); x.Attr("transport", c.Transport.ToString()); x.Attr("hour", c.Hour.FormatDateTm()); x.Attr("requiressecuritylabel", c.RequiresSecurityLabel.ToString()); x.Attr("church", c.Church); x.Attr("email", c.Email); x.Attr("dob", c.dob); x.Attr("goesby", c.Goesby); x.Attr("addr", c.Addr); x.Attr("zip", c.Zip); x.Attr("home", c.Home); x.Attr("cell", c.Cell); x.Attr("marital", c.Marital.ToString()); x.Attr("allergies", c.Allergies); x.Attr("grade", c.Grade.ToString()); x.Attr("parent", c.Parent); x.Attr("emfriend", c.Emfriend); x.Attr("emphone", c.Emphone); x.Attr("activeother", c.Activeother.ToString()); x.Attr("haspicture", c.HasPicture.ToString()); x.Attr("parents", parents); x.End(); } x.End(); } }
public void WriteXmlMessages(XmlWriter writer, Messages messages) { var w = new APIWriter(writer); w.Start("Messages"); w.Attr("id", OrgId); w.AddComment($"{Util.UserPeopleId} {Util.Now:g}"); if (messages.Confirmation) { w.Start("Confirmation") .Add("Subject", Subject) .AddCdata("Body", Body) .End(); } if (messages.Reminder) { w.Start("Reminder") .Add("Subject", ReminderSubject) .AddCdata("Body", ReminderBody) .End(); } if (messages.Support) { w.Start("SupportEmail") .Add("Subject", SupportSubject) .AddCdata("Body", SupportBody) .End(); } if (messages.Support) { w.Start("SenderEmail") .Add("Subject", SenderSubject) .AddCdata("Body", SenderBody) .End(); } w.StartPending("Instructions"); if (messages.Login) { w.AddCdata("Login", InstructionLogin); } if (messages.Select) { w.AddCdata("Select", InstructionSelect); } if (messages.Find) { w.AddCdata("Find", InstructionFind); } if (messages.Options) { w.AddCdata("Options", InstructionOptions); } if (messages.Special) { w.AddCdata("Special", InstructionSpecial); } if (messages.Submit) { w.AddCdata("Submit", InstructionSubmit); } if (messages.Sorry) { w.AddCdata("Sorry", InstructionSorry); } w.EndPending(); w.End(); }
public virtual void WriteXml(APIWriter w) { w.Start(Type); w.End(); }
public void WriteXml(XmlWriter writer) { var optionsAdded = false; var checkoxesAdded = false; var w = new APIWriter(writer); foreach (PropertyInfo pi in typeof(OnlineRegPersonModel).GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(vv => vv.CanRead && vv.CanWrite)) { switch (pi.Name) { case "FundItem": if (FundItem != null && FundItem.Count > 0) { foreach (var f in FundItem.Where(ff => ff.Value > 0)) { w.Start("FundItem"); w.Attr("fund", f.Key); w.AddText(f.Value.Value.ToString()); w.End(); } } break; case "FamilyAttend": if (FamilyAttend != null && FamilyAttend.Count > 0) { foreach (var f in FamilyAttend) { w.Start("FamilyAttend"); w.Attr("PeopleId", f.PeopleId); w.Attr("Name", f.Name); w.Attr("Attend", f.Attend); w.Attr("Birthday", f.Birthday); w.Attr("GenderId", f.GenderId); w.Attr("MaritalId", f.MaritalId); w.End(); } } break; case "ExtraQuestion": if (ExtraQuestion != null) { for (var i = 0; i < ExtraQuestion.Count; i++) { if (ExtraQuestion[i] != null && ExtraQuestion[i].Count > 0) { foreach (var q in ExtraQuestion[i]) { w.Start("ExtraQuestion"); w.Attr("set", i); w.Attr("question", q.Key); w.AddText(q.Value); w.End(); } } } } break; case "YesNoQuestion": if (YesNoQuestion != null && YesNoQuestion.Count > 0) { foreach (var q in YesNoQuestion) { w.Start("YesNoQuestion"); w.Attr("question", q.Key); w.AddText(q.Value.ToString()); w.End(); } } break; case "option": if (option != null && option.Count > 0 && !optionsAdded) { foreach (var o in option) { w.Add("option", o); } } optionsAdded = true; break; case "Checkbox": if (Checkbox != null && Checkbox.Count > 0 && !checkoxesAdded) { foreach (var c in Checkbox) { w.Add("Checkbox", c); } } checkoxesAdded = true; break; case "MenuItem": if (MenuItem != null) { for (var i = 0; i < MenuItem.Count; i++) { if (MenuItem[i] != null && MenuItem[i].Count > 0) { foreach (var q in MenuItem[i]) { w.Start("MenuItem"); w.Attr("set", i); w.Attr("name", q.Key); w.Attr("number", q.Value); w.End(); } } } } break; case "MissionTripPray": if (Parent.SupportMissionTrip) { w.Add(pi.Name, MissionTripPray); } break; case "MissionTripGoerId": if (Parent.SupportMissionTrip) { w.Add(pi.Name, MissionTripGoerId); } break; case "IsFilled": if (IsFilled) { w.Add(pi.Name, IsFilled); } break; case "CreatingAccount": if (CreatingAccount) { w.Add(pi.Name, CreatingAccount); } break; case "MissionTripNoNoticeToGoer": if (MissionTripNoNoticeToGoer) { w.Add(pi.Name, MissionTripNoNoticeToGoer); } break; case "memberus": if (memberus) { w.Add(pi.Name, memberus); } break; case "otherchurch": if (otherchurch) { w.Add(pi.Name, otherchurch); } break; default: w.Add(pi.Name, pi.GetValue(this, null)); break; } } }