C# Class BlueCollar.SQLiteRepository

Inheritance: IRepository
Mostrar archivo Open project: ChadBurggraf/blue-collar Class Usage Examples

Public Methods

Method Description
BeginTransaction ( ) : IDbTransaction

Begins a transaction.

BeginTransaction ( IsolationLevel level ) : IDbTransaction

Begins a transaction.

ClearWorkingSignalPair ( long workerId, long workingId, IDbTransaction transaction ) : void

Clears signals for the given worker and working job if applicable.

CreateQueuedAndHistoryForSchedule ( long scheduleId, System.DateTime scheduleDate, IEnumerable queued, IEnumerable history, IDbTransaction transaction ) : int

Creates the queue and history records for the given schedule.

DeleteAll ( string applicationName, IDbTransaction transaction ) : void

Deletes all data in the repository.

DeleteHistory ( string applicationName, System.DateTime olderThan, IDbTransaction transaction ) : void

Deletes history older than the given date.

DeleteQueued ( long id, IDbTransaction transaction ) : void

Deletes the queued record with the given ID.

DeleteSchedule ( long id, IDbTransaction transaction ) : void

Deletes the schedule record with the given ID.

DeleteScheduledJob ( long id, IDbTransaction transaction ) : void

Deletes the scheduled job record with the given ID.

DeleteWorker ( long id, IDbTransaction transaction ) : void

Deletes the worker record with the given ID.

DeleteWorking ( long id, IDbTransaction transaction ) : void

Deletes the working record with the given ID.

Dispose ( ) : void

Disposes of resources used by this instance.

GetCounts ( string applicationName, IDbTransaction transaction ) : CountsRecord

Gets a set of counts for the given application.

GetHistoryDetails ( long id, IDbTransaction transaction ) : HistoryDetailsRecord

Gets a history details record.

GetHistoryList ( string applicationName, string search, int limit, int offset, IDbTransaction transaction ) : RecordList

Gets a list of history records.

GetQueuedDetails ( long id, IDbTransaction transaction ) : QueueDetailsRecord

Gets a queued details record.

GetQueuedList ( string applicationName, string search, int limit, int offset, IDbTransaction transaction ) : RecordList

Gets a list of queue records.

GetSchedule ( long id, IDbTransaction transaction ) : ScheduleRecord

Gets the schedule with the given ID, NOT including its related scheduled jobs.

GetScheduleDateExistsForSchedule ( long scheduleId, System.DateTime scheduleDate, IDbTransaction transaction ) : bool

Gets a value indicating whether data exists for the given schedule ID and calculated schedule date. If it does, this indicates that jobs have already been enqueued for the schedule and should not be enqueued again until the next calculated schedule date.

GetScheduleEnqueueingLock ( long scheduleId, System.DateTime forceIfOlderThan, IDbTransaction transaction ) : bool

Attempts to obtain the enqueueing lock for the given schedule ID.

GetScheduleList ( string applicationName, string search, int limit, int offset, IDbTransaction transaction ) : RecordList

Gets a list of schedule records.

GetScheduledJobList ( string applicationName, long id, string search, int limit, int offset, IDbTransaction transaction ) : ScheduledJobRecordList

Gets a schedule and its related scheduled jobs, filtered by the given list parameters.

GetSchedules ( string applicationName, IDbTransaction transaction ) : IEnumerable

Gets a collection of schedules and their related scheduled jobs for the given application name.

GetStatistics ( string applicationName, System.DateTime recentBeginDate, System.DateTime distantBeginDate, System.DateTime endDate, IDbTransaction transaction ) : StatisticsRecord

Gets a set of system statistics for the given application name and date ranges.

GetWorker ( long id, IDbTransaction transaction ) : WorkerRecord

Gets the worker record with the given ID.

GetWorkerList ( string applicationName, string search, int limit, int offset, IDbTransaction transaction ) : RecordList

Gets a list of worker records.

GetWorkers ( string applicationName, string machineAddress, string machineName, IDbTransaction transaction ) : IEnumerable

Gets the worker collection for the given machine.

GetWorking ( long id, IDbTransaction transaction ) : WorkingRecord

Gets the working record with the given ID.

