示例#1
0
        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"));
        }
示例#2
0
        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));
            }
        }
示例#3
0
 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);
     }
 }
示例#4
0
 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);
     }
 }
示例#5
0
		    public void WriteXml(APIWriter w)
		    {
		        w.Start("Size")
		            .Add("Description", Description)
		            .Add("SmallGroup", SmallGroup)
		            .End();
		    }
示例#6
0
 public string ExtraValues(int orgid, string fields)
 {
     try
     {
         var a        = (fields ?? "").Split(',');
         var nofields = !fields.HasValue();
         var q        = from v in Db.OrganizationExtras
                        where nofields || a.Contains(v.Field)
                        where v.OrganizationId == orgid
                        select v;
         var w = new APIWriter();
         w.Start("ExtraOrgValues");
         w.Attr("Id", orgid);
         foreach (var v in q)
         {
             w.Add(v.Field, v.Data);
         }
         w.End();
         return(w.ToString());
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
示例#7
0
		    public void WriteXml(APIWriter w)
		    {
		        w.Start("GradeOption")
		            .Attr("Code", Code)
		            .AddText(Description)
		            .End();
		    }
示例#8
0
		    public void WriteXml(APIWriter w)
		    {
		        w.Start("YesNoQuestion")
		            .Add("Question", Question ?? "need a question here")
		            .Add("SmallGroup", SmallGroup)
		            .End();
		    }
示例#9
0
        //        public string OrgMembersPython(int orgid)
        //        {
        //            var list = OrgMembersData(orgid);
        //            var script = Db.Content("API-OrgMembers");
        //            if (script == null)
        //            {
        //                script = new Content();
        //                script.Body = @"
        //from System import *
        //from System.Text import *
        //
        //class OrgMembers(object):
        //
        //	def Run(self, m, w, q):
        //		w.Start('OrgMembers')
        //		for i in q:
        //			w.Start('Member')
        //			w.Attr('PeopleId', i.member.PeopleId)
        //			w.Attr('Name', i.member.Person.Name)
        //			w.Attr('PreferredName', i.member.Person.PreferredName)
        //			w.Attr('LastName', i.member.Person.LastName)
        //			w.Attr('Email', i.member.Person.EmailAddress)
        //			w.Attr('Enrolled', i.member.EnrollmentDate)
        //			w.Attr('MemberType', i.member.MemberType.Description)
        //			for t in i.tags:
        //				w.Add('Group', t)
        //			w.End()
        //		w.End()
        //		return w.ToString()
        //";
        //            }
        //            if (script == null)
        //                return "<login error=\"no API-OrgMembers script\" />";
        //            var engine = Python.CreateEngine();
        //            var sc = engine.CreateScriptSourceFromString(script.Body);
        //            try
        //            {
        //                var code = sc.Compile();
        //                var scope = engine.CreateScope();
        //                code.Execute(scope);
        //
        //                dynamic LoginInfo = scope.GetVariable("OrgMembers");
        //                dynamic m = LoginInfo();
        //                var w = new APIWriter();
        //                return m.Run(this, w, list);
        //            }
        //            catch (Exception ex,
        //            {
        //                return $"<login error=\"API-OrgMembers script error: {ex.Message}\" />";
        //            }
        //        }

        public string OrgMembers2(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,
                m.Person.Name,
                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("PeopleId", m.PeopleId);
                w.Attr("Name", m.Name);
                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());
        }
示例#10
0
 private bool WriteDropdownOptions(bool optionsAdded, APIWriter w)
 {
     if (option != null && option.Count > 0 && !optionsAdded)
         foreach (var o in option)
             w.Add("option", o);
     optionsAdded = true;
     return optionsAdded;
 }
示例#11
0
	    public override void WriteXml(APIWriter w)
	    {
			if (list.Count == 0)
				return;
	        w.Start(Type);
	        foreach (var q in list)
                q.WriteXml(w);
	        w.End();
	    }
示例#12
0
	    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();
	    }
