Esempio n. 1
0
    public static int SendEmail(Sites Site, string MailTo, string Subject, string Body)
    {
        SendEmailTask sendemailtask = new SendEmailTask(Site, MailTo, Subject, Body);
        sendemailtask.Run();

        return 0;
    }
        private void SendEmail(ProfileData _profile)
        {
            generatedCode = GenerateCode();
            string fromEmail    = "*****@*****.**".Trim();
            string fromPassword = "******";
            string emailSubject = "MIA Privilege Scheme App – Reset of Password";
            string emailBody    = "This email has been sent to you because a request was made to reset the password of this app.<br/><br/>Your verification code is: <b>" + generatedCode + "</b><br/><br/>" + "Return to the app and enter this verification code to be able to reset your password.";

            SendEmailTask.SendEmail(fromEmail, _profile.Email, emailSubject, emailBody, fromEmail, fromPassword);
        }
Esempio n. 3
0
        private static void SendEmail(string recipient)
        {
            SendEmailTask t = new SendEmailTask
            {
                To      = recipient,
                Subject = "NiN SendEmailTaskTests",
                Body    = "Test PASS"
            };

            TestTaskQueue.ProcessTask(t);
        }
Esempio n. 4
0
 public Home(ITenantContext tenantContext, TenantStore tenantStore, Axuno.BackgroundTask.IBackgroundQueue queue, SendEmailTask sendEmailTask, ILogger <Home> logger, IStringLocalizer <Account> localizer)
 {
     _tenantContext = tenantContext;
     _tenantStore   = tenantStore;
     _appDb         = _tenantContext.DbContext.AppDb;
     _queue         = queue;
     _sendEmailTask = sendEmailTask;
     _logger        = logger;
     _localizer     = localizer;
     _tenantContext = tenantContext;
 }
Esempio n. 5
0
 public Cron(TenantStore tenantStore, ITenantContext tenantContext, IConfiguration configuration,
             Axuno.BackgroundTask.IBackgroundQueue queue,
             SendEmailTask sendMailTask, IMemoryCache cache, ILogger <Cron> logger)
 {
     _tenantContext = tenantContext;
     _configuration = configuration;
     _queue         = queue;
     _sendMailTask  = sendMailTask;
     _tenantStore   = tenantStore;
     _cache         = cache;
     _logger        = logger;
 }
Esempio n. 6
0
    public override Task Handle(HandlerContext <Command> context)
    {
        SendEmailTask task = SendEmailTask.Create(
            context.Payload.Recipient,
            context.Payload.ReplyTo,
            context.Payload.Subject,
            context.Payload.Content,
            context.Payload.Rate,
            context.Payload.PerSeconds,
            context.Payload.Key);

        context.PublishMessage(task);
        return(Task.CompletedTask);
    }
Esempio n. 7
0
        public async Task <bool> DelAsync(SendEmailTask sendEmailTask)
        {
            bool flag = false;

            try
            {
                DataContext dataContext = new DataContext();
                dataContext.SendEmailTasks.Remove(sendEmailTask);
                await dataContext.SaveChangesAsync();

                flag = true;
            }
            catch (Exception e)
            {
                ClassLoger.Error("SendEmailTaskDal.DelAsync", e);
            }
            return(flag);
        }
Esempio n. 8
0
 public Match(ITenantContext tenantContext, IStringLocalizer <Match> localizer,
              IAuthorizationService authorizationService,
              Axuno.Tools.DateAndTime.TimeZoneConverter timeZoneConverter, Axuno.BackgroundTask.IBackgroundQueue queue,
              SendEmailTask sendMailTask, RankingUpdateTask rankingUpdateTask,
              RazorViewToStringRenderer razorViewToStringRenderer, IConfiguration configuration, ILogger <Match> logger)
 {
     _tenantContext             = tenantContext;
     _appDb                     = tenantContext.DbContext.AppDb;
     _localizer                 = localizer;
     _authorizationService      = authorizationService;
     _timeZoneConverter         = timeZoneConverter;
     _queue                     = queue;
     _sendMailTask              = sendMailTask;
     _rankingUpdateTask         = rankingUpdateTask;
     _razorViewToStringRenderer = razorViewToStringRenderer;
     _configuration             = configuration;
     _logger                    = logger;
 }