GetWorkingDetails ( long id, IDbTransaction transaction ) : WorkingDetailsRecord

Gets a working details record.

GetWorkingForWorker ( long workerId, long excludingId, IDbTransaction transaction ) : IEnumerable

Gets a collection of working records that belong to the given worker ID.

GetWorkingList ( string applicationName, string search, int limit, int offset, IDbTransaction transaction ) : RecordList

Gets a list of working records.

GetWorkingSignals ( long workerId, long workingId, IDbTransaction transaction ) : SignalsRecord

Gets the current signals set for a worker and a working job, if applicable.

ReleaseScheduleEnqueueingLock ( long scheduleId, IDbTransaction transaction ) : void

Releases the enqueueing lock for the schedule with the given ID.

SQLiteRepository ( string connectionString ) : System

Initializes a new instance of the SQLiteRepository class.

SignalWorkers ( string applicationName, WorkerSignal signal, IDbTransaction transaction ) : void

Signals all workers for the given application name.

UpdateSchedule ( ScheduleRecord record, IDbTransaction transaction ) : ScheduleRecord

Updates the given schedule.

UpdateScheduledJob ( ScheduledJobRecord record, IDbTransaction transaction ) : ScheduledJobRecord

Updates the given scheduled job.

UpdateScheduledJobOrder ( ScheduledJobOrderRecord record, IDbTransaction transaction ) : void

Updates the scheduled job's order number.

UpdateWorker ( WorkerRecord record, IDbTransaction transaction ) : WorkerRecord

Updates the given worker.

UpdateWorkerStatus ( long id, WorkerStatus status, IDbTransaction transaction ) : void

Updates the status of the worker with the given ID.

UpdateWorking ( WorkingRecord record, IDbTransaction transaction ) : WorkingRecord

Updates the given working record.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Disposes of resources used by this instance.

EnsureDatabase ( string path ) : void

Ensures that the SQLite database at the given path exists, creating it if it doesn't.

Private Methods

Method Description
CreateCounts ( Dapper.SqlMapper multi ) : CountsRecord

Creates a new CountsRecord by reading from the given multi-mapped reader.

CreateHistory ( HistoryRecord record, IDbTransaction transaction ) : HistoryRecord
CreateHistoryStatusCounts ( Dapper.SqlMapper multi ) : HistoryStatusCountsRecord

Creates a new HistoryStatusCountsRecord by reading from the given multi-mapped reader.

CreateQueued ( QueueRecord record, IDbTransaction transaction ) : QueueRecord
CreateSchedule ( ScheduleRecord record, IDbTransaction transaction ) : ScheduleRecord
CreateScheduledJob ( ScheduledJobRecord record, IDbTransaction transaction ) : ScheduledJobRecord
CreateWorker ( WorkerRecord record, IDbTransaction transaction ) : WorkerRecord
CreateWorking ( WorkingRecord record, IDbTransaction transaction ) : WorkingRecord
GetQueued ( string applicationName, QueueNameFilters queueFilters, System.DateTime queuedBefore, IDbTransaction transaction ) : QueueRecord

Method Details

BeginTransaction() public method

Begins a transaction.
public BeginTransaction ( ) : IDbTransaction
return IDbTransaction

BeginTransaction() public method

Begins a transaction.
public BeginTransaction ( IsolationLevel level ) : IDbTransaction
level IsolationLevel The isolation level to use for the transaction.
return IDbTransaction

ClearWorkingSignalPair() public method

Clears signals for the given worker and working job if applicable.
public ClearWorkingSignalPair ( long workerId, long workingId, IDbTransaction transaction ) : void
workerId long The ID of the worker to clear the signal of.
workingId long The ID of the working job to clear the signal of, if applicable.
transaction IDbTransaction The transaction to use, if applicable.
return void

CreateQueuedAndHistoryForSchedule() public method

Creates the queue and history records for the given schedule.
public CreateQueuedAndHistoryForSchedule ( long scheduleId, System.DateTime scheduleDate, IEnumerable queued, IEnumerable history, IDbTransaction transaction ) : int
scheduleId long The ID of the schedule records are being created for.
scheduleDate System.DateTime The schedule date records are being created for.
queued IEnumerable The queued records to create.
history IEnumerable The history records to create.
transaction IDbTransaction The transaction to use, if applicable.
return int