示例#13
0
        public string OrgMembersPython(int orgid)
        {
            var list   = OrgMembersData(orgid);
            var script = Db.Content("API-OrgMembers");

            if (script == null)
            {
                script = new Content();

                script.Body = @"
from System import *
from System.Text import *

class OrgMembers(object):

	def Run(self, m, w, q):
		w.Start('OrgMembers')
		for i in q:
			w.Start('Member')
			w.Attr('PeopleId', i.member.PeopleId)
			w.Attr('Name', i.member.Person.Name)
			w.Attr('PreferredName', i.member.Person.PreferredName)
			w.Attr('LastName', i.member.Person.LastName)
			w.Attr('Email', i.member.Person.EmailAddress)
			w.Attr('Enrolled', i.member.EnrollmentDate)
			w.Attr('MemberType', i.member.MemberType.Description)
			for t in i.tags:
				w.Add('Group', t)
			w.End()
		w.End()
		return w.ToString()
";
            }
            if (script == null)
            {
                return("<login error=\"no API-OrgMembers script\" />");
            }
            var engine = Python.CreateEngine();
            var sc     = engine.CreateScriptSourceFromString(script.Body);

            try
            {
                var code  = sc.Compile();
                var scope = engine.CreateScope();
                code.Execute(scope);

                dynamic LoginInfo = scope.GetVariable("OrgMembers");
                dynamic m         = LoginInfo();
                var     w         = new APIWriter();
                return(m.Run(this, w, list));
            }
            catch (Exception ex)
            {
                return("<login error=\"API-OrgMembers script error: {0}\" />".Fmt(ex.Message));
            }
        }
示例#14
0
 public override void WriteXml(APIWriter w)
 {
     if (list.Count == 0)
         return;
     w.Start(Type)
         .Add("Label", Label);
     foreach (var i in list)
         i.WriteXml(w);
     w.End();
 }
示例#15
0
	    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();
	    }
示例#16
0
 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();
 }
示例#17
0
 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();
 }
示例#18
0
        public string Login(Person p)
        {
            var script = Db.Content("API-LoginInfo");

            if (script == null)
            {
                script      = new Content();
                script.Body = @"
from System import *
from System.Text import *

class LoginInfo(object):

	def Run(self, m, w, p):
		w.Start('Login')
		w.Attr('PeopleId', p.PeopleId)
		w.Attr('PreferredName', p.PreferredName)
		w.Attr('Last', p.LastName)
		w.Attr('EmailAddress', p.EmailAddress)
		w.Attr('IsMember', p.MemberStatusId == 10)
		for b in m.StatusFlags(p.PeopleId):
			w.Add('StatusFlag', b);
		w.End()
		return w.ToString()
";
            }
            var engine = Python.CreateEngine();
            var sc     = engine.CreateScriptSourceFromString(script.Body);

            try
            {
                var code  = sc.Compile();
                var scope = engine.CreateScope();
                code.Execute(scope);

                dynamic LoginInfo = scope.GetVariable("LoginInfo");
                dynamic m         = LoginInfo();
                var     api       = new APIFunctions(Db);
                var     w         = new APIWriter();
                return(m.Run(api, w, p));
            }
            catch (Exception ex)
            {
                return("<login error=\"API-LoginInfo script error: {0}\" />".Fmt(ex.Message));
            }
        }
示例#19
0
        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());
        }
示例#20
0
        private static string WriteXmlFromReader(IDataReader rd)
        {
            var w = new APIWriter();

            w.Start("SqlScriptXml");
            while (rd.Read())
            {
                w.Start("Row");
                for (var i = 0; i < rd.FieldCount; i++)
                {
                    var name  = rd.GetName(i);
                    var value = rd.GetValue(i);
                    w.Add(name, value);
                }
                w.End();
            }
            w.End();
            return(w.ToString());
        }
示例#21
0
 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 "FromMobile":
                 if (FromMobile.HasValue())
                     w.Add(pi.Name, FromMobile);
                 else if (MobileAppMenuController.Source.HasValue())
                     w.Add(pi.Name, MobileAppMenuController.Source);
                 break;
             case "prospect":
                 if (prospect)
                     w.Add(pi.Name, prospect);
                 break;
             default:
                 w.Add(pi.Name, pi.GetValue(this, null));
                 break;
         }
     }
 }
示例#22
0
        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();
        }
示例#23
0
 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");
 }