Esempio n. 9
0
 public TeamApplication(ITenantContext tenantContext,
                        Axuno.Tools.DateAndTime.TimeZoneConverter timeZoneConverter,
                        IStringLocalizer <TeamApplication> localizer, IAuthorizationService authorizationService,
                        RegionInfo regionInfo,
                        IConfiguration configuration, Axuno.BackgroundTask.IBackgroundQueue queue,
                        SendEmailTask sendEmailTask, ILogger <TeamApplication> logger)
 {
     _tenantContext     = tenantContext;
     _timeZoneConverter = timeZoneConverter;
     _regionInfo        = regionInfo;
     _googleConfig      = new GoogleConfiguration();
     configuration.Bind(nameof(GoogleConfiguration), _googleConfig);
     _queue                = queue;
     _sendEmailTask        = sendEmailTask;
     _appDb                = tenantContext.DbContext.AppDb;
     _authorizationService = authorizationService;
     _logger               = logger;
 }
Esempio n. 10
0
        public async Task <int> AddAsync(SendEmailTask sendEmailTask)
        {
            int id = 0;

            try
            {
                DataContext dataContext = new DataContext();
                var         entity      = await dataContext.SendEmailTasks.AddAsync(sendEmailTask);

                await dataContext.SaveChangesAsync();

                id = entity.Entity.Id;
            }
            catch (Exception e)
            {
                ClassLoger.Error("SendEmailTaskDal.AddAsync", e);
            }
            return(id);
        }
Esempio n. 11
0
        public HttpResponseMessage Send([FromBody] MailRequest request)
        {
            if (request == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid request"));
            }

            var configuration = DocumentSession.Load <MailConfiguration>(request.HostId);

            if (configuration == null || !configuration.Recipients.Any(x => x.Equals(request.Destination, StringComparison.InvariantCultureIgnoreCase)))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid request"));
            }

            if (request.Async)
            {
                TaskExecutor.ExecuteTask(new SendEmailTask(configuration, request));
                var response = Request.CreateResponse(HttpStatusCode.OK, new { Message = "Message sent" });
                if (!string.IsNullOrEmpty(request.RedirectUri))
                {
                    response.Headers.Location = new Uri(request.RedirectUri);
                }

                return(response);
            }
            else
            {
                var sendEmail = new SendEmailTask(configuration, request);
                if (sendEmail.Run(DocumentSession) == false)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError,
                                                       "Unable to send the email"));
                }

                var response = Request.CreateResponse(HttpStatusCode.Redirect);
                response.Headers.Location = new Uri(request.RedirectUri);

                return(response);
            }
        }
Esempio n. 12
0
 public Account(
     SignInManager <ApplicationUser> signInManager,
     IStringLocalizer <Account> localizer,
     IOptions <DataProtectionTokenProviderOptions> dataProtectionTokenProviderOptions,
     ILogger <Account> logger,
     ITenantContext siteContext,
     Axuno.BackgroundTask.IBackgroundQueue queue,
     SendEmailTask sendEmailTask,
     DataProtection.DataProtector dataProtector,
     TournamentManager.DI.PhoneNumberService phoneNumberService,
     RegionInfo regionInfo)
 {
     _signInManager = signInManager;
     _localizer     = localizer;
     _dataProtectionTokenProviderOptions = dataProtectionTokenProviderOptions;
     _logger             = logger;
     _tenantContext      = siteContext;
     _queue              = queue;
     _sendEmailTask      = sendEmailTask;
     _dataProtector      = dataProtector;
     _phoneNumberService = phoneNumberService;
     _regionInfo         = regionInfo;
 }
