2022-03-15 18:00:53 +00:00
|
|
|
// (c) Copyright Ascensio System SIA 2010-2022
|
|
|
|
//
|
|
|
|
// This program is a free software product.
|
|
|
|
// You can redistribute it and/or modify it under the terms
|
|
|
|
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
|
|
|
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
|
|
|
|
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
|
|
|
|
// any third-party rights.
|
|
|
|
//
|
|
|
|
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
|
|
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
|
|
|
|
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
//
|
|
|
|
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
|
|
|
//
|
|
|
|
// The interactive user interfaces in modified source and object code versions of the Program must
|
|
|
|
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
|
|
|
//
|
|
|
|
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
|
|
|
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
|
|
|
// trademark law for use of our trademarks.
|
|
|
|
//
|
|
|
|
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
|
|
|
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
|
|
|
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-06-17 16:19:00 +00:00
|
|
|
|
2022-06-09 12:11:45 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
namespace ASC.Feed.Data;
|
|
|
|
|
|
|
|
[Scope]
|
|
|
|
public class FeedAggregateDataProvider
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
private FeedDbContext FeedDbContext => _lazyFeedDbContext.Value;
|
|
|
|
|
|
|
|
private readonly AuthContext _authContext;
|
|
|
|
private readonly TenantManager _tenantManager;
|
|
|
|
private readonly Lazy<FeedDbContext> _lazyFeedDbContext;
|
2022-03-17 15:07:17 +00:00
|
|
|
private readonly IMapper _mapper;
|
2022-02-10 18:39:04 +00:00
|
|
|
|
|
|
|
public FeedAggregateDataProvider(
|
|
|
|
AuthContext authContext,
|
|
|
|
TenantManager tenantManager,
|
|
|
|
DbContextManager<FeedDbContext> dbContextManager,
|
|
|
|
IMapper mapper)
|
2022-04-14 19:23:57 +00:00
|
|
|
: this(authContext, tenantManager, mapper)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
_lazyFeedDbContext = new Lazy<FeedDbContext>(() => dbContextManager.Get(Constants.FeedDbId));
|
|
|
|
}
|
2019-12-10 08:54:53 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
public FeedAggregateDataProvider(
|
|
|
|
AuthContext authContext,
|
|
|
|
TenantManager tenantManager,
|
|
|
|
IMapper mapper)
|
|
|
|
{
|
|
|
|
_authContext = authContext;
|
|
|
|
_tenantManager = tenantManager;
|
|
|
|
_mapper = mapper;
|
|
|
|
}
|
2019-10-10 08:52:21 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
public DateTime GetLastTimeAggregate(string key)
|
|
|
|
{
|
|
|
|
var value = FeedDbContext.FeedLast.Where(r => r.LastKey == key).Select(r => r.LastDate).FirstOrDefault();
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
return value != default ? value.AddSeconds(1) : value;
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
public void SaveFeeds(IEnumerable<FeedRow> feeds, string key, DateTime value)
|
|
|
|
{
|
|
|
|
var feedLast = new FeedLast
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
LastKey = key,
|
|
|
|
LastDate = value
|
|
|
|
};
|
2019-12-09 11:59:22 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
FeedDbContext.AddOrUpdate(r => r.FeedLast, feedLast);
|
|
|
|
FeedDbContext.SaveChanges();
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
const int feedsPortionSize = 1000;
|
|
|
|
var aggregatedDate = DateTime.UtcNow;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
var feedsPortion = new List<FeedRow>();
|
|
|
|
foreach (var feed in feeds)
|
|
|
|
{
|
|
|
|
feedsPortion.Add(feed);
|
|
|
|
if (feedsPortion.Sum(f => f.Users.Count) <= feedsPortionSize)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
continue;
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
2022-02-10 16:59:02 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
SaveFeedsPortion(feedsPortion, aggregatedDate);
|
|
|
|
feedsPortion.Clear();
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
if (feedsPortion.Count > 0)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
SaveFeedsPortion(feedsPortion, aggregatedDate);
|
|
|
|
}
|
|
|
|
}
|
2019-08-15 15:08:40 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
private void SaveFeedsPortion(IEnumerable<FeedRow> feeds, DateTime aggregatedDate)
|
|
|
|
{
|
2022-05-25 13:55:38 +00:00
|
|
|
var strategy = FeedDbContext.Database.CreateExecutionStrategy();
|
2019-08-15 15:08:40 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
strategy.Execute(() =>
|
2022-02-10 18:39:04 +00:00
|
|
|
{
|
2022-05-25 13:55:38 +00:00
|
|
|
using var tx = FeedDbContext.Database.BeginTransaction();
|
|
|
|
|
|
|
|
foreach (var f in feeds)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-05-25 13:55:38 +00:00
|
|
|
if (0 >= f.Users.Count)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
var feedAggregate = _mapper.Map<FeedRow, FeedAggregate>(f);
|
|
|
|
feedAggregate.AggregateDate = aggregatedDate;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
if (f.ClearRightsBeforeInsert)
|
2019-08-15 15:08:40 +00:00
|
|
|
{
|
2022-05-25 13:55:38 +00:00
|
|
|
var fu = FeedDbContext.FeedUsers.Where(r => r.FeedId == f.Id).FirstOrDefault();
|
|
|
|
if (fu != null)
|
|
|
|
{
|
|
|
|
FeedDbContext.FeedUsers.Remove(fu);
|
|
|
|
}
|
2019-08-15 15:08:40 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
FeedDbContext.AddOrUpdate(r => r.FeedAggregates, feedAggregate);
|
2019-12-23 13:36:37 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
foreach (var u in f.Users)
|
2019-08-15 15:08:40 +00:00
|
|
|
{
|
2022-05-25 13:55:38 +00:00
|
|
|
var feedUser = new FeedUsers
|
|
|
|
{
|
|
|
|
FeedId = f.Id,
|
|
|
|
UserId = u
|
|
|
|
};
|
2019-12-09 11:59:22 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
FeedDbContext.AddOrUpdate(r => r.FeedUsers, feedUser);
|
|
|
|
}
|
2019-08-15 15:08:40 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
FeedDbContext.SaveChanges();
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
tx.Commit();
|
|
|
|
});
|
2022-02-10 18:39:04 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
public void RemoveFeedAggregate(DateTime fromTime)
|
|
|
|
{
|
2022-05-25 13:55:38 +00:00
|
|
|
var strategy = FeedDbContext.Database.CreateExecutionStrategy();
|
|
|
|
|
|
|
|
strategy.Execute(() =>
|
|
|
|
{
|
|
|
|
using var tx = FeedDbContext.Database.BeginTransaction(IsolationLevel.ReadUncommitted);
|
2019-12-09 11:59:22 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
var aggregates = FeedDbContext.FeedAggregates.Where(r => r.AggregateDate <= fromTime);
|
|
|
|
FeedDbContext.FeedAggregates.RemoveRange(aggregates);
|
2019-12-09 11:59:22 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
var users = FeedDbContext.FeedUsers.Where(r => FeedDbContext.FeedAggregates.Where(r => r.AggregateDate <= fromTime).Any(a => a.Id == r.FeedId));
|
|
|
|
FeedDbContext.FeedUsers.RemoveRange(users);
|
2019-12-09 11:59:22 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
tx.Commit();
|
|
|
|
});
|
2022-02-10 18:39:04 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
public List<FeedResultItem> GetFeeds(FeedApiFilter filter)
|
|
|
|
{
|
|
|
|
var filterOffset = filter.Offset;
|
|
|
|
var filterLimit = filter.Max > 0 && filter.Max < 1000 ? filter.Max : 1000;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
var feeds = new Dictionary<string, List<FeedResultItem>>();
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
var tryCount = 0;
|
|
|
|
List<FeedResultItem> feedsIteration;
|
|
|
|
do
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
feedsIteration = GetFeedsInternal(filter);
|
|
|
|
foreach (var feed in feedsIteration)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
if (feeds.TryGetValue(feed.GroupId, out var value))
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
value.Add(feed);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
2022-02-10 18:39:04 +00:00
|
|
|
else
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
feeds[feed.GroupId] = new List<FeedResultItem> { feed };
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
}
|
2022-02-10 18:39:04 +00:00
|
|
|
filter.Offset += feedsIteration.Count;
|
|
|
|
} while (feeds.Count < filterLimit
|
|
|
|
&& feedsIteration.Count == filterLimit
|
|
|
|
&& tryCount++ < 5);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
filter.Offset = filterOffset;
|
2019-12-10 08:54:53 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
return feeds.Take(filterLimit).SelectMany(group => group.Value).ToList();
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-01 16:45:27 +00:00
|
|
|
private List<FeedResultItem> GetFeedsInternal(FeedApiFilter filter)
|
|
|
|
{
|
|
|
|
var q = FeedDbContext.FeedAggregates
|
|
|
|
.Where(r => r.Tenant == _tenantManager.GetCurrentTenant().Id)
|
|
|
|
.Where(r => r.ModifiedBy != _authContext.CurrentAccount.ID)
|
|
|
|
.Join(FeedDbContext.FeedUsers, a => a.Id, b => b.FeedId, (aggregates, users) => new { aggregates, users })
|
|
|
|
.Where(r => r.users.UserId == _authContext.CurrentAccount.ID)
|
|
|
|
.OrderByDescending(r => r.aggregates.ModifiedDate)
|
|
|
|
.Skip(filter.Offset)
|
|
|
|
.Take(filter.Max);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
if (filter.OnlyNew)
|
|
|
|
{
|
|
|
|
q = q.Where(r => r.aggregates.AggregateDate >= filter.From);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (1 < filter.From.Year)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
q = q.Where(r => r.aggregates.ModifiedDate >= filter.From);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
2022-02-10 18:39:04 +00:00
|
|
|
if (filter.To.Year < 9999)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
q = q.Where(r => r.aggregates.ModifiedDate <= filter.To);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
}
|
2019-12-10 08:54:53 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
if (!string.IsNullOrEmpty(filter.Product))
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
q = q.Where(r => r.aggregates.Product == filter.Product);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
2019-12-10 08:54:53 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
if (filter.Author != Guid.Empty)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
q = q.Where(r => r.aggregates.ModifiedBy == filter.Author);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
2019-12-10 08:54:53 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
if (filter.SearchKeys != null && filter.SearchKeys.Length > 0)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
var keys = filter.SearchKeys
|
|
|
|
.Where(s => !string.IsNullOrEmpty(s))
|
|
|
|
.Select(s => s.Replace("\\", "\\\\").Replace("%", "\\%").Replace("_", "\\_"))
|
|
|
|
.ToList();
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
q = q.Where(r => keys.Any(k => r.aggregates.Keywords.StartsWith(k)));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
var news = q.Select(r => r.aggregates).AsEnumerable();
|
|
|
|
|
|
|
|
return _mapper.Map<IEnumerable<FeedAggregate>, List<FeedResultItem>>(news);
|
|
|
|
}
|
|
|
|
|
2022-03-01 16:45:27 +00:00
|
|
|
public int GetNewFeedsCount(DateTime lastReadedTime, AuthContext authContext, TenantManager tenantManager)
|
|
|
|
{
|
|
|
|
var count = FeedDbContext.FeedAggregates
|
|
|
|
.Where(r => r.Tenant == tenantManager.GetCurrentTenant().Id)
|
|
|
|
.Where(r => r.ModifiedBy != authContext.CurrentAccount.ID)
|
|
|
|
.Join(FeedDbContext.FeedUsers, r => r.Id, u => u.FeedId, (agg, user) => new { agg, user })
|
|
|
|
.Where(r => r.user.UserId == authContext.CurrentAccount.ID);
|
2019-08-15 12:04:42 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
if (1 < lastReadedTime.Year)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
count = count.Where(r => r.agg.AggregateDate >= lastReadedTime);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
return count.Take(1001).Select(r => r.agg.Id).Count();
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
public IEnumerable<int> GetTenants(TimeInterval interval)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
return FeedDbContext.FeedAggregates
|
|
|
|
.Where(r => r.AggregateDate >= interval.From && r.AggregateDate <= interval.To)
|
|
|
|
.GroupBy(r => r.Tenant)
|
|
|
|
.Select(r => r.Key)
|
|
|
|
.ToList();
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-04-14 19:23:57 +00:00
|
|
|
public FeedResultItem GetFeedItem(string id)
|
2022-02-10 18:39:04 +00:00
|
|
|
{
|
|
|
|
var news =
|
|
|
|
FeedDbContext.FeedAggregates
|
|
|
|
.Where(r => r.Id == id)
|
|
|
|
.FirstOrDefault();
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
return _mapper.Map<FeedAggregate, FeedResultItem>(news);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
public void RemoveFeedItem(string id)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-05-25 13:55:38 +00:00
|
|
|
var strategy = FeedDbContext.Database.CreateExecutionStrategy();
|
|
|
|
|
|
|
|
strategy.Execute(() =>
|
|
|
|
{
|
|
|
|
using var tx = FeedDbContext.Database.BeginTransaction(IsolationLevel.ReadUncommitted);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
var aggregates = FeedDbContext.FeedAggregates.Where(r => r.Id == id);
|
|
|
|
FeedDbContext.FeedAggregates.RemoveRange(aggregates);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
var users = FeedDbContext.FeedUsers.Where(r => r.FeedId == id);
|
|
|
|
FeedDbContext.FeedUsers.RemoveRange(users);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
FeedDbContext.SaveChanges();
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-05-25 13:55:38 +00:00
|
|
|
tx.Commit();
|
|
|
|
});
|
2022-02-10 18:39:04 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
public class FeedResultItem : IMapFrom<FeedAggregate>
|
|
|
|
{
|
|
|
|
public string Json { get; private set; }
|
|
|
|
public string Module { get; private set; }
|
|
|
|
public Guid AuthorId { get; private set; }
|
|
|
|
public Guid ModifiedById { get; private set; }
|
|
|
|
public string GroupId { get; private set; }
|
|
|
|
public bool IsToday { get; private set; }
|
|
|
|
public bool IsYesterday { get; private set; }
|
2022-06-05 15:44:37 +00:00
|
|
|
public bool IsTomorrow { get; private set; }
|
2022-02-10 18:39:04 +00:00
|
|
|
public DateTime CreatedDate { get; private set; }
|
|
|
|
public DateTime ModifiedDate { get; private set; }
|
|
|
|
public DateTime AggregatedDate { get; private set; }
|
|
|
|
|
2022-03-01 16:45:27 +00:00
|
|
|
public FeedResultItem() { }
|
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
public FeedResultItem(
|
|
|
|
string json,
|
|
|
|
string module,
|
|
|
|
Guid authorId,
|
|
|
|
Guid modifiedById,
|
|
|
|
string groupId,
|
|
|
|
DateTime createdDate,
|
|
|
|
DateTime modifiedDate,
|
|
|
|
DateTime aggregatedDate,
|
|
|
|
TenantUtil tenantUtil)
|
|
|
|
{
|
|
|
|
var now = tenantUtil.DateTimeFromUtc(DateTime.UtcNow);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
Json = json;
|
|
|
|
Module = module;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
AuthorId = authorId;
|
|
|
|
ModifiedById = modifiedById;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
GroupId = groupId;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-06-09 12:11:45 +00:00
|
|
|
var compareDate = JsonNode.Parse(Json)["IsAllDayEvent"].GetValue<bool>()
|
|
|
|
? tenantUtil.DateTimeToUtc(createdDate).Date
|
|
|
|
: createdDate.Date;
|
|
|
|
|
|
|
|
if (now.Date == compareDate.AddDays(-1))
|
|
|
|
{
|
|
|
|
IsTomorrow = true;
|
|
|
|
}
|
|
|
|
else if (now.Date == compareDate)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
IsToday = true;
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
2022-06-09 12:11:45 +00:00
|
|
|
else if (now.Date == compareDate.AddDays(1))
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-02-10 18:39:04 +00:00
|
|
|
IsYesterday = true;
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
CreatedDate = createdDate;
|
|
|
|
ModifiedDate = modifiedDate;
|
|
|
|
AggregatedDate = aggregatedDate;
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-02-10 18:39:04 +00:00
|
|
|
public void Mapping(Profile profile)
|
|
|
|
{
|
|
|
|
profile.CreateMap<FeedAggregate, FeedResultItem>()
|
|
|
|
.ConvertUsing<FeedTypeConverter>();
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
2022-02-10 18:39:04 +00:00
|
|
|
}
|