コード例 #1
0
        public static async Task<string> EnqueueAsync(this IQueue<EventPost> queue, EventPostInfo data, IFileStorage storage, bool shouldArchive = true, CancellationToken cancellationToken = default(CancellationToken)) {
            string path = $"q\\{Guid.NewGuid().ToString("N")}.json";
            if (!await storage.SaveObjectAsync(path, data, cancellationToken).AnyContext())
                return null;

            return await queue.EnqueueAsync(new EventPost {
                FilePath = path,
                ShouldArchive = shouldArchive
            }).AnyContext();
        }
コード例 #2
0
 public EventContext(PersistentEvent ev, EventPostInfo epi = null) {
     Event = ev;
     EventPostInfo = epi;
     StackSignatureData = new Dictionary<string, string>();
 }
コード例 #3
0
        private List<PersistentEvent> ParseEventPost(EventPostInfo ep) {
            byte[] data = ep.Data;
            if (!String.IsNullOrEmpty(ep.ContentEncoding))
                data = data.Decompress(ep.ContentEncoding);

            var encoding = Encoding.UTF8;
            if (!String.IsNullOrEmpty(ep.CharSet))
                encoding = Encoding.GetEncoding(ep.CharSet);

            string input = encoding.GetString(data);
            List<PersistentEvent> events = _eventParserPluginManager.ParseEvents(input, ep.ApiVersion, ep.UserAgent);
            events.ForEach(e => {
                // set the project id on all events
                e.ProjectId = ep.ProjectId;

                // set the reference id to the event id if one was defined.
                if (!String.IsNullOrEmpty(e.Id) && String.IsNullOrEmpty(e.ReferenceId))
                    e.ReferenceId = e.Id;

                // the event id, stack id and organization id should never be set for posted events
                e.Id = e.StackId = e.OrganizationId = null;
            });

            return events;
        }