DeleteAll() public method

Deletes all data in the repository.
public DeleteAll ( string applicationName, IDbTransaction transaction ) : void
applicationName string The name of the application to delete data for.
transaction IDbTransaction The transaction to use, if applicable.
return void

DeleteHistory() public method

Deletes history older than the given date.
public DeleteHistory ( string applicationName, System.DateTime olderThan, IDbTransaction transaction ) : void
applicationName string The name of the application to delete data for.
olderThan System.DateTime The date to delete history older than.
transaction IDbTransaction The transaction to use, if applicable.
return void

DeleteQueued() public method

Deletes the queued record with the given ID.
public DeleteQueued ( long id, IDbTransaction transaction ) : void
id long The ID of the queued record to delete.
transaction IDbTransaction The transaction to use, if applicable.
return void

DeleteSchedule() public method

Deletes the schedule record with the given ID.
public DeleteSchedule ( long id, IDbTransaction transaction ) : void
id long The ID of the schedule to delete.
transaction IDbTransaction The transaction to use, if applicable.
return void

DeleteScheduledJob() public method

Deletes the scheduled job record with the given ID.
public DeleteScheduledJob ( long id, IDbTransaction transaction ) : void
id long The ID of the scheduled job to delete.
transaction IDbTransaction The transaction to use, if applicable.
return void

DeleteWorker() public method

Deletes the worker record with the given ID.
public DeleteWorker ( long id, IDbTransaction transaction ) : void
id long The ID of the worker to delete.
transaction IDbTransaction The transaction to use, if applicable.
return void

DeleteWorking() public method

Deletes the working record with the given ID.
public DeleteWorking ( long id, IDbTransaction transaction ) : void
id long The ID of the working record to delete.
transaction IDbTransaction The transaction to use, if applicable.
return void

Dispose() public method

Disposes of resources used by this instance.
public Dispose ( ) : void
return void

Dispose() protected method

Disposes of resources used by this instance.
protected Dispose ( bool disposing ) : void
disposing bool A value indicating whether to dispose of managed resources.
return void

EnsureDatabase() protected static method

Ensures that the SQLite database at the given path exists, creating it if it doesn't.
protected static EnsureDatabase ( string path ) : void
path string The path of the SQLite database to ensure.
return void

GetCounts() public method

Gets a set of counts for the given application.
public GetCounts ( string applicationName, IDbTransaction transaction ) : CountsRecord
applicationName string The name of the application to get counts for.
transaction IDbTransaction The transaction to use, if applicable.
return CountsRecord

GetHistoryDetails() public method

Gets a history details record.
public GetHistoryDetails ( long id, IDbTransaction transaction ) : HistoryDetailsRecord
id long The ID of the record to get.
transaction IDbTransaction The transaction to use, if applicable.
return HistoryDetailsRecord

GetHistoryList() public method

Gets a list of history records.
public GetHistoryList ( string applicationName, string search, int limit, int offset, IDbTransaction transaction ) : RecordList
applicationName string The name of the application to get the history list for.
search string The search query to filter the collection with.
limit int The paging limit to use.
offset int The paging offset to use.
transaction IDbTransaction The transaction to use, if applicable.
return RecordList

GetQueuedDetails() public method

Gets a queued details record.
public GetQueuedDetails ( long id, IDbTransaction transaction ) : QueueDetailsRecord
id long The ID of the record to get.
transaction IDbTransaction The transaction to use, if applicable.
return QueueDetailsRecord

GetQueuedList() public method

Gets a list of queue records.
public GetQueuedList ( string applicationName, string search, int limit, int offset, IDbTransaction transaction ) : RecordList
applicationName string The name of the application to get the queue list for.
search string The search query to filter the collection with.
limit int The paging limit to use.
offset int The paging offset to use.
transaction IDbTransaction The transaction to use, if applicable.
return RecordList

GetSchedule() public method

Gets the schedule with the given ID, NOT including its related scheduled jobs.
public GetSchedule ( long id, IDbTransaction transaction ) : ScheduleRecord
id long The ID of the schedule to get.
transaction IDbTransaction The transaction to use, if applicable.
return ScheduleRecord

