Пример #1
0
        private void SetHeaders2(int id)
        {
            var org   = CurrentDatabase.LoadOrganizationById(id);
            var shell = GetAlternativeManagedGivingShell(org.OrganizationId);

            if (!shell.HasValue() && (settings == null || !settings.ContainsKey(id)) && org != null)
            {
                var setting = CurrentDatabase.CreateRegistrationSettings(id);
                shell = CurrentDatabase.ContentOfTypeHtml(setting.ShellBs)?.Body;
            }
            if (!shell.HasValue() && settings != null && settings.ContainsKey(id))
            {
                shell = CurrentDatabase.ContentOfTypeHtml(settings[id].ShellBs)?.Body;
            }

            if (!shell.HasValue())
            {
                shell = CurrentDatabase.ContentOfTypeHtml("ShellDefaultBs")?.Body;
                if (!shell.HasValue())
                {
                    shell = CurrentDatabase.ContentOfTypeHtml("DefaultShellBs")?.Body;
                }
            }


            if (shell != null && shell.HasValue())
            {
                shell = shell.Replace("{title}", ViewBag.Title);
                var re = new Regex(@"(.*<!--FORM START-->\s*).*(<!--FORM END-->.*)", RegexOptions.Singleline);
                var t  = re.Match(shell).Groups[1].Value.Replace("<!--FORM CSS-->", ViewExtensions2.Bootstrap3Css());
                ViewBag.hasshell = true;
                ViewBag.top      = t;
                var b = re.Match(shell).Groups[2].Value;
                ViewBag.bottom = b;
            }
            else
            {
                ViewBag.hasshell = false;
            }
        }
Пример #2
0
        public void SendMovedNotices()
        {
            var q = from om in CurrentDatabase.OrganizationMembers
                    where om.Organization.DivOrgs.Any(di => di.DivId == SourceDivId)
                    where om.Moved == true || EmailAllNotices
                    select new
            {
                om,
                om.Person,
                om.Person.FromEmail,
                om.Person.EmailAddress,
                om.RegisterEmail,
                om.Person.Name,
                om.PeopleId,
                om.Organization.OrganizationName,
                om.Organization.Location,
                om.Organization.LeaderName,
                om.Organization.PhoneNumber
            };
            var content = CurrentDatabase.ContentOfTypeHtml("OrgMembersModel_SendMovedNotices");

            if (content == null)
            {
                content = new Content()
                {
                    Name  = "OrgMembersModel_SendMovedNotices",
                    Body  = Resource1.OrgMembersModel_SendMovedNotices,
                    Title = "Room Assignment for {name} in {org}"
                };
                CurrentDatabase.Contents.InsertOnSubmit(content);
                CurrentDatabase.SubmitChanges();
            }
            if (content.Title == "SendMovedNotices")                   // replace old Title with new, improved version
            {
                content.Title = "Room Assignment for {name} in {org}"; // this will be the subject
            }

            var sb = new StringBuilder("Org Assignment Notices sent to:\r\n<pre>\r\n");

            foreach (var i in q)
            {
                var msg = content.Body.Replace("{name}", i.Name)
                          .Replace("{org}", i.OrganizationName)
                          .Replace("{room}", i.Location)
                          .Replace("{leader}", i.LeaderName)
                          .Replace("{phone}", CurrentDatabase.Setting("ChurchPhone", "ChurchPhone"))
                          .Replace("{church}", CurrentDatabase.Setting("NameOfChurch", "NameOfChurch"));

                var subj = content.Title // the title of the content is the subject
                           .Replace("{name}", i.Name)
                           .Replace("{org}", i.OrganizationName)
                           .Replace("{room}", i.Location);

                if (i.om.Moved == true || EmailAllNotices)
                {
                    if (i.RegisterEmail.HasValue())
                    {
                        CurrentDatabase.Email(CurrentDatabase.CurrentUser.Person.FromEmail,
                                              i.om.Person, Util.ToMailAddressList(i.RegisterEmail),
                                              subj, msg, false);
                        sb.Append($"\"{i.Name}\" [{i.FromEmail}]R ({i.PeopleId}): {i.Location}\r\n");
                        i.om.Moved = false;
                    }

                    var flist = (from fm in i.om.Person.Family.People
                                 where (fm.EmailAddress ?? "") != ""
                                 where fm.EmailAddress != i.RegisterEmail
                                 where fm.PositionInFamilyId == PositionInFamily.PrimaryAdult
                                 select fm).ToList();
                    CurrentDatabase.Email(CurrentDatabase.CurrentUser.Person.FromEmail, flist, subj, msg);
                    foreach (var m in flist)
                    {
                        sb.Append($"{m}P ({i.PeopleId}): {i.Location}\r\n");
                        i.om.Moved = false;
                    }
                }
            }
            sb.Append("</pre>\n");

            var q0 = from o in CurrentDatabase.Organizations
                     where o.DivOrgs.Any(di => di.DivId == SourceDivId)
                     where o.NotifyIds.Length > 0
                     where o.RegistrationTypeId > 0
                     select o;
            var onlineorg = q0.FirstOrDefault();

            if (onlineorg == null)
            {
                CurrentDatabase.Email(CurrentDatabase.CurrentUser.Person.FromEmail,
                                      CurrentDatabase.CurrentUserPerson,
                                      "Org Assignment notices sent to:", sb.ToString());
            }
            else
            {
                CurrentDatabase.Email(CurrentDatabase.CurrentUser.Person.FromEmail,
                                      CurrentDatabase.PeopleFromPidString(onlineorg.NotifyIds),
                                      "Org Assignment notices sent to:", sb.ToString());
            }

            CurrentDatabase.SubmitChanges();
        }