当前位置: 首页>>代码示例>>C#>>正文


C# CMSDataContext.SendPeopleEmail方法代码示例

本文整理汇总了C#中CmsData.CMSDataContext.SendPeopleEmail方法的典型用法代码示例。如果您正苦于以下问题:C# CMSDataContext.SendPeopleEmail方法的具体用法?C# CMSDataContext.SendPeopleEmail怎么用?C# CMSDataContext.SendPeopleEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CmsData.CMSDataContext的用法示例。


在下文中一共展示了CMSDataContext.SendPeopleEmail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendEmails

        public void SendEmails()
        {
            var tag = Db.FetchOrCreateTag(Util.SessionId, Util.UserPeopleId, Db.NextTagId);
            Db.ExecuteCommand("delete TagPerson where Id = {0}", tag.Id);
            Db.TagAll(pids, tag);
            var dt = new DateTime(ticks);

            foreach (var id in pids)
            {
                var vr = new SubRequest
                {
                    AttendId = attend.AttendId,
                    RequestorId = person.PeopleId,
                    Requested = dt,
                    SubstituteId = id,
                };
                attend.SubRequests.Add(vr);
            }

            var qb = Db.ScratchPadCondition();
            qb.Reset(Db);
            qb.AddNewClause(QueryType.HasMyTag, CompareType.Equal, "{0},temp".Fmt(tag.Id));
            attend.Commitment = CmsData.Codes.AttendCommitmentCode.FindSub;
            qb.Save(DbUtil.Db);

            var reportlink = @"<a href=""{0}OnlineReg/VolSubReport/{1}/{2}/{3}"">Substitute Status Report</a>"
                .Fmt(Db.CmsHost, attend.AttendId, person.PeopleId, dt.Ticks);
            var list = Db.PeopleFromPidString(org.NotifyIds).ToList();
            //list.Insert(0, person);
            Db.Email(person.FromEmail, list,
                "Volunteer Substitute Commitment for " + org.OrganizationName,
                @"
            <p>{0} has requested a substitute on {1:MMM d} at {1:h:mm tt}.</p>
            <blockquote>
            {2}
            </blockquote>".Fmt(person.Name, attend.MeetingDate, reportlink));

            // Email subs
            var m = new MassEmailer(qb.Id, null);
            m.Subject = subject;
            m.Body = message;

            DbUtil.LogActivity("Emailing Vol Subs");
            m.FromName = person.Name;
            m.FromAddress = person.FromEmail;

            var eqid = m.CreateQueue(transactional: true);
            string host = Util.Host;
            // save these from HttpContext to set again inside thread local storage
            var useremail = Util.UserEmail;
            var isinroleemailtest = HttpContext.Current.User.IsInRole("EmailTest");

            TaskAlias.Factory.StartNew(() =>
            {
                Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
                try
                {
                    var db = new CMSDataContext(Util.GetConnectionString(host));
                    db.Host = host;
                    // set these again inside thread local storage
                    Util.UserEmail = useremail;
                    Util.IsInRoleEmailTest = isinroleemailtest;
                    db.SendPeopleEmail(eqid);
                }
                catch (Exception ex)
                {
                    var ex2 = new Exception("Emailing error for queueid " + eqid, ex);
                    ErrorLog errorLog = ErrorLog.GetDefault(null);
                    errorLog.Log(new Error(ex2));

                    var db = new CMSDataContext(Util.GetConnectionString(host));
                    db.Host = host;
                    // set these again inside thread local storage
                    Util.UserEmail = useremail;
                    Util.IsInRoleEmailTest = isinroleemailtest;
                    var equeue = db.EmailQueues.Single(ee => ee.Id == eqid);
                    equeue.Error = ex.Message.Truncate(200);
                    db.SubmitChanges();
                }
            });
        }
开发者ID:hkouns,项目名称:bvcms,代码行数:81,代码来源:VolSubModel.cs

示例2: SendNow

        public ActionResult SendNow(int id)
        {
            string host = Util.Host;
            // save these from HttpContext to set again inside thread local storage
            var useremail = Util.UserEmail;
            var isinroleemailtest = User.IsInRole("EmailTest");

            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
                try
                {
                    var Db = new CMSDataContext(Util.GetConnectionString(host));
                    Db.Host = host;
                    var cul = Db.Setting("Culture", "en-US");
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
                    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul);
                    // set these again inside thread local storage
                    Util.UserEmail = useremail;
                    Util.IsInRoleEmailTest = isinroleemailtest;
                    Db.SendPeopleEmail(id);
                }
                catch (Exception ex)
                {
                    var ex2 = new Exception("Emailing error for queueid " + id, ex);
                    ErrorLog errorLog = ErrorLog.GetDefault(null);
                    errorLog.Log(new Error(ex2));

                    var Db = new CMSDataContext(Util.GetConnectionString(host));
                    Db.Host = host;
                    var equeue = Db.EmailQueues.Single(ee => ee.Id == id);
                    equeue.Error = ex.Message.Truncate(200);
                    Db.SubmitChanges();
                }
            });
            return Redirect("/Manage/Emails/Details/" + id);
        }
