/// <summary> /// Selects the archive content not in index to list. /// </summary> /// <returns>The archive content not in index to list.</returns> /// <param name="contentLang">Content lang.</param> /// <param name="limit">Limit.</param> public IList<ArchiveContent> SelectArchiveContentNotInIndexToList(int contentLang, long limit) { try { var sbQuery = new StringBuilder(); sbQuery.Append("SELECT * FROM archivecontent "); sbQuery.Append("WHERE ContentLang = @ContentLang "); sbQuery.Append("AND Id NOT IN "); sbQuery.Append("(SELECT ContentId FROM archiveindex "); sbQuery.Append("WHERE archiveindex.ContentId = archivecontent.Id) "); sbQuery.Append("LIMIT @Limit "); string query = sbQuery.ToString(); var contentList = new List<ArchiveContent>(); if (this.Connection.State != ConnectionState.Open) { this.OpenConnection(); } MySqlCommand cmd = new MySqlCommand(query, this.Connection); cmd.Parameters.AddWithValue("@ContentLang", contentLang); cmd.Parameters.AddWithValue("@Limit", limit); MySqlDataReader dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { var content = new ArchiveContent(); content.GetArchiveContent(dataReader); contentList.Add(content); } } dataReader.Close(); this.CloseConnection(); return contentList; } catch (Exception) { throw; } }
/// <summary> /// Selects the archive content by language to list. /// </summary> /// <returns>The archive content by language to list.</returns> /// <param name="contentLang">Content lang.</param> /// <param name="contentCountMin">Content count minimum.</param> /// <param name="contentCountMax">Content count max.</param> public IList<ArchiveContent> SelectArchiveContentByLanguageToList(int contentLang, long contentCountMin, long contentCountMax) { try { var sbQuery = new StringBuilder(); sbQuery.Append("SELECT * FROM archivecontent "); sbQuery.Append("WHERE ContentLang = @ContentLang "); sbQuery.Append("AND Id < @ContentCountMax "); sbQuery.Append("AND Id > @ContentCountMin "); sbQuery.Append("ORDER BY Id DESC"); string query = sbQuery.ToString(); var contentList = new List<ArchiveContent>(); if (this.Connection.State != ConnectionState.Open) { this.OpenConnection(); } MySqlCommand cmd = new MySqlCommand(query, this.Connection); cmd.Parameters.AddWithValue("@ContentLang", contentLang); cmd.Parameters.AddWithValue("@ContentCountMax", contentCountMax); cmd.Parameters.AddWithValue("@ContentCountMin", contentCountMin); MySqlDataReader dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { var content = new ArchiveContent(); content.GetArchiveContent(dataReader); contentList.Add(content); } } dataReader.Close(); this.CloseConnection(); return contentList; } catch (Exception) { throw; } }