/// <summary>
        /// 将事件源进行反序列化
        /// </summary>
        /// <param name="storedEvents"></param>
        private static void UsersHistoryDeserializer(IEnumerable <StoredEvent> storedEvents)
        {
            foreach (var e in storedEvents)
            {
                var     slot = new UsersHistoryData();
                dynamic values;

                switch (e.MessageType)
                {
                case "UsersRegisteredEvent":
                    values         = JsonConvert.DeserializeObject <dynamic>(e.Data);
                    slot.BirthDate = values["BirthDate"];
                    slot.Email     = values["Email"];
                    slot.Phone     = values["Phone"];
                    slot.Name      = values["Name"];
                    slot.Action    = "Registered";
                    slot.When      = values["Timestamp"];
                    slot.Id        = values["Id"];
                    slot.Who       = e.User;
                    break;

                case "UsersUpdatedEvent":
                    values         = JsonConvert.DeserializeObject <dynamic>(e.Data);
                    slot.BirthDate = values["BirthDate"];
                    slot.Email     = values["Email"];
                    slot.Phone     = values["Phone"];
                    slot.Name      = values["Name"];
                    slot.Action    = "Updated";
                    slot.When      = values["Timestamp"];
                    slot.Id        = values["Id"];
                    slot.Who       = e.User;
                    break;

                case "UsersRemovedEvent":
                    values      = JsonConvert.DeserializeObject <dynamic>(e.Data);
                    slot.Action = "Removed";
                    slot.When   = values["Timestamp"];
                    slot.Id     = values["Id"];
                    slot.Who    = e.User;
                    break;
                }
                HistoryData.Add(slot);
            }
        }
        // 将数据从事件源中获取到list中
        public static IList <UsersHistoryData> ToJavaScriptStudentHistory(IList <StoredEvent> storedEvents)
        {
            HistoryData = new List <UsersHistoryData>();
            UsersHistoryDeserializer(storedEvents);

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

            foreach (var change in sorted)
            {
                var jsSlot = new UsersHistoryData
                {
                    Id = change.Id == Guid.Empty.ToString() || change.Id == last.Id
                        ? ""
                        : change.Id,
                    Name = string.IsNullOrWhiteSpace(change.Name) || change.Name == last.Name
                        ? ""
                        : change.Name,
                    Email = string.IsNullOrWhiteSpace(change.Email) || change.Email == last.Email
                        ? ""
                        : change.Email,
                    Phone = string.IsNullOrWhiteSpace(change.Phone) || change.Phone == last.Phone
                        ? ""
                        : change.Phone,
                    BirthDate = string.IsNullOrWhiteSpace(change.BirthDate) || change.BirthDate == last.BirthDate
                        ? ""
                        : change.BirthDate.Substring(0, 10),
                    Action = string.IsNullOrWhiteSpace(change.Action) ? "" : change.Action,
                    When   = change.When,
                    Who    = change.Who
                };

                list.Add(jsSlot);
                last = change;
            }
            return(list);
        }