Esempio n. 1
0
        public static void ParseResults(int id, int peopleId, NameValueCollection elements )
        {
            var org = (from e in DbUtil.Db.Organizations
                          where e.OrganizationId == id
                          select e).FirstOrDefault();

            var person = (from e in DbUtil.Db.People
                              where e.PeopleId == peopleId
                              select e).FirstOrDefault();

            if (person == null) return;
            if (org == null) return;

            var summary = "";

            foreach (var item in elements.AllKeys)
            {
                if (item.StartsWith("EV_"))
                {
                    var evName = item.Substring(3);
                    int iValue;

                    if (Int32.TryParse(elements[item], out iValue))
                    {
                        person.AddEditExtraInt(evName, iValue);
                    }
                    else
                    {
                        person.AddEditExtraValue(evName, elements[item]);
                    }

                    summary += evName + ": " + elements[item] + "<br>";
                }
            }

            DbUtil.Db.SubmitChanges();

            List<Person> staffList = DbUtil.Db.StaffPeopleForOrg(id);
            var staff = staffList[0];

            var regSettings = new Settings(org.RegSetting, DbUtil.Db, id);

            var subject = Util.PickFirst(regSettings.Subject, "No subject");
            var body = Util.PickFirst(regSettings.Body, "confirmation email body not found");

            subject = subject.Replace("{org}", org.OrganizationName);

            body = body.Replace("{church}", DbUtil.Db.Setting("NameOfChurch", "church"), ignoreCase: true);
            body = body.Replace("{name}", person.Name, ignoreCase: true);
            body = body.Replace("{date}", DateTime.Now.ToString("d"), ignoreCase: true);
            body = body.Replace("{email}", person.EmailAddress, ignoreCase: true);
            body = body.Replace("{phone}", person.HomePhone.FmtFone(), ignoreCase: true);
            body = body.Replace("{contact}", staff.Name, ignoreCase: true);
            body = body.Replace("{contactemail}", staff.EmailAddress, ignoreCase: true);
            body = body.Replace("{contactphone}", org.PhoneNumber.FmtFone(), ignoreCase: true);
            body = body.Replace("{details}", summary, ignoreCase: true);

            DbUtil.Db.Email(staff.FromEmail, person, subject, body);
            DbUtil.Db.Email(person.FromEmail, staff, "Registration completed for {0}".Fmt(org.OrganizationName), "{0} completed {1}<br/><br/>{2}".Fmt(person.Name, org.OrganizationName, summary));
        }
Esempio n. 2
0
 public ActionResult ConvertFromMdy(int id)
 {
     var cul = "en-US";
     Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
     Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul);
     var org = DbUtil.Db.LoadOrganizationById(id);
     var m = new Settings(org.RegSetting, DbUtil.Db, id);
     var os = new Settings(m.ToString(), DbUtil.Db, id);
     m.org.RegSetting = os.ToString();
     DbUtil.Db.SubmitChanges();
     return Redirect("/RegSetting/Index/" + id);
 }
Esempio n. 3
0
        public Parser(string s, Settings settings)
        {
            set = settings;
            lines = SplitLines(s);
            for (lineno = 0; lineno < lines.Length; )
            {
                var d = GetLineData();
                if (d == null)
                    break;
                data.Add(d);
            }
            lines = null;
            lineno = 0;

        }
Esempio n. 4
0
 public ActionResult Update(int id, string text)
 {
     var org = DbUtil.Db.LoadOrganizationById(id);
     try
     {
         var os = new Settings(text, DbUtil.Db, id);
         org.RegSetting = text;
     }
     catch (Exception ex)
     {
         TempData["error"] = ex.Message;
         TempData["regsetting"] = text;
         return Redirect("/RegSettings/" + id);
     }
     DbUtil.Db.SubmitChanges();
     return Redirect("/RegSettings/" + id);
 }
Esempio n. 5
0
        public static Settings ParseSettings(string s)
        {
            var settings = new Settings();
            var parser = new Parser(s, settings);

            while (parser.NextSection())
                parser.ParseSection();
            settings.SetUniqueIds("AskDropdown");
            settings.SetUniqueIds("AskExtraQuestions");
            settings.SetUniqueIds("AskCheckboxes");
            settings.SetUniqueIds("AskText");
            settings.SetUniqueIds("AskMenu");
            var sglist = new List<string>();
            settings.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;
            return settings;
        }
Esempio n. 6
0
        private void DoUpdate(string text)
        {
            var xdoc = XDocument.Parse(text.TrimStart());
            if (xdoc.Root == null)
                throw new UserInputException("could not parse xml document");

            foreach (var x in xdoc.Root.Elements("Messages"))
            {
                var oid = x.Attribute("id").Value.ToInt();
                os = DbUtil.Db.CreateRegistrationSettings(oid);
                var o = DbUtil.Db.LoadOrganizationById(oid);
                foreach (var e in x.Elements())
                {
                    var name = e.Name.ToString();
                    switch (name)
                    {
                        case "Confirmation":
                            SubjectAndBody("", e); // no prefix
                            break;
                        case "Reminder":
                            SubjectAndBody("Reminder", e);
                            break;
                        case "SupportEmail":
                            SubjectAndBody("Support", e);
                            break;
                        case "SenderEmail":
                            SubjectAndBody("Sender", e);
                            break;
                        case "Instructions":
                            Instruction(e);
                            break;
                    }
                }
                o.UpdateRegSetting(os);
                DbUtil.Db.SubmitChanges();
            }
        }
