public void Send(ContentItemRecord recipient, string type, string service, Dictionary<string, string> properties = null) {
            if ( !HasChannels() )
                return;

            Logger.Information("Sending message {0}", type);
            try {

                var context = new MessageContext {
                    Recipient = recipient,
                    Type = type,
                    Service = service
                };

                try {

                    if (properties != null) {
                        foreach (var key in properties.Keys)
                            context.Properties.Add(key, properties[key]);
                    }

                    _messageEventHandler.Sending(context);

                    foreach (var channel in _channels) {
                        channel.SendMessage(context);
                    }

                    _messageEventHandler.Sent(context);
                }
                finally {
                    context.MailMessage.Dispose();
                }

                Logger.Information("Message {0} sent", type);
            }
            catch ( Exception e ) {
                Logger.Error(e, "An error occured while sending the message {0}", type);
            }
        }
예제 #2
0
 public void Send(ContentItemRecord recipient, string type, string service, Dictionary<string, string> properties = null) {
     Send(new [] { recipient }, type, service, properties);    
 }
예제 #3
0
        private ContentItemRecord CreateModelRecord(string contentType) {
            var contentTypeRepository = _container.Resolve<IRepository<ContentTypeRecord>>();
            var contentItemRepository = _container.Resolve<IRepository<ContentItemRecord>>();
            var contentItemVersionRepository = _container.Resolve<IRepository<ContentItemVersionRecord>>();

            var modelRecord = new ContentItemRecord { ContentType = contentTypeRepository.Get(x => x.Name == contentType) };
            if (modelRecord.ContentType == null) {
                modelRecord.ContentType = new ContentTypeRecord { Name = contentType };
                contentTypeRepository.Create(modelRecord.ContentType);
            }
            contentItemRepository.Create(modelRecord);

            contentItemVersionRepository.Create(new ContentItemVersionRecord { ContentItemRecord = modelRecord, Latest = true, Published = true, Number = 1 });

            _session.Flush();
            _session.Clear();
            return modelRecord;
        }
예제 #4
0
 private IContentQuery<TermPart> GetContainables(ContentItemRecord record) {
     return _contentManager
         .Query<TermPart>()
         .Join<CommonPartRecord>()
         .Where(cr => cr.Container == record);
 } 
예제 #5
0
        public void Weld(ContentPart part)
        {
            var contentVersionPart = part as ContentVersionPart;
            if (contentVersionPart != null)
            {
                if(VersionRecord == null)
                {
                    VersionRecord = new ContentItemVersionRecord();
                }

                VersionRecord.Parts.Add(contentVersionPart);
            }
            else
            {
                if (Record == null)
                {
                    Record = new ContentItemRecord();
                }

                Record.Parts.Add(part);
            }

            part.ContentItem = this;
        }