Beispiel #1
0
        private string SendLinkUrl(EmailQueueTo emailqueueto,
                                   Dictionary <string, OneTimeLink> list,
                                   string id,
                                   bool showfamily = false)
        {
            string qs = "{0},{1},{2},{3}".Fmt(id, emailqueueto.PeopleId, emailqueueto.Id,
                                              showfamily ? "registerlink2" : "registerlink");

            OneTimeLink ot;

            if (list.ContainsKey(qs))
            {
                ot = list[qs];
            }
            else
            {
                ot = new OneTimeLink
                {
                    Id          = Guid.NewGuid(),
                    Querystring = qs
                };
                OneTimeLinks.InsertOnSubmit(ot);
                SubmitChanges();
                list.Add(qs, ot);
            }
            string url = Util.URLCombine(CmsHost, "/OnlineReg/SendLink/{0}".Fmt(ot.Id.ToCode()));

            return(url);
        }
Beispiel #2
0
        private string OrgMemberReplacement(string code, EmailQueueTo emailqueueto)
        {
            var match = OrgMemberRe.Match(code);
            var divid = match.Groups["divid"].Value.ToInt();
            var type  = match.Groups["type"].Value;
            var org   = (from om in db.OrganizationMembers
                         where om.PeopleId == emailqueueto.PeopleId
                         where om.Organization.DivOrgs.Any(dd => dd.DivId == divid)
                         select om.Organization).FirstOrDefault();

            if (org == null)
            {
                return("?");
            }

            switch (type.ToLower())
            {
            case "location":
                return(org.Location);

            case "pendinglocation":
            case "pendingloc":
                return(org.PendingLoc);

            case "orgname":
            case "name":
                return(org.OrganizationName);

            case "leader":
                return(org.LeaderName);
            }
            return(code);
        }
Beispiel #3
0
        private string ExtraValueReplacement(string code, EmailQueueTo emailqueueto)
        {
            var match = ExtraValueRe.Match(code);
            var field = match.Groups["field"].Value;
            var type  = match.Groups["type"].Value;
            var ev    = db.PeopleExtras.SingleOrDefault(ee => ee.Field == field && emailqueueto.PeopleId == ee.PeopleId);

            if (ev == null)
            {
                return("");
            }

            switch (type)
            {
            case "value":
            case "code":
                return(ev.StrValue);

            case "data":
            case "text":
                return(ev.Data);

            case "date":
                return(ev.DateValue.FormatDate());

            case "int":
                return(ev.IntValue.ToString());

            case "bit":
            case "bool":
                return(ev.BitValue.ToString());
            }
            return(code);
        }
Beispiel #4
0
        private OrgInfo GetOrgInfo(EmailQueueTo emailqueueto)
        {
            OrgInfo oi = null;

            if (emailqueueto == null && db.CurrentOrgId > 0)
            {
                emailqueueto = new EmailQueueTo()
                {
                    OrgId = db.CurrentOrgId
                }
            }
            ;
            if (emailqueueto != null && emailqueueto.OrgId.HasValue)
            {
                if (!orgcount.ContainsKey(emailqueueto.OrgId.Value))
                {
                    var q = from i in db.Organizations
                            where i.OrganizationId == emailqueueto.OrgId.Value
                            select new OrgInfo()
                    {
                        Name  = i.OrganizationName,
                        Count = i.OrganizationMembers.Count().ToString()
                    };
                    oi = q.SingleOrDefault();
                    orgcount.Add(emailqueueto.OrgId.Value, oi);
                }
                else
                {
                    oi = orgcount[emailqueueto.OrgId.Value];
                }
            }
            return(oi ?? new OrgInfo());
        }

        const string AddSmallGroupRe   = @"\{addsmallgroup:\[(?<group>[^\]]*)\]\}";
Beispiel #5
0
        private string VolSubLink(string code, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary <string, OneTimeLink>();

            var doc = new HtmlDocument();

            doc.LoadHtml(code);
            HtmlNode ele    = doc.DocumentNode.Element("a");
            string   inside = ele.InnerHtml;
            Dictionary <string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

            string qs = "{0},{1},{2},{3}"
                        .Fmt(d["aid"], d["pid"], d["ticks"], emailqueueto.PeopleId);
            OneTimeLink ot = null;

            if (list.ContainsKey(qs))
            {
                ot = list[qs];
            }
            else
            {
                ot = new OneTimeLink
                {
                    Id          = Guid.NewGuid(),
                    Querystring = qs
                };
                db.OneTimeLinks.InsertOnSubmit(ot);
                db.SubmitChanges();
                list.Add(qs, ot);
            }

            var url = Util.URLCombine(db.CmsHost, "/OnlineReg/ClaimVolSub/{0}/{1}".Fmt(d["ans"], ot.Id.ToCode()));

            return(@"<a href=""{0}"">{1}</a>".Fmt(url, inside));
        }
Beispiel #6
0
        private string SendSupportLinkUrl(EmailQueueTo emailqueueto, Dictionary <string, OneTimeLink> list)
        {
            string qs = "{0},{1},{2},{3},{4}".Fmt(emailqueueto.OrgId, emailqueueto.PeopleId, emailqueueto.Id, "supportlink", emailqueueto.GoerSupportId);

            OneTimeLink ot;

            if (list.ContainsKey(qs))
            {
                ot = list[qs];
            }
            else
            {
                ot = new OneTimeLink
                {
                    Id          = Guid.NewGuid(),
                    Querystring = qs
                };
                OneTimeLinks.InsertOnSubmit(ot);
                SubmitChanges();
                list.Add(qs, ot);
            }
            string url = Util.URLCombine(CmsHost, "/OnlineReg/SendLink/{0}".Fmt(ot.Id.ToCode()));

            return(url);
        }
Beispiel #7
0
        private string UnsubscribeReplacement(EmailQueueTo emailqueueto)
        {
            var qs  = "OptOut/UnSubscribe/?enc=" + Util.EncryptForUrl($"{emailqueueto.PeopleId}|{@from.Address}");
            var url = db.ServerLink(qs);

            return($@"<a href=""{url}"">Unsubscribe</a>");
        }
Beispiel #8
0
        private string VolSubLinkReplacement(string code, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary <string, OneTimeLink>();

            var doc = new HtmlDocument();

            doc.LoadHtml(code);
            var ele    = doc.DocumentNode.Element("a");
            var inside = ele.InnerHtml.Replace("{last}", person.LastName);
            var d      = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

            var         qs = $"{d["aid"]},{d["pid"]},{d["ticks"]},{emailqueueto.PeopleId}";
            OneTimeLink ot = null;

            if (list.ContainsKey(qs))
            {
                ot = list[qs];
            }
            else
            {
                ot = new OneTimeLink
                {
                    Id          = Guid.NewGuid(),
                    Querystring = qs,
                    Expires     = Util.Now.AddHours(72)
                };
                db.OneTimeLinks.InsertOnSubmit(ot);
                db.SubmitChanges();
                list.Add(qs, ot);
            }

            var url = db.ServerLink($"/OnlineReg/ClaimVolSub/{d["ans"]}/{ot.Id.ToCode()}");

            return($@"<a href=""{url}"">{inside}</a>");
        }
        private string CreateUserTag(EmailQueueTo emailqueueto)
        {
            User user = (from u in db.Users
                         where u.PeopleId == emailqueueto.PeopleId
                         select u).FirstOrDefault();

            if (user != null)
            {
                user.ResetPasswordCode    = Guid.NewGuid();
                user.ResetPasswordExpires = DateTime.Now.AddHours(db.Setting("ResetPasswordExpiresHours", "24").ToInt());
                string link = db.ServerLink("/Account/SetPassword/" + user.ResetPasswordCode.ToString());
                db.SubmitChanges();
                return($@"<a href=""{link}"">Set password for {user.Username}</a>");
            }
            var ot = new OneTimeLink
            {
                Id          = Guid.NewGuid(),
                Querystring = emailqueueto.PeopleId.ToString()
            };

            db.OneTimeLinks.InsertOnSubmit(ot);
            db.SubmitChanges();
            var url = db.ServerLink($"/Account/CreateAccount/{ot.Id.ToCode()}");

            return($@"<a href=""{url}"">Create Account</a>");
        }
