Ejemplo n.º 1
0
        private AssociateItemHistory GetAssociateItemHistory(
            DateTime @from, DateTime to, int itemId, ItemHistoryType itemType, AssociateDeletableItem item = null)
        {
            bool     hasRestoredDelete;
            DateTime?createdDate;
            DateTime?deletedDate;
            IEnumerable <ItemHistory> h = this.associateRepo.GetItemHistory(
                itemId, itemType, @from, to, out createdDate, out deletedDate, out hasRestoredDelete);

            if (item != null)
            {
                item.IsDeletedOnServer = deletedDate.HasValue;
            }

            List <AssociateItemRestoredDeleteHistoryRecord> restoredDeleteHistory = null;

            if (hasRestoredDelete)
            {
                IEnumerable <ItemRestoredDeleteHistory> r = this.associateRepo.GetItemRestoredDeleteHistory(
                    itemId, itemType);
                restoredDeleteHistory = this.dataMapper.MapItemRestoredDeleteHistoryListE2M(r);
            }

            var associateItemHistory = new AssociateItemHistory
            {
                RestoredDeleteHistory = restoredDeleteHistory,
                CreatedDate           = createdDate,
                DeletedDate           = deletedDate,
                CreatedDuringPeriod   = (@from <= createdDate && createdDate <= to),
                DeletedDuringPeriod   = (@from <= deletedDate && deletedDate <= to),
                ItemHistoryType       = itemType
            };

            // format the address data column from json into a string
            h.Where(x => x.Col == "AddressData" && !string.IsNullOrEmpty(x.Val)).ForEach(this.FormatAddress);

            associateItemHistory.HistoryRecords.AddRange(this.dataMapper.MapItemHistoryListE2M(h));

            return(associateItemHistory);
        }
Ejemplo n.º 2
0
        public IEnumerable <ItemHistory> GetItemHistory(
            int?itemId,
            ItemHistoryType itemType,
            DateTime from,
            DateTime to,
            out DateTime?createdDate,
            out DateTime?deletedDate,
            out bool hasRestoredDelete)
        {
            if (!Enum.IsDefined(typeof(ItemHistoryType), itemType))
            {
                throw new InvalidEnumArgumentException("itemType", (int)itemType, typeof(ItemHistoryType));
            }

            var createdDateParam       = new ObjectParameter("CreatedDate", typeof(DateTime));
            var deletedDateParam       = new ObjectParameter("DeletedDate", typeof(DateTime));
            var hasRestoredDeleteParam = new ObjectParameter("HasRestoredDelete", typeof(bool));

            var itemHistory =
                this.MomentaDb.GetItemHistory(
                    itemId,
                    itemType.ToString(),
                    from,
                    to,
                    createdDateParam,
                    deletedDateParam,
                    hasRestoredDeleteParam).ToList();

            createdDate = createdDateParam.Value == DBNull.Value
                              ? (DateTime?)null
                              : DateTime.SpecifyKind((DateTime)createdDateParam.Value, DateTimeKind.Utc);
            deletedDate = deletedDateParam.Value == DBNull.Value
                              ? (DateTime?)null
                              : DateTime.SpecifyKind((DateTime)deletedDateParam.Value, DateTimeKind.Utc);

            hasRestoredDelete = hasRestoredDeleteParam.Value != DBNull.Value && (bool)hasRestoredDeleteParam.Value;

            return(itemHistory);
        }
Ejemplo n.º 3
0
        private AssociateItemHistory GetAssociateItemHistory(
            DateTime @from, DateTime to, int itemId, ItemHistoryType itemType, AssociateDeletableItem item = null)
        {
            bool hasRestoredDelete;
            DateTime? createdDate;
            DateTime? deletedDate;
            IEnumerable<ItemHistory> h = this.associateRepo.GetItemHistory(
                itemId, itemType, @from, to, out createdDate, out deletedDate, out hasRestoredDelete);

            if (item != null)
            {
                item.IsDeletedOnServer = deletedDate.HasValue;
            }

            List<AssociateItemRestoredDeleteHistoryRecord> restoredDeleteHistory = null;

            if (hasRestoredDelete)
            {
                IEnumerable<ItemRestoredDeleteHistory> r = this.associateRepo.GetItemRestoredDeleteHistory(
                    itemId, itemType);
                restoredDeleteHistory = this.dataMapper.MapItemRestoredDeleteHistoryListE2M(r);
            }

            var associateItemHistory = new AssociateItemHistory
                                           {
                                               RestoredDeleteHistory = restoredDeleteHistory,
                                               CreatedDate = createdDate,
                                               DeletedDate = deletedDate,
                                               CreatedDuringPeriod = (@from <= createdDate && createdDate <= to),
                                               DeletedDuringPeriod = (@from <= deletedDate && deletedDate <= to),
                                               ItemHistoryType = itemType
                                           };

            // format the address data column from json into a string
            h.Where(x => x.Col == "AddressData" && !string.IsNullOrEmpty(x.Val)).ForEach(this.FormatAddress);

            associateItemHistory.HistoryRecords.AddRange(this.dataMapper.MapItemHistoryListE2M(h));

            return associateItemHistory;
        }
Ejemplo n.º 4
0
 public IEnumerable<ItemRestoredDeleteHistory> GetItemRestoredDeleteHistory(
     int? itemId, ItemHistoryType itemType)
 {
     return this.MomentaDb.GetItemRestoredDeleteHistory(itemId, itemType.ToString());
 }
Ejemplo n.º 5
0
        public IEnumerable<ItemHistory> GetItemHistory(
            int? itemId,
            ItemHistoryType itemType,
            DateTime from,
            DateTime to,
            out DateTime? createdDate,
            out DateTime? deletedDate,
            out bool hasRestoredDelete)
        {
            if (!Enum.IsDefined(typeof(ItemHistoryType), itemType))
            {
                throw new InvalidEnumArgumentException("itemType", (int)itemType, typeof(ItemHistoryType));
            }

            var createdDateParam = new ObjectParameter("CreatedDate", typeof(DateTime));
            var deletedDateParam = new ObjectParameter("DeletedDate", typeof(DateTime));
            var hasRestoredDeleteParam = new ObjectParameter("HasRestoredDelete", typeof(bool));

            var itemHistory =
                this.MomentaDb.GetItemHistory(
                    itemId,
                    itemType.ToString(),
                    from,
                    to,
                    createdDateParam,
                    deletedDateParam,
                    hasRestoredDeleteParam).ToList();

            createdDate = createdDateParam.Value == DBNull.Value
                              ? (DateTime?)null
                              : DateTime.SpecifyKind((DateTime)createdDateParam.Value, DateTimeKind.Utc);
            deletedDate = deletedDateParam.Value == DBNull.Value
                              ? (DateTime?)null
                              : DateTime.SpecifyKind((DateTime)deletedDateParam.Value, DateTimeKind.Utc);

            hasRestoredDelete = hasRestoredDeleteParam.Value != DBNull.Value && (bool)hasRestoredDeleteParam.Value;

            return itemHistory;
        }
Ejemplo n.º 6
0
 public IEnumerable <ItemRestoredDeleteHistory> GetItemRestoredDeleteHistory(
     int?itemId, ItemHistoryType itemType)
 {
     return(this.MomentaDb.GetItemRestoredDeleteHistory(itemId, itemType.ToString()));
 }