Example #1
0
 private static void PublishAuditEvent(MessageContext context)
 {
     #region 审核事件
     using (var auditAct = new WfAct(context.Host, context, context.Ontology.MessageProvider, "持久化本地事件,转化为待分发事件打入分发队列"))
     {
         var evnt = new MessageEntity(MessageTypeKind.LocalEvent, context.Command.Id, context.Command.DataTuple)
         {
             Verb = context.Command.Verb,
             ClientType = context.Command.ClientType,
             ReceivedOn = context.Command.ReceivedOn,
             TimeStamp = context.Command.TimeStamp,
             CreateOn = DateTime.Now,
             LocalEntityId = context.LocalEntityId,
             CatalogCode = context.CatalogCode,
             ClientId = context.Command.ClientId,
             Ontology = context.Command.Ontology,
             Status = (int)context.Result.Status,
             ReasonPhrase = context.Result.ReasonPhrase,
             Description = context.Result.Description,
             MessageId = context.Command.MessageId,
             EventSourceType = EventSourceType.Command.ToName(),
             EventSubjectCode = EventSubjectCode.StateCodeChanged_Audit,
             MessageType = context.Command.MessageType,
             UserName = context.Command.UserName,
             IsDumb = context.Command.IsDumb,
             Version = context.Command.Version
         };
         // 持久化本地事件
         context.Ontology.MessageProvider.SaveCommand(context.Ontology, evnt);
         // 如果是之前已经接收的命令,但现在需要审核了。这往往是因为成功接收后系统配置有变化
         if (context.Command is IEntity)
         {
             context.Ontology.MessageProvider.DeleteCommand(MessageTypeKind.Received, context.Ontology, context.Command.Id, context.Command.IsDumb);
         }
     }
     #endregion
 }