Beispiel #1
0
        public static IList <OperationHistoryData> ToJavaScriptCustomerHistory(IList <StoredEvent> storedEvents)
        {
            HistoryData = new List <OperationHistoryData>();
            OperationHistoryDeserializer(storedEvents);

            var sorted = HistoryData.OrderBy(c => c.When);
            var list   = new List <OperationHistoryData>();
            var last   = new OperationHistoryData();

            foreach (var change in sorted)
            {
                var jsSlot = new OperationHistoryData
                {
                    Id = change.Id == Guid.Empty.ToString() || change.Id == last.Id
                        ? ""
                        : change.Id,
                    Action = string.IsNullOrWhiteSpace(change.Action) ? "" : change.Action,
                    When   = change.When,
                    Who    = change.Who
                };

                list.Add(jsSlot);
                last = change;
            }
            return(list);
        }
Beispiel #2
0
        private static void OperationHistoryDeserializer(IEnumerable <StoredEvent> storedEvents)
        {
            foreach (var e in storedEvents)
            {
                var     slot = new OperationHistoryData();
                dynamic values;

                switch (e.MessageType)
                {
                case "OperationDispatchedEvent":
                    values      = JsonConvert.DeserializeObject <dynamic>(e.Data);
                    slot.Action = "NewOperation";
                    slot.When   = values["Timestamp"];
                    slot.Id     = values["Id"];
                    slot.Who    = e.User;
                    break;
                }
                HistoryData.Add(slot);
            }
        }