示例#1
0
    public async Task RestoreAsync()
    {
        await _bkRepo.DeleteAllAsync();

        await _bkMetadataRepo.UpsertAsync(new BkMetadata
        {
            Id = Consts.SingleOneDataId
        });
    }
    public async Task AddCountAsync(string tag, int count)
    {
        var bkTag = await _tagsRepo.GetAsync(tag);

        if (bkTag != null)
        {
            bkTag.ClickedCount += count;
            bkTag.LastClickTime = _clock.UtcNow;
            await _tagsRepo.UpsertAsync(bkTag);
        }
    }
    public async ValueTask StartAsync()
    {
        var afMetadata = await _afMetadataRepo.GetSingleOneAsync() ?? new AfMetadata();

        if (afMetadata.WhatsNewVersion != Consts.CurrentVersion)
        {
            var whatsNew = _staticUrlOptions.Value.WhatsNew;
            if (!string.IsNullOrEmpty(whatsNew))
            {
                await _applicationInsights.TrackEvent(Events.AfWhatsNewShown);

                await _newNotification.NewReleaseAsync(new NewReleaseInput
                {
                    Version     = Consts.CurrentVersion,
                    WhatsNewUrl = whatsNew
                });

                _logger.LogInformation("Whats new shown");
            }

            afMetadata.WhatsNewVersion = Consts.CurrentVersion;
            await _afMetadataRepo.UpsertAsync(afMetadata);
        }
        else
        {
            _logger.LogDebug("Whats new was shown before");
        }
    }
示例#4
0
    public async Task AddClickAsync(string url, int moreCount)
    {
        var bk = await _bkRepo.GetAsync(url);

        if (bk == null)
        {
            return;
        }

        bk.ClickedCount += moreCount;
        bk.LastClickTime = _clock.UtcNow;
        await _bkRepo.UpsertAsync(bk);
    }
 public async Task AddAsync(UserClickRecord userClickRecord)
 {
     await _searchRecordRepo.UpsertAsync(new SearchRecord
     {
         Id         = _clock.UtcNow,
         RecordJson = JsonSerializer.Serialize(userClickRecord)
     });
 }
示例#6
0
 public async Task SaveAsync <T>(T data) where T : ISimpleData
 {
     var id = GetId(typeof(T));
     await _repo.UpsertAsync(new SimpleDataEntity
     {
         Id          = id,
         PayloadJson = JsonSerializer.Serialize(data)
     });
 }
示例#7
0
    public async ValueTask StartAsync()
    {
        var list = await _bkRepo.GetAllAsync();

        foreach (var bk in list)
        {
            if (string.IsNullOrEmpty(bk.UrlHash))
            {
                bk.UrlHash = _urlHashService.GetHash(bk.Url);
                await _bkRepo.UpsertAsync(bk);
            }
        }
    }
示例#8
0
    private async Task AppendTagsAsync(string tag)
    {
        var oldTag = await _tagsRepo.GetAsync(tag);

        if (oldTag == null)
        {
            _logger.LogInformation("A new tag {Tag} added to all collection", tag);
            oldTag = new BkTag
            {
                Tag      = tag,
                TagAlias = new()
            };
            await _tagsRepo.UpsertAsync(oldTag);
        }
    }
    public async Task AddAsync(MsgItem item)
    {
        var records = await _notificationRepo.GetAllAsync();

        var groupName = item.Type.ToString();
        var record    = records.FirstOrDefault(x => x.Group == groupName);
        var now       = _clock.UtcNow;

        item.CreatedTime = now;
        if (record == null)
        {
            record = new NotificationRecord
            {
                Group = groupName,
                Id    = now,
                Items = new List <MsgItem>
                {
                    item
                },
                UpdateTime = now
            };
        }
        else
        {
            record.Items.Insert(0, item);
            while (record.Items.Count > 10)
            {
                record.Items.RemoveAt(record.Items.Count - 1);
            }
            record.UpdateTime = now;
        }

        await _notificationRepo.UpsertAsync(record);

        var status = await _simpleDataStorage.GetOrDefaultAsync <NotificationCenterStatus>();

        status.NewMessage = true;
        await _simpleDataStorage.SaveAsync(status);

        await _afEventHub.PublishAsync(new NewNotificationEvent());
    }
    public async ValueTask StartAsync()
    {
        var afMetadata = await _afMetadataRepo.GetSingleOneAsync() ?? new AfMetadata();

        if (!afMetadata.WelcomeShown)
        {
            var welcomeUrl = _staticUrlOptions.Value.Welcome;
            if (!string.IsNullOrEmpty(welcomeUrl))
            {
                await _applicationInsights.TrackEvent(Events.AfWelcomeShown);

                await _newNotification.WelcomeAsync();

                _logger.LogInformation("Welcome shown");
            }

            afMetadata.WelcomeShown = true;
            await _afMetadataRepo.UpsertAsync(afMetadata);
        }
        else
        {
            _logger.LogDebug("Welcome was shown before");
        }
    }
 public async Task SaveAsync(UserOptions options)
 {
     await _userOptionsRepo.UpsertAsync(options);
 }