GetScheduleDateExistsForSchedule() public method

Gets a value indicating whether data exists for the given schedule ID and calculated schedule date. If it does, this indicates that jobs have already been enqueued for the schedule and should not be enqueued again until the next calculated schedule date.
public GetScheduleDateExistsForSchedule ( long scheduleId, System.DateTime scheduleDate, IDbTransaction transaction ) : bool
scheduleId long The ID of the schedule to check data for.
scheduleDate System.DateTime The calculated schedule date to check data for.
transaction IDbTransaction The transaction to use, if applicable.
return bool

GetScheduleEnqueueingLock() public method

Attempts to obtain the enqueueing lock for the given schedule ID.
public GetScheduleEnqueueingLock ( long scheduleId, System.DateTime forceIfOlderThan, IDbTransaction transaction ) : bool
scheduleId long The ID of the schedule to obtain the schedule enqueueing lock for.
forceIfOlderThan System.DateTime A date to compare the enqueue lock's last updated date with. If /// the lock is older than the given date, then it will be forced and acquired by the caller.
transaction IDbTransaction The transaction to use, if applicable.
return bool

GetScheduleList() public method

Gets a list of schedule records.
public GetScheduleList ( string applicationName, string search, int limit, int offset, IDbTransaction transaction ) : RecordList
applicationName string The name of the application to get the schedule list for.
search string The search query to filter the collection with.
limit int The paging limit to use.
offset int The paging offset to use.
transaction IDbTransaction The transaction to use, if applicable.
return RecordList

GetScheduledJobList() public method

Gets a schedule and its related scheduled jobs, filtered by the given list parameters.
public GetScheduledJobList ( string applicationName, long id, string search, int limit, int offset, IDbTransaction transaction ) : ScheduledJobRecordList
applicationName string The name of the application to get the scheduled job list for.
id long The ID of the schedule to get.
search string The search query to filter the related job collection with.
limit int The paging limit to use.
offset int The paging offset to use.
transaction IDbTransaction The transaction to use, if applicable.
return ScheduledJobRecordList

GetSchedules() public method

Gets a collection of schedules and their related scheduled jobs for the given application name.
public GetSchedules ( string applicationName, IDbTransaction transaction ) : IEnumerable
applicationName string The name of the application to get schedules for.
transaction IDbTransaction The transaction to use, if applicable.
return IEnumerable

GetStatistics() public method

Gets a set of system statistics for the given application name and date ranges.
public GetStatistics ( string applicationName, System.DateTime recentBeginDate, System.DateTime distantBeginDate, System.DateTime endDate, IDbTransaction transaction ) : StatisticsRecord
applicationName string The name of the application to get system statistics for.
recentBeginDate System.DateTime The begin date of the recent period to get statistics for.
distantBeginDate System.DateTime The begin date of the distant period to get statistics for.
endDate System.DateTime The end date of the distant period to get statistics for.
transaction IDbTransaction The transaction to use, if applicable.
return StatisticsRecord

GetWorker() public method

Gets the worker record with the given ID.
public GetWorker ( long id, IDbTransaction transaction ) : WorkerRecord
id long The ID of the worker record to get.
transaction IDbTransaction The transaction to use.
return WorkerRecord

GetWorkerList() public method

Gets a list of worker records.
public GetWorkerList ( string applicationName, string search, int limit, int offset, IDbTransaction transaction ) : RecordList
applicationName string The application name to get records for.
search string The search query to filter the collection with.
limit int The paging limit to use.
offset int The paging offset to use.
transaction IDbTransaction The transaction to use, if applicable.
return RecordList

GetWorkers() public method

Gets the worker collection for the given machine.
public GetWorkers ( string applicationName, string machineAddress, string machineName, IDbTransaction transaction ) : IEnumerable
applicationName string The application name to get workers for.
machineAddress string The address of the machine to get workers for.
machineName string The name of the machine to get workers for.
transaction IDbTransaction The transaction to use, if applicable.
return IEnumerable

GetWorking() public method

Gets the working record with the given ID.
public GetWorking ( long id, IDbTransaction transaction ) : WorkingRecord
id long The ID of the record to get.
transaction IDbTransaction The transaction to use, if applicable.
return WorkingRecord

