コード例 #1
0
        public void ConfirmPickSlots()
        {
            var p = List[0];

            if (p.IsNew)
            {
                p.AddPerson(null, GetEntryPoint());
            }
            if (p.CreatingAccount == true)
            {
                p.CreateAccount();
            }

            var c = DbUtil.Content("OneTimeConfirmationVolunteer");

            if (c == null)
            {
                c = new Content();
            }

            var message = Util.PickFirst(c.Body,
                                         @"Hi {name},
<p>Here is your <a href=""{url}"">link</a> to manage your volunteer commitments. (note: it will only work once for security reasons)</p> ");

            List <Person> Staff = null;

            Staff = DbUtil.Db.StaffPeopleForOrg(Orgid.Value);
            p.SendOneTimeLink(
                Staff.First().FromEmail,
                DbUtil.Db.ServerLink("/OnlineReg/ManageVolunteer/"), "Manage Your Volunteer Commitments", message);
        }
コード例 #2
0
        public void SendLinkToManageGiving()
        {
            var p = List[0];

            if (p.IsNew)
            {
                p.AddPerson(null, p.org.EntryPointId ?? 0);
            }
            if (p.CreatingAccount == true)
            {
                p.CreateAccount();
            }

            var c = DbUtil.Content("OneTimeManageGiving");

            if (c == null)
            {
                c       = new Content();
                c.Title = "Manage your recurring giving";
                c.Body  = @"Hi {name},
<p>Here is your <a href=""{url}"">link</a> to manage your recurring giving. (note: it will only work once for security reasons)</p> ";
            }

            p.SendOneTimeLink(
                DbUtil.Db.StaffPeopleForOrg(Orgid.Value).First().FromEmail,
                DbUtil.Db.ServerLink("/OnlineReg/ManageGiving/"), c.Title, c.Body);
        }
コード例 #3
0
ファイル: EnrollAndConfirm.cs プロジェクト: suraninoman/bvcms
        public ConfirmEnum ConfirmManageSubscriptions()
        {
            var p = List[0];

            if (p.IsNew)
            {
                p.AddPerson(null, GetEntryPoint());
            }
            if (p.CreatingAccount)
            {
                p.CreateAccount();
            }

            var c = DbUtil.Content("OneTimeConfirmation");

            if (c == null)
            {
                c       = new Content();
                c.Name  = "OneTimeConfirmation";
                c.Title = "Manage Your Subscriptions";
                c.Body  = @"Hi {name},
<p>Here is your <a href=""{url}"">link</a> to manage your subscriptions. (note: it will only work once for security reasons)</p>
";
                DbUtil.Db.Contents.InsertOnSubmit(c);
                DbUtil.Db.SubmitChanges();
            }

            var Staff = DbUtil.Db.StaffPeopleForOrg(masterorgid.Value);

            p.SendOneTimeLink(
                Staff.First().FromEmail,
                DbUtil.Db.ServerLink("/OnlineReg/ManageSubscriptions/"), c.Title, c.Body);
            Log("SendOneTimeLinkManageSub");
            return(ConfirmEnum.ConfirmAccount);
        }
コード例 #4
0
ファイル: EnrollAndConfirm.cs プロジェクト: suraninoman/bvcms
        internal ConfirmEnum SendLinkToManageGiving()
        {
            var p = List[0];

            if (p.IsNew)
            {
                p.AddPerson(null, p.org.EntryPointId ?? 0);
            }
            if (p.CreatingAccount)
            {
                p.CreateAccount();
            }

            var c = DbUtil.Content("OneTimeManageGiving");

            if (c == null)
            {
                c       = new Content();
                c.Name  = "OneTimeManageGiving";
                c.Title = "Manage your recurring giving";
                c.Body  = @"Hi {name},
<p>Here is your <a href=""{url}"">link</a> to manage your recurring giving. (note: it will only work once for security reasons)</p> ";
                DbUtil.Db.Contents.InsertOnSubmit(c);
                DbUtil.Db.SubmitChanges();
            }

            p.SendOneTimeLink(
                DbUtil.Db.StaffPeopleForOrg(Orgid.Value).First().FromEmail,
                DbUtil.Db.ServerLink("/OnlineReg/ManageGiving/"), c.Title, c.Body);
            Log("SendOneTimeLinkManageGiving");
            return(ConfirmEnum.ConfirmAccount);
        }
コード例 #5
0
        public void load(string sName)
        {
            var xml = DbUtil.Content("SGF-" + sName + ".xml", "");

            var xs = new XmlSerializer(typeof(SmallGroupFinder), new XmlRootAttribute("SGF"));
            var sr = new StringReader(xml);

            sgf = (SmallGroupFinder)xs.Deserialize(sr);

            sTemplate = DbUtil.Content(sgf.layout, "");
            sGutter   = DbUtil.Content(sgf.gutter, "");
        }
コード例 #6
0
        public IEnumerable <MarkerInfo> Locations()
        {
            var qlist = SmallGroupInfo();

            if (useEmbeddedMap)
            {
                UpdateGeoCodes(qlist);
            }

            var template = DbUtil.Content(DbUtil.Db, "SGF-MapTooltip", "");

            if (string.IsNullOrEmpty(template))
            {
                template = @"
<div>
[SGF:Name]<br />
[SGF:Neighborhood]<br />
Group Type: [SGF:Type]<br />
Meeting Time: [SGF:Day] at [SGF:Time]<br />
<a target='smallgroup' href='/OnlineReg/[SGF:OrgID]'>Signup</a>
</div>";
            }

            var loadAllValues   = DbUtil.Db.Setting("SGF-LoadAllExtraValues");
            var sortSettings    = sortBy;
            var mapPinTextColor = DbUtil.Db.Setting("UX-MapPinTextColor", "000000");

            return((from ql in qlist
                    where ql.gc == null || ql.gc.Latitude != 0
                    select new
            {
                model = ql,
                dict = GetValuesDictionary(ql.org, loadAllValues)
            })
                   .OrderBy(x =>
            {
                string orderBy;
                return x.dict.TryGetValue(sortSettings, out orderBy)
                        ? orderBy
                        : "SGF:Name";
            })
                   .Select(i => new MarkerInfo
            {
                html = BuildMapFromTemplate(template, i.dict),
                org = i.model.org,
                latitude = i.model.gc?.Latitude ?? 0,
                longitude = i.model.gc?.Longitude ?? 0,
                image =
                    $"//chart.googleapis.com/chart?chst=d_map_pin_letter&chld={i.model.markertext}|{i.model.color}|{mapPinTextColor}"
            }));
        }
コード例 #7
0
ファイル: SetHeaders.cs プロジェクト: SolidCharity/bvcms
        private void SetHeaders(int id)
        {
            Settings setting = null;
            var      org     = CurrentDatabase.LoadOrganizationById(id);

            if (org != null)
            {
                SetHeaders2(id);
                return;
            }

            var shell = SetAlternativeManagedGivingShell();

            if (!shell.HasValue() && (settings == null || !settings.ContainsKey(id)))
            {
                setting = CurrentDatabase.CreateRegistrationSettings(id);
                shell   = DbUtil.Content(CurrentDatabase, setting.Shell, null);
            }
            if (!shell.HasValue() && settings != null && settings.ContainsKey(id))
            {
                shell = DbUtil.Content(CurrentDatabase, settings[id].Shell, null);
            }
            if (!shell.HasValue())
            {
                shell = DbUtil.Content(CurrentDatabase, "ShellDiv-" + id, DbUtil.Content(CurrentDatabase, "ShellDefault", ""));
            }

            var s = shell;

            if (s.HasValue())
            {
                var re = new Regex(@"(.*<!--FORM START-->\s*).*(<!--FORM END-->.*)", RegexOptions.Singleline);
                var t  = re.Match(s).Groups[1].Value.Replace("<!--FORM CSS-->",
                                                             ViewExtensions2.jQueryUICss() +
                                                             "\r\n<link href=\"/Content/styles/onlinereg.css?v=8\" rel=\"stylesheet\" type=\"text/css\" />\r\n");
                ViewBag.hasshell = true;
                var b = re.Match(s).Groups[2].Value;
                ViewBag.bottom = b;
            }
            else
            {
                ViewBag.hasshell = false;
                ViewBag.header   = DbUtil.Content(CurrentDatabase, "OnlineRegHeader-" + id,
                                                  DbUtil.Content(CurrentDatabase, "OnlineRegHeader", ""));
                ViewBag.top = DbUtil.Content(CurrentDatabase, "OnlineRegTop-" + id,
                                             DbUtil.Content(CurrentDatabase, "OnlineRegTop", ""));
                ViewBag.bottom = DbUtil.Content(CurrentDatabase, "OnlineRegBottom-" + id,
                                                DbUtil.Content(CurrentDatabase, "OnlineRegBottom", ""));
            }
        }
コード例 #8
0
ファイル: CmsController.cs プロジェクト: chrisgundersen/bvcms
        public static string HeaderHtml(string altcontent, string headertext, string logoimg)
        {
            var c = DbUtil.Content("Site2Header" + altcontent) ?? DbUtil.Content("Site2Header");

            if (c != null)
            {
                return(c.Body);
            }
            return(@"
		<div id=""header"">
		   <div id=""title"">
		      <h1><img alt=""logo"" src='{0}' align=""middle"" />&nbsp;{1}</h1>
		   </div>
		</div>"        .Fmt(logoimg, headertext));
        }
コード例 #9
0
        public string GetSpecialScript()
        {
            if (org == null)
            {
                return("Organization not found.");
            }

            var settings = DbUtil.Db.CreateRegistrationSettings(org.OrganizationId);

            var body = DbUtil.Content(settings.SpecialScript, "Shell not found.");

            body = body.Replace("[action]", "/OnlineReg/SpecialRegistrationResults/" + org.OrganizationId, true);

            return(body);
        }
コード例 #10
0
        public ActionResult RunScriptExcel(string scriptname, string parameter = null)
        {
            var content = DbUtil.Content(scriptname);

            if (content == null)
            {
                return(Content("no content"));
            }
            var cs = User.IsInRole("Finance")
                ? Util.ConnectionString
                : Util.ConnectionStringReadOnly;
            var cn     = new SqlConnection(cs);
            var script = "DECLARE @p1 VARCHAR(100) = '{0}'\n{1}\n".Fmt(parameter, content.Body);

            return(cn.ExecuteReader(script).ToExcel("RunScript.xlsx"));
        }
コード例 #11
0
        public ActionResult RunScriptExcel(string scriptname, string parameter = null)
        {
            var content = DbUtil.Content(scriptname);

            if (content == null)
            {
                return(Message("no content"));
            }
            var cs = User.IsInRole("Finance")
                ? Util.ConnectionString
                : Util.ConnectionStringReadOnly;
            var cn     = new SqlConnection(cs);
            var script = RunScriptSql(DbUtil.Db, parameter, content.Body);

            return(cn.ExecuteReader(script).ToExcel("RunScript.xlsx"));
        }
コード例 #12
0
        private void SetHeaders(int id)
        {
            Settings setting = null;
            var      org     = DbUtil.Db.LoadOrganizationById(id);
            var      shell   = "";

            if ((settings == null || !settings.ContainsKey(id)) && org != null)
            {
                setting = OnlineRegModel.ParseSetting(org.RegSetting, id);
                shell   = DbUtil.Content(setting.Shell, null);
            }
            if (!shell.HasValue() && settings != null && settings.ContainsKey(id))
            {
                shell = DbUtil.Content(settings[id].Shell, null);
            }
            if (!shell.HasValue())
            {
                shell = DbUtil.Content("ShellDiv-" + id, DbUtil.Content("ShellDefault", ""));
            }

            var s = shell;

            if (s.HasValue())
            {
                var re = new Regex(@"(.*<!--FORM START-->\s*).*(<!--FORM END-->.*)", RegexOptions.Singleline);
                var t  = re.Match(s).Groups[1].Value.Replace("<!--FORM CSS-->",
                                                             @"
<link href=""/Content/styles/jquery-ui-1.10.0.custom.css"" rel=""stylesheet"" type=""text/css"" />
<link href=""/Content/styles/onlinereg.css?v=8"" rel=""stylesheet"" type=""text/css"" />
");
                ViewData["hasshell"] = true;
                ViewData["top"]      = t;
                var b = re.Match(s).Groups[2].Value;
                ViewData["bottom"] = b;
            }
            else
            {
                ViewData["hasshell"] = false;
                ViewData["header"]   = DbUtil.Content("OnlineRegHeader-" + id,
                                                      DbUtil.Content("OnlineRegHeader", ""));
                ViewData["top"] = DbUtil.Content("OnlineRegTop-" + id,
                                                 DbUtil.Content("OnlineRegTop", ""));
                ViewData["bottom"] = DbUtil.Content("OnlineRegBottom-" + id,
                                                    DbUtil.Content("OnlineRegBottom", ""));
            }
        }
コード例 #13
0
        public void load(string sName)
        {
            var xml = DbUtil.Content("SGF-" + sName + ".xml", "");

            var xs = new XmlSerializer(typeof(SmallGroupFinder), new XmlRootAttribute("SGF"));
            var sr = new StringReader(xml);

            sgf = (SmallGroupFinder)xs.Deserialize(sr);

            string[] divs = sgf.divisionid.Split(',');
            foreach (var div in divs)
            {
                divList.Add(Convert.ToInt32(div));
            }

            sShell    = DbUtil.Content(sgf.shell, "");
            sTemplate = DbUtil.Content(sgf.layout, "");
            sGutter   = DbUtil.Content(sgf.gutter, "");
        }
コード例 #14
0
        public ActionResult RunScript(string name, string parameter = null)
        {
            var content = DbUtil.Content(name);

            if (content == null)
            {
                return(Content("no content"));
            }
            var cs = User.IsInRole("Finance")
                ? Util.ConnectionString
                : Util.ConnectionStringReadOnly;
            var cn = new SqlConnection(cs);

            cn.Open();
            var script = "DECLARE @p1 VARCHAR(100) = '{0}'\n{1}\n".Fmt(parameter, content.Body);
            var rd     = cn.ExecuteReader(script);

            ViewData["name"] = name;
            return(View(rd));
        }
コード例 #15
0
        internal ConfirmEnum SendLinkToManageGiving()
        {
            var p = List[0];

            if (p.IsNew)
            {
                p.AddPerson(null, p.org.EntryPointId ?? 0);
            }

            if (p.CreatingAccount)
            {
                p.CreateAccount();
            }

            var c = DbUtil.Content(CurrentDatabase, "OneTimeManageGiving");

            if (c == null)
            {
                c       = new Content();
                c.Name  = "OneTimeManageGiving";
                c.Title = "Manage your recurring giving";
                c.Body  = @"Hi {name},
<p>Here is your <a href=""{url}"">link</a> to manage your recurring giving. (note: it will only work once for security reasons)</p> ";
                CurrentDatabase.Contents.InsertOnSubmit(c);
                CurrentDatabase.SubmitChanges();
            }

            var parameters = new List <string>
            {
                $"{(!string.IsNullOrWhiteSpace(Campus) ? $"campus={Campus}" : string.Empty)}",
                $"{(!string.IsNullOrWhiteSpace(DefaultFunds) ? $"funds={DefaultFunds}" : string.Empty)}"
            };

            var appendQueryString = string.Join("&", parameters.Where(i => !string.IsNullOrEmpty(i)));

            p.SendOneTimeLink(
                CurrentDatabase.StaffPeopleForOrg(Orgid.Value).First().FromEmail,
                CurrentDatabase.ServerLink($"/OnlineReg/ManageGiving/"), c.Title, c.Body, appendQueryString);
            Log("SendOneTimeLinkManageGiving");
            return(ConfirmEnum.ConfirmAccount);
        }
コード例 #16
0
        public ActionResult RunScript(string name, string parameter = null, string title = null)
        {
            var content = DbUtil.Content(name);

            if (content == null)
            {
                return(Content("no content"));
            }
            var cs = User.IsInRole("Finance")
                ? Util.ConnectionString
                : Util.ConnectionStringReadOnly;
            var cn = new SqlConnection(cs);

            cn.Open();
            var script = RunScriptSql(DbUtil.Db, parameter, content.Body);

            ViewBag.name = title ?? "Run Script {0} {1}".Fmt(name, parameter);
            var rd = cn.ExecuteReader(script);

            return(View(rd));
        }
コード例 #17
0
ファイル: CreateAccount.cs プロジェクト: davidbwire/bvcms
        public User CreateAccount()
        {
            var Db = DbUtil.Db;

            if (!person.EmailAddress.HasValue())
            {
                CannotCreateAccount = true;
            }
            else if (person.Users.Count() > 0) // already have account
            {
                SawExistingAccount = true;
                var user = person.Users.OrderByDescending(uu => uu.LastActivityDate).First();

                var message = DbUtil.Content("ExistingUserConfirmation",
                                             @"Hi {name},
<p>We noticed you already have an account in our church database.</p>
<p>You can login at <a href=""{host}"">{host}</a>. 
And if you can't remember your password or username, click the Forgot Password link when you get there. 
Note: you will need to know your username for this to work. If you do not know your username, then please click forgot username first.
This will send you a link you can use to reset your password.</p>
<p>You can use your account to help us maintain your correct address, email and phone numbers.
Just login to <a href=""{host}"">{host}</a> and you will be taken to your record where you can make corrections if needed.</p>
<p>Thank You</p>
");
                message = message
                          .Replace("{name}", person.Name)
                          .Replace("{host}", DbUtil.Db.CmsHost);

                Db.Email(DbUtil.AdminMail, person, "Account information for " + Db.Host, message);
            }
            else
            {
                CreatedAccount = true;
                var user = MembershipService.CreateUser(Db, person.PeopleId);
                AccountModel.SendNewUserEmail(user.Username);
                return(user);
            }
            return(null);
        }
コード例 #18
0
        public void load(string sName)
        {
            var xml = DbUtil.Content(DbUtil.Db, "SGF-" + sName + ".xml", "");

            var xs = new XmlSerializer(typeof(SmallGroupFinder), new XmlRootAttribute("SGF"));
            var sr = new StringReader(xml);

            _sgf = (SmallGroupFinder)xs.Deserialize(sr);

            var divs = _sgf.divisionid?.Split(',') ?? new string[] { };

            foreach (var div in divs)
            {
                _divList.Add(Convert.ToInt32(div));
            }

            _shell    = DbUtil.Content(DbUtil.Db, _sgf.shell, "");
            _template = DbUtil.Content(DbUtil.Db, _sgf.layout, "");
            _gutter   = DbUtil.Content(DbUtil.Db, _sgf.gutter, "");

            UseNewUi = getSetting("UseNewUI")?.value == "true";
        }
コード例 #19
0
        public void ConfirmManageSubscriptions()
        {
            var p = List[0];

            if (p.IsNew)
            {
                p.AddPerson(null, GetEntryPoint());
            }
            if (p.CreatingAccount == true)
            {
                p.CreateAccount();
            }

            var c = DbUtil.Content("OneTimeConfirmation");

            if (c == null)
            {
                c = new Content();
            }

            var message = Util.PickFirst(c.Body,
                                         @"Hi {name},
<p>Here is your <a href=""{url}"">link</a> to manage your subscriptions. (note: it will only work once for security reasons)</p> ");

            List <Person> Staff = null;

            if (masterorgid != null)
            {
                Staff = DbUtil.Db.StaffPeopleForOrg(masterorgid.Value);
            }
            else
            {
                Staff = DbUtil.Db.StaffPeopleForDiv(divid.Value);
            }
            p.SendOneTimeLink(
                Staff.First().FromEmail,
                Util.ServerLink("/OnlineReg/ManageSubscriptions/"), "Manage Your Subscriptions", message);
        }
コード例 #20
0
        private void SetHeaders2(int id)
        {
            var org   = DbUtil.Db.LoadOrganizationById(id);
            var shell = "";

            if ((settings == null || !settings.ContainsKey(id)) && org != null)
            {
                var setting = OnlineRegModel.ParseSetting(org.RegSetting, id);
                shell = DbUtil.Content(setting.ShellBs, null);
            }
            if (!shell.HasValue() && settings != null && settings.ContainsKey(id))
            {
                shell = DbUtil.Content(settings[id].ShellBs, null);
            }
            if (!shell.HasValue())
            {
                shell = DbUtil.Content("ShellDefaultBs", "");
                if (!shell.HasValue())
                {
                    shell = DbUtil.Content("DefaultShellBs", "");
                }
            }


            if (shell.HasValue())
            {
                var re = new Regex(@"(.*<!--FORM START-->\s*).*(<!--FORM END-->.*)", RegexOptions.Singleline);
                var t  = re.Match(shell).Groups[1].Value.Replace("<!--FORM CSS-->", ViewExtensions2.OnlineReg2Css());
                ViewBag.hasshell = true;
                ViewBag.top      = t;
                var b = re.Match(shell).Groups[2].Value;
                ViewBag.bottom = b;
            }
            else
            {
                ViewBag.hasshell = false;
            }
        }
コード例 #21
0
        private ConfirmEnum ConfirmPickSlots()
        {
            var p = List[0];

            if (p.IsNew)
            {
                p.AddPerson(null, GetEntryPoint());
            }

            if (p.CreatingAccount)
            {
                p.CreateAccount();
            }

            var c = DbUtil.Content(CurrentDatabase, "OneTimeConfirmationVolunteer");

            if (c == null)
            {
                c       = new Content();
                c.Name  = "OneTimeConfirmationVolunteer";
                c.Title = "Manage Your Volunteer Commitments";
                c.Body  = @"Hi {name},
<p>Here is your <a href=""{url}"">link</a> to manage your volunteer commitments. (note: it will only work once for security reasons)</p>";
                CurrentDatabase.Contents.InsertOnSubmit(c);
                CurrentDatabase.SubmitChanges();
            }

            List <Person> Staff = null;

            Staff = CurrentDatabase.StaffPeopleForOrg(Orgid.Value);

            p.SendOneTimeLink(
                Staff.First().FromEmail,
                CurrentDatabase.ServerLink("/OnlineReg/ManageVolunteer/"), c.Title, c.Body);
            Log("SendOneTimeLinkManageVol");
            URL = null;
            return(ConfirmEnum.ConfirmAccount);
        }
コード例 #22
0
ファイル: SGMapModel.cs プロジェクト: SolidCharity/bvcms
        public IEnumerable <MarkerInfo> Locations()
        {
            var qlist = SmallGroupInfo();

            var addlist = new List <GeoCode>();

            foreach (var i in qlist)
            {
                i.gc = addlist.SingleOrDefault(g => g.Address == i.addr)
                       ?? DbUtil.Db.GeoCodes.FirstOrDefault(g => g.Address == i.addr);

                if (i.gc == null)
                {
                    i.gc = GetGeocode(i.addr);
                    addlist.Add(i.gc);
                }
                else if (i.gc.Latitude == 0)
                {
                    GeoCode gcMod = GetGeocode(i.addr);
                    i.gc.Latitude  = gcMod.Latitude;
                    i.gc.Longitude = gcMod.Longitude;
                }
            }
            if (addlist.Count > 0)
            {
                DbUtil.Db.GeoCodes.InsertAllOnSubmit(addlist);
            }
            DbUtil.Db.SubmitChanges();

            var template = DbUtil.Content(DbUtil.Db, "SGF-MapTooltip", "");

            if (string.IsNullOrEmpty(template))
            {
                template = @"
<div>
[SGF:Name]<br />
[SGF:Neighborhood]<br />
Group Type: [SGF:Type]<br />
Meeting Time: [SGF:Day] at [SGF:Time]<br />
<a target='smallgroup' href='/OnlineReg/[SGF:OrgID]'>Signup</a>
</div>";
            }

            var loadAllValues   = DbUtil.Db.Setting("SGF-LoadAllExtraValues");
            var sortSettings    = DbUtil.Db.Setting("UX-SGFSortBy", "SGF:Name");
            var mapPinTextColor = DbUtil.Db.Setting("UX-MapPinTextColor", "000000");

            return((from ql in qlist
                    where ql.gc.Latitude != 0
                    select new
            {
                model = ql,
                dict = GetValuesDictionary(ql.org, loadAllValues)
            })
                   .OrderBy(x =>
            {
                string orderBy;
                return x.dict.TryGetValue(sortSettings, out orderBy)
                        ? orderBy
                        : "SGF:Name";
            })
                   .Select(i => new MarkerInfo
            {
                html = BuildMapFromTemplate(template, i.dict),
                org = i.model.org,
                latitude = i.model.gc.Latitude,
                longitude = i.model.gc.Longitude,
                image =
                    $"//chart.googleapis.com/chart?chst=d_map_pin_letter&chld={i.model.markertext}|{i.model.color}|{mapPinTextColor}"
            }));
        }
コード例 #23
0
        public static void CheckNotifyDiffEmails(Person person, string fromemail, string regemail, string orgname, string phone)
        {
            MailAddress ma = null;

            try { ma = new MailAddress(regemail); }
            catch (Exception) { }
            if (ma != null)
            {
                /* If one of the email addresses we have on record
                 * is the same as the email address given in registration
                 * then no problem, (not different) */
                if (person.EmailAddress.HasValue() &&
                    string.Compare(ma.Address, person.EmailAddress, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return;
                }
                if (person.EmailAddress2.HasValue() &&
                    String.Compare(ma.Address, person.EmailAddress2, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return;
                }

                /* So now we check to see if anybody in the famiy
                 * has the email address used in registration
                 * if so then that is OK too. */
                var flist = from fm in person.Family.People
                            where fm.PositionInFamilyId == PositionInFamily.PrimaryAdult
                            select fm;
                foreach (var fm in flist)
                {
                    if (fm.EmailAddress.HasValue() &&
                        string.Compare(ma.Address, fm.EmailAddress, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return;
                    }
                    if (fm.EmailAddress2.HasValue() &&
                        string.Compare(ma.Address, fm.EmailAddress2, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return;
                    }
                }
            }

            /* so now we have a different email address than the one on record
             * we need to notify them */
            if (person.EmailAddress.HasValue() || person.EmailAddress2.HasValue())
            {
                var c = DbUtil.Content("DiffEmailMessage");
                if (c == null)
                {
                    c       = new Content();
                    c.Body  = @"Hi {name},
<p>You registered for {org} using a different email address than the one we have on record.
It is important that you call the church <strong>{phone}</strong> to update our records
so that you will receive future important notices regarding this registration.</p>";
                    c.Title = "{org}, different email address than one on record";
                }
                var msg = c.Body.Replace("{name}", person.Name, ignoreCase: true);
                msg = msg.Replace("{first}", person.PreferredName, ignoreCase: true);
                msg = msg.Replace("{org}", orgname, ignoreCase: true);
                msg = msg.Replace("{phone}", phone.FmtFone(), ignoreCase: true);
                var subj = c.Title.Replace("{org}", orgname, ignoreCase: true);
                DbUtil.Db.Email(fromemail,
                                person, Util.ToMailAddressList(regemail),
                                subj, msg, false);
            }
            else
            {
                var c = DbUtil.Content("NoEmailMessage");
                if (c == null)
                {
                    c       = new Content();
                    c.Body  = @"Hi {name},
<p>You registered for {org}, and we found your record, 
but there was no email address on your existing record in our database.
If you would like for us to update your record with this email address or another,
Please contact the church at <strong>{phone}</strong> to let us know.
It is important that we have your email address so that
you will receive future important notices regarding this registration.
But we won't add that to your record without your permission.

Thank you</p>";
                    c.Title = "{org}, no email on your record";
                }
                var msg = c.Body.Replace("{name}", person.Name);
                msg = msg.Replace("{first}", person.PreferredName, ignoreCase: true);
                msg = msg.Replace("{org}", orgname, ignoreCase: true);
                msg = msg.Replace("{phone}", phone.FmtFone(), ignoreCase: true);
                var subj = c.Title.Replace("{org}", orgname, ignoreCase: true);
                DbUtil.Db.Email(fromemail,
                                person, Util.ToMailAddressList(regemail),
                                subj, msg, false);
            }
        }
コード例 #24
0
        public ActionResult SendLink(string id, FormCollection formCollection)
        {
            var li = new LinkInfo(sendlinkSTR, landingSTR, id);

            if (li.error.HasValue())
            {
                return(Message(li.error));
            }

            try
            {
                if (!li.pid.HasValue)
                {
                    throw new Exception("missing peopleid");
                }

                if (!li.oid.HasValue)
                {
                    throw new Exception("missing orgid");
                }

                var queueid  = li.a[2].ToInt();
                var linktype = li.a[3]; // for supportlink, this will also have the goerid
                var q        = (from pp in DbUtil.Db.People
                                where pp.PeopleId == li.pid
                                let org = DbUtil.Db.LoadOrganizationById(li.oid)
                                          select new { p = pp, org }).Single();

                if (q.org == null && DbUtil.Db.Host == "trialdb")
                {
                    var oid = li.oid + Util.TrialDbOffset;
                    q = (from pp in DbUtil.Db.People
                         where pp.PeopleId == li.pid
                         let org = DbUtil.Db.LoadOrganizationById(oid)
                                   select new { p = pp, org }).Single();
                }

                if (q.org.RegistrationClosed == true || q.org.OrganizationStatusId == OrgStatusCode.Inactive)
                {
                    throw new Exception("sorry, registration has been closed");
                }

                if (q.org.RegistrationTypeId == RegistrationTypeCode.None)
                {
                    throw new Exception("sorry, registration is no longer available");
                }

                DbUtil.LogActivity($"{sendlinkSTR}{confirmSTR}", li.oid, li.pid);

                var expires = DateTime.Now.AddMinutes(DbUtil.Db.Setting("SendlinkExpireMintues", "30").ToInt());
                var c       = DbUtil.Content("SendLinkMessage");
                if (c == null)
                {
                    c = new Content
                    {
                        Name  = "SendLinkMessage",
                        Title = "Your Link for {org}",
                        Body  = @"
<p>Here is your temporary <a href='{url}'>LINK</a> to register for {org}.</p>

<p>This link will expire at {time} (30 minutes).
You may request another link by clicking the link in the original email you received.</p>

<p>Note: If you did not request this link, please ignore this email,
or contact the church if you need help.</p>
"
                    };
                    DbUtil.Db.Contents.InsertOnSubmit(c);
                    DbUtil.Db.SubmitChanges();
                }
                var url = EmailReplacements.RegisterLinkUrl(DbUtil.Db,
                                                            li.oid.Value, li.pid.Value, queueid, linktype, expires);
                var subject = c.Title.Replace("{org}", q.org.OrganizationName);
                var msg     = c.Body.Replace("{org}", q.org.OrganizationName)
                              .Replace("{time}", expires.ToString("f"))
                              .Replace("{url}", url)
                              .Replace("%7Burl%7D", url);

                var NotifyIds = DbUtil.Db.StaffPeopleForOrg(q.org.OrganizationId);
                DbUtil.Db.Email(NotifyIds[0].FromEmail, q.p, subject, msg); // send confirmation

                return(Message($"Thank you, {q.p.PreferredName}, we just sent an email to {Util.ObscureEmail(q.p.EmailAddress)} with your link..."));
            }
            catch (Exception ex)
            {
                DbUtil.LogActivity($"{sendlinkSTR}{confirmSTR}Error: {ex.Message}", li.oid, li.pid);
                return(Message(ex.Message));
            }
        }
コード例 #25
0
        public ActionResult SendLink(string id, FormCollection formCollection)
        {
            var li = new LinkInfo(CurrentDatabase, sendlinkSTR, landingSTR, id);

            if (li.error.HasValue())
            {
                return(Message(li.error));
            }

            try
            {
                if (!li.pid.HasValue)
                {
                    throw new Exception("missing peopleid");
                }

                if (!li.oid.HasValue)
                {
                    throw new Exception("missing orgid");
                }

                var queueid  = li.a[2].ToInt();
                var linktype = li.a[3]; // for supportlink, this will also have the goerid

                int?gsid = null;
                if (linktype.Contains("supportlink:"))
                {
                    gsid = linktype.Split(':')[1].ToInt();
                }

                Organization  oorg   = null;
                Person        person = null;
                string        personPreferredName;
                string        personEmailAddress;
                GoerSupporter gs = null;
                if (li.pid == 0)
                {
                    oorg = CurrentDatabase.Organizations.SingleOrDefault(o => o.OrganizationId == li.oid);
                    gs   = CurrentDatabase.GoerSupporters.SingleOrDefault(s => s.Id == gsid);
                    personPreferredName = string.Empty;
                    personEmailAddress  = gs.NoDbEmail;
                }
                else
                {
                    var q = (from pp in CurrentDatabase.People
                             where pp.PeopleId == li.pid
                             let org = CurrentDatabase.LoadOrganizationById(li.oid)
                                       select new { p = pp, org }).Single();

                    oorg   = q.org;
                    person = q.p;
                    personPreferredName = $"{person.PreferredName}, ";
                    personEmailAddress  = person.EmailAddress;
                }

                if (oorg == null && CurrentDatabase.Host == "trialdb")
                {
                    var oid = li.oid + Util.TrialDbOffset;
                    var q   = (from pp in CurrentDatabase.People
                               where pp.PeopleId == li.pid
                               let org = CurrentDatabase.LoadOrganizationById(oid)
                                         select new { p = pp, org }).Single();

                    oorg   = q.org;
                    person = q.p;
                    personPreferredName = $"{person.PreferredName}, ";
                    personEmailAddress  = person.EmailAddress;
                }

                if (oorg.RegistrationClosed == true || oorg.OrganizationStatusId == OrgStatusCode.Inactive)
                {
                    throw new Exception("sorry, registration has been closed");
                }

                if (oorg.RegistrationTypeId == RegistrationTypeCode.None)
                {
                    throw new Exception("sorry, registration is no longer available");
                }

                DbUtil.LogActivity($"{sendlinkSTR}{confirmSTR}", li.oid, li.pid);

                var    expires = DateTime.Now.AddMinutes(CurrentDatabase.Setting("SendlinkExpireMinutes", "30").ToInt());
                string action  = (linktype.Contains("supportlink") ? "support" : "register for");
                string minutes = CurrentDatabase.Setting("SendLinkExpireMinutes", "30");
                var    c       = DbUtil.Content(CurrentDatabase, "SendLinkMessage");
                if (c == null)
                {
                    c = new Content
                    {
                        Name  = "SendLinkMessage",
                        Title = "Your Link for {org}",
                        Body  = @"
<p>Here is your temporary <a href='{url}'>LINK</a> to {action} {org}.</p>

<p>This link will expire at {time} ({minutes} minutes).
You may request another link by clicking the link in the original email you received.</p>

<p>Note: If you did not request this link, please ignore this email,
or contact the church if you need help.</p>
"
                    };
                    CurrentDatabase.Contents.InsertOnSubmit(c);
                    CurrentDatabase.SubmitChanges();
                }
                var url = EmailReplacements.RegisterLinkUrl(CurrentDatabase,
                                                            li.oid.Value, li.pid.Value, queueid, linktype, expires);
                var subject = c.Title.Replace("{org}", oorg.OrganizationName);
                var msg     = c.Body.Replace("{org}", oorg.OrganizationName)
                              .Replace("{time}", expires.ToString("f"))
                              .Replace("{url}", url)
                              .Replace("{action}", action)
                              .Replace("{minutes}", minutes)
                              .Replace("%7Burl%7D", url);

                var NotifyIds = CurrentDatabase.StaffPeopleForOrg(oorg.OrganizationId);

                if (person != null)
                {
                    CurrentDatabase.Email(NotifyIds[0].FromEmail, person, subject, msg); // send confirmation
                }
                else //send email to no db person
                {
                    var from = new MailAddress(NotifyIds[0].EmailAddress ?? NotifyIds[0].EmailAddress2, NotifyIds[0].Name);
                    CurrentDatabase.SendEmail(from, subject, msg, Util.ToMailAddressList(gs.NoDbEmail), gs.Id);
                }

                return(Message($"Thank you, {personPreferredName}we just sent an email to {Util.ObscureEmail(personEmailAddress)} with your link..."));
            }
            catch (Exception ex)
            {
                DbUtil.LogActivity($"{sendlinkSTR}{confirmSTR}Error: {ex.Message}", li.oid, li.pid);
                return(Message(ex.Message));
            }
        }