public ActionResult Lookups(string id) { var ret = AuthenticateDeveloper(); if (ret.StartsWith("!")) { return(Content("<Lookups error=\"{0}\" />".Fmt(ret.Substring(1)))); } if (!id.HasValue()) { return(Content("Lookups error=\"not found\">")); } var q = DbUtil.Db.ExecuteQuery <Setup.Controllers.LookupController.Row>("select * from lookup." + id); var w = new CmsData.API.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 ActionResult SQLView(string id) { var ret = AuthenticateDeveloper(); if (ret.StartsWith("!")) return Content("<SQLView error=\"{0}\" />".Fmt(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.{0}\" />".Fmt(id)); } }
public string OrganizationsForDiv(int divid) { var q = from o in Db.Organizations where o.DivOrgs.Any(dd => dd.DivId == divid) where o.OrganizationStatusId == CmsData.Codes.OrgStatusCode.Active let leader = Db.People.SingleOrDefault(ll => ll.PeopleId == o.LeaderId) select new { o.OrganizationId, o.OrganizationName, o.Location, o.Description, o.CampusId, o.LeaderName, o.LeaderId, Email = leader != null ? leader.EmailAddress : "", IsParent = o.ChildOrgs.Count() > 0, NumMembers = o.OrganizationMembers.Count(om => om.Pending != true && om.MemberTypeId != CmsData.Codes.MemberTypeCode.InActive) }; var w = new APIWriter(); w.Start("Organizations"); foreach (var o in q) { w.Start("Organization"); w.Attr("Id", o.OrganizationId); w.Attr("Name", o.OrganizationName); w.Attr("NumMembers", o.NumMembers); if (o.IsParent) w.Attr("IsParent", o.IsParent); w.Attr("Location", o.Location); w.Attr("Description", o.Description); w.Attr("CampusId", o.CampusId); w.Attr("Leader", o.LeaderName); w.Attr("LeaderId", o.LeaderId); w.Attr("Email", o.Email); w.End(); } w.End(); return w.ToString(); }
public ActionResult Lookups(string id) { var ret = AuthenticateDeveloper(); if (ret.StartsWith("!")) return Content("<Lookups error=\"{0}\" />".Fmt(ret.Substring(1))); if (!id.HasValue()) return Content("Lookups error=\"not found\">"); var q = DbUtil.Db.ExecuteQuery<Setup.Controllers.LookupController.Row>("select * from lookup." + id); var w = new CmsData.API.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(APIWriter w) { w.StartPending("TimeSlots"); w.Attr("LockDays", TimeSlotLockDays); foreach (var c in list) { w.Start("Slot") .Attr("Time", c.Time.ToString2("t")) .Attr("DayOfWeek", c.DayOfWeek) .Attr("Limit", c.Limit) .AddText(c.Description) .End(); } w.EndPending(); }
public string OrgMembers(int orgid, string search) { search = search ?? ""; var nosearch = !search.HasValue(); var qm = from m in Db.OrganizationMembers where m.OrganizationId == orgid where nosearch || m.Person.Name2.StartsWith(search) select new { m.PeopleId, First = m.Person.PreferredName, Last = m.Person.LastName, m.Person.EmailAddress, m.EnrollmentDate, MemberType = m.MemberType.Description, IsLeaderType = (m.MemberType.AttendanceTypeId ?? 0) == CmsData.Codes.AttendTypeCode.Leader, }; var mt = from m in Db.OrgMemMemTags where m.OrganizationMember.OrganizationId == orgid where m.OrganizationMember.MemberTypeId != Codes.MemberTypeCode.InActive select new { m.OrganizationMember.PeopleId, m.MemberTag.Name }; var mtags = mt.ToList(); var w = new APIWriter(); w.Start("OrgMembers"); foreach (var m in qm.ToList()) { w.Start("Member"); w.Attr("PreferredName", m.First); w.Attr("LastName", m.Last); w.Attr("Email", m.EmailAddress); w.Attr("Enrolled", m.EnrollmentDate); w.Attr("MemberType", m.MemberType); if (m.IsLeaderType) { w.Attr("IsLeader", m.IsLeaderType); } var qt = from t in mtags where t.PeopleId == m.PeopleId select t.Name; foreach (var group in qt) { w.Add("Group", group); } w.End(); } w.End(); return(w.ToString()); }
public string ExtraValues(int meetingid, string fields) { try { var a = (fields ?? "").Split(','); var nofields = !fields.HasValue(); var q = from v in Db.MeetingExtras where nofields || a.Contains(v.Field) where v.MeetingId == meetingid select v; var w = new APIWriter(); w.Start("ExtraMeetingValues"); w.Attr("Id", meetingid); foreach (var v in q) w.Add(v.Field, v.Data); w.End(); return w.ToString(); } catch (Exception ex) { return ex.Message; } }
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(); } }
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 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 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(); } }
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 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 string Export(int id, string name) { var clause = Db.LoadQueryById(id); var w = new APIWriter(); w.Start("Search"); w.Attr("Description", name); //var settings = new XmlWriterSettings(); //settings.Encoding = new System.Text.UTF8Encoding(false); //using (w = XmlWriter.Create(context.HttpContext.Response.OutputStream, settings)) //{ // w.WriteStartElement("Search"); // WriteClause(clause); // w.WriteEndElement(); //} return ""; }
public void WriteXmlMessages(XmlWriter writer, Messages messages) { var w = new APIWriter(writer); w.Start("Messages"); w.Attr("id", OrgId); w.AddComment($"{Util.UserPeopleId} {DateTime.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 string ExtraValues(int peopleid, string fields) { try { var a = (fields ?? "").Split(','); var nofields = !fields.HasValue(); var q = from v in Db.PeopleExtras where nofields || a.Contains(v.Field) where v.PeopleId == peopleid select v; var w = new APIWriter(); w.Start("ExtraValues"); w.Attr("Id", peopleid); foreach (var v in q) w.Add(v.Field, v.StrValue ?? v.Data ?? v.DateValue.FormatDate() ?? v.IntValue.ToString()); w.End(); return w.ToString(); } catch (Exception ex) { return ex.Message; } }
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) group ev by new {ev.Field, ev.Type} into g orderby g.Key.Field select g.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(); } 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) { w.Start("Column") .Attr("name", "AmountTot") .Attr("orgid", orgid) .End(); w.Start("Column") .Attr("name", "AmountPaid") .Attr("orgid", orgid) .End(); w.Start("Column") .Attr("name", "AmountDue") .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 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; } } }
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")); var code = DbUtil.Db.NextSecurityCode(DateTime.Today).Select(c => c.Code).Single(); x.Attr("securitycode", code); var accommodateCheckInBug = DbUtil.Db.Setting("AccommodateCheckinBug", "false").ToBool(); foreach (var c in q) { double leadtime = 0; if (c.Hour.HasValue) { var midnight = c.Hour.Value.Date; var now = midnight.Add(Util.Now.TimeOfDay); leadtime = c.Hour.Value.Subtract(now).TotalHours; leadtime -= DbUtil.Db.Setting("TZOffset", "0").ToInt(); // positive to the east, negative to the west } 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", leadtime.ToString()); x.Attr("age", c.Age.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.End(); } x.End(); } }
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) 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; default: w.Add(pi.Name, pi.GetValue(this, null)); break; } } }
public string FamilyMembers(int familyid) { try { var q = from p in Db.People where p.FamilyId == familyid select p; var w = new APIWriter(); w.Start("Family"); w.Attr("Id", familyid); foreach (var m in q) { w.Start("Member"); w.Add("peopleid", m.PeopleId); w.Add("first", m.FirstName); w.Add("last", m.LastName); w.Add("goesby", m.NickName); w.Add("birthday", m.BDate); w.Add("position", m.PositionInFamilyId); w.Add("marital", m.MaritalStatusId); w.Add("suffix", m.SuffixCode); w.Add("title", m.TitleCode); w.End(); } w.End(); return w.ToString(); } catch (Exception ex) { return ex.Message; } }
public void WriteXml(XmlWriter writer) { var w = new APIWriter(writer); w.Attr("id", OrgId); w.AddComment($"{Util.UserPeopleId} {DateTime.Now:g}"); w.StartPending("Confirmation") .Add("Subject", Subject) .AddCdata("Body", Body) .EndPending(); w.StartPending("Reminder") .Add("Subject", ReminderSubject) .AddCdata("Body", ReminderBody) .EndPending(); w.StartPending("SupportEmail") .Add("Subject", SupportSubject) .AddCdata("Body", SupportBody) .EndPending(); w.StartPending("SenderEmail") .Add("Subject", SenderSubject) .AddCdata("Body", SenderBody) .EndPending(); w.StartPending("Fees") .Add("Fee", Fee) .Add("Deposit", Deposit) .Add("ExtraFee", ExtraFee) .Add("MaximumFee", MaximumFee) .Add("ExtraValueFeeName", ExtraValueFeeName) .Add("AccountingCode", AccountingCode) .AddIfTrue("ApplyMaxToOtherFees", ApplyMaxToOtherFees) .AddIfTrue("IncludeOtherFeesWithDeposit", IncludeOtherFeesWithDeposit) .AddIfTrue("OtherFeesAddedToOrgFee", OtherFeesAddedToOrgFee) .AddIfTrue("AskDonation", AskDonation) .Add("DonationLabel", DonationLabel) .Add("DonationFundId", DonationFundId) .EndPending(); w.StartPending("OrgFees"); foreach (var i in OrgFees) w.Start("Fee") .Attr("OrgId", i.OrgId) .Attr("Fee", i.Fee) .End(); w.EndPending(); w.StartPending("AgeGroups"); foreach (var i in AgeGroups) w.Start("Group") .Attr("StartAge", i.StartAge) .Attr("EndAge", i.EndAge) .Attr("Fee", i.Fee) .AddText(i.SmallGroup) .End(); w.EndPending(); w.StartPending("Instructions") .AddCdata("Login", InstructionLogin) .AddCdata("Select", InstructionSelect) .AddCdata("Find", InstructionFind) .AddCdata("Options", InstructionOptions) .AddCdata("Special", InstructionSpecial) .AddCdata("Submit", InstructionSubmit) .AddCdata("Sorry", InstructionSorry) .AddCdata("Thanks", ThankYouMessage) .AddCdata("Terms", Terms) .EndPending(); w.StartPending("Options") .AddCdata("ConfirmationTrackingCode", ConfirmationTrackingCode) .Add("ValidateOrgs", ValidateOrgs) .Add("Shell", Shell) .Add("ShellBs", ShellBs) .Add("FinishRegistrationButton", FinishRegistrationButton) .Add("SpecialScript", SpecialScript) .Add("GroupToJoin", GroupToJoin) .Add("TimeOut", TimeOut) .AddIfTrue("AllowOnlyOne", AllowOnlyOne) .AddIfTrue("TargetExtraValues", TargetExtraValues) .AddIfTrue("AllowReRegister", AllowReRegister) .AddIfTrue("AllowSaveProgress", AllowSaveProgress) .AddIfTrue("MemberOnly", MemberOnly) .AddIfTrue("AddAsProspect", AddAsProspect) .AddIfTrue("DisallowAnonymous", DisallowAnonymous) .EndPending(); w.StartPending("NotRequired") .AddIfTrue("NoReqBirthYear", NoReqBirthYear) .AddIfTrue("NotReqDOB", NotReqDOB) .AddIfTrue("NotReqAddr", NotReqAddr) .AddIfTrue("NotReqZip", NotReqZip) .AddIfTrue("NotReqPhone", NotReqPhone) .AddIfTrue("NotReqGender", NotReqGender) .AddIfTrue("NotReqMarital", NotReqMarital) .EndPending(); TimeSlots?.WriteXml(w); w.StartPending("AskItems"); foreach (var a in AskItems) a.WriteXml(w); w.EndPending(); }
public string OrgMembers(int orgid, string search) { search = search ?? ""; var nosearch = !search.HasValue(); var qm = from m in Db.OrganizationMembers where m.OrganizationId == orgid where nosearch || m.Person.Name2.StartsWith(search) select new { m.PeopleId, First = m.Person.PreferredName, Last = m.Person.LastName, m.Person.EmailAddress, m.EnrollmentDate, MemberType = m.MemberType.Description, IsLeaderType = (m.MemberType.AttendanceTypeId ?? 0) == CmsData.Codes.AttendTypeCode.Leader, }; var mt = from m in Db.OrgMemMemTags where m.OrganizationMember.OrganizationId == orgid where m.OrganizationMember.MemberTypeId != Codes.MemberTypeCode.InActive select new { m.OrganizationMember.PeopleId, m.MemberTag.Name }; var mtags = mt.ToList(); var w = new APIWriter(); w.Start("OrgMembers"); foreach (var m in qm.ToList()) { w.Start("Member"); w.Attr("PreferredName", m.First); w.Attr("LastName", m.Last); w.Attr("Email", m.EmailAddress); w.Attr("Enrolled", m.EnrollmentDate); w.Attr("MemberType", m.MemberType); if (m.IsLeaderType) w.Attr("IsLeader", m.IsLeaderType); var qt = from t in mtags where t.PeopleId == m.PeopleId select t.Name; foreach (var group in qt) w.Add("Group", group); w.End(); } w.End(); return w.ToString(); }
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(DateTime.Today).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", c.Age.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(); } }