Beispiel #10
0
        public DocX DocXReplacements(Person p, int?orgId = null)
        {
            person = p;
            var eqto = new EmailQueueTo()
            {
                OrgId = orgId, PeopleId = p.PeopleId
            };
            var texta = new List <string>(stringlist);
            var dict  = new Dictionary <string, string>();

            for (var i = 1; i < texta.Count; i += 2)
            {
                if (!dict.ContainsKey(texta[i]))
                {
                    dict.Add(texta[i], DoReplaceCode(texta[i], eqto));
                }
            }
            var doc = DocXDocument.Copy();

            foreach (var d in dict)
            {
                doc.ReplaceText(d.Key, Util.PickFirst(d.Value, "____"));
            }
            return(doc);
        }
Beispiel #11
0
        private string DoSmallGroupData(string text, EmailQueueTo emailqueueto)
        {
            const string RE    = @"\{smallgroup:\[(?<prefix>[^\]]*)\](?:,(?<def>[^}]*)){0,1}\}";
            var          re    = new Regex(RE, RegexOptions.Singleline);
            Match        match = re.Match(text);

            while (match.Success && emailqueueto.OrgId.HasValue)
            {
                string tag    = match.Value;
                string prefix = match.Groups["prefix"].Value;
                string def    = match.Groups["def"].Value;
                string sg     = (from mm in OrgMemMemTags
                                 where mm.OrgId == emailqueueto.OrgId
                                 where mm.PeopleId == emailqueueto.PeopleId
                                 where mm.MemberTag.Name.StartsWith(prefix)
                                 select mm.MemberTag.Name).FirstOrDefault();
                if (!sg.HasValue())
                {
                    sg = def;
                }
                text  = text.Replace(tag, sg);
                match = match.NextMatch();
            }
            return(text);
        }