Esempio n. 13
0
 public Manage(
     SignInManager <ApplicationUser> signInManager, IStringLocalizer <Manage> localizer,
     Axuno.Tools.DateAndTime.TimeZoneConverter timeZoneConverter,
     Axuno.BackgroundTask.IBackgroundQueue queue,
     SendEmailTask sendEmailTask,
     IOptions <DataProtectionTokenProviderOptions> dataProtectionTokenProviderOptions,
     MetaDataHelper metaData, ITenantContext tenantContext,
     RegionInfo regionInfo, PhoneNumberService phoneNumberService,
     ILogger <Manage> logger)
 {
     _userManager       = signInManager.UserManager;
     _signInManager     = signInManager;
     _localizer         = localizer;
     _timeZoneConverter = timeZoneConverter;
     _queue             = queue;
     _sendEmailTask     = sendEmailTask;
     _dataProtectionTokenProviderOptions = dataProtectionTokenProviderOptions;
     _metaData           = metaData;
     _tenantContext      = tenantContext;
     _phoneNumberService = phoneNumberService;
     _regionInfo         = regionInfo;
     _logger             = logger;
 }
    public async Task Handle(SendDelayedMailCommand command)
    {
        Tenant tenant = await Databases.Snittlistan.Tenants.SingleAsync(x => x.Hostname == command.Hostname);

        TaskPublisher taskPublisher = new(
            tenant,
            Databases,
            MsmqFactory,
            command.CorrelationId,
            null);
        SendEmailTask emailTask = SendEmailTask.Create(
            command.Recipient,
            command.ReplyTo,
            command.Subject,
            command.Content,
            command.Rate,
            command.PerSeconds,
            DateTime.Now.Ticks.ToString());

        taskPublisher.PublishDelayedTask(
            emailTask,
            DateTime.Now.AddSeconds(command.DelayInSeconds),
            "system");
    }
Esempio n. 15
0
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
#line 3 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"

            ViewData["Title"] = "邮件发送日志";
            Layout            = "~/Pages/_Layout.cshtml";
            SendEmailTask taskinfo = ViewBag.taskinfo;

