/// <summary> /// 修改网站通知配置 /// </summary> public void UpdateSiteNotice(string key, SiteMessageCategory category, string title, string content) { var manager = new InnerMailManager(); var notice = manager.QuerySiteMessageScene(key); if (notice == null) { return; } notice.MsgCategory = category; notice.MsgTemplateTitle = title; notice.MsgTemplateContent = content; manager.UpdateSiteMessageScene(notice); }
/// <summary> /// 某场景触发的发送站内消息 /// </summary> /// <param name="userId">用户编号</param> /// <param name="mobile">手机号</param> /// <param name="sceneKey">场景编码</param> /// <param name="msgTemplateParams">消息模板参数,key=value 如:[UserName]=张三</param> public void DoSendSiteMessage(string userId, string mobile, string sceneKey, params string[] msgTemplateParams) { try { if (string.IsNullOrEmpty(sceneKey)) { return; } var manager = new InnerMailManager(); var scene = manager.QuerySiteMessageScene(sceneKey); if (scene == null) { return; } if (scene.MsgCategory == SiteMessageCategory.None) { return; } if (string.IsNullOrEmpty(scene.MsgTemplateContent)) { return; } var msgContent = scene.MsgTemplateContent; var msgTitle = scene.MsgTemplateTitle; var category = scene.MsgCategory; foreach (var item in msgTemplateParams) { var array = item.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries); if (array.Length != 2) { continue; } msgContent = msgContent.Replace(array[0], array[1]); } switch (category) { case SiteMessageCategory.None: break; case SiteMessageCategory.MobileSMS: if (string.IsNullOrEmpty(mobile)) { mobile = manager.QueryMobileByUserId(userId); } if (!string.IsNullOrEmpty(mobile)) { this.SendSMS(mobile, msgContent, userId); } break; case SiteMessageCategory.InnerMail: this.SendInnerMail(new InnerMailInfo_Send { Title = msgTitle, Content = msgContent, ActionTime = DateTime.Now, Receivers = string.Format("U:{0}", userId), }, userId); break; default: break; } } catch (Exception ex) { Common.Log.LogWriterGetter.GetLogWriter().Write("SiteMessageControllBusiness", "DoSendSiteMessage", ex); } }