public void Simple() { var inputFilePath = Path.Combine(WorkDirecoryPath, "Images", "test.jpg"); var messageDto = new MessageDto { StrId = Guid.NewGuid().ToString(), Text = Guid.NewGuid().ToString(), ImageBytes = File.ReadAllBytes(inputFilePath), EditDate = DateTime.Now, ForwardFromMessageId = 42, ChatId = 411, CreateDate = DateTime.Now, ForwardFromChatId = 4444, ForwardFromChatName = Guid.NewGuid().ToString(), ForwardFromUserId = 3333, ForwardFromUserName = Guid.NewGuid().ToString(), FromUserId = 322, FromUserName = Guid.NewGuid().ToString(), IntId = 444556, MessageDate = DateTime.Now, Timestamp = DateTime.Now.Ticks }; imageBayanService.SaveMessage(messageDto); var queryExecutor = queryExecutorFactory.Create <MessageHandler, MessageDbo>(); var messageDbos = queryExecutor.Execute(x => x.Select(new[] { messageDto.StrId })); Assert.NotEmpty(messageDbos); var actual = messageDbos.Single(); AssertEqual(messageDto, actual); }
public async Task WriteImportLogsAsync(ImportResult[] results, Guid userId, Guid?sessionId) { var now = DateTime.Now; sessionId ??= Guid.NewGuid(); var importResults = results.Select(x => new ImportResultDbo { Id = Guid.NewGuid(), Date = now, UserId = userId, SessionId = sessionId.Value, Title = x.ImportingTrack.Title, Artist = x.ImportingTrack.Artist, CandidateArtist = x.Candidate?.Artist ?? string.Empty, CandidateTitle = x.Candidate?.Title ?? string.Empty, NormalizedArtist = x.NormalizedTrack?.Artist ?? string.Empty, NormalizedTitle = x.NormalizedTrack?.Title ?? string.Empty, Message = x.Message ?? string.Empty, Status = x.ImportStatus, ApprovedManual = false, CandidateAlbumId = x.CandidateAlbumId, CandidateTrackId = x.CandidateTrackId, PlaylistId = x.PlaylistId }).ToArray(); using var queryExecutor = queryExecutorFactory.Create <ImportResultHandler, ImportResultDbo>(); await queryExecutor.ExecuteAsync(x => x.CreateAsync(importResults)).ConfigureAwait(false); }
public async Task SaveTempSessionAsync(Guid sessionId, Guid?userId, string inputTracksText) { var sessionDbo = new TempSessionDbo { UserId = userId, Text = inputTracksText, Date = DateTime.UtcNow, Id = sessionId }; using var queryExecutor = queryExecutorFactory.Create <TempSessionHandler, TempSessionDbo>(); await queryExecutor.ExecuteAsync(x => x.CreateAsync(sessionDbo)).ConfigureAwait(false); }
public async Task <ActionResult> GetInputTracksFromFile(IFormFile uploadedFile) { await using var memoryStream = new MemoryStream(); await uploadedFile.CopyToAsync(memoryStream).ConfigureAwait(true); var fileBody = Encoding.UTF8.GetString(memoryStream.ToArray()); var playlist = new PlaylistDbo { Id = Guid.NewGuid(), Content = fileBody, Date = DateTime.Now, UserId = UserId, Filename = uploadedFile.FileName, Extension = new string(uploadedFile.FileName?.Reverse().TakeWhile(c => c != '.').Reverse().ToArray() ?? Array.Empty <char>()) }; using var queryExecutor = queryExecutorFactory.Create <PlaylistsHandler, PlaylistDbo>(); await queryExecutor.ExecuteAsync(f => f.CreateAsync(playlist)).ConfigureAwait(true); var sourceTracks = trackGetter.GetTracks(fileBody); return(View("InputTracks", sourceTracks.ToTracksWizardModel())); }
public void SaveMessage(params MessageDto[] messages) { var msgByStrId = messages.GroupBy(x => x.StrId).Select(x => x.First()).ToDictionary(x => x.StrId); using var queryExecutor = queryExecutorFactory.Create <MessageHandler, MessageDbo>(); var existents = queryExecutor.Execute(x => x.Select(msgByStrId.Keys.ToArray())); foreach (var existent in existents) { Convert(msgByStrId[existent.StrId], existent); } var existentStrIds = new HashSet <string>(existents.Select(x => x.StrId)); var toCreate = msgByStrId.Values.Where(x => !existentStrIds.Contains(x.StrId)).Select(x => Convert(x)) .ToArray(); queryExecutor.Execute(x => x.Create(toCreate)); queryExecutor.Execute(x => x.Update()); }
public async Task Find(string key) { using var queryExecutor = queryExecutorFactory.Create <KeyValueHandler, KeyValue>(); var keyValue = await queryExecutor.ExecuteAsync(h => h.FindAsync(key)).ConfigureAwait(true); await WriteResponse(keyValue).ConfigureAwait(true); }
public Task <TResult> SendAsync <TResult>(IQuery <TResult> query) { var executor = _executorFactory.Create <TResult>(_serviceProvider, query.GetType()); return(executor.ExecuteAsync(query)); }
public IPagedGraphCollection <TResult> Query <TResult>(IQuery <TResult> query, bool enlist = false) { var executor = _queryExecutorFactory.Create(query, this); return(executor.ExecuteWithPaging(this, query, enlist)); }