Exemplo n.º 1
0
        public async Task <IActionResult> Done([FromBody] DoneDto obj)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = Extensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            var model = await _actionPlanService.Done(obj.id, userID, obj.KPILevelCode, obj.CategoryID);

            await _hubContext.Clients.All.SendAsync("ReceiveMessage", "user", "message");


            if (model.Item1.Count > 0 && await _settingService.IsSendMail("DONE"))
            {
                Thread thread = new Thread(async() =>
                {
                    string URL = _configuaration.GetSection("AppSettings:URL").ToSafetyString();

                    var data       = model.Item1.DistinctBy(x => x);
                    string content = @"<p><b>*PLEASE DO NOT REPLY* this email was automatically sent from the KPI system.</b></p> 
                                    <p>The account <b>" + data.First()[0].ToTitleCase() + "</b> has finished the action plan name <b>'" + data.First()[3] + "'</b></p>" +
                                     "<p>Link: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>Click Here</a></p>" +
                                     "<br/>" +

                                     @"<p><b>*請勿回信*這封信是KPI系統自動寄出.</b></p> 
                                    <p>帳號 <b>" + data.First()[0].ToTitleCase() + "</b> 已經完成行動方案 <b>'" + data.First()[3] + "'</b></p>" +
                                     "<p>連結: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>點選這裡</a></p>"
                    ;
                    await _mailHelper.SendEmailRange(data.Select(x => x[1]).ToList(), "[KPI System-04] Action Plan (Finished Task) - 行動方案(任務完成)", content);
                });
                thread.Start();
            }
            return(Ok(new { status = model.Item2, isSendmail = true }));
        }