开发者ID:hkouns,项目名称:bvcms,代码行数:37,代码来源:EmailsController.cs

示例3: QueueEmails

        public ActionResult QueueEmails(MassEmailer m)
        {
            if (!m.Subject.HasValue() || !m.Body.HasValue())
                return Json(new { id = 0, content = "<h2>Both Subject and Body need some text</h2>" });
            if (!User.IsInRole("Admin") && m.Body.Contains("{createaccount}"))
                return Json(new { id = 0, content = "<h2>Only Admin can use {createaccount}</h2>" });

            if (Util.SessionTimedOut())
            {
                Session["massemailer"] = m;
                return Content("timeout");
            }

            DbUtil.LogActivity("Emailing people");

            if (m.EmailFroms().Count(ef => ef.Value == m.FromAddress) == 0)
                return Json(new { id = 0, content = "No email address to send from" });
            m.FromName = m.EmailFroms().First(ef => ef.Value == m.FromAddress).Text;

            int id;
            try
            {
                id = m.CreateQueue();
                if (id == 0)
                    throw new Exception("No Emails to send (tag does not exist)");
                if (m.Schedule.HasValue)
                    return Json(new { id = 0, content = "<h2>Emails Queued</h2>" });
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return Json(new { id = 0, content = "<h2>Error</h2><p>{0}</p>".Fmt(ex.Message) });
            }

            string host = Util.Host;
            // save these from HttpContext to set again inside thread local storage
            var useremail = Util.UserEmail;
            var isinroleemailtest = User.IsInRole("EmailTest");

            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
                try
                {
                    var Db = new CMSDataContext(Util.GetConnectionString(host));
                    Db.Host = host;
                    var cul = Db.Setting("Culture", "en-US");
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
                    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul);
                    // set these again inside thread local storage
                    Util.UserEmail = useremail;
                    Util.IsInRoleEmailTest = isinroleemailtest;
                    Db.SendPeopleEmail(id);
                }
                catch (Exception ex)
                {
                    var ex2 = new Exception("Emailing error for queueid " + id, ex);
                    ErrorLog errorLog = ErrorLog.GetDefault(null);
                    errorLog.Log(new Error(ex2));

                    var Db = new CMSDataContext(Util.GetConnectionString(host));
                    Db.Host = host;
                    var equeue = Db.EmailQueues.Single(ee => ee.Id == id);
                    equeue.Error = ex.Message.Truncate(200);
                    Db.SubmitChanges();
                }
            });
            string keepdraft = Request["keepdraft"];
            int saveid = Request["saveid"].ToInt();

            System.Diagnostics.Debug.Print("Keep: " + keepdraft + " - Save ID: " + saveid);
            if (keepdraft != "on" && saveid > 0) DbUtil.ContentDeleteFromID(saveid);
            return Json(new { id = id });
        }
开发者ID:hkouns,项目名称:bvcms,代码行数:74,代码来源:EmailController.cs

示例4: Email2

        private void Email2(CMSDataContext db2, IQueryable<Person> q, int queuedBy, string fromAddr, string fromName, string subject,
            string body)
        {
            var from = new MailAddress(fromAddr, fromName);
            q = from p in q
                where p.EmailAddress != null
                where p.EmailAddress != ""
                where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false)
                select p;
            var tag = db2.PopulateSpecialTag(q, DbUtil.TagTypeId_Emailer);

            Util.IsInRoleEmailTest = TestEmail;
            var queueremail = db2.People.Where(pp => pp.PeopleId == queuedBy).Select(pp => pp.EmailAddress).SingleOrDefault();
            if(!queueremail.HasValue())
                throw new Exception("QueuedBy PeopleId not found in model.Email");
            Util.UserEmail = queueremail;
            db2.SetCurrentOrgId(CurrentOrgId);

            var emailqueue = db2.CreateQueue(queuedBy, from, subject, body, null, tag.Id, false);
            emailqueue.Transactional = Transactional;
            db2.SendPeopleEmail(emailqueue.Id);
        }
开发者ID:GSBCfamily,项目名称:bvcms,代码行数:22,代码来源:Email.cs


注:本文中的CmsData.CMSDataContext.SendPeopleEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。