#line default
#line hidden
            BeginContext(185, 533, true);
            WriteLiteral(@"<fieldset class=""layui-elem-field layui-field-title"" style=""margin-top: 20px;"">
    <legend>邮件发送日志</legend>
</fieldset>
<div class=""layui-fluid"">
    <div class=""layui-row"">
        <table class=""layui-table"">
            <thead>
            <tr>
                <th>任务名称</th>
                <th>邮箱</th>
                <th>姓名</th>
                <th>是否已发送</th>
                <th>是否发送成功</th>
                <th>是否已读</th>
                <th>操作</th>

            </tr>
            </thead>
            <tbody>
");
            EndContext();
#line 27 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
            if (Model != null)
            {
                foreach (var log in Model)
                {
                    string isokstr   = string.Empty;
                    string IsReadstr = string.Empty;
                    if (!log.IsSend)
                    {
                        isokstr   = "未发送";
                        IsReadstr = "未发送";
                    }
                    else
                    {
                        if (log.IsSendOk)
                        {
                            isokstr = "发送成功";
                        }
                        else
                        {
                            isokstr = "发送失败";
                        }
                        if (log.IsRead)
                        {
                            IsReadstr = "已读";
                        }
                        else
                        {
                            IsReadstr = "未读";
                        }
                    }

#line default
#line hidden
                    BeginContext(1724, 54, true);
                    WriteLiteral("                    <tr>\r\n                        <td>");
                    EndContext();
                    BeginContext(1780, 18, false);
#line 58 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                    Write(taskinfo?.TaskName);

#line default
#line hidden
                    EndContext();
                    BeginContext(1799, 35, true);
                    WriteLiteral("</td>\r\n                        <td>");
                    EndContext();
                    BeginContext(1836, 9, false);
#line 59 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                    Write(log.Email);

#line default
#line hidden
                    EndContext();
                    BeginContext(1846, 35, true);
                    WriteLiteral("</td>\r\n                        <td>");
                    EndContext();
                    BeginContext(1883, 8, false);
#line 60 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                    Write(log.Name);

#line default
#line hidden
                    EndContext();
                    BeginContext(1892, 35, true);
                    WriteLiteral("</td>\r\n                        <td>");
                    EndContext();
                    BeginContext(1929, 26, false);
#line 61 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                    Write(log.IsSend ? "已发送" : "未发送");

#line default
#line hidden
                    EndContext();
                    BeginContext(1956, 35, true);
                    WriteLiteral("</td>\r\n                        <td>");
                    EndContext();
                    BeginContext(1993, 7, false);
#line 62 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                    Write(isokstr);

#line default
#line hidden
                    EndContext();
                    BeginContext(2001, 35, true);
                    WriteLiteral("</td>\r\n                        <td>");
                    EndContext();
                    BeginContext(2038, 9, false);
#line 63 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                    Write(IsReadstr);

#line default
#line hidden
                    EndContext();
                    BeginContext(2048, 91, true);
                    WriteLiteral("</td>\r\n                        <td><a href=\"javascript:;\" class=\"layui-btn layui-btn-small\"");
                    EndContext();
                    BeginWriteAttribute("onclick", " onclick=\"", 2139, "\"", 2171, 3);
                    WriteAttributeValue("", 2149, "sendemail(\'", 2149, 11, true);
#line 64 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                    WriteAttributeValue("", 2160, log.Id, 2160, 9, false);

#line default
#line hidden
                    WriteAttributeValue("", 2169, "\')", 2169, 2, true);
                    EndWriteAttribute();
                    BeginContext(2172, 41, true);
                    WriteLiteral(">发送</a></td>\r\n                    </tr>\r\n");
                    EndContext();
#line 66 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                }
            }

#line default
#line hidden
            BeginContext(2247, 93, true);
            WriteLiteral("            </tbody>\r\n        </table>\r\n        <div id=\"page\"></div>\r\n    </div>\r\n</div>\r\n\r\n");
            EndContext();
            DefineSection("Scripts", async() => {
                BeginContext(2357, 451, true);
                WriteLiteral(@"
    <script type=""text/javascript"">
        var layer, laypage;
        layui.use(['element', 'layer', 'table','laypage'],
            function() {
                var element = layui.element;
                layer = layui.layer;
                var table = layui.table;
                laypage = layui.laypage;
                //分页
                laypage.render({
                    elem: 'page' //分页容器的id
                    , count: ");
                EndContext();
                BeginContext(2810, 13, false);
#line 86 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                Write(ViewBag.count);

#line default
#line hidden
                EndContext();
                BeginContext(2824, 35, true);
                WriteLiteral(" //总页数\r\n                    ,limit:");
                EndContext();
                BeginContext(2861, 16, false);
#line 87 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                Write(ViewBag.pageSize);

#line default
#line hidden
                EndContext();
                BeginContext(2878, 120, true);
                WriteLiteral("\r\n                    , skin: \'#1E9FFF\' //自定义选中色值\r\n                    //,skip: true //开启跳页\r\n                    ,curr: ");
                EndContext();
                BeginContext(3000, 17, false);
#line 90 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                Write(ViewBag.pageIndex);

#line default
#line hidden
                EndContext();
                BeginContext(3018, 228, true);
                WriteLiteral(" //获取起始页\r\n                    , jump: function (obj, first) {\r\n                        if (!first) {\r\n                            window.location =\r\n                                \'/EmailManage/SendEmailLogList?sendEmailTaskId=");
                EndContext();
                BeginContext(3248, 23, false);
#line 94 "D:\gitCode\crm\lsc\lsc.crm\Views\EmailManage\SendEmailLogList.cshtml"
                Write(ViewBag.sendEmailTaskId);

#line default
#line hidden
                EndContext();
                BeginContext(3272, 807, true);
                WriteLiteral(@"&pageIndex=' +
                                obj.curr;
                        }
                    }
                    , hash: 'fenye' //自定义hash值
                });
            });
        sendemail = function (id) {
            layer.confirm('是否发送邮件?', { icon: 3, title: '邮件发送提示' }, function (index) {
                $.get('/EmailManage/SendEmail?logId=' + id,
                    function (res) {
                        if (res.code == 1) {
                            layer.msg('已经发送', { icon: 6 });
                            window.location.reload();
                        } else {
                            layer.msg('发送失败', { icon: 5 });
                        }
                    });
                layer.close(index);
            });
        }
    </script>
");
                EndContext();
            }
                          );
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="notification"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public Task Handle(AddNewProjectEvent notification, CancellationToken cancellationToken)
 {
     return(SendEmailTask.Send($"new project Add {notification.Name}", $"new Project Added to ssystem" +
                               $" with name {notification.Name} </br> {notification.Description}", "*****@*****.**"));
 }
Esempio n. 17
0
        public async Task <IActionResult> SaveSendEmailTask()
        {
            SendEmailTask   sendEmailTask   = new SendEmailTask();
            SendEmailLogBll sendEmailLogBll = new SendEmailLogBll();

            sendEmailTask.EmailTempId = Request.Form["EmailTempId"].TryToInt(0);
            sendEmailTask.TaskName    = Request.Form["TaskName"].TryToString();
            sendEmailTask.CreateTime  = DateTime.Now;
            string           Email = Request.Form["Email"].TryToString();
            bool             flag  = Request.Form["sendAll"].TryToString() == "on";
            SendEmailTaskBll bll   = new SendEmailTaskBll();
            int id = await bll.AddAsync(sendEmailTask);

            if (id > 0)
            {
                Task.Run(async() =>
                {
                    if (!Email.IsNull())
                    {
                        SendEmailLog log = new SendEmailLog
                        {
                            SendEmailTaskId = id,
                            Email           = Email,
                            IsRead          = false,
                            IsSend          = false,
                            IsSendOk        = false,
                            Name            = Email,
                            EmailTempId     = sendEmailTask.EmailTempId,
                        };
                        await sendEmailLogBll.AddAsync(log);
                    }
                    if (flag)
                    {
                        TargetEmailBll targetEmailBll = new TargetEmailBll();
                        int pageIndex = 0;
                        int pageSize  = 50;
                        A:
                        pageIndex++;
                        var tup = await targetEmailBll.GetList(pageIndex, pageSize);
                        if (tup.Item1 != null && tup.Item1.Count > 0)
                        {
                            foreach (TargetEmail targetEmail in tup.Item1)
                            {
                                SendEmailLog log1 = new SendEmailLog
                                {
                                    SendEmailTaskId = id,
                                    Email           = targetEmail.Email,
                                    IsRead          = false,
                                    IsSend          = false,
                                    IsSendOk        = false,
                                    Name            = targetEmail.Name,
                                    EmailTempId     = sendEmailTask.EmailTempId,
                                };
                                await sendEmailLogBll.AddAsync(log1);
                            }
                            goto A;
                        }
                    }
                    SendEmailHelper.StartSendEmail(id);
                });
            }
            return(Json(new { code = 1, msg = "OK" }));
        }
Esempio n. 18
0
 public async Task <bool> DelAsync(SendEmailTask sendEmailTask)
 {
     return(await SendEmailTaskDal.Ins.DelAsync(sendEmailTask));
 }
Esempio n. 19
0
 public async Task <int> AddAsync(SendEmailTask sendEmailTask)
 {
     return(await SendEmailTaskDal.Ins.AddAsync(sendEmailTask));
 }