Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
示例#1
0
        public ActionResult RedirectEdit(Content cContent)
        {
            switch (cContent.TypeID) // 0 = HTML, 1 = Text, 2 = eMail Template
            {
            case ContentTypeCode.TypeHtml:
                cContent.RemoveGrammarly();
                return(View("EditHTML", cContent));

            case ContentTypeCode.TypeText:
                return(View("EditText", cContent));

            case ContentTypeCode.TypeSqlScript:
                return(View("EditSqlScript", cContent));

            case ContentTypeCode.TypePythonScript:
                ViewBag.SimpleTextarea = CurrentDatabase.UserPreference("SimpleTextarea", "false");
                return(View("EditPythonScript", cContent));

            case ContentTypeCode.TypeEmailTemplate:
                cContent.RemoveGrammarly();
                return(View("EditTemplate", cContent));

            case ContentTypeCode.TypeSavedDraft:
                cContent.RemoveGrammarly();
                return(View("EditDraft", cContent));
            }

            return(View("Index"));
        }
示例#2
0
        private string GetIndexTabUrl(Content content)
        {
            var url = Url.Action("Index");

            switch (content.TypeID)
            {
            case ContentTypeCode.TypeHtml:
                url += "#tab_htmlContent";
                break;

            case ContentTypeCode.TypeText:
                url += "#tab_textContent";
                break;

            case ContentTypeCode.TypeSqlScript:
                url += "#tab_sqlScripts";
                break;

            case ContentTypeCode.TypePythonScript:
                url += "#tab_pythonScripts";
                break;

            case ContentTypeCode.TypeEmailTemplate:
                url += "#tab_emailTemplates";
                break;

            case ContentTypeCode.TypeSavedDraft:
                url += "#tab_savedDrafts";
                break;
            }

            return(url);
        }
示例#3
0
        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
        public ActionResult ContentCreate(int newType, string newName, int? newRole)
        {
            var content = new Content();
            content.Name = newName;
            content.TypeID = newType;
            content.RoleID = newRole ?? 0;
            content.Title = content.Body = "";

            DbUtil.Db.Contents.InsertOnSubmit(content);
            DbUtil.Db.SubmitChanges();

            return RedirectEdit(content);
        }
示例#5
0
        public ActionResult ContentCreate(int newType, string newName, int?newRole)
        {
            var content = new Content();

            content.Name        = newName;
            content.TypeID      = newType;
            content.RoleID      = newRole ?? 0;
            content.Title       = newName;
            content.Body        = "";
            content.DateCreated = DateTime.Now;

            DbUtil.Db.Contents.InsertOnSubmit(content);
            DbUtil.Db.SubmitChanges();

            return(RedirectEdit(content));
        }
示例#6
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> ");

            var Staff = DbUtil.Db.StaffPeopleForOrg(masterorgid.Value);
            p.SendOneTimeLink(
                Staff.First().FromEmail,
                DbUtil.Db.ServerLink("/OnlineReg/ManageSubscriptions/"), "Manage Your Subscriptions", message);
        }
示例#7
0
        public void ConfirmManagePledge()
        {
            var p = List[0];
            if (p.IsNew)
                p.AddPerson(null, p.org.EntryPointId ?? 0);
            if (p.CreatingAccount == true)
                p.CreateAccount();

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

            p.SendOneTimeLink(
                DbUtil.Db.StaffPeopleForOrg(orgid.Value).First().FromEmail,
                Util.ServerLink("/OnlineReg/ManagePledge/"), c.Title, c.Body);
        }
示例#8
0
        public ActionResult ContentCreate(int newType, string newName, int?newRole)
        {
            var content = new Content();

            content.Name        = newName;
            content.TypeID      = newType;
            content.RoleID      = newRole ?? 0;
            content.Title       = newName;
            content.Body        = "";
            content.DateCreated = DateTime.Now;
            var ContentKeywordFilter = Session["ContentKeywordFilter"] as string;

            if (ContentKeywordFilter.HasValue())
            {
                content.SetKeyWords(CurrentDatabase, new[] { ContentKeywordFilter });
            }

            CurrentDatabase.Contents.InsertOnSubmit(content);
            CurrentDatabase.SubmitChanges();
            ViewBag.ContentKeywords = ContentKeywordFilter ?? "";

            return(RedirectEdit(content));
        }
