예제 #1
0
        /// <summary>
        /// 生成通知内容
        /// </summary>
        /// <param name="notice">通知实体</param>
        /// <returns>返回生成的通知内容</returns>
        public string Resolve(Notice notice)
        {
            if (notice == null || string.IsNullOrEmpty(notice.TemplateName))
                return string.Empty;

            if (NoticeTemplates==null || !NoticeTemplates.ContainsKey(notice.TemplateName))
                return string.Empty;

            //使用RazorEngine解析通知内容
            try
            {
                return Razor.Parse(NoticeTemplates[notice.TemplateName], notice, notice.TemplateName);
            }
            catch (Exception e)
            {
                throw new ExceptionFacade(new CommonExceptionDescriptor("编译通知模板时报错"), e);
            }
        }
예제 #2
0
파일: Notice.cs 프로젝트: hbulzy/SYS
 /// <summary>
 /// 新建实体时使用
 /// </summary>
 public static Notice New()
 {
     Notice notice = new Notice()
     {
         TemplateName = string.Empty,
         LeadingActor = string.Empty,
         RelativeObjectName = string.Empty,
         RelativeObjectUrl = string.Empty,
         Body = string.Empty,
         DateCreated = DateTime.UtcNow
     };
     return notice;
 }
예제 #3
0
파일: NoticeService.cs 프로젝트: hbulzy/SYS
 /// <summary>
 /// 创建通知
 /// </summary>
 /// <param name="entity">通知实体</param>
 /// <remarks>已检查通知设置</remarks>
 public void Create(Notice entity)
 {
     EventBus<Notice>.Instance().OnBefore(entity, new CommonEventArgs(EventOperationType.Instance().Create(), entity.ApplicationId));
     if (!IsAllowedSend(entity.UserId, entity.TypeId))
         return;
     noticeRepository.Insert(entity);
     EventBus<Notice>.Instance().OnAfter(entity, new CommonEventArgs(EventOperationType.Instance().Create(), entity.ApplicationId));
 }