Esempio n. 7
0
 private bool IsSmallGroupFilled(Settings setting, int orgid, string sg)
 {
     var GroupTags = (from mt in DbUtil.Db.OrgMemMemTags
                      where mt.OrgId == orgid
                      select mt.MemberTag.Name).ToList();
     return setting.AskItems.Where(aa => aa.Type == "AskDropdown").Any(aa => ((AskDropdown) aa).IsSmallGroupFilled(GroupTags, sg))
            || setting.AskItems.Where(aa => aa.Type == "AskCheckboxes").Any(aa => ((AskCheckboxes) aa).IsSmallGroupFilled(GroupTags, sg));
 }
Esempio n. 8
0
        public ActionResult RsvpLinkSg(string id, string message, bool? confirm)
        {
            if (!id.HasValue())
                return Content("bad link");

            var guid = id.ToGuid();
            if (guid == null)
                return Content("invalid link");
            var ot = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
            if (ot == null)
                return Content("invalid link");
            if (ot.Used)
                return Content("link used");
            if (ot.Expires.HasValue && ot.Expires < DateTime.Now)
                return Content("link expired");
            var a = ot.Querystring.SplitStr(",", 4);
            var meetingid = a[0].ToInt();
            var pid = a[1].ToInt();
            var emailid = a[2].ToInt();
            var smallgroup = a[3];
            var q = (from pp in DbUtil.Db.People
                     where pp.PeopleId == pid
                     let meeting = DbUtil.Db.Meetings.SingleOrDefault(mm => mm.MeetingId == meetingid)
                     let org = meeting.Organization
                     select new { p = pp, org, meeting }).Single();

            if (q.org.RegistrationClosed == true || q.org.OrganizationStatusId == OrgStatusCode.Inactive)
                return Content("sorry, registration has been closed");

            if (q.org.RegistrationTypeId == RegistrationTypeCode.None)
                return Content("rsvp is no longer available");

            if (q.org.Limit <= q.meeting.Attends.Count(aa => aa.Commitment == 1))
                return Content("sorry, maximum limit has been reached");
            var omb = OrganizationMember.InsertOrgMembers(DbUtil.Db,
                                              q.meeting.OrganizationId, pid, MemberTypeCode.Member, DateTime.Now, null, false);
            if (smallgroup.HasValue())
                omb.AddToGroup(DbUtil.Db, smallgroup);
            omb.AddToGroup(DbUtil.Db, "emailid:" + emailid);

            ot.Used = true;
            DbUtil.Db.SubmitChanges();
            Attend.MarkRegistered(DbUtil.Db, pid, meetingid, 1);
            DbUtil.LogActivity("Rsvplink: {0}".Fmt(q.org.OrganizationName));
            var setting = new Settings(q.org.RegSetting, DbUtil.Db, q.meeting.OrganizationId);

            if (confirm == true)
            {
                var subject = Util.PickFirst(setting.Subject, "no subject");
                var msg = Util.PickFirst(setting.Body, "no message");
                msg = CmsData.API.APIOrganization.MessageReplacements(DbUtil.Db, q.p, q.org.DivisionName, q.org.OrganizationName, q.org.Location, msg);
                msg = msg.Replace("{details}", q.meeting.MeetingDate.ToString2("f"));
                var NotifyIds = DbUtil.Db.StaffPeopleForOrg(q.org.OrganizationId);

                DbUtil.Db.Email(NotifyIds[0].FromEmail, q.p, subject, msg); // send confirmation
                DbUtil.Db.Email(q.p.FromEmail, NotifyIds,
                          q.org.OrganizationName,
                          "{0} has registered for {1}<br>{2}".Fmt(q.p.Name, q.org.OrganizationName, q.meeting.MeetingDate.ToString2("f")));
            }
            return Content(message);
        }