示例#9
0
        private string GetIndexTabUrl(Content content)
        {
            var url = Url.Action("Index");
            switch (content.TypeID)
            {
                case ContentTypeCode.TypeHtml:
                    url += "#tab_htmlContent";
                    break;
                case ContentTypeCode.TypeText:
                    url += "#tab_textContent";
                    break;
                case ContentTypeCode.TypeSqlScript:
                    url += "#tab_sqlScripts";
                    break;
                case ContentTypeCode.TypePythonScript:
                    url += "#tab_pythonScripts";
                    break;
                case ContentTypeCode.TypeEmailTemplate:
                    url += "#tab_emailTemplates";
                    break;
                case ContentTypeCode.TypeSavedDraft:
                    url += "#tab_savedDrafts";
                    break;
            }

            return url;
        }
示例#10
0
        public ActionResult RedirectEdit(Content cContent)
        {
            switch (cContent.TypeID) // 0 = HTML, 1 = Text, 2 = eMail Template
            {
                case ContentTypeCode.TypeHtml:
                    return View("EditHTML", cContent);

                case ContentTypeCode.TypeText:
                    return View("EditText", cContent);

                case ContentTypeCode.TypeSqlScript:
                    return View("EditSqlScript", cContent);

                case ContentTypeCode.TypePythonScript:
                    ViewBag.SimpleTextarea = DbUtil.Db.UserPreference("SimpleTextarea", "false");
                    return View("EditPythonScript", cContent);

                case ContentTypeCode.TypeEmailTemplate:
                    return View("EditTemplate", cContent);

                case ContentTypeCode.TypeSavedDraft:
                    return View("EditDraft", cContent);
            }

            return View("Index");
        }
示例#11
0
        public ActionResult RedirectEdit(Content cContent)
        {
            switch (cContent.TypeID) // 0 = HTML, 1 = Text, 2 = eMail Template
            {
                case ContentTypeCode.TypeHtml:
                    return View("EditHTML", cContent);

                case ContentTypeCode.TypeText:
                    return View("EditText", cContent);

                case ContentTypeCode.TypeEmailTemplate:
                case ContentTypeCode.TypeSavedDraft:
                    return View("EditTemplate", cContent);
            }

            return View("Index");
        }
示例#12
0
        public ActionResult SaveDraft(int tagId, bool wantParents, int saveid, string name, string subject, string body, int roleid)
        {
            Content content;

            if (saveid > 0)
            {
                content = DbUtil.ContentFromID(saveid);
            }
            else
            {
                content = new Content
                {
                    Name = name.HasValue() ? name
                        : "new draft " + DateTime.Now.FormatDateTm(),
                    TypeID = ContentTypeCode.TypeSavedDraft,
                    RoleID = roleid
                };
                content.OwnerID = Util.UserId;
            }

            content.Title = subject;
            content.Body = body;

            content.DateCreated = DateTime.Now;

            if (saveid == 0) DbUtil.Db.Contents.InsertOnSubmit(content);
            DbUtil.Db.SubmitChanges();

            var m = new MassEmailer
                            {
                                TagId = tagId,
                                wantParents = wantParents,
                                CmsHost = DbUtil.Db.CmsHost,
                                Host = Util.Host,
                                Subject = subject,
                            };

            System.Diagnostics.Debug.Print("Template ID: " + content.Id);

            ViewBag.parents = wantParents;
            ViewBag.templateID = content.Id;
            return View("Compose", m);
        }
