public QueryResult<FileOrganizationResult> GetResults(FileOrganizationResultQuery query) { var results = _repo.GetResults(query); foreach (var result in results.Items) { result.IsInProgress = _inProgressItemIds.ContainsKey(result.Id); } return results; }
public QueryResult<FileOrganizationResult> GetResults(FileOrganizationResultQuery query) { return _repo.GetResults(query); }
public QueryResult<FileOrganizationResult> GetResults(FileOrganizationResultQuery query) { if (query == null) { throw new ArgumentNullException("query"); } using (var connection = CreateConnection(true).Result) { using (var cmd = connection.CreateCommand()) { cmd.CommandText = "SELECT ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults"; if (query.StartIndex.HasValue && query.StartIndex.Value > 0) { cmd.CommandText += string.Format(" WHERE ResultId NOT IN (SELECT ResultId FROM FileOrganizerResults ORDER BY OrganizationDate desc LIMIT {0})", query.StartIndex.Value.ToString(_usCulture)); } cmd.CommandText += " ORDER BY OrganizationDate desc"; if (query.Limit.HasValue) { cmd.CommandText += " LIMIT " + query.Limit.Value.ToString(_usCulture); } cmd.CommandText += "; select count (ResultId) from FileOrganizerResults"; var list = new List<FileOrganizationResult>(); var count = 0; using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) { while (reader.Read()) { list.Add(GetResult(reader)); } if (reader.NextResult() && reader.Read()) { count = reader.GetInt32(0); } } return new QueryResult<FileOrganizationResult>() { Items = list.ToArray(), TotalRecordCount = count }; } } }
public QueryResult<SmartMatchInfo> GetSmartMatchInfos(FileOrganizationResultQuery query) { if (query == null) { throw new ArgumentNullException("query"); } var options = GetAutoOrganizeOptions(); var items = options.SmartMatchInfos.Skip(query.StartIndex ?? 0).Take(query.Limit ?? Int32.MaxValue).ToArray(); return new QueryResult<SmartMatchInfo>() { Items = items, TotalRecordCount = options.SmartMatchInfos.Length }; }