Esempio n. 9
0
        public ActionResult VoteLinkSg(string id, string message, bool? confirm)
        {
            if (!id.HasValue())
                return Content("bad link");

            var guid = id.ToGuid();
            if (guid == null)
                return Content("invalid link");
            var ot = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
            if (ot == null)
                return Content("invalid link");
            if (ot.Used)
                return Content("link used");
            if (ot.Expires.HasValue && ot.Expires < DateTime.Now)
                return Content("link expired");
            var a = ot.Querystring.SplitStr(",", 5);
            var oid = a[0].ToInt();
            var pid = a[1].ToInt();
            var emailid = a[2].ToInt();
            var pre = a[3];
            var smallgroup = a[4];
            var q = (from pp in DbUtil.Db.People
                     where pp.PeopleId == pid
                     let org = DbUtil.Db.Organizations.SingleOrDefault(oo => oo.OrganizationId == oid)
                     let om = DbUtil.Db.OrganizationMembers.SingleOrDefault(oo => oo.OrganizationId == oid && oo.PeopleId == pid)
                     select new { p = pp, org = org, om = om }).Single();

            if (q.org == null)
                return Content("org missing, bad link");

            if (q.org.RegistrationTypeId == RegistrationTypeCode.None)
                return Content("votelink is no longer active");

            if (q.om == null && q.org.Limit <= q.org.MemberCount)
                return Content("sorry, maximum limit has been reached");

            if (q.om == null && (q.org.RegistrationClosed == true || q.org.OrganizationStatusId == OrgStatusCode.Inactive))
                return Content("sorry, registration has been closed");

            var setting = new Settings(q.org.RegSetting, DbUtil.Db, oid);
            if (IsSmallGroupFilled(setting, oid, smallgroup))
                return Content("sorry, maximum limit has been reached for " + smallgroup);

            var omb = q.om;
            omb = OrganizationMember.InsertOrgMembers(DbUtil.Db,
                 oid, pid, MemberTypeCode.Member, DateTime.Now, null, false);
            //DbUtil.Db.UpdateMainFellowship(oid);

            if (q.org.AddToSmallGroupScript.HasValue())
            {
                var script = DbUtil.Db.Content(q.org.AddToSmallGroupScript);
                if (script != null && script.Body.HasValue())
                {
                    try
                    {
                        var pe = new PythonEvents(DbUtil.Db, "RegisterEvent", script.Body);
                        pe.instance.AddToSmallGroup(smallgroup, omb);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            omb.AddToGroup(DbUtil.Db, smallgroup);
            omb.AddToGroup(DbUtil.Db, "emailid:" + emailid);
            ot.Used = true;
            DbUtil.Db.SubmitChanges();
            DbUtil.LogActivity("Votelink: {0}".Fmt(q.org.OrganizationName));

            if (confirm == true)
            {
                var subject = Util.PickFirst(setting.Subject, "no subject");
                var msg = Util.PickFirst(setting.Body, "no message");
                msg = CmsData.API.APIOrganization.MessageReplacements(DbUtil.Db, q.p, q.org.DivisionName, q.org.OrganizationName, q.org.Location, msg);
                msg = msg.Replace("{details}", smallgroup);
                var NotifyIds = DbUtil.Db.StaffPeopleForOrg(q.org.OrganizationId);

                try
                {
                    DbUtil.Db.Email(NotifyIds[0].FromEmail, q.p, subject, msg); // send confirmation
                }
                catch (Exception ex)
                {
                    DbUtil.Db.Email(q.p.FromEmail, NotifyIds,
                                         q.org.OrganizationName,
                                         "There was a problem sending confirmation from org: " + ex.Message);
                }
                DbUtil.Db.Email(q.p.FromEmail, NotifyIds,
                          q.org.OrganizationName,
                          "{0} has registered for {1}<br>{2}<br>(from votelink)".Fmt(q.p.Name, q.org.OrganizationName, smallgroup));
            }

            return Content(message);
        }
Esempio n. 10
0
        public void SendVolunteerReminders(int id, bool sendall)
        {
            var org = Db.LoadOrganizationById(id);
            var setting = new Registration.Settings(org.RegSetting, Db, org.OrganizationId);
            setting.org = org;
            var currmembers = (from om in org.OrganizationMembers
                               where (om.Pending ?? false) == false
                               where om.MemberTypeId != CmsData.Codes.MemberTypeCode.InActive
                               where org.Attends.Any(a => (a.MeetingDate <= DateTime.Today.AddDays(7) || sendall)
                                   && a.MeetingDate >= DateTime.Today
                                   && (a.Commitment == AttendCommitmentCode.Attending || a.Commitment == AttendCommitmentCode.Substitute)
                                   && a.PeopleId == om.PeopleId)
                               select om).ToList();

            var subject = Util.PickFirst(setting.ReminderSubject, "no subject");
            var message = Util.PickFirst(setting.ReminderBody, "no body");
            if (subject == "no subject" || message == "no body")
                throw new Exception("no subject or body");
            var notify = Db.StaffPeopleForOrg(org.OrganizationId);
            var from = notify.FirstOrDefault();
            if (from == null)
                throw new Exception("no notify person");

            foreach (var om in currmembers)
            {
                var q = from a in org.Attends
                        where a.PeopleId == om.PeopleId
                        where a.Commitment == AttendCommitmentCode.Attending || a.Commitment == AttendCommitmentCode.Substitute
                        where a.MeetingDate >= DateTime.Today
                        orderby a.MeetingDate
                        select a.MeetingDate;
                if (!q.Any())
                    continue;
                var details = Razor.Parse(@"@model IEnumerable<DateTime>
            <blockquote>
            <table>
            <tr>
            <td> Date </td>
            <td> Time </td>
            </tr>
            @foreach (var dt in Model)
            {
            <tr>
                <td>@dt.ToLongDateString()</td>
                <td>@dt.ToLongTimeString()</td>
            </tr>
            }
            </table>
            </blockquote>", q);

                var oname = org.OrganizationName;

                subject = Util.PickFirst(setting.ReminderSubject, "no subject");
                message = Util.PickFirst(setting.ReminderBody, "no body");

                string loc = org.Location;
                message = MessageReplacements(Db, om.Person, null, oname, loc, message);

                message = message.Replace("{phone}", org.PhoneNumber.FmtFone7());
                message = message.Replace("{details}", details);

                Db.Email(from.FromEmail, om.Person, subject, message);
            }
            var sb = new StringBuilder(@"
            <blockquote>
            <table>
            <tr>
            <td> Date </td>
            <td> Time </td>
            </tr>");
            foreach (var om in currmembers)
            {
                var q = (from a in org.Attends
                         where a.PeopleId == om.PeopleId
                         where
                             a.Commitment == AttendCommitmentCode.Attending ||
                             a.Commitment == AttendCommitmentCode.Substitute
                         where a.MeetingDate >= DateTime.Today
                         where a.MeetingDate <= DateTime.Today.AddDays(7)
                         orderby a.MeetingDate
                         select a.MeetingDate).ToList();
                if (!q.Any())
                    continue;
                foreach (var d in q)
                    sb.AppendFormat("\n<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>", om.Person.Name, d.ToLongDateString(), d.ToLongTimeString());
            }
            sb.Append(@"
            </table>
            </blockquote>
            ");
            foreach (var n in notify)
            {
                var organizationName = org.OrganizationName;

                message = Util.PickFirst(setting.ReminderBody, "no body");

                string location = org.Location;
                message = MessageReplacements(Db, n, null, organizationName, location, message);

                message = message.Replace("{phone}", org.PhoneNumber.FmtFone7());
                message = message.Replace("{details}", sb.ToString());

                Db.Email(from.FromEmail, n, "Reminder Notices sent for " + organizationName, message);
            }
        }
Esempio n. 11
0
 public void UpdateRegSetting(Registration.Settings os)
 {
     RegSettingXml = Util.Serialize(os);
 }
Esempio n. 12
0
 public void UpdateRegSetting(Registration.Settings os)
 {
     RegSettingXml = Util.Serialize(os);
     RegSetting    = RegistrationSettingsParser.Parser.Output(os);
 }
Esempio n. 13
0
 public SummaryInfo(CMSDataContext db, OrganizationMember om)
 {
     this.om = om;
     First = om.Person.PreferredName;
     Last = om.Person.LastName;
     Orgname = om.Organization.OrganizationName;
     setting = db.CreateRegistrationSettings(om.OrganizationId);
 }
Esempio n. 14
0
 private bool SettingVisible(Settings setting, string name)
 {
     if (setting != null)
         return setting.AskVisible(name);
     return false;
 }
Esempio n. 15
0
        public string GetThankYouMessage()
        {
            var def = DbUtil.Db.ContentHtml("OnlineRegThanks", Resource1.OnlineRegModel_ThankYouMessage);

            string msg = null;
            if (masterorg != null)
            {
                var setting1 = new Settings();
                if (settings.ContainsKey(masterorg.OrganizationId))
                    setting1 = settings[masterorg.OrganizationId];
                var setting2 = setting1;
                if (last != null && last.org != null && settings.ContainsKey(last.org.OrganizationId))
                    setting1 = settings[last.org.OrganizationId];
                msg = Util.PickFirst(setting1.ThankYouMessage, setting2.ThankYouMessage, def);
            }
            else
            {
                var setting = new Settings();
                if (settings.ContainsKey(org.OrganizationId))
                    setting = settings[org.OrganizationId];
                msg = Util.PickFirst(setting.ThankYouMessage, def);
            }
            msg = msg.Replace("{org}", Header)
                     .Replace("{email}", Util.ObscureEmail(email))
                     .Replace("{url}", URL)
                     .Replace(WebUtility.UrlEncode("{url}"), URL);
            return msg;
        }
Esempio n. 16
0
        internal void PostContribution()
        {
            if (AmountGeneral > 0 || AmountGoer > 0)
            {

                var org = DbUtil.Db.LoadOrganizationById(OrgId);
                var notifyIds = DbUtil.Db.NotifyIds(org.OrganizationId, org.GiftNotifyIds);
                var person = DbUtil.Db.LoadPersonById(PeopleId ?? 0);
                var setting = new Settings(org.RegSetting, DbUtil.Db, org.OrganizationId);
                var fund = setting.DonationFundId;
                if (AmountGoer > 0)
                {
                    DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(
                        new GoerSenderAmount
                        {
                            Amount = AmountGoer,
                            GoerId = Goer.Value.ToInt(),
                            Created = DateTime.Now,
                            OrgId = org.OrganizationId,
                            SupporterId = PeopleId ?? 0,
                        });
                    var c = person.PostUnattendedContribution(DbUtil.Db,
                        AmountGoer ?? 0, fund,
                        "SupportMissionTrip: org={0}; goer={1}".Fmt(OrgId, Goer.Value), typecode: BundleTypeCode.ChecksAndCash);
                    c.CheckNo = CheckNo;
                    // send notices
                    var goer = DbUtil.Db.LoadPersonById(Goer.Value.ToInt());
                    ToGoerName = "to " + goer.Name;
                    DbUtil.Db.Email(notifyIds[0].FromEmail, goer, org.OrganizationName + "-donation",
                        "{0:C} donation received from {1}".Fmt(AmountGoer, person.Name));
                }
                if (AmountGeneral > 0)
                {
                    DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(
                        new GoerSenderAmount
                        {
                            Amount = AmountGeneral,
                            Created = DateTime.Now,
                            OrgId = org.OrganizationId,
                            SupporterId = PeopleId ?? 0
                        });
                    var c = person.PostUnattendedContribution(DbUtil.Db,
                        AmountGeneral ?? 0, fund,
                        "SupportMissionTrip: org={0}".Fmt(OrgId), typecode: BundleTypeCode.ChecksAndCash);
                    c.CheckNo = CheckNo;
                }
                DbUtil.Db.SubmitChanges();
            }
        }
Esempio n. 17
0
 public ActionResult TestRegs()
 {
     foreach (var o in DbUtil.Db.Organizations)
     {
         try
         {
             var rs = new Settings(o.RegSetting, DbUtil.Db, o.OrganizationId);
         }
         catch (Exception ex)
         {
             return Content("bad org <a href=\"{0}{1}\">{2}</a>\n{3}".Fmt(Util.ServerLink("/RegSetting/Index/"), o.OrganizationId, o.OrganizationName, ex.Message));
         }
     }
     return Content("ok");
 }
Esempio n. 18
0
 public ActionResult RegMessages(OrgSearchModel m, Settings.Messages messages)
 {
     Response.ContentType = "text/xml";
     m.RegMessagesXml(Response.OutputStream, messages);
     return new EmptyResult();
 }
Esempio n. 19
0
 private void Populate()
 {
     var i = (from mm in DbUtil.Db.OrganizationMembers
              where mm.OrganizationId == OrgId && mm.PeopleId == PeopleId
              select new
                  {
                      mm,
                      mm.Person.Name,
                      mm.Organization.OrganizationName,
                      mm.Organization.RegSetting,
                      mm.Organization,
                      mm.OrgMemMemTags,
                      mm.Organization.IsMissionTrip
                  }).SingleOrDefault();
     if (i == null)
         throw new Exception("missing OrgMember at oid={0}, pid={0}".Fmt(OrgId, PeopleId));
     om = i.mm;
     this.CopyPropertiesFrom(om);
     Name = i.Name;
     AmountPaidTransactions = om.TotalPaid(DbUtil.Db);
     OrgName = i.OrganizationName;
     Organization = i.Organization;
     OrgMemMemTags = i.OrgMemMemTags.ToList();
     IsMissionTrip = i.IsMissionTrip ?? false;
     Setting = new Settings(i.RegSetting, DbUtil.Db, OrgId.Value);
 }
Esempio n. 20
0
 public Parser(Settings settings)
 {
     set = settings;
 }
Esempio n. 21
0
        public void SendEventReminders(int id)
        {
            var org = Db.LoadOrganizationById(id);
            var setting = new Settings(org.RegSetting, Db, org.OrganizationId) { org = org };
            var currmembers = from om in org.OrganizationMembers
                              where (om.Pending ?? false) == false
                              where om.MemberTypeId != CmsData.Codes.MemberTypeCode.InActive
                              select om;

            const string noSubject = "no subject";
            const string noBody = "no body";

            var subject = Util.PickFirst(setting.ReminderSubject, noSubject);
            var message = Util.PickFirst(setting.ReminderBody, noBody);
            if (subject == noSubject || message == noBody)
                throw new Exception("no subject or body");
            var notify = Db.StaffPeopleForOrg(org.OrganizationId).FirstOrDefault();
            if (notify == null)
                throw new Exception("no notify person");

            foreach (var om in currmembers)
            {
                var details = PrepareSummaryText2(om);
                var organizationName = org.OrganizationName;

                subject = Util.PickFirst(setting.ReminderSubject, noSubject);
                message = Util.PickFirst(setting.ReminderBody, noBody);

                string location = org.Location;
                message = MessageReplacements(Db, om.Person, null, organizationName, location, message);

                message = message.Replace("{phone}", org.PhoneNumber.FmtFone7());
                message = message.Replace("{details}", details);

                Db.Email(notify.FromEmail, om.Person, subject, message);
            }
        }
Esempio n. 22
0
 private static IEnumerable<SelectListItem> ShirtSizes(Settings setting)
 {
     var list = new List<SelectListItem>();
     list.Insert(0, new SelectListItem {Value = "0", Text = "(please select)"});
     var askSize = setting.AskItems.FirstOrDefault(aa => aa is AskSize) as AskSize;
     if (askSize != null)
     {
         var q = from ss in askSize.list
                 select new SelectListItem
                 {
                     Value = ss.SmallGroup,
                     Text = ss.Description
                 };
         list.InsertRange(1, q.ToList());
     }
     if (askSize?.AllowLastYear ?? false)
         list.Add(new SelectListItem {Value = "lastyear", Text = "Use shirt from last year"});
     return list;
 }
Esempio n. 23
0
        public string GetFinishRegistrationButton()
        {
            string def = DbUtil.Db.Setting("FinishRegBtnText", "Finish Registration");

            string text = null;
            if (masterorg != null)
            {
                var setting1 = new Settings();
                if (settings.ContainsKey(masterorg.OrganizationId))
                    setting1 = settings[masterorg.OrganizationId];
                var setting2 = setting1;
                if (last?.org != null && settings.ContainsKey(last.org.OrganizationId))
                    setting1 = settings[last.org.OrganizationId];
                text = Util.PickFirst(setting1.FinishRegistrationButton, setting2.FinishRegistrationButton, def);
            }
            else
            {
                var setting = new Settings();
                if (settings.ContainsKey(org.OrganizationId))
                    setting = settings[org.OrganizationId];
                text = Util.PickFirst(setting.FinishRegistrationButton, def);
            }
            return text;
        }
Esempio n. 24
0
 public SummaryInfo(CMSDataContext db, OrganizationMember om)
 {
     this.om = om;
     First = om.Person.PreferredName;
     Last = om.Person.LastName;
     Orgname = om.Organization.OrganizationName;
     setting = new Settings(om.Organization.RegSetting, db, om.Organization.OrganizationId) { org = om.Organization };
 }
Esempio n. 25
0
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "filename=foo.pdf");

            dt = Util.Now;

            doc = new Document(PageSize.LETTER, 72, 72, 72, 72);
            var w = PdfWriter.GetInstance(doc, Response.OutputStream);
            w.PageEvent = pageEvents;
            doc.Open();
            dc = w.DirectContent;

            if (qid != null) // print using a query
            {
                var re = new Regex("((?<label>.*?:) (?<value>.*$))|(?<value0>.*$)", RegexOptions.Multiline);
                pageEvents.StartPageSet("Registration Report: {0:d}".Fmt(dt));
                var q2 = DbUtil.Db.PeopleQuery(qid.Value);
                var q = from p in q2
                        orderby p.Name2
                        select new
                        {
                            p,
                            h = p.Family.HeadOfHousehold,
                            s = p.Family.HeadOfHouseholdSpouse,
                            m = p.OrganizationMembers.SingleOrDefault(om => om.OrganizationId == oid),
                            o = p.OrganizationMembers.SingleOrDefault(om => om.OrganizationId == oid).Organization
                        };
                if (!q.Any())
                    doc.Add(new Phrase("no data"));
                else
                    foreach (var i in q)
                    {
                        Settings setting = null;
                        if (i.o != null)
                            setting = new Settings(i.o.RegSetting, DbUtil.Db, i.o.OrganizationId);
                        var t1 = new PdfPTable(1);
                        SetDefaults(t1);
                        t1.AddCell(i.p.Name);
                        t1.AddCell(i.p.PrimaryAddress);
                        if (i.p.PrimaryAddress2.HasValue())
                            t1.AddCell(i.p.PrimaryAddress2);
                        t1.AddCell(i.p.CityStateZip);
                        t1.AddCell(i.p.EmailAddress);
                        if (i.p.HomePhone.HasValue())
                            t1.AddCell(i.p.HomePhone.FmtFone("H"));
                        if (i.p.CellPhone.HasValue())
                            t1.AddCell(i.p.CellPhone.FmtFone("C"));
                        t1.SpacingAfter = FLOAT_t1SpacingAfter;
                        doc.Add(t1);

                        var t2 = new PdfPTable(new float[] { 35, 65 });
                        SetDefaults(t2);
                        if (i.h != null
                            && i.h.PeopleId != i.p.PeopleId
                            && i.h.PositionInFamilyId == PositionInFamily.PrimaryAdult)
                        {
                            t2.AddCell(i.h.Name);
                            if (i.h.CellPhone.HasValue())
                                t2.AddCell(i.h.CellPhone.FmtFone("C"));
                            else if (i.h.HomePhone.HasValue())
                                t2.AddCell(i.h.HomePhone.FmtFone("H"));
                            else
                                t2.AddCell(" ");
                        }
                        if (i.s != null)
                        {
                            t2.AddCell(i.s.Name);
                            if (i.s.CellPhone.HasValue())
                                t2.AddCell(i.s.CellPhone.FmtFone("C"));
                            else if (i.h.HomePhone.HasValue())
                                t2.AddCell(i.s.HomePhone.FmtFone("H"));
                            else
                                t2.AddCell(" ");
                        }
                        t2.AddCell(" ");
                        t2.AddCell(" ");

                        var rr = GetRecRegOrTemp(i.p);

                        t2.AddCell("Date of Birth");
                        t2.AddCell(i.p.DOB);
                        if (i.o == null || SettingVisible(setting, "AskSize"))
                        {
                            t2.AddCell("Shirt Size:");
                            t2.AddCell(rr.ShirtSize);
                        }
                        t2.SpacingAfter = FLOAT_t1SpacingAfter;
                        doc.Add(t2);

                        if (rr.MedicalDescription.HasValue())
                            doc.Add(new Phrase("Allergies or Medical Problems: " + rr.MedicalDescription));

                        if (i.o == null || SettingVisible(setting, "AskTylenolEtc"))
                        {
                            var t4 = new PdfPTable(new float[] { 20, 80 });
                            SetDefaults(t4);
                            t4.AddCell("Tylenol:");
                            t4.AddCell(rr.Tylenol == true ? "Yes" : "No");
                            t4.AddCell("Advil:");
                            t4.AddCell(rr.Advil == true ? "Yes" : "No");
                            t4.AddCell("Robitussin:");
                            t4.AddCell(rr.Robitussin == true ? "Yes" : "No");
                            t4.AddCell("Maalox:");
                            t4.AddCell(rr.Maalox == true ? "Yes" : "No");
                            t4.SpacingAfter = FLOAT_t1SpacingAfter;
                            doc.Add(t4);
                        }
                        var t5 = new PdfPTable(new float[] { 45, 55 });
                        SetDefaults(t5);

                        if (i.o == null || SettingVisible(setting, "AskEmContact"))
                        {
                            t5.AddCell("Emergency Contact:");
                            t5.AddCell(rr.Emcontact);
                            t5.AddCell("Emergency Phone:");
                            t5.AddCell(rr.Emphone.FmtFone());
                        }
                        if (i.o == null || SettingVisible(setting, "AskInsurance"))
                        {
                            t5.AddCell("Health Insurance Carrier:");
                            t5.AddCell(rr.Insurance);
                            t5.AddCell("Policy #:");
                            t5.AddCell(rr.Policy);
                        }
                        if (i.o == null || SettingVisible(setting, "AskDoctor"))
                        {
                            t5.AddCell("Family Physician Name:");
                            t5.AddCell(rr.Doctor);
                            t5.AddCell("Family Physician Phone:");
                            t5.AddCell(rr.Docphone.FmtFone());
                        }
                        if (i.o == null || SettingVisible(setting, "AskParents"))
                        {
                            t5.AddCell("Mother's Name:");
                            t5.AddCell(rr.Mname);
                            t5.AddCell("Father's Name:");
                            t5.AddCell(rr.Fname);
                        }
                        if (i.m != null && i.m.UserData != null)
                        {
                            var m = re.Match(i.m.UserData);
                            while (m.Success)
                            {
                                var value0 = m.Groups["value0"];
                                var value = m.Groups["value"];
                                var label = m.Groups["label"];
                                if (value0.Success)
                                {
                                    t5.AddCell("");
                                    t5.AddCell(value0.Value);
                                }
                                else
                                {
                                    t5.AddCell(label.Value);
                                    t5.AddCell(value.Value);
                                }
                                m = m.NextMatch();
                            }
                        }
                        doc.Add(t5);
                        if (i.m != null)
                        {
                            var groups = string.Join(", ", i.m.OrgMemMemTags.Select(om => om.MemberTag.Name).ToArray());
                            doc.Add(new Paragraph("Groups: " + groups));
                        }
                        doc.Add(Chunk.NEXTPAGE);
                    }
            }
            else
                doc.Add(new Phrase("no data"));
            pageEvents.EndPageSet();
            doc.Close();
        }
Esempio n. 26
0
 private Settings GetMasterOrgSettings()
 {
     if (_masterSettings != null)
         return _masterSettings;
     if (masterorgid == null)
         throw new Exception("masterorgid was null in SendConfirmation");
     if (settings == null)
         throw new Exception("settings was null");
     if (!settings.ContainsKey(masterorgid.Value))
         throw new Exception("setting not found for masterorgid " + masterorgid.Value);
     ParseSettings();
     return _masterSettings = settings[masterorgid.Value];
 }
Esempio n. 27
0
 public static string Output(Settings set)
 {
     var parser = new Parser(set);
     return parser.Output();
 }
Esempio n. 28
0
 private static List<SelectListItem> ShirtSizes(Settings setting)
 {
     var askSize = setting.AskItems.FirstOrDefault(aa => aa is AskSize) as AskSize;
     var q = from ss in askSize.list
             select new SelectListItem
             {
                 Value = ss.SmallGroup,
                 Text = ss.Description
             };
     var list = q.ToList();
     list.Insert(0, new SelectListItem { Value = "0", Text = "(please select)" });
     if (askSize.AllowLastYear)
         list.Add(new SelectListItem { Value = "lastyear", Text = "Use shirt from last year" });
     return list;
 }
Esempio n. 29
0
        private void DoUpdate(string text)
        {
            csv = new CsvReader(new StringReader(text), true, '\t');
            if(csv.GetFieldIndex("OrganizationId") == -1)
                throw new UserInputException("Missing required OrganizationId column");
            while (csv.ReadNextRecord())
            {
                var oid = csv["OrganizationId"].ToInt();
                var o = DbUtil.Db.LoadOrganizationById(oid);
                rs = DbUtil.Db.CreateRegistrationSettings(oid);

                var name = FindColumn("OrganizationName");
                if (name.HasValue())
                    o.OrganizationName = name;

                UpdateAsk("AskAllergies");
                UpdateAsk("AnswersNotRequired");
                UpdateAsk("AskChurch");
                UpdateAsk("AskCoaching");
                UpdateAsk("AskDoctor");
                UpdateAsk("AnswersNotRequired");
                UpdateAsk("AskChurch");
                UpdateAsk("AskCoaching");
                UpdateAsk("AskDoctor");
                UpdateAsk("AskEmContact");
                UpdateAsk("AskInsurance");
                UpdateAsk("AskParents");
                UpdateAsk("AskSMS");
                UpdateAsk("AskTylenolEtc");
                UpdateAsk("AskSuggestedFee");
                UpdateAskLabel("AskRequest");
                UpdateAskLabel("AskTickets");

                var b = FindColumn("NoReqBirthYear").ToBool2();
                if (b.HasValue)
                    rs.NoReqBirthYear = b.Value;
                b = FindColumn("NotReqDOB").ToBool2();
                if (b.HasValue)
                    rs.NotReqDOB = b.Value;
                b = FindColumn("NotReqAddr").ToBool2();
                if (b.HasValue)
                    rs.NotReqAddr = b.Value;
                b = FindColumn("NotReqGender").ToBool2();
                if (b.HasValue)
                    rs.NotReqGender = b.Value;
                b = FindColumn("NotReqMarital").ToBool2();
                if (b.HasValue)
                    rs.NotReqMarital = b.Value;
                b = FindColumn("NotReqPhone").ToBool2();
                if (b.HasValue)
                    rs.NotReqPhone = b.Value;
                b = FindColumn("NotReqZip").ToBool2();
                if (b.HasValue)
                    rs.NotReqZip = b.Value;

                b = FindColumn("AllowOnlyOne").ToBool2();
                if (b.HasValue)
                    rs.AllowOnlyOne = b.Value;
                b = FindColumn("MemberOnly").ToBool2();
                if (b.HasValue)
                    rs.MemberOnly = b.Value;
                b = FindColumn("AddAsProspect").ToBool2();
                if (b.HasValue)
                    rs.AddAsProspect = b.Value;
                b = FindColumn("TargetExtraValues").ToBool2();
                if (b.HasValue)
                    rs.TargetExtraValues = b.Value;
                b = FindColumn("AllowReRegister").ToBool2();
                if (b.HasValue)
                    rs.AllowReRegister = b.Value;
                b = FindColumn("AllowSaveProgress").ToBool2();
                if (b.HasValue)
                    rs.AllowSaveProgress = b.Value;
                b = FindColumn("DisallowAnonymous").ToBool2();
                if (b.HasValue)
                    rs.DisallowAnonymous = b.Value;
                b = FindColumn("ApplyMaxToOtheFees").ToBool2();
                if (b.HasValue)
                    rs.ApplyMaxToOtherFees = b.Value;
                b = FindColumn("IncludeOtherFeesWithDeposit").ToBool2();
                if (b.HasValue)
                    rs.IncludeOtherFeesWithDeposit = b.Value;
                b = FindColumn("OtherFeesAddedToOrgFee").ToBool2();
                if (b.HasValue)
                    rs.OtherFeesAddedToOrgFee = b.Value;
                b = FindColumn("AskDonation").ToBool2();
                if (b.HasValue)
                    rs.AskDonation = b.Value;

                var s = FindColumn("ConfirmationTrackingCode");
                rs.ConfirmationTrackingCode = s;

                s = FindColumn("ValidateOrgs");
                rs.ValidateOrgs = s;

                s = FindColumn("Shell");
                rs.Shell = s;

                s = FindColumn("ShellBs");
                rs.ShellBs = s;

                s = FindColumn("FinishRegistrationButton");
                rs.FinishRegistrationButton = s;

                s = FindColumn("SpecialScript");
                rs.SpecialScript = s;

                s = FindColumn("GroupToJoin");
                rs.GroupToJoin = s;

                s = FindColumn("TimeOut");
                rs.TimeOut = s.ToInt();

                s = FindColumn("Fee");
                rs.Fee = s.ToDecimal();

                s = FindColumn("MaximumFee");
                rs.MaximumFee = s.ToDecimal();

                s = FindColumn("ExtraFee");
                rs.ExtraFee = s.ToDecimal();

                s = FindColumn("Deposit");
                rs.Deposit = s.ToDecimal();

                s = FindColumn("AccountingCode");
                rs.AccountingCode = s;

                s = FindColumn("ExtraValueFeeName");
                rs.ExtraValueFeeName = s;

                s = FindColumn("DonationLabel");
                rs.DonationLabel = s;

                s = FindColumn("DonationFundId");
                rs.DonationFundId = s.ToInt();

                o.UpdateRegSetting(rs);
                DbUtil.Db.SubmitChanges();
            }
        }
Esempio n. 30
0
 public static List<SelectListItem> ShirtSizes(CMSDataContext Db, Organization org)
 {
     var setting = new Settings(org.RegSetting, Db, org.OrganizationId);
     return ShirtSizes(setting);
 }
Esempio n. 31
0
 public void RegMessagesXml(Stream stream, Settings.Messages messages)
 {
     var q = FetchOrgs();
     var w = new CmsData.API.APIWriter(stream);
     w.Start("OrgSearch");
     foreach (var o in q)
     {
         var os = DbUtil.Db.CreateRegistrationSettings(o.OrganizationId);
         os.WriteXmlMessages(w.writer, messages);
     }
     w.End();
     w.writer.Flush();
 }
Esempio n. 32
0
        public ActionResult TestVoteLink(string id, string smallgroup, string message, bool? confirm)
        {
            if (!id.HasValue())
                return Content("bad link");

            var guid = id.ToGuid();
            if (guid == null)
                return Content("not a guid");
            var ot = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
            if (ot == null)
                return Content("cannot find link");
            if (ot.Used)
                return Content("link used");
            if (ot.Expires.HasValue && ot.Expires < DateTime.Now)
                return Content("link expired");
            var a = ot.Querystring.SplitStr(",", 5);
            var oid = a[0].ToInt();
            var pid = a[1].ToInt();
            var emailid = a[2].ToInt();
            var pre = a[3];
            if (a.Length == 5)
                smallgroup = a[4];
            var q = (from pp in DbUtil.Db.People
                     where pp.PeopleId == pid
                     let org = DbUtil.Db.Organizations.SingleOrDefault(oo => oo.OrganizationId == oid)
                     let om = DbUtil.Db.OrganizationMembers.SingleOrDefault(oo => oo.OrganizationId == oid && oo.PeopleId == pid)
                     select new { p = pp, org, om }).SingleOrDefault();
            if (q == null)
                return Content("peopleid {0} not found".Fmt(pid));

            if (q.org == null)
                return Content("no org " + oid);

            if (q.om == null && q.org.Limit <= q.org.MemberCount)
                return Content("sorry, maximum limit has been reached");

            if (q.om == null && (q.org.RegistrationClosed == true || q.org.OrganizationStatusId == OrgStatusCode.Inactive))
                return Content("sorry, registration has been closed");

            var setting = new Settings(q.org.RegSetting, DbUtil.Db, oid);
            if (IsSmallGroupFilled(setting, oid, smallgroup))
                return Content("sorry, maximum limit has been reached for " + smallgroup);

            return Content(@"<pre>
            looks ok
            oid={0}
            pid={1}
            emailid={2}
            </pre>".Fmt(oid, pid, emailid));
        }