Beispiel #12
0
        private string DoRegisterLink(string text, string CmsHost, EmailQueueTo emailqueueto)
        {
            var          list       = new Dictionary <string, OneTimeLink>();
            const string VoteLinkRE = "<a[^>]*?href=\"https{0,1}://(?<rlink>registerlink2{0,1})/{0,1}\"[^>]*>.*?</a>";
            var          re         = new Regex(VoteLinkRE, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
            Match        match      = re.Match(text);

            while (match.Success)
            {
                string tag   = match.Value;
                string rlink = match.Groups["rlink"].Value.ToLower();

                var doc = new HtmlDocument();
                doc.LoadHtml(tag);
                HtmlNode ele    = doc.DocumentNode.Element("a");
                string   inside = ele.InnerHtml;
                Dictionary <string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

                if (!d.ContainsKey("id"))
                {
                    throw new Exception("RegisterTag: no id attribute");
                }
                string id = d["id"];

                string url = RegisterTagUrl(text, CmsHost, emailqueueto, list, tag, id,
                                            showfamily: rlink == "registerlink2");
                text  = text.Replace(tag, @"<a href=""{0}"">{1}</a>".Fmt(url, inside));
                match = match.NextMatch();
            }
            return(text);
        }
Beispiel #13
0
        private string DoCreateUserTag(string CmsHost, EmailQueueTo emailqueueto)
        {
            User user = (from u in Users
                         where u.PeopleId == emailqueueto.PeopleId
                         select u).FirstOrDefault();

            if (user != null)
            {
                user.ResetPasswordCode    = Guid.NewGuid();
                user.ResetPasswordExpires = DateTime.Now.AddHours(Setting("ResetPasswordExpiresHours", "24").ToInt());
                string link = Util.URLCombine(CmsHost, "/Account/SetPassword/" + user.ResetPasswordCode.ToString());
                SubmitChanges();
                return(@"<a href=""{0}"">Set password for {1}</a>".Fmt(link, user.Username));
            }
            var ot = new OneTimeLink
            {
                Id          = Guid.NewGuid(),
                Querystring = emailqueueto.PeopleId.ToString()
            };

            OneTimeLinks.InsertOnSubmit(ot);
            SubmitChanges();
            string url = Util.URLCombine(CmsHost, "/Account/CreateAccount/{0}".Fmt(ot.Id.ToCode()));

            return(@"<a href=""{0}"">Create Account</a>".Fmt(url));
        }
Beispiel #14
0
        private string VoteLinkUrl(string text,
                                   string CmsHost,
                                   EmailQueueTo emailqueueto,
                                   Dictionary <string, OneTimeLink> list,
                                   string votelink,
                                   string id,
                                   string msg,
                                   string confirm,
                                   string smallgroup,
                                   string pre)
        {
            string      qs = "{0},{1},{2},{3},{4}".Fmt(id, emailqueueto.PeopleId, emailqueueto.Id, pre, smallgroup);
            OneTimeLink ot;

            if (list.ContainsKey(qs))
            {
                ot = list[qs];
            }
            else
            {
                ot = new OneTimeLink
                {
                    Id          = Guid.NewGuid(),
                    Querystring = qs
                };
                OneTimeLinks.InsertOnSubmit(ot);
                SubmitChanges();
                list.Add(qs, ot);
            }
            string url = Util.URLCombine(CmsHost, "/OnlineReg/VoteLinkSg/{0}?confirm={1}&message={2}"
                                         .Fmt(ot.Id.ToCode(), confirm, HttpUtility.UrlEncode(msg)));

            return(url);
        }
Beispiel #15
0
        private string DoRegisterTag(string text, string CmsHost, EmailQueueTo emailqueueto)
        {
            var          list       = new Dictionary <string, OneTimeLink>();
            const string VoteLinkRE = @"<registertag[^>]*>(?<inside>.+?)</registertag>";
            var          re         = new Regex(VoteLinkRE, RegexOptions.Singleline | RegexOptions.Multiline);
            Match        match      = re.Match(text);

            while (match.Success)
            {
                string tag    = match.Value;
                string inside = match.Groups["inside"].Value;

                var doc = new HtmlDocument();
                doc.LoadHtml(tag);
                HtmlNode ele = doc.DocumentNode.Element("registertag");
                Dictionary <string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

                if (!d.ContainsKey("id"))
                {
                    throw new Exception("RegisterTag: no id attribute");
                }
                string id = d["id"];

                string url = RegisterTagUrl(text, CmsHost, emailqueueto, list, tag, id);
                text  = text.Replace(tag, @"<a href=""{0}"">{1}</a>".Fmt(url, inside));
                match = match.NextMatch();
            }
            return(text);
        }
Beispiel #16
0
        public string PledgeReplacement(string code, EmailQueueTo emailqueueto)
        {
            var match  = PledgeRe.Match(code);
            var type   = match.Groups["type"].Value;
            var fund   = match.Groups["fund"].Value;
            var fundid = fund.AllDigits()
                ? fund.ToInt()
                : db.Setting(fund, "-1").ToInt();
            var i = GetPledgeInfo(fundid, emailqueueto);

            if (i == null)
            {
                return("");
            }

            switch (type.ToLower())
            {
            case "bal":
                return((i.Balance ?? 0).ToString("N"));

            case "amt":
                return((i.PledgeAmt ?? 0).ToString("N"));

            case "given":
                return((i.GivenAmt ?? 0).ToString("N"));
            }
            return(code);
        }
Beispiel #17
0
        private string RegisterTagUrl(string text,
                                      string CmsHost,
                                      EmailQueueTo emailqueueto,
                                      Dictionary <string, OneTimeLink> list,
                                      string votelink,
                                      string id,
                                      bool showfamily = false)
        {
            string      qs = "{0},{1},{2}".Fmt(id, emailqueueto.PeopleId, emailqueueto.Id);
            OneTimeLink ot;

            if (list.ContainsKey(qs))
            {
                ot = list[qs];
            }
            else
            {
                ot = new OneTimeLink
                {
                    Id          = Guid.NewGuid(),
                    Querystring = qs
                };
                OneTimeLinks.InsertOnSubmit(ot);
                SubmitChanges();
                list.Add(qs, ot);
            }
            string url = Util.URLCombine(CmsHost, "/OnlineReg/RegisterLink/{0}".Fmt(ot.Id.ToCode()));

            if (showfamily)
            {
                url += "?showfamily=true";
            }
            return(url);
        }
Beispiel #18
0
        private string MasterLinkReplacement(string code, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary <string, OneTimeLink>();

            var doc = new HtmlDocument();

            doc.LoadHtml(code);
            var ele    = doc.DocumentNode.Element("a");
            var inside = ele.InnerHtml.Replace("{last}", person.LastName);
            var d      = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

            var oid = GetId(d, "MasterLink");
            var qs  = $"{oid},{emailqueueto.PeopleId},{emailqueueto.Id},{"masterlink"}";

            OneTimeLink ot;

            if (list.ContainsKey(qs))
            {
                ot = list[qs];
            }
            else
            {
                ot = new OneTimeLink
                {
                    Id          = Guid.NewGuid(),
                    Querystring = qs
                };
                db.OneTimeLinks.InsertOnSubmit(ot);
                db.SubmitChanges();
                list.Add(qs, ot);
            }
            var url = db.ServerLink($"/OnlineReg/SendLink/{ot.Id.ToCode()}");

            return($@"<a href=""{url}"">{inside}</a>");
        }
        private OrgInfo GetOrgInfo(EmailQueueTo emailqueueto)
        {
            OrgInfo oi = null;

            if (emailqueueto != null && emailqueueto.OrgId.HasValue)
            {
                if (!orgcount.ContainsKey(emailqueueto.OrgId.Value))
                {
                    var q = from i in db.Organizations
                            where i.OrganizationId == emailqueueto.OrgId.Value
                            select new OrgInfo()
                    {
                        Name  = i.OrganizationName,
                        Count = i.OrganizationMembers.Count().ToString()
                    };
                    oi = q.SingleOrDefault();
                    orgcount.Add(emailqueueto.OrgId.Value, oi);
                }
                else
                {
                    oi = orgcount[emailqueueto.OrgId.Value];
                }
            }
            return(oi ?? new OrgInfo());
        }
Beispiel #20
0
        private string UnSubscribeLink(EmailQueueTo emailqueueto)
        {
            var qs  = "OptOut/UnSubscribe/?enc=" + Util.EncryptForUrl("{0}|{1}".Fmt(emailqueueto.PeopleId, from.Address));
            var url = Util.URLCombine(db.CmsHost, qs);

            return(@"<a href=""{0}"">Unsubscribe</a>".Fmt(url));
        }
Beispiel #21
0
        private string SupportLink(string code, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary <string, OneTimeLink>();

            var doc = new HtmlDocument();

            doc.LoadHtml(code);
            HtmlNode ele    = doc.DocumentNode.Element("a");
            string   inside = ele.InnerHtml;
            Dictionary <string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

            var    oid = GetId(d, "SupportLink");
            string qs  = "{0},{1},{2},{3},{4}".Fmt(oid, emailqueueto.PeopleId, emailqueueto.Id, "supportlink", emailqueueto.GoerSupportId);

            OneTimeLink ot;

            if (list.ContainsKey(qs))
            {
                ot = list[qs];
            }
            else
            {
                ot = new OneTimeLink
                {
                    Id          = Guid.NewGuid(),
                    Querystring = qs
                };
                db.OneTimeLinks.InsertOnSubmit(ot);
                db.SubmitChanges();
                list.Add(qs, ot);
            }
            string url = db.ServerLink("/OnlineReg/SendLink/{0}".Fmt(ot.Id.ToCode()));

            return(@"<a href=""{0}"">{1}</a>".Fmt(url, inside));
        }
Beispiel #22
0
        private string DoRegisterTag2(string text, EmailQueueTo emailqueueto)
        {
            var          list       = new Dictionary <string, OneTimeLink>();
            const string VoteLinkRE = @"&lt;registertag .*?&gt;(?<inside>.+?)&lt;/registertag&gt;";
            var          re         = new Regex(VoteLinkRE, RegexOptions.Singleline | RegexOptions.Multiline);
            Match        match      = re.Match(text);

            while (match.Success)
            {
                string tag    = match.Value;
                string inside = HttpUtility.HtmlDecode(match.Groups["inside"].Value);

                var doc = new HtmlDocument();
                doc.LoadHtml(tag);
                HtmlNode ele = doc.DocumentNode.Element("registertag");
                Dictionary <string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

                var id = GetId(d, "RegisterTag");

                string url = RegisterTagUrl(emailqueueto, list, id);
                text  = text.Replace(tag, @"<a href=""{0}"">{1}</a>".Fmt(url, inside));
                match = match.NextMatch();
            }
            return(text);
        }
Beispiel #23
0
        private string DoSendLink(string text, EmailQueueTo emailqueueto)
        {
            var          list       = new Dictionary <string, OneTimeLink>();
            const string SendLinkRE = "<a[^>]*?href=\"https{0,1}://(?<slink>sendlink2{0,1})/{0,1}\"[^>]*>.*?</a>";
            var          re         = new Regex(SendLinkRE, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
            Match        match      = re.Match(text);

            while (match.Success)
            {
                string tag   = match.Value;
                string slink = match.Groups["slink"].Value.ToLower();

                var doc = new HtmlDocument();
                doc.LoadHtml(tag);
                HtmlNode ele    = doc.DocumentNode.Element("a");
                string   inside = ele.InnerHtml;
                Dictionary <string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

                var id = GetId(d, "SendLink");

                string url = SendLinkUrl(emailqueueto, list, id, showfamily: slink == "sendlink2");
                text  = text.Replace(tag, @"<a href=""{0}"">{1}</a>".Fmt(url, inside));
                match = match.NextMatch();
            }
            return(text);
        }
        private string OrgBarcode(string code, EmailQueueTo emailqueueto)
        {
            var oid = code.StartsWith("{orgbarcode:")
                ? code.Substring(12).TrimEnd('}').ToInt()
                : emailqueueto.OrgId;

            return($@"<img src='{db.ServerLink($"/Track/Barcode/{oid}-{emailqueueto.PeopleId}")}' width='95%' />");
        }
Beispiel #25
0
        private string DoVoteLinkAnchorStyle(string text, EmailQueueTo emailqueueto)
        {
            var          list       = new Dictionary <string, OneTimeLink>();
            const string VoteLinkRE = @"{votelink(?<inside>[^}]*)}";
            var          re         = new Regex(VoteLinkRE, RegexOptions.Singleline | RegexOptions.Multiline);
            Match        match      = re.Match(text);

            while (match.Success)
            {
                string votelink = match.Value;
                string anchor   = "<a " + match.Groups["inside"].Value + ">text</a>";
                anchor = anchor.Replace("&quot;", "\"");
                anchor = anchor.Replace("&rdquo;", "\"");
                anchor = anchor.Replace("&ldquo;", "\"");

                var doc = new HtmlDocument();
                doc.LoadHtml(anchor);
                HtmlNode ele = doc.DocumentNode.Element("a");
                Dictionary <string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);
                string txt = "click here";
                if (d.ContainsKey("text"))
                {
                    txt = d["text"];
                }

                string msg = "Thank you for responding.";
                if (d.ContainsKey("message"))
                {
                    msg = d["message"];
                }

                string confirm = "false";
                if (d.ContainsKey("confirm"))
                {
                    confirm = d["confirm"];
                }

                if (!d.ContainsKey("smallgroup"))
                {
                    throw new Exception("Votelink: no smallgroup attribute");
                }
                string   smallgroup = d["smallgroup"];
                string   pre        = "";
                string[] a          = smallgroup.SplitStr(":");
                if (a.Length > 1)
                {
                    pre = a[0];
                }

                var id = GetId(d, "VoteLink");

                string url = VoteLinkUrl(text, emailqueueto, list, votelink, id, msg, confirm, smallgroup, pre);
                text = text.Replace(votelink, @"<a href=""{0}"">{1}</a>".Fmt(url, txt));

                match = match.NextMatch();
            }
            return(text);
        }
Beispiel #26
0
        private string RsvpLink(string code, EmailQueueTo emailqueueto)
        {
            //<a dir="ltr" href="http://rsvplink" id="798" rel="meetingid" title="This is a message">test</a>
            var list = new Dictionary <string, OneTimeLink>();

            var doc = new HtmlDocument();

            doc.LoadHtml(code);
            HtmlNode ele    = doc.DocumentNode.Element("a");
            string   inside = ele.InnerHtml;
            Dictionary <string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

            string msg = "Thank you for responding.";

            if (d.ContainsKey("title"))
            {
                msg = d["title"];
            }

            string confirm = "false";

            if (d.ContainsKey("dir") && d["dir"] == "ltr")
            {
                confirm = "true";
            }

            string smallgroup = null;

            if (d.ContainsKey("rel"))
            {
                smallgroup = d["rel"];
            }

            var id = GetId(d, "RsvpLink");

            string      qs = "{0},{1},{2},{3}".Fmt(id, emailqueueto.PeopleId, emailqueueto.Id, smallgroup);
            OneTimeLink ot;

            if (list.ContainsKey(qs))
            {
                ot = list[qs];
            }
            else
            {
                ot = new OneTimeLink
                {
                    Id          = Guid.NewGuid(),
                    Querystring = qs
                };
                db.OneTimeLinks.InsertOnSubmit(ot);
                db.SubmitChanges();
                list.Add(qs, ot);
            }
            string url = Util.URLCombine(db.CmsHost, "/OnlineReg/RsvpLinkSg/{0}?confirm={1}&message={2}"
                                         .Fmt(ot.Id.ToCode(), confirm, HttpUtility.UrlEncode(msg)));

            return(@"<a href=""{0}"">{1}</a>".Fmt(url, inside));
        }
Beispiel #27
0
        public string SqlLookupReplacement(string code, EmailQueueTo emailqueueto)
        {
            var match   = SqlLookupRe.Match(code);
            var sqlfile = match.Groups["file"].Value;
            var column  = match.Groups["col"].Value;
            var i       = GetSqlInfo(sqlfile, column, emailqueueto);

            return(i?[column].ToString() ?? "");
        }
Beispiel #28
0
        private PledgeBalance GetPledgeInfo(int fundid, EmailQueueTo emailqueueto)
        {
            var pid = emailqueueto.PeopleId;

            if (pledgeinfos == null)
            {
                pledgeinfos = db.PledgeBalances(fundid).Where(vv => vv.PledgeAmt > 0).ToList();
            }
            return(pledgeinfos.SingleOrDefault(vv => vv.CreditGiverId == pid || vv.SpouseId == pid) ?? new PledgeBalance());
        }
Beispiel #29
0
        public string DoReplacements(Person p, EmailQueueTo emailqueueto)
        {
            var pi = emailqueueto.OrgId.HasValue
                ? (from m in db.OrganizationMembers
                   let ts = db.ViewTransactionSummaries.SingleOrDefault(tt => tt.RegId == m.TranId && tt.PeopleId == m.PeopleId)
                            where m.PeopleId == emailqueueto.PeopleId && m.OrganizationId == emailqueueto.OrgId
                            select new PayInfo
            {
                PayLink = m.PayLink2(db),
                Amount = ts.IndAmt,
                AmountPaid = ts.IndPaid,
                AmountDue = ts.IndDue,
                RegisterMail = m.RegisterEmail
            }).SingleOrDefault()
                : null;

            var aa = db.GetAddressList(p);

            if (emailqueueto.EmailQueue.CCParents ?? false)
            {
                aa.AddRange(db.GetCcList(p, emailqueueto));
            }

            if (emailqueueto.AddEmail.HasValue())
            {
                foreach (string ad in emailqueueto.AddEmail.SplitStr(","))
                {
                    Util.AddGoodAddress(aa, ad);
                }
            }

            if (emailqueueto.OrgId.HasValue && pi != null)
            {
                Util.AddGoodAddress(aa, Util.FullEmail(pi.RegisterMail, p.Name));
            }

            ListAddresses = aa.DistinctEmails();

            var noreplacements = emailqueueto.EmailQueue.NoReplacements ?? false;
            var texta          = new List <string>(stringlist);

            for (var i = 1; i < texta.Count; i += 2)
            {
                if (noreplacements)
                {
                    texta[i] = "";
                }
                else
                {
                    texta[i] = DoReplaceCode(texta[i], p, pi, emailqueueto);
                }
            }

            return(string.Join("", texta));
        }
Beispiel #30
0
        private string DoVoteLink(string text, string CmsHost, EmailQueueTo emailqueueto)
        {
            //<a dir="ltr" href="http://votelink" id="798" rel="smallgroup" title="This is a message">test</a>
            var          list       = new Dictionary <string, OneTimeLink>();
            const string VoteLinkRE = "<a[^>]*?href=\"https{0,1}://votelink/{0,1}\"[^>]*>.*?</a>";
            var          re         = new Regex(VoteLinkRE, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
            Match        match      = re.Match(text);

            while (match.Success)
            {
                string tag = match.Value;

                var doc = new HtmlDocument();
                doc.LoadHtml(tag);
                HtmlNode ele    = doc.DocumentNode.Element("a");
                string   inside = ele.InnerHtml;
                Dictionary <string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

                string msg = "Thank you for responding.";
                if (d.ContainsKey("title"))
                {
                    msg = d["title"];
                }

                string confirm = "false";
                if (d.ContainsKey("dir") && d["dir"] == "ltr")
                {
                    confirm = "true";
                }

                if (!d.ContainsKey("rel"))
                {
                    throw new Exception("Votelink: no smallgroup attribute");
                }
                string   smallgroup = d["rel"];
                string   pre        = "";
                string[] a          = smallgroup.SplitStr(":");
                if (a.Length > 1)
                {
                    pre = a[0];
                }

                if (!d.ContainsKey("id"))
                {
                    throw new Exception("Votelink: no id attribute");
                }
                string id = d["id"];

                string url = VoteLinkUrl(text, CmsHost, emailqueueto, list, tag, id, msg, confirm, smallgroup, pre);
                text  = text.Replace(tag, @"<a href=""{0}"">{1}</a>".Fmt(url, inside));
                match = match.NextMatch();
            }
            return(text);
        }
Beispiel #31
0
 private string VoteLinkUrl(string text,
                            EmailQueueTo emailqueueto,
                            Dictionary<string, OneTimeLink> list,
                            string votelink,
                            string id,
                            string msg,
                            string confirm,
                            string smallgroup,
                            string pre)
 {
     string qs = "{0},{1},{2},{3},{4}".Fmt(id, emailqueueto.PeopleId, emailqueueto.Id, pre, smallgroup);
     OneTimeLink ot;
     if (list.ContainsKey(qs))
         ot = list[qs];
     else
     {
         ot = new OneTimeLink
             {
                 Id = Guid.NewGuid(),
                 Querystring = qs
             };
         OneTimeLinks.InsertOnSubmit(ot);
         SubmitChanges();
         list.Add(qs, ot);
     }
     string url = Util.URLCombine(CmsHost, "/OnlineReg/VoteLinkSg/{0}?confirm={1}&message={2}"
                                               .Fmt(ot.Id.ToCode(), confirm, HttpUtility.UrlEncode(msg)));
     return url;
 }
Beispiel #32
0
        //&lt;votetag .*?&gt;(?<inside>.+?)&lt;/votetag&gt;
        private string DoVoteTag2(string text, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary<string, OneTimeLink>();
            const string VoteLinkRE = @"&lt;votetag .*?&gt;(?<inside>.+?)&lt;/votetag&gt;";
            var re = new Regex(VoteLinkRE, RegexOptions.Singleline | RegexOptions.Multiline);
            Match match = re.Match(text);
            while (match.Success)
            {
                string tag = match.Value;
                string inside = HttpUtility.HtmlDecode(match.Groups["inside"].Value);

                var doc = new HtmlDocument();
                doc.LoadHtml(tag);
                HtmlNode ele = doc.DocumentNode.Element("votetag");
                Dictionary<string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

                string msg = "Thank you for responding.";
                if (d.ContainsKey("message"))
                    msg = d["message"];

                string confirm = "false";
                if (d.ContainsKey("confirm"))
                    confirm = d["confirm"];

                if (!d.ContainsKey("smallgroup"))
                    throw new Exception("Votelink: no smallgroup attribute");
                string smallgroup = d["smallgroup"];
                string pre = "";
                string[] a = smallgroup.SplitStr(":");
                if (a.Length > 1)
                    pre = a[0];

                var id = GetId(d, "VoteTag");

                string url = VoteLinkUrl(text, emailqueueto, list, tag, id, msg, confirm, smallgroup, pre);
                text = text.Replace(tag, @"<a href=""{0}"">{1}</a>".Fmt(url, inside));
                match = match.NextMatch();
            }
            return text;
        }
Beispiel #33
0
        private string DoVoteLink(string text, EmailQueueTo emailqueueto)
        {
            //<a dir="ltr" href="http://votelink" id="798" rel="smallgroup" title="This is a message">test</a>
            var list = new Dictionary<string, OneTimeLink>();
            const string VoteLinkRE = "<a[^>]*?href=\"https{0,1}://votelink/{0,1}\"[^>]*>.*?</a>";
            var re = new Regex(VoteLinkRE, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
            Match match = re.Match(text);
            while (match.Success)
            {
                string tag = match.Value;

                var doc = new HtmlDocument();
                doc.LoadHtml(tag);
                HtmlNode ele = doc.DocumentNode.Element("a");
                string inside = ele.InnerHtml;
                Dictionary<string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

                string msg = "Thank you for responding.";
                if (d.ContainsKey("title"))
                    msg = d["title"];

                string confirm = "false";
                if (d.ContainsKey("dir") && d["dir"] == "ltr")
                    confirm = "true";

                if (!d.ContainsKey("rel"))
                    throw new Exception("Votelink: no smallgroup attribute");
                string smallgroup = d["rel"];
                string pre = "";
                string[] a = smallgroup.SplitStr(":");
                if (a.Length > 1)
                    pre = a[0];

                var id = GetId(d, "VoteLink");

                string url = VoteLinkUrl(text, emailqueueto, list, tag, id, msg, confirm, smallgroup, pre);
                text = text.Replace(tag, @"<a href=""{0}"">{1}</a>".Fmt(url, inside));
                match = match.NextMatch();
            }
            return text;
        }
Beispiel #34
0
 private string DoSmallGroupData(string text, EmailQueueTo emailqueueto)
 {
     const string RE = @"\{smallgroup:\[(?<prefix>[^\]]*)\](?:,(?<def>[^}]*)){0,1}\}";
     var re = new Regex(RE, RegexOptions.Singleline);
     Match match = re.Match(text);
     while (match.Success && emailqueueto.OrgId.HasValue)
     {
         string tag = match.Value;
         string prefix = match.Groups["prefix"].Value;
         string def = match.Groups["def"].Value;
         string sg = (from mm in OrgMemMemTags
                      where mm.OrgId == emailqueueto.OrgId
                      where mm.PeopleId == emailqueueto.PeopleId
                      where mm.MemberTag.Name.StartsWith(prefix)
                      select mm.MemberTag.Name).FirstOrDefault();
         if (!sg.HasValue())
             sg = def;
         text = text.Replace(tag, sg);
         match = match.NextMatch();
     }
     return text;
 }
Beispiel #35
0
        public List<MailAddress> DoReplacements(ref string text, Person p, EmailQueueTo emailqueueto)
        {
            if (text == null)
                text = "(no content)";
            if (text.Contains("{name}", ignoreCase: true))
                if (p.Name.Contains("?") || p.Name.Contains("unknown", true))
                    text = text.Replace("{name}", string.Empty);
                else
                    text = text.Replace("{name}", p.Name, ignoreCase: true);

            if (text.Contains("{first}", ignoreCase: true))
                if (p.PreferredName.Contains("?", true) || (p.PreferredName.Contains("unknown", true)))
                    text = text.Replace("{first}", string.Empty, ignoreCase: true);
                else
                    text = text.Replace("{first}", p.PreferredName, ignoreCase: true);
            text = text.Replace("{last}", p.LastName, ignoreCase: true);
            if (text.Contains("{occupation}", ignoreCase: true))
                text = text.Replace("{occupation}", p.OccupationOther, ignoreCase: true);

            if (text.Contains("{emailhref}", ignoreCase: true))
            {
                string eurl = Util.URLCombine(CmsHost, "Manage/Emails/View/" + emailqueueto.Id);
                text = text.Replace("{emailhref}", eurl, ignoreCase: true);
            }

            text = DoVoteLinkAnchorStyle(text, emailqueueto);
            text = DoVoteTag(text, emailqueueto);
            text = DoVoteTag2(text, emailqueueto);
            text = DoRegisterTag(text, emailqueueto);
            text = DoRegisterTag2(text, emailqueueto);
            text = DoExtraValueData(text, emailqueueto);
            if (emailqueueto.OrgId.HasValue)
            {
                if (text.Contains("{smallgroup:", ignoreCase: true))
                    text = DoSmallGroupData(text, emailqueueto);
                if (text.Contains("{addsmallgroup:", ignoreCase: true))
                    text = DoAddSmallGroup(text, emailqueueto);
                if (text.Contains("{nextmeetingtime}", ignoreCase: true))
                    text = DoMeetingDate(text, emailqueueto);
                if (text.Contains("{smallgroups", ignoreCase: true))
                    text = DoSmallGroups(text, emailqueueto);
            }
            if (text.Contains("{today}", ignoreCase: true))
                text = text.Replace("{today}", DateTime.Today.ToShortDateString());
            if (text.Contains("{createaccount}", ignoreCase: true))
                text = text.Replace("{createaccount}", DoCreateUserTag(emailqueueto));
            if (text.Contains("{peopleid}", ignoreCase: true))
                text = text.Replace("{peopleid}", emailqueueto.PeopleId.ToString(), ignoreCase: true);
            if (text.Contains("http://votelink", ignoreCase: true))
                text = DoVoteLink(text, emailqueueto);
            if (text.Contains("http://registerlink", ignoreCase: true))
                text = DoRegisterLink(text, emailqueueto);
            if (text.Contains("http://rsvplink", ignoreCase: true))
                text = DoRsvpLink(text, emailqueueto);
            if (text.Contains("http://volsublink", ignoreCase: true))
                text = DoVolSubLink(text, emailqueueto);
            if (text.Contains("http://volreqlink", ignoreCase: true))
                text = DoVolReqLink(text, emailqueueto);
            if (text.Contains("{barcode}", ignoreCase: true))
            {
                string link = Util.URLCombine(CmsHost, "/Track/Barcode/" + emailqueueto.PeopleId);
                text = text.Replace("{barcode}", "<img src='" + link + "' />", ignoreCase: true);
            }
            if (text.Contains("{cellphone}", ignoreCase: true))
                text = text.Replace("{cellphone}", p.CellPhone.HasValue() ? p.CellPhone.FmtFone() : "no cellphone on record", true);

            if (text.Contains("{campus}", ignoreCase: true))
                text = text.Replace("{campus}", p.CampusId != null ? p.Campu.Description : "No Campus Specified", true);

            if (emailqueueto.Guid.HasValue)
            {
                string turl = Util.URLCombine(CmsHost, "/Track/Key/" + emailqueueto.Guid.Value.GuidToQuerystring());
                text = text.Replace("{track}", "<img src=\"{0}\" />".Fmt(turl), ignoreCase: true);
            }

            List<MailAddress> aa = GetAddressList(p);

            if (emailqueueto.AddEmail.HasValue())
                foreach (string ad in emailqueueto.AddEmail.SplitStr(","))
                    Util.AddGoodAddress(aa, ad);

            if (emailqueueto.OrgId.HasValue)
            {
                var qm = (from m in OrganizationMembers
                          where m.PeopleId == emailqueueto.PeopleId && m.OrganizationId == emailqueueto.OrgId
                          select new { m.PayLink, m.Amount, m.AmountPaid, m.RegisterEmail }).SingleOrDefault();
                if (qm != null)
                {
                    if (qm.PayLink.HasValue())
                        if (text.Contains("{paylink}", ignoreCase: true))
                            text = text.Replace("{paylink}", "<a href=\"{0}\">payment link</a>".Fmt(qm.PayLink),
                                                ignoreCase: true);
                    if (text.Contains("{amtdue}", ignoreCase: true))
                        text = text.Replace("{amtdue}", (qm.Amount - qm.AmountPaid).ToString2("c"), ignoreCase: true);
                    Util.AddGoodAddress(aa, Util.FullEmail(qm.RegisterEmail, p.Name));
                }
            }
            return aa.DistinctEmails();
        }
Beispiel #36
0
 private string DoMeetingDate(string text, EmailQueueTo emailqueueto)
 {
     DateTime mt = (from aa in Attends
                    where aa.OrganizationId == emailqueueto.OrgId
                    where aa.PeopleId == emailqueueto.PeopleId
                    where aa.Commitment == AttendCommitmentCode.Attending
                    where aa.MeetingDate > DateTime.Now
                    orderby aa.MeetingDate
                    select aa.MeetingDate).FirstOrDefault();
     text = text.Replace("{nextmeetingtime}", mt.ToString("g"));
     return text;
 }
Beispiel #37
0
 private string DoCreateUserTag(EmailQueueTo emailqueueto)
 {
     User user = (from u in Users
                  where u.PeopleId == emailqueueto.PeopleId
                  select u).FirstOrDefault();
     if (user != null)
     {
         user.ResetPasswordCode = Guid.NewGuid();
         user.ResetPasswordExpires = DateTime.Now.AddHours(Setting("ResetPasswordExpiresHours", "24").ToInt());
         string link = Util.URLCombine(CmsHost, "/Account/SetPassword/" + user.ResetPasswordCode.ToString());
         SubmitChanges();
         return @"<a href=""{0}"">Set password for {1}</a>".Fmt(link, user.Username);
     }
     var ot = new OneTimeLink
         {
             Id = Guid.NewGuid(),
             Querystring = emailqueueto.PeopleId.ToString()
         };
     OneTimeLinks.InsertOnSubmit(ot);
     SubmitChanges();
     string url = Util.URLCombine(CmsHost, "/Account/CreateAccount/{0}".Fmt(ot.Id.ToCode()));
     return @"<a href=""{0}"">Create Account</a>".Fmt(url);
 }
Beispiel #38
0
 private string RegisterTag(string code, EmailQueueTo emailqueueto)
 {
     var doc = new HtmlDocument();
     if (code.Contains("&lt;"))
         code = HttpUtility.HtmlDecode(code);
     doc.LoadHtml(code);
     var ele = doc.DocumentNode.FirstChild;
     var inside = ele.InnerHtml.Replace("{last}", person.LastName);
     var id = ele.Id.ToInt();
     var url = RegisterLinkUrl(db, id, emailqueueto.PeopleId, emailqueueto.Id, "registerlink");
     return $@"<a href=""{url}"">{inside}</a>";
 }
Beispiel #39
0
		private void detach_EmailQueueTos(EmailQueueTo entity)
		{
			this.SendPropertyChanging();
			entity.Person = null;
		}
Beispiel #40
0
        private string RegText(string code, EmailQueueTo emailqueueto)
        {
            var match = regTextRe.Match(code);
            if (!match.Success)
                return code;
            var field = match.Groups["field"].Value;
            var type = match.Groups["type"].Value;
            var answer = (from qa in db.ViewOnlineRegQAs
                          where qa.Question == field
                          where qa.Type == type
                          where qa.PeopleId == emailqueueto.PeopleId
                          where qa.OrganizationId == emailqueueto.OrgId
                          select qa.Answer).SingleOrDefault();

            return answer;
        }
Beispiel #41
0
        private string RsvpLink(string code, EmailQueueTo emailqueueto)
        {
            //<a dir="ltr" href="http://rsvplink" id="798" rel="meetingid" title="This is a message">test</a>
            var list = new Dictionary<string, OneTimeLink>();

            var doc = new HtmlDocument();
            doc.LoadHtml(code);
            var ele = doc.DocumentNode.Element("a");
            var inside = ele.InnerHtml.Replace("{last}", person.LastName);
            var d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

            var msg = "Thank you for responding.";
            if (d.ContainsKey("title"))
                msg = d["title"];

            string confirm = "false";
            if (d.ContainsKey("dir") && d["dir"] == "ltr")
                confirm = "true";

            string smallgroup = null;
            if (d.ContainsKey("rel"))
                smallgroup = d["rel"];

            var id = GetId(d, "RsvpLink");

            string qs = $"{id},{emailqueueto.PeopleId},{emailqueueto.Id},{smallgroup}";
            OneTimeLink ot;
            if (list.ContainsKey(qs))
                ot = list[qs];
            else
            {
                ot = new OneTimeLink
                {
                    Id = Guid.NewGuid(),
                    Querystring = qs
                };
                db.OneTimeLinks.InsertOnSubmit(ot);
                db.SubmitChanges();
                list.Add(qs, ot);
            }
            var url = db.ServerLink(
                $"/OnlineReg/RsvpLinkSg/{ot.Id.ToCode()}?confirm={confirm}&message={HttpUtility.UrlEncode(msg)}");

            var href = d["href"];
            if (href.Contains("regretslink", ignoreCase: true))
                url = url + "&regrets=true";

            return $@"<a href=""{url}"">{inside}</a>";
        }
Beispiel #42
0
        private string VolSubLink(string code, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary<string, OneTimeLink>();

            var doc = new HtmlDocument();
            doc.LoadHtml(code);
            var ele = doc.DocumentNode.Element("a");
            var inside = ele.InnerHtml.Replace("{last}", person.LastName);
            var d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

            var qs = $"{d["aid"]},{d["pid"]},{d["ticks"]},{emailqueueto.PeopleId}";
            OneTimeLink ot = null;
            if (list.ContainsKey(qs))
                ot = list[qs];
            else
            {
                ot = new OneTimeLink
                {
                    Id = Guid.NewGuid(),
                    Querystring = qs
                };
                db.OneTimeLinks.InsertOnSubmit(ot);
                db.SubmitChanges();
                list.Add(qs, ot);
            }

            var url = db.ServerLink($"/OnlineReg/ClaimVolSub/{d["ans"]}/{ot.Id.ToCode()}");
            return $@"<a href=""{url}"">{inside}</a>";
        }
Beispiel #43
0
 private string UnSubscribeLink(EmailQueueTo emailqueueto)
 {
     var qs = "OptOut/UnSubscribe/?enc=" + Util.EncryptForUrl($"{emailqueueto.PeopleId}|{@from.Address}");
     var url = db.ServerLink(qs);
     return $@"<a href=""{url}"">Unsubscribe</a>";
 }
Beispiel #44
0
        private string SendLink(string code, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary<string, OneTimeLink>();

            var doc = new HtmlDocument();
            doc.LoadHtml(code);
            var ele = doc.DocumentNode.Element("a");
            var inside = ele.InnerHtml.Replace("{last}", person.LastName);
            var d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

            var id = GetId(d, "SendLink");

            var showfamily = code.Contains("sendlink2", ignoreCase: true);
            var qs = $"{id},{emailqueueto.PeopleId},{emailqueueto.Id},{(showfamily ? "registerlink2" : "registerlink")}";

            OneTimeLink ot;
            if (list.ContainsKey(qs))
                ot = list[qs];
            else
            {
                ot = new OneTimeLink
                {
                    Id = Guid.NewGuid(),
                    Querystring = qs
                };
                db.OneTimeLinks.InsertOnSubmit(ot);
                db.SubmitChanges();
                list.Add(qs, ot);
            }
            var url = db.ServerLink($"/OnlineReg/SendLink/{ot.Id.ToCode()}");
            return $@"<a href=""{url}"">{inside}</a>";
        }
Beispiel #45
0
 private string DoAddSmallGroup(string text, EmailQueueTo emailqueueto)
 {
     const string RE = @"\{addsmallgroup:\[(?<group>[^\]]*)\]\}";
     var re = new Regex(RE, RegexOptions.Singleline);
     Match match = re.Match(text);
     if (match.Success && emailqueueto.OrgId.HasValue)
     {
         string tag = match.Value;
         string group = match.Groups["group"].Value;
         OrganizationMember om = (from mm in OrganizationMembers
                                  where mm.OrganizationId == emailqueueto.OrgId
                                  where mm.PeopleId == emailqueueto.PeopleId
                                  select mm).SingleOrDefault();
         if (om != null)
             om.AddToGroup(this, group);
         text = text.Replace(tag, "");
     }
     return text;
 }
Beispiel #46
0
        private string RegisterLinkHref(string code, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary<string, OneTimeLink>();

            var match = RegisterHrefReId.Match(code);
            if (!match.Success)
                return code;
            var id = match.Groups["id"].Value.ToInt();

            var showfamily = code.Contains("registerlink2", ignoreCase: true);
            string qs = $"{id},{emailqueueto.PeopleId},{emailqueueto.Id}";
            OneTimeLink ot;
            if (list.ContainsKey(qs))
                ot = list[qs];
            else
            {
                ot = new OneTimeLink
                {
                    Id = Guid.NewGuid(),
                    Querystring = qs
                };
                db.OneTimeLinks.InsertOnSubmit(ot);
                db.SubmitChanges();
                list.Add(qs, ot);
            }
            string url = db.ServerLink($"/OnlineReg/RegisterLink/{ot.Id.ToCode()}");
            if (showfamily)
                url += "?showfamily=true";
            return $"href=\"{url}\"";
        }
Beispiel #47
0
 private string DoExtraValueData(string text, EmailQueueTo emailqueueto)
 {
     const string RE = @"{extra(?<type>.*?):(?<field>.*?)}";
     var re = new Regex(RE, RegexOptions.Singleline);
     Match match = re.Match(text);
     while (match.Success)
     {
         string tag = match.Value;
         string field = match.Groups["field"].Value;
         string type = match.Groups["type"].Value;
         var ev =
             PeopleExtras.SingleOrDefault(ee => ee.Field == field && emailqueueto.PeopleId == ee.PeopleId);
         string value = "";
         switch (type)
         {
             case "value":
                 value = ev.StrValue;
                 break;
             case "data":
                 value = ev.Data;
                 break;
             case "date":
                 value = ev.DateValue.FormatDate();
                 break;
             case "int":
                 value = ev.IntValue.ToString();
                 break;
         }
         text = text.Replace(tag, value);
         match = match.NextMatch();
     }
     return text;
 }
Beispiel #48
0
        private string OrgMember(string code, EmailQueueTo emailqueueto)
        {
            var match = orgMemberRe.Match(code);
            if (!match.Success)
                return code;
            var divid = match.Groups["divid"].Value.ToInt();
            var type = match.Groups["type"].Value;
            var org = (from om in db.OrganizationMembers
                       where om.PeopleId == emailqueueto.PeopleId
                       where om.Organization.DivOrgs.Any(dd => dd.DivId == divid)
                       select om.Organization).FirstOrDefault();

            if (org == null)
                return "?";

            switch (type.ToLower())
            {
                case "location":
                    return org.Location;
                case "pendinglocation":
                case "pendingloc":
                    return org.PendingLoc;
                case "orgname":
                case "name":
                    return org.OrganizationName;
                case "leader":
                    return org.LeaderName;
            }
            return code;
        }
Beispiel #49
0
        private string DoRegisterLink(string text, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary<string, OneTimeLink>();
            const string VoteLinkRE = "<a[^>]*?href=\"https{0,1}://(?<rlink>registerlink2{0,1})/{0,1}\"[^>]*>.*?</a>";
            var re = new Regex(VoteLinkRE, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
            Match match = re.Match(text);
            while (match.Success)
            {
                string tag = match.Value;
                string rlink = match.Groups["rlink"].Value.ToLower();

                var doc = new HtmlDocument();
                doc.LoadHtml(tag);
                HtmlNode ele = doc.DocumentNode.Element("a");
                string inside = ele.InnerHtml;
                Dictionary<string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

                var id = GetId(d, "RegisterLink");

                string url = RegisterTagUrl(text, emailqueueto, list, tag, id,
                                            showfamily: rlink == "registerlink2");
                text = text.Replace(tag, @"<a href=""{0}"">{1}</a>".Fmt(url, inside));
                match = match.NextMatch();
            }
            return text;
        }
Beispiel #50
0
 private string OrgExtra(string code, EmailQueueTo emailqueueto)
 {
     var match = orgExtraRe.Match(code);
     if (!match.Success || !emailqueueto.OrgId.HasValue)
         return code;
     var field = match.Groups["field"].Value;
     var ev = db.OrganizationExtras.SingleOrDefault(ee => ee.Field == field && ee.OrganizationId == db.CurrentOrg.Id);
     if (ev == null || !ev.Data.HasValue())
         return null;
     return ev.Data;
 }
Beispiel #51
0
        private string DoRegisterTag2(string text, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary<string, OneTimeLink>();
            const string VoteLinkRE = @"&lt;registertag .*?&gt;(?<inside>.+?)&lt;/registertag&gt;";
            var re = new Regex(VoteLinkRE, RegexOptions.Singleline | RegexOptions.Multiline);
            Match match = re.Match(text);
            while (match.Success)
            {
                string tag = match.Value;
                string inside = HttpUtility.HtmlDecode(match.Groups["inside"].Value);

                var doc = new HtmlDocument();
                doc.LoadHtml(tag);
                HtmlNode ele = doc.DocumentNode.Element("registertag");
                Dictionary<string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

                var id = GetId(d, "RegisterTag");

                string url = RegisterTagUrl(text, emailqueueto, list, tag, id);
                text = text.Replace(tag, @"<a href=""{0}"">{1}</a>".Fmt(url, inside));
                match = match.NextMatch();
            }
            return text;
        }
Beispiel #52
0
 private string OrgBarcode(string code, EmailQueueTo emailqueueto)
 {
     var oid = code.StartsWith("{orgbarcode:")
         ? code.Substring(12).TrimEnd('}').ToInt()
         : emailqueueto.OrgId;
     return $@"<img src='{db.ServerLink($"/Track/Barcode/{oid}-{emailqueueto.PeopleId}")}' width='95%' />";
 }
Beispiel #53
0
 private string DoSmallGroups(string text, EmailQueueTo emailqueueto)
 {
     const string RE = @"\{smallgroups(:\[(?<prefix>[^\]]*)\]){0,1}\}";
     var re = new Regex(RE, RegexOptions.Singleline);
     Match match = re.Match(text);
     while (match.Success && emailqueueto.OrgId.HasValue)
     {
         string tag = match.Value;
         string prefix = match.Groups["prefix"].Value;
         var q = from mm in OrgMemMemTags
                 where mm.OrgId == emailqueueto.OrgId
                 where mm.PeopleId == emailqueueto.PeopleId
                 where mm.MemberTag.Name.StartsWith(prefix) || prefix == null || prefix == ""
                 orderby mm.MemberTag.Name
                 select mm.MemberTag.Name.Substring(prefix.Length);
         text = text.Replace(tag, string.Join("<br/>\n", q));
         match = match.NextMatch();
     }
     return text;
 }
Beispiel #54
0
        private string NextMeetingDate0(string code, EmailQueueTo emailqueueto)
        {
            if (!emailqueueto.OrgId.HasValue)
                return code;

            var mt = (from mm in db.Meetings
                      where mm.OrganizationId == emailqueueto.OrgId
                      where mm.MeetingDate > DateTime.Now
                      orderby mm.MeetingDate
                      select mm.MeetingDate).FirstOrDefault() ?? DateTime.MinValue;
            return mt == DateTime.MinValue ? "none" : mt.ToString("g");
        }
Beispiel #55
0
        private string DoVoteLinkAnchorStyle(string text, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary<string, OneTimeLink>();
            const string VoteLinkRE = @"{votelink(?<inside>[^}]*)}";
            var re = new Regex(VoteLinkRE, RegexOptions.Singleline | RegexOptions.Multiline);
            Match match = re.Match(text);
            while (match.Success)
            {
                string votelink = match.Value;
                string anchor = "<a " + match.Groups["inside"].Value + ">text</a>";
                anchor = anchor.Replace("&quot;", "\"");
                anchor = anchor.Replace("&rdquo;", "\"");
                anchor = anchor.Replace("&ldquo;", "\"");

                var doc = new HtmlDocument();
                doc.LoadHtml(anchor);
                HtmlNode ele = doc.DocumentNode.Element("a");
                Dictionary<string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);
                string txt = "click here";
                if (d.ContainsKey("text"))
                    txt = d["text"];

                string msg = "Thank you for responding.";
                if (d.ContainsKey("message"))
                    msg = d["message"];

                string confirm = "false";
                if (d.ContainsKey("confirm"))
                    confirm = d["confirm"];

                if (!d.ContainsKey("smallgroup"))
                    throw new Exception("Votelink: no smallgroup attribute");
                string smallgroup = d["smallgroup"];
                string pre = "";
                string[] a = smallgroup.SplitStr(":");
                if (a.Length > 1)
                    pre = a[0];

                var id = GetId(d, "VoteLink");

                string url = VoteLinkUrl(text, emailqueueto, list, votelink, id, msg, confirm, smallgroup, pre);
                text = text.Replace(votelink, @"<a href=""{0}"">{1}</a>".Fmt(url, txt));

                match = match.NextMatch();
            }
            return text;
        }
Beispiel #56
0
        private string NextMeetingDate(string code, EmailQueueTo emailqueueto)
        {
            if (!emailqueueto.OrgId.HasValue)
                return code;

            var mt = (from aa in db.Attends
                      where aa.OrganizationId == emailqueueto.OrgId
                      where aa.PeopleId == emailqueueto.PeopleId
                      where AttendCommitmentCode.committed.Contains(aa.Commitment ?? 0)
                      where aa.MeetingDate > DateTime.Now
                      orderby aa.MeetingDate
                      select aa.MeetingDate).FirstOrDefault();
            return mt == DateTime.MinValue ? "none" : mt.ToString("g");
        }
Beispiel #57
0
 private string RegisterTagUrl(string text,
                               EmailQueueTo emailqueueto,
                               Dictionary<string, OneTimeLink> list,
                               string votelink,
                               string id,
                               bool showfamily = false)
 {
     string qs = "{0},{1},{2}".Fmt(id, emailqueueto.PeopleId, emailqueueto.Id);
     OneTimeLink ot;
     if (list.ContainsKey(qs))
         ot = list[qs];
     else
     {
         ot = new OneTimeLink
             {
                 Id = Guid.NewGuid(),
                 Querystring = qs
             };
         OneTimeLinks.InsertOnSubmit(ot);
         SubmitChanges();
         list.Add(qs, ot);
     }
     string url = Util.URLCombine(CmsHost, "/OnlineReg/RegisterLink/{0}".Fmt(ot.Id.ToCode()));
     if (showfamily)
         url += "?showfamily=true";
     return url;
 }
Beispiel #58
0
        public string DoVolSubLink(string text, EmailQueueTo emailqueueto)
        {
            var list = new Dictionary<string, OneTimeLink>();
            const string VolSubLinkRE = "<a[^>]*?href=\"https{0,1}://volsublink\"[^>]*>.*?</a>";
            var re = new Regex(VolSubLinkRE, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);
            Match match = re.Match(text);
            while (match.Success)
            {
                string tag = match.Value;

                var doc = new HtmlDocument();
                doc.LoadHtml(tag);
                HtmlNode ele = doc.DocumentNode.Element("a");
                string inside = ele.InnerHtml;
                Dictionary<string, string> d = ele.Attributes.ToDictionary(aa => aa.Name.ToString(), aa => aa.Value);

                string qs = "{0},{1},{2},{3}"
                    .Fmt(d["aid"], d["pid"], d["ticks"], emailqueueto.PeopleId);
                OneTimeLink ot = null;
                if (list.ContainsKey(qs))
                    ot = list[qs];
                else
                {
                    ot = new OneTimeLink
                        {
                            Id = Guid.NewGuid(),
                            Querystring = qs
                        };
                    OneTimeLinks.InsertOnSubmit(ot);
                    SubmitChanges();
                    list.Add(qs, ot);
                }

                string url = Util.URLCombine(CmsHost, "/OnlineReg/ClaimVolSub/{0}/{1}".Fmt(d["ans"], ot.Id.ToCode()));
                text = text.Replace(tag, @"<a href=""{0}"">{1}</a>".Fmt(url, inside));
                match = match.NextMatch();
            }
            return text;
        }
Beispiel #59
0
        private string SmallGroups(string code, EmailQueueTo emailqueueto)
        {
            const string RE = @"\{smallgroups(:\[(?<prefix>[^\]]*)\]){0,1}\}";
            var re = new Regex(RE, RegexOptions.Singleline);
            var match = re.Match(code);
            if (!match.Success || !emailqueueto.OrgId.HasValue)
                return code;

            var prefix = match.Groups["prefix"].Value;
            var q = from mm in db.OrgMemMemTags
                    where mm.OrgId == emailqueueto.OrgId
                    where mm.PeopleId == emailqueueto.PeopleId
                    where mm.MemberTag.Name.StartsWith(prefix) || prefix == null || prefix == ""
                    orderby mm.MemberTag.Name
                    select mm.MemberTag.Name.Substring(prefix.Length);
            return string.Join("<br/>\n", q);
        }
Beispiel #60
0
        private string SmallGroup(string code, EmailQueueTo emailqueueto)
        {
            var match = smallGroupRe.Match(code);
            if (!match.Success || !emailqueueto.OrgId.HasValue)
                return code;

            var prefix = match.Groups["prefix"].Value;
            var def = match.Groups["def"].Value;
            var sg = (from mm in db.OrgMemMemTags
                      where mm.OrgId == emailqueueto.OrgId
                      where mm.PeopleId == emailqueueto.PeopleId
                      where mm.MemberTag.Name.StartsWith(prefix)
                      select mm.MemberTag.Name).FirstOrDefault();
            if (!sg.HasValue())
                sg = def;
            return sg;
        }