Ejemplo n.º 1
0
        private long Count(string clientName, bool completed, DateTime?clientStartTime)
        {
            var parameters = new QueryParameters();

            parameters.Fields.Add(new QueryField {
                Name = QueryFieldName.Name, Type = QueryFieldType.Equal, Value = clientName
            });
            parameters.Fields.Add(new QueryField
            {
                Name  = QueryFieldName.Result,
                Type  = completed ? QueryFieldType.Equal : QueryFieldType.NotEqual,
                Value = (int)WorkUnitResult.FinishedUnit
            });
            if (clientStartTime.HasValue)
            {
                parameters.Fields.Add(new QueryField
                {
                    Name  = completed ? QueryFieldName.CompletionDateTime : QueryFieldName.DownloadDateTime,
                    Type  = QueryFieldType.GreaterThan,
                    Value = clientStartTime.Value
                });
            }
            PetaPoco.Sql where = WhereBuilder.Execute(parameters);

            var countSql = PetaPoco.Sql.Builder.Select("ID", "InstanceName", "DownloadDateTime", "CompletionDateTime", "Result", "COUNT(*)")
                           .From("WuHistory")
                           .Append(where);

            using (var table = Select(countSql.SQL, countSql.Arguments))
            {
                return((long)table.Rows[0][5]);
            }
        }
Ejemplo n.º 2
0
        private IList <HistoryEntry> FetchInternal(QueryParameters parameters, BonusCalculationType bonusCalculation)
        {
            Debug.Assert(TableExists(SqlTable.WuHistory));

            var select = new PetaPoco.Sql(SqlTableCommandDictionary[SqlTable.WuHistory].SelectSql);

            select.Append(WhereBuilder.Execute(parameters));
            GetProduction.BonusCalculation = bonusCalculation;
            using (var connection = new SQLiteConnection(ConnectionString))
            {
                connection.Open();
                using (var database = new PetaPoco.Database(connection))
                {
                    List <HistoryEntry> query = database.Fetch <HistoryEntry>(select);
                    return(query);
                }
            }
        }
Ejemplo n.º 3
0
        private PetaPoco.Page <HistoryEntry> PageInternal(long page, long itemsPerPage, QueryParameters parameters, BonusCalculationType bonusCalculation)
        {
            Debug.Assert(TableExists(SqlTable.WuHistory));

            var select = new PetaPoco.Sql(SqlTableCommandDictionary[SqlTable.WuHistory].SelectSql);

            select.Append(WhereBuilder.Execute(parameters));
            GetProduction.BonusCalculation = bonusCalculation;
            using (var connection = new SQLiteConnection(ConnectionString))
            {
                connection.Open();
                using (var database = new PetaPoco.Database(connection))
                {
                    PetaPoco.Page <HistoryEntry> query = database.Page <HistoryEntry>(page, itemsPerPage, select);
                    Debug.Assert(query != null);
                    return(query);
                }
            }
        }