GetWorkingDetails() public method

Gets a working details record.
public GetWorkingDetails ( long id, IDbTransaction transaction ) : WorkingDetailsRecord
id long The ID of the record to get.
transaction IDbTransaction The transaction to use, if applicable.
return WorkingDetailsRecord

GetWorkingForWorker() public method

Gets a collection of working records that belong to the given worker ID.
public GetWorkingForWorker ( long workerId, long excludingId, IDbTransaction transaction ) : IEnumerable
workerId long The ID of the worker to get working records for.
excludingId long The ID of the working record to exclude, if applicable.
transaction IDbTransaction The transaction to use, if applicable.
return IEnumerable

GetWorkingList() public method

Gets a list of working records.
public GetWorkingList ( string applicationName, string search, int limit, int offset, IDbTransaction transaction ) : RecordList
applicationName string The application name to get records for.
search string The search query to filter the collection with.
limit int The paging limit to use.
offset int The paging offset to use.
transaction IDbTransaction The transaction to use, if applicable.
return RecordList

GetWorkingSignals() public method

Gets the current signals set for a worker and a working job, if applicable.
public GetWorkingSignals ( long workerId, long workingId, IDbTransaction transaction ) : SignalsRecord
workerId long The ID of the worker to get a signal for.
workingId long The ID of the working job to get a signal for, if applicable.
transaction IDbTransaction The transaction to use, if applicable.
return SignalsRecord

ReleaseScheduleEnqueueingLock() public method

Releases the enqueueing lock for the schedule with the given ID.
public ReleaseScheduleEnqueueingLock ( long scheduleId, IDbTransaction transaction ) : void
scheduleId long The ID of the schedule to release the enqueueing lock for.
transaction IDbTransaction The transaction to use, if applicable.
return void

SQLiteRepository() public method

Initializes a new instance of the SQLiteRepository class.
public SQLiteRepository ( string connectionString ) : System
connectionString string The connection string to use when connecting to the database.
return System

SignalWorkers() public method

Signals all workers for the given application name.
public SignalWorkers ( string applicationName, WorkerSignal signal, IDbTransaction transaction ) : void
applicationName string The application name to signal workers for.
signal WorkerSignal The signal to set.
transaction IDbTransaction The transaction to use, if applicable.
return void

UpdateSchedule() public method

Updates the given schedule.
public UpdateSchedule ( ScheduleRecord record, IDbTransaction transaction ) : ScheduleRecord
record ScheduleRecord The schedule record to update.
transaction IDbTransaction The transaction to use, if applicable.
return ScheduleRecord

UpdateScheduledJob() public method

Updates the given scheduled job.
public UpdateScheduledJob ( ScheduledJobRecord record, IDbTransaction transaction ) : ScheduledJobRecord
record ScheduledJobRecord The scheduled job record to update.
transaction IDbTransaction The transaction to use, if applicable.
return ScheduledJobRecord

UpdateScheduledJobOrder() public method

Updates the scheduled job's order number.
public UpdateScheduledJobOrder ( ScheduledJobOrderRecord record, IDbTransaction transaction ) : void
record ScheduledJobOrderRecord The scheduled job order record identifying the scheduled job to update.
transaction IDbTransaction The transaction to use, if applicable.
return void

UpdateWorker() public method

Updates the given worker.
public UpdateWorker ( WorkerRecord record, IDbTransaction transaction ) : WorkerRecord
record WorkerRecord The worker record to update.
transaction IDbTransaction The transaction to use, if applicable.
return WorkerRecord

UpdateWorkerStatus() public method

Updates the status of the worker with the given ID.
public UpdateWorkerStatus ( long id, WorkerStatus status, IDbTransaction transaction ) : void
id long The ID of the worker to update status for.
status WorkerStatus The status to update.
transaction IDbTransaction The transaction to use, if applicable.
return void

UpdateWorking() public method

Updates the given working record.
public UpdateWorking ( WorkingRecord record, IDbTransaction transaction ) : WorkingRecord
record WorkingRecord The working record to update.
transaction IDbTransaction The transaction to use, if applicable.
return WorkingRecord