示例#24
0
 private void WriteClause(QueryBuilderClause clause, API.APIWriter w)
 {
     //w.WriteStartElement("Condition");
     //w.WriteAttributeString("ClauseOrder", clause.ClauseOrder.ToString());
     //w.WriteAttributeString("Field", clause.Field);
     //if (clause.Description.HasValue())
     //    w.WriteAttributeString("Description", clause.Description);
     //w.WriteAttributeString("Comparison", clause.Comparison);
     //if (clause.TextValue.HasValue())
     //    w.WriteAttributeString("TextValue", clause.TextValue);
     //if (clause.DateValue.HasValue)
     //    w.WriteAttributeString("DateValue", clause.DateValue.ToString());
     //if (clause.CodeIdValue.HasValue())
     //    w.WriteAttributeString("CodeIdValue", clause.CodeIdValue);
     //if (clause.StartDate.HasValue)
     //    w.WriteAttributeString("StartDate", clause.StartDate.ToString());
     //if (clause.EndDate.HasValue)
     //    w.WriteAttributeString("EndDate", clause.EndDate.ToString());
     //if (clause.Program > 0)
     //    w.WriteAttributeString("Program", clause.Program.ToString());
     //if (clause.Division > 0)
     //    w.WriteAttributeString("Division", clause.Division.ToString());
     //if (clause.Organization > 0)
     //    w.WriteAttributeString("Organization", clause.Organization.ToString());
     //if (clause.Days > 0)
     //    w.WriteAttributeString("Days", clause.Days.ToString());
     //if (clause.Quarters.HasValue())
     //    w.WriteAttributeString("Quarters", clause.Quarters);
     //if (clause.Tags.HasValue())
     //    w.WriteAttributeString("Tags", clause.Tags);
     //if (clause.Schedule > 0)
     //    w.WriteAttributeString("Schedule", clause.Schedule.ToString());
     //if (clause.Age.HasValue)
     //    w.WriteAttributeString("Age", clause.Age.ToString());
     //foreach (var qc in clause.Clauses)
     //    WriteClause(qc);
     //w.WriteEndElement();
 }
示例#25
0
 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;
     }
 }
示例#26
0
 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;
     }
 }
示例#27
0
 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;
     }
 }
示例#28
0
 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();
                 }
 }
示例#29
0
        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;
        }
示例#30
0
 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();
         }
 }
示例#31
0
 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();
                 }
 }
示例#32
0
 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();
                 }
 }
示例#33
0
 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();
         }
 }
示例#34
0
 private bool WriteCheckboxChoices(bool checkoxesAdded, APIWriter w)
 {
     if (Checkbox != null && Checkbox.Count > 0 && !checkoxesAdded)
         foreach (var c in Checkbox)
             w.Add("Checkbox", c);
     checkoxesAdded = true;
     return checkoxesAdded;
 }
示例#35
0
        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 "SpecialTest":
                        WriteSpecialTest(w);
                        break;
                    case "FundItem":
                        WriteFundItems(w);
                        break;
                    case "FamilyAttend":
                        WriteFamilyAttend(w);
                        break;
                    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;
                    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;
                }
            }
        }
示例#36
0
        public string Login(Person p)
        {
            var script = Db.Content("API-LoginInfo");
            if (script == null)
            {
                script = new Content();
                script.Body = @"
            from System import *
            from System.Text import *

            class LoginInfo(object):

            def Run(self, m, w, p):
            w.Start('Login')
            w.Attr('PeopleId', p.PeopleId)
            w.Attr('PreferredName', p.PreferredName)
            w.Attr('Last', p.LastName)
            w.Attr('EmailAddress', p.EmailAddress)
            w.Attr('IsMember', p.MemberStatusId == 10)
            for b in m.StatusFlags(p.PeopleId):
            w.Add('StatusFlag', b);
            w.End()
            return w.ToString()
            ";
            }
            var engine = Python.CreateEngine();
            var sc = engine.CreateScriptSourceFromString(script.Body);
            try
            {
                var code = sc.Compile();
                var scope = engine.CreateScope();
                code.Execute(scope);

                dynamic LoginInfo = scope.GetVariable("LoginInfo");
                dynamic m = LoginInfo();
                var api = new APIFunctions(Db);
                var w = new APIWriter();
                return m.Run(api, w, p);
            }
            catch (Exception ex)
            {
                return $"<login error=\"API-LoginInfo script error: {ex.Message}\" />";
            }
        }
示例#37
0
 private static string WriteXmlFromReader(IDataReader rd)
 {
     var w = new APIWriter();
     w.Start("SqlScriptXml");
     while (rd.Read())
     {
         w.Start("Row");
         for (var i = 0; i < rd.FieldCount; i++)
         {
             var name = rd.GetName(i);
             var value = rd.GetValue(i);
             w.Add(name, value);
         }
         w.End();
     }
     w.End();
     return w.ToString();
 }
示例#38
0
 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();
         }
 }
示例#39
0
        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();
        }
示例#40
0
 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();
         }
 }