public async Task <NotifyResp> NotifyMsg(NotifyTemplateConfig template, NotifyReq msg) { var config = await GetEmailConfig(); if (config == null) { return(new NotifyResp().WithResp(RespTypes.ObjectNull, "未发现邮件配置信息!")); } var body = msg.body_paras.Aggregate(template.content, (current, p) => current.Replace(string.Concat("{", p.Key, "}"), p.Value)); var emailMsg = new EmailMsgMo { body = body, is_html = template.is_html > 0, subject = string.IsNullOrEmpty(msg.msg_title) ? template.title : msg.msg_title, to_emails = msg.targets }; var eRes = await SendAsync(config, emailMsg); var notifyResp = new NotifyResp().WithResp(eRes); notifyResp.msg_biz_id = msg.msg_Id; return(notifyResp); }
/// <summary> /// 设置通知模板信息 /// </summary> /// <returns></returns> public async Task <Resp> SetTemplateConfig(string templateCode, NotifyTemplateConfig config) { string dirKey = string.Concat(CoreDirConfigKeys.plugs_notify_template_bycode, templateCode); var res = await DirConfigHelper.SetDirConfig(dirKey, config); return(res ? new Resp() : new Resp(RespTypes.OperateFailed, "设置华为云短信账号信息失败!")); }
public Task <Resp> SetTemplateConfig(string t_code, [FromBody] NotifyTemplateConfig req) { if (string.IsNullOrEmpty(t_code) || req == null) { return(Task.FromResult(GetInvalidResp())); } return(_service.SetTemplateConfig(t_code, req)); }