示例#13
0
        private ConfirmEnum ConfirmPickSlots()
        {
            var p = List[0];
            if (p.IsNew)
                p.AddPerson(null, GetEntryPoint());
            if (p.CreatingAccount)
                p.CreateAccount();

            var c = DbUtil.Content("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>";
                DbUtil.Db.Contents.InsertOnSubmit(c);
                DbUtil.Db.SubmitChanges();
            }

            List<Person> Staff = null;
            Staff = DbUtil.Db.StaffPeopleForOrg(Orgid.Value);
            p.SendOneTimeLink(
                Staff.First().FromEmail,
                DbUtil.Db.ServerLink("/OnlineReg/ManageVolunteer/"), c.Title, c.Body);
            Log("SendOneTimeLinkManageVol");
            URL = null;
            return ConfirmEnum.ConfirmAccount;
        }
示例#14
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("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;
        }
示例#15
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,
                Util.ServerLink("/OnlineReg/ManageVolunteer/"), "Manage Your Volunteer Commitments", message);
        }
示例#16
0
        public void SendMovedNotices()
        {
            var Db = DbUtil.Db;

            var q = from om in Db.OrganizationMembers
                    where om.Organization.DivOrgs.Any(di => di.DivId == DivId)
                    where om.Moved == true || EmailAllNotices
                    select new
                    {
                        om,
                        om.Person,
                        om.Person.FromEmail,
                        om.Person.EmailAddress,
                        om.RegisterEmail,
                        om.Person.Name,
                        om.PeopleId,
                        om.Organization.OrganizationName,
                        om.Organization.Location,
                        om.Organization.LeaderName,
                        om.Organization.PhoneNumber
                    };
            var content = DbUtil.Db.ContentOfTypeHtml("OrgMembersModel_SendMovedNotices");
            if (content == null)
            {
                content = new Content()
                {
                    Name = "OrgMembersModel_SendMovedNotices",
                    Body = Resource1.OrgMembersModel_SendMovedNotices,
                    Title = "Room Assignment for {name} in {org}"
                };
                DbUtil.Db.Contents.InsertOnSubmit(content);
                DbUtil.Db.SubmitChanges();
            }
            if (content.Title == "SendMovedNotices") // replace old Title with new, improved version
                content.Title = "Room Assignment for {name} in {org}"; // this will be the subject

            var sb = new StringBuilder("Org Assignment Notices sent to:\r\n<pre>\r\n");
            foreach (var i in q)
            {
                var msg = content.Body.Replace("{name}", i.Name)
                    .Replace("{org}", i.OrganizationName)
                    .Replace("{room}", i.Location)
                    .Replace("{leader}", i.LeaderName)
                    .Replace("{phone}", DbUtil.Db.Setting("ChurchPhone", "ChurchPhone"))
                    .Replace("{church}", DbUtil.Db.Setting("NameOfChurch", "NameOfChurch"));

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

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

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

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

            if (onlineorg == null)
                Db.Email(Db.CurrentUser.Person.FromEmail,
                    Db.CurrentUserPerson,
                    "Org Assignment notices sent to:", sb.ToString());
            else
                Db.Email(Db.CurrentUser.Person.FromEmail,
                    Db.PeopleFromPidString(onlineorg.NotifyIds),
                    "Org Assignment notices sent to:", sb.ToString());
            Db.SubmitChanges();
        }
示例#17
0
        private static int SaveDraft(int? draftId, string name, int roleId, string draftSubject, string draftBody)
        {
            Content content = null;

            if (draftId.HasValue && draftId > 0)
                content = DbUtil.ContentFromID(draftId.Value);

            if (content != null)
                DbUtil.Db.ArchiveContent(draftId);
            else 
            {
                content = new Content
                {
                    Name = name.HasValue()
                        ? name
                        : "new draft " + DateTime.Now.FormatDateTm(),
                    TypeID = ContentTypeCode.TypeSavedDraft,
                    RoleID = roleId,
                    OwnerID = Util.UserId
                };
            }

            content.Title = draftSubject;
            content.Body = GetBody(draftBody);
            content.Archived = null;
            content.ArchivedFromId = null;

            content.DateCreated = DateTime.Now;

            if (!draftId.HasValue || draftId == 0)
                DbUtil.Db.Contents.InsertOnSubmit(content);

            DbUtil.Db.SubmitChanges();

            return content.Id;
        }
示例